/* 残高突合 — iz11weu_design_system に従う。
   色・余白・書体は design_system/tokens.css の変数だけを使い、値は直接書かない。
   紙とインク / 箱ではなく罫線 / 影なし / 角丸なし(入力欄だけ radius-sm)
   アクセント(蛍光イエロー)は塗りとして1画面1か所だけ = 「一致」の印 */
:root {
  /* アクセントの上に載せる文字は、ダークでも常に暗い色(ink はダークで明るくなるため) */
  --on-accent: #141410;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --gutter: var(--space-4);
  --num: "Karla", "Noto Sans JP", -apple-system, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--paper); min-height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink);
  font-family: var(--font-sans); font-weight: 400; font-size: 14px; line-height: 1.8; letter-spacing: .04em;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; letter-spacing: inherit; }
input { font: inherit; color: inherit; letter-spacing: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- 読み込み中: html.pre のあいだだけ出す ---------- */
.boot { display: none; }
html.pre .boot {
  position: fixed; top: 0; left: 0; width: 100%; height: 100vh; height: 100lvh; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--paper);
}
.boot-title { font-family: var(--font-serif); font-size: 36px; font-weight: 400; letter-spacing: .18em; line-height: 1.3; text-align: center; margin: 0 0 var(--space-6); }
.boot-spin { height: 32px; display: flex; align-items: center; }
.boot-spin i { width: 22px; height: 22px; border: 2px solid var(--rule); border-top-color: var(--ink); border-radius: var(--radius-full); animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 上のバー ---------- */
.topbar {
  position: fixed; z-index: 20; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--sat) + 14px) var(--gutter) 12px;
  background: var(--paper); border-bottom: 1px solid var(--rule);
}
.logo { font-family: var(--font-serif); font-size: 17px; letter-spacing: .28em; }
.icon-btn { width: 36px; height: 36px; margin-right: -8px; display: grid; place-items: center; color: var(--ink-muted); transition: color .2s ease; }
.icon-btn:hover { color: var(--ink); }
.i-sun { display: none; }
[data-theme="dark"] .i-sun { display: block; }
[data-theme="dark"] .i-moon { display: none; }

/* ---------- 本文 ---------- */
.content {
  max-width: var(--width-reading); margin: 0 auto;
  padding: calc(var(--sat) + 72px) var(--gutter) calc(var(--sab) + var(--space-5));
}
.sec { margin-top: var(--space-5); }
.sec:first-child { margin-top: var(--space-4); }
.label {
  margin: 0; padding-bottom: var(--space-2); border-bottom: 1px solid var(--rule);
  font-family: var(--font-sans); font-size: 12px; font-weight: 400; letter-spacing: .24em; text-transform: uppercase; color: var(--ink-muted);
}

.row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: 56px; padding: var(--space-2) 0; border-bottom: 1px solid var(--rule); cursor: text;
}
.row.plain { cursor: default; min-height: 44px; }
.name { font-size: 15px; }
.num, .amt { font-family: var(--num); font-variant-numeric: lining-nums tabular-nums; }
.num { font-size: 16px; text-align: right; }
.num.big { font-size: 26px; }
.row.total { border-bottom-color: var(--ink); }

.amt {
  width: 168px; max-width: 52%; text-align: right; font-size: 18px; padding: 8px 10px;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-sm);
  transition: border-color .2s ease; -webkit-appearance: none; appearance: none;
}
.amt:hover { border-color: var(--stone-400); }
.amt:focus { outline: 2px solid var(--ink); outline-offset: 0; border-color: var(--ink); }
.amt[readonly] { background: var(--paper-sunken); color: var(--ink-muted); cursor: default; }
.amt::placeholder { color: var(--stone-400); }

/* 枚数で数える */
.toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) 0; color: var(--ink-muted); font-size: 13px; text-align: left; transition: color .2s ease; }
.toggle:hover { color: var(--ink); }
.chev { display: inline-block; font-size: 18px; line-height: 1; transition: transform .2s ease; }
.toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.toggle.quiet { justify-content: flex-start; margin-top: var(--space-2); }
.counts { padding-bottom: var(--space-2); }
.counts[hidden] { display: none; }
.denom { display: grid; grid-template-columns: 1fr 72px 96px; gap: var(--space-2); align-items: center; padding: 4px 0; border-bottom: 1px solid var(--rule); }
.denom .unit { font-size: 14px; }
.denom input { width: 72px; text-align: center; font-size: 17px; padding: 6px; font-family: var(--num); font-variant-numeric: lining-nums tabular-nums; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-sm); -webkit-appearance: none; appearance: none; }
.denom input:focus { outline: 2px solid var(--ink); outline-offset: 0; border-color: var(--ink); }
.denom .sub { text-align: right; color: var(--ink-muted); font-family: var(--num); font-variant-numeric: lining-nums tabular-nums; font-size: 13px; }
.hint { margin: var(--space-2) 0 0; font-size: 12px; color: var(--ink-muted); line-height: 1.7; }

/* ---------- 結果 ---------- */
.status { margin-top: var(--space-4); min-height: 76px; }
.status .head { margin: 0; font-family: var(--font-serif); font-size: 28px; line-height: 1.4; letter-spacing: .08em; font-variant-numeric: lining-nums; }
.status .head.idle { color: var(--ink-muted); font-size: 20px; }
.status .head.ng { color: var(--danger); }
/* 一致の印: アクセントは塗りとして、ここだけ */
.status .mark { background: var(--accent); color: var(--on-accent); padding: 0 .4em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.status .why { margin: var(--space-1) 0 0; font-size: 13px; color: var(--ink-muted); }

.actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); }
.btn { padding: 12px 22px; border: 1px solid var(--ink); border-radius: var(--radius-none); font-size: 14px; transition: background .2s ease, color .2s ease; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--paper); color: var(--ink); }
.btn:not(.primary) { background: var(--paper); color: var(--ink); border-color: var(--rule); }
.btn:not(.primary):hover { border-color: var(--ink); }
.btn:active { opacity: .7; }

/* ---------- 履歴 ---------- */
.h-row { display: grid; grid-template-columns: 1fr auto auto; gap: var(--space-3); align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 13px; }
.h-row .when { color: var(--ink-muted); }
.h-row .v { font-family: var(--num); font-variant-numeric: lining-nums tabular-nums; text-align: right; }
.h-row .d { min-width: 72px; }
.h-row .d.ng { color: var(--danger); }
.h-empty { padding: var(--space-3) 0; color: var(--ink-muted); font-size: 13px; }

.foot { margin: var(--space-6) 0 0; font-size: 12px; color: var(--ink-muted); line-height: 1.8; }

/* 960px 未満は文字を少し小さく(デザインシステムの切り替えは960pxの1つだけ) */
@media (min-width: 960px) {
  body { font-size: 16px; }
  .content { padding-top: calc(var(--sat) + 88px); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* 入力が揃うまで「記録する」は押せない */
.btn:disabled { cursor: default; }
.btn.primary:disabled:hover { background: var(--ink); color: var(--paper); }
