:root {
  box-sizing: border-box;
  --bg: #fbfaf8; --fg: #1c1a17; --muted: #756e63;
  --line: #e4e0d8; --card: #f3f1ec;
  --accent: #b5601f; --accent-fg: #fffaf3;
  --warn: #9a5a00; --warn-bg: #fbeed9;
  --danger: #a52424; --danger-bg: #fbe9e9;
  --radius: 10px;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140f; --fg: #ece7dd; --muted: #a89d8b;
    --line: #332c22; --card: #211c15;
    --accent: #e08a3e; --accent-fg: #1a1108;
    --warn: #e3ac4e; --warn-bg: #2b2210;
    --danger: #e58080; --danger-bg: #2b1414;
  }
}
* , *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.55;
}
#app-root { max-width: 480px; margin-inline: auto; padding: 16px 16px 40px; min-height: 100vh; }

.screen { display: flex; flex-direction: column; gap: 16px; }
.topbar { display: flex; align-items: center; gap: 10px; }
.topbar h1 { font-size: 1.05rem; margin: 0; }
.btn-back { background: none; border: none; color: var(--muted); font-size: .9rem; padding: 4px 0; }

.loading, .empty { color: var(--muted); padding: 24px 0; text-align: center; }

.vswitch-mount { position: relative; }
.vswitch-btn {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font-size: .95rem; font-weight: 600;
}
.vswitch-sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex;
  align-items: flex-end; z-index: 50;
}
.vswitch-sheet-inner {
  width: 100%; background: var(--bg); border-radius: 16px 16px 0 0; padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.vswitch-title { color: var(--muted); font-size: .8rem; margin: 0 0 8px; }
.vswitch-item {
  display: block; width: 100%; text-align: left; padding: 12px 10px; border: none;
  background: none; color: var(--fg); font-size: 1rem; border-radius: 8px;
}
.vswitch-item.active { background: var(--card); font-weight: 700; }
.vswitch-cancel { display: block; width: 100%; text-align: center; padding: 12px; margin-top: 6px; color: var(--muted); background: none; border: none; }

.stat-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 4px; border-bottom: 1px solid var(--line);
}
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.actions { display: flex; flex-direction: column; gap: 10px; }
.btn {
  min-height: 50px; border-radius: var(--radius); border: 1px solid transparent;
  font-size: 1rem; font-weight: 600; font-family: inherit; cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-secondary { background: var(--card); color: var(--fg); border-color: var(--line); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.btn:disabled { opacity: .5; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.field span { color: var(--muted); }
.field input {
  padding: 11px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font-size: 1rem;
}
.field.details summary { color: var(--accent); font-size: .88rem; cursor: pointer; }
fieldset.field { border: none; padding: 0; margin: 0; }
fieldset legend { color: var(--muted); font-size: .9rem; padding: 0; margin-bottom: 4px; }
.radio { display: inline-flex; align-items: center; gap: 6px; margin-right: 18px; font-size: .95rem; }
.hint { margin: 0; font-size: .78rem; color: var(--muted); }
.hint.warn { color: var(--warn); }
.form-error { color: var(--danger); background: var(--danger-bg); padding: 10px 12px; border-radius: 8px; font-size: .85rem; }

.confirm-body { display: flex; flex-direction: column; gap: 16px; }
.confirm-list { margin: 0; display: flex; flex-direction: column; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.confirm-list > div { display: flex; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.confirm-list > div:last-child { border-bottom: none; }
.confirm-list dt { color: var(--muted); font-size: .85rem; margin: 0; }
.confirm-list dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.section-title { font-size: .9rem; color: var(--muted); margin: 0; }
.no-warning { color: var(--muted); font-size: .9rem; }
.warning-card {
  background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 12px;
  font-size: .85rem; margin-bottom: 8px;
}
.warning-card b { margin-right: 6px; }

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-row {
  text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; font-family: inherit;
}
.history-row-date { color: var(--muted); font-size: .78rem; }
.history-row-main { display: flex; gap: 14px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.badge-warn { color: var(--warn); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal-body { background: var(--bg); border-radius: 14px; padding: 20px; max-width: 340px; width: 100%; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }
