/* Appearance tokens are generated exclusively by accents.js. */
:root {
  color-scheme: only light;
  font: 16px system-ui, -apple-system, sans-serif;
  --page: #ffffff;
  --text: #222222;
  --muted: var(--muted-light);
  --panel: var(--surface-light);
  --raised: var(--surface-light-raised);
  --field: var(--field-light);
  --border: var(--border-light);
  --chart-ink: var(--accent-ink);
  --error-text: #a52335;
  --error-surface: #fff0ef;
  background: var(--page);
  color: var(--text);
}
:root[data-theme="dark"] {
  color-scheme: only dark;
  --page: #080808;
  --text: #f4f4f4;
  --muted: var(--muted-dark);
  --panel: var(--surface-dark);
  --raised: var(--surface-dark-raised);
  --field: var(--field-dark);
  --border: var(--surface-dark-border);
  --chart-ink: var(--accent);
  --error-text: #ffbab3;
  --error-surface: #291719;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--page); }
header { max-width: 1040px; margin: auto; padding: 24px; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.brand { display: block; width: 48px; height: 48px; flex-shrink: 0; border-radius: 12px; background: #080808; }
.brand .brand-mark { fill: var(--accent); }
.name { font-size: 21px; font-weight: 750; letter-spacing: .04em; }
header small { display: block; color: var(--muted); font-size: 14px; }
main { max-width: 1040px; margin: auto; padding: 12px 24px 36px; }
h1 { font-size: clamp(26px, 4vw, 36px); letter-spacing: -1px; margin: 4px 0 8px; }
h2 { font-size: 18px; margin: 0 0 22px; }
.intro { margin: 0 0 24px; color: var(--muted); }
.layout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 24px; }
.field { margin-bottom: 20px; }
label { display: block; font-weight: 650; font-size: 15px; margin-bottom: 8px; }
.input { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; background: var(--field); overflow: hidden; }
.input:focus-within { outline: 3px solid var(--accent-ring); border-color: var(--accent); }
input { width: 100%; min-width: 0; font: inherit; font-size: 20px; padding: 12px; border: 0; background: transparent; color: var(--text); outline: none; }
.unit { padding-right: 14px; color: var(--muted); }
button { font: inherit; border: 1px solid var(--border); background: var(--field); color: var(--text); padding: 11px 16px; border-radius: 10px; cursor: pointer; min-height: 44px; }
button:hover { background: var(--raised); }
button:focus-visible, a:focus-visible { outline: 3px solid var(--chart-ink); outline-offset: 3px; }
button[type="reset"], .book-link { background: var(--accent); color: #111111; border-color: var(--accent); }
button[type="reset"]:hover, .book-link:hover { background: var(--accent); filter: brightness(.96); }
.hint, .note { font-size: 14px; color: var(--muted); line-height: 1.5; }
.note { margin: 20px 0 0; line-height: 1.6; }
.result { background: var(--raised); color: var(--text); }
.result h2, .result .hero { color: var(--chart-ink); }
.hero-label { font-size: 16px; }
.hero { font-size: clamp(40px, 6vw, 58px); font-weight: 750; letter-spacing: -1px; line-height: 1.2; margin: 6px 0 4px; overflow-wrap: anywhere; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }
.metric span { display: block; font-size: 14px; color: var(--muted); line-height: 1.4; }
.metric strong { display: block; font-size: 24px; margin-top: 5px; overflow-wrap: anywhere; }
.recovery { margin-top: 26px; padding: 18px; background: var(--panel); border-radius: 12px; line-height: 1.5; }
.recovery strong { font-size: 20px; }
.bar { margin-top: 12px; background: var(--border); height: 8px; border-radius: 8px; overflow: hidden; }
.bar div { height: 100%; background: var(--chart-ink); transition: width .15s; }
.error, .result.negative { color: var(--error-text); background: var(--error-surface); }
.error { padding: 12px; border-radius: 8px; margin-bottom: 18px; }
.result.negative h2, .result.negative .hero, .result.negative .hint, .result.negative .metric span { color: var(--error-text); }

.tabs { display: flex; gap: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 5px; margin: 4px 0 26px; }
.tab { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 15px; font-weight: 650; padding: 13px 8px; line-height: 1.4; }
.tab:hover { background: var(--raised); }
.tab[aria-selected="true"] { background: var(--accent); color: #111111; }

.theme-switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 0; background: transparent; padding: 10px 4px; font-size: 15px; font-weight: 650; white-space: nowrap; width: 100%; }
.theme-switch:hover { background: transparent; }
.switch-track { display: block; width: 44px; height: 26px; border-radius: 20px; background: var(--accent); padding: 3px; flex-shrink: 0; }
.switch-thumb { display: block; width: 20px; height: 20px; border-radius: 50%; background: white; transition: transform .18s; }
.theme-switch[aria-checked="true"] .switch-thumb { background: #111111; transform: translateX(18px); }
.options-menu { position: relative; margin-left: auto; }
.options-menu > summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 650; }
.options-menu summary::-webkit-details-marker { display: none; }
.options-menu summary:focus-visible { outline: 3px solid var(--chart-ink); outline-offset: 3px; }
.options-content { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 280px; max-width: calc(100vw - 40px); padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--panel); box-shadow: 0 12px 32px #0002; }
.options-heading { margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.accent-picker > summary { list-style: none; cursor: pointer; min-height: 44px; display: flex; align-items: center; justify-content: space-between; font-size: 14px; font-weight: 650; padding: 10px 4px; }
.accent-menu { padding-top: 8px; }
.accent-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.accent-swatch { background: var(--swatch); color: #111111; width: 44px; height: 44px; padding: 0; border: 2px solid transparent; box-shadow: inset 0 0 0 1px #0002; font-size: 22px; }
.accent-swatch:hover { background: var(--swatch); border-color: var(--chart-ink); }
.accent-swatch[aria-pressed="true"] { border-color: var(--chart-ink); }
#accentStatus { margin: 12px 0 0; }

.book-banner { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 20px; margin-top: 28px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); }
.book-cover { display: block; width: 64px; height: auto; border-radius: 4px; }
.book-copy { min-width: 0; }
.book-kicker { margin: 0 0 5px; font-size: 12px; font-weight: 650; letter-spacing: .04em; color: var(--muted); }
.book-banner h2 { font-size: 17px; line-height: 1.4; margin: 0 0 5px; }
.book-description { font-size: 14px; line-height: 1.5; margin: 0; color: var(--muted); }
.book-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-size: 14px; font-weight: 650; line-height: 1.4; padding: 11px 15px; border-radius: 10px; min-height: 44px; }
.app-notice { margin-top: 28px; }
.app-notice h2 { margin: 0 0 8px; line-height: 1.4; }
.app-notice p { margin: 0; line-height: 1.6; }
.app-notice .hint { margin-top: 8px; }
.app-notice ul { margin: 12px 0; padding-left: 22px; line-height: 1.6; }
.app-notice li + li { margin-top: 4px; }

.chart-panel { margin-top: 24px; }
.chart-panel h2 { margin-bottom: 8px; }
.chart-panel .hint { margin: 0 0 16px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 18px; font-size: 14px; line-height: 1.5; margin-bottom: 12px; }
.chart-key { display: inline-block; width: 22px; height: 4px; background: var(--chart-ink); vertical-align: middle; margin-right: 7px; border-radius: 4px; }
.chart-key.secondary { background: var(--muted); }
.chart-key.zero { height: 0; border-top: 2px dashed var(--muted); background: transparent; }
.chart-output { max-width: 720px; margin: auto; }
.chart-output svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-output text { fill: var(--muted); font-family: inherit; font-size: 15px; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-zero { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-line { fill: none; stroke: var(--chart-ink); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart-line.secondary { stroke: var(--muted); stroke-dasharray: 6 4; stroke-width: 2; }
.chart-empty { padding: 38px 0; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; }
.chart-axis { text-align: center; color: var(--muted); font-size: 14px; margin: 4px 0 0; }

.cash-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(90px, .8fr) 44px; align-items: center; gap: 8px; margin-bottom: 12px; }
.cash-row input { font-size: 16px; padding: 10px; }
.cash-remove { padding: 0; width: 44px; min-height: 44px; }
.cash-row .input { min-width: 0; }
#cashflowForm h3 { font-size: 16px; margin: 24px 0 12px; }
#cashflowPane .chart-output { max-width: 800px; }
.cash-positive { fill: var(--accent); stroke: var(--chart-ink); stroke-width: 1; }
.cash-deduction { fill: var(--raised); stroke: var(--chart-ink); stroke-width: 1; }
.cash-negative { fill: var(--error-surface); stroke: var(--error-text); stroke-width: 1; }
.cash-connector { stroke: var(--chart-ink); stroke-dasharray: 4 4; fill: none; }
.result .cash-result-negative { color: var(--error-text); }

@media (max-width: 650px) {
  header { padding: 18px 20px; }
  main { padding: 6px 20px 28px; }
  .layout { grid-template-columns: 1fr; gap: 16px; }
  .panel { padding: 20px; }
  .field { margin-bottom: 16px; }
  .intro { margin-bottom: 18px; }
  .hero { font-size: 44px; }
  .metrics { gap: 16px; }
  h1 { font-size: 28px; }
}
@media (max-width: 500px) {
  header { gap: 8px; }
  .options-menu > summary { padding: 10px 8px; font-size: 13px; }
  header small { font-size: 12px; }
  .book-banner { grid-template-columns: 56px minmax(0, 1fr); align-items: start; gap: 12px; padding: 16px; }
  .book-cover { width: 56px; grid-row: 1 / 3; }
  .book-link { grid-column: 2; justify-self: start; }
}
@media (max-width: 420px) {
  .brand { width: 42px; height: 42px; }
  .name { font-size: 18px; }
  .cash-row { gap: 5px; grid-template-columns: minmax(0, 1fr) 95px 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .bar div, .switch-thumb { transition: none; }
}
