/* KOLLAZ Toolz, DIRECTION 1 "ledger": The Precision Ledger.
   Deep ink navy + warm paper, hairline rules, tabular numerals,
   a mono accent for figures. Both schemes are full token sets. */
@layer reset, tokens, base, layout, components, states;

@font-face { font-family: "Newsreader"; src: url("../fonts/newsreader-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("../fonts/newsreader-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url("../fonts/newsreader-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Noto Sans"; src: url("../fonts/noto-sans-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Noto Sans"; src: url("../fonts/noto-sans-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Noto Sans"; src: url("../fonts/noto-sans-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

@layer tokens {
  :root {
    color-scheme: light dark;
    --paper: #f6f1e5; --surface: #fffdf6; --surface-2: #efe8d8;
    --ink: #1b2a3d; --ink-strong: #101e30; --muted: #46586d;
    --line: #8d99a8; --line-soft: #c9cfd6;
    --link: #14467c; --link-hover: #0d3460;
    --btn-bg: #16283f; --btn-ink: #f6f1e5; --btn-bg-hover: #0e1d31;
    --accent: #7a5410; --error: #9c1a24; --error-bg: #fbeeee;
    --ok: #1d5c38; --ok-bg: #e9f3ec;
    --focus: #14467c;
    --band: #16283f; --band-ink: #f2ecdc; --band-link: #a9cbf2; --band-muted: #c3cede;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --paper: #0c1521; --surface: #132032; --surface-2: #1a2c44;
      --ink: #ece4d0; --ink-strong: #f7f2e3; --muted: #b3bfd0;
      --line: #5f7189; --line-soft: #33465e;
      --link: #9ec2ee; --link-hover: #c2d9f7;
      --btn-bg: #ece4d0; --btn-ink: #101e30; --btn-bg-hover: #ffffff;
      --accent: #d9ab4e; --error: #f0a3ab; --error-bg: #3a1d24;
      --ok: #9fd4b2; --ok-bg: #173527;
      --focus: #9ec2ee;
      --band: #060d16; --band-ink: #f2ecdc; --band-link: #a9cbf2; --band-muted: #c3cede;
    }
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --paper: #0c1521; --surface: #132032; --surface-2: #1a2c44;
    --ink: #ece4d0; --ink-strong: #f7f2e3; --muted: #b3bfd0;
    --line: #5f7189; --line-soft: #33465e;
    --link: #9ec2ee; --link-hover: #c2d9f7;
    --btn-bg: #ece4d0; --btn-ink: #101e30; --btn-bg-hover: #ffffff;
    --accent: #d9ab4e; --error: #f0a3ab; --error-bg: #3a1d24;
    --ok: #9fd4b2; --ok-bg: #173527;
    --focus: #9ec2ee;
    --band: #060d16; --band-ink: #f2ecdc; --band-link: #a9cbf2; --band-muted: #c3cede;
  }
  :root[data-theme="light"] { color-scheme: light; }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, p, ul, figure, fieldset { margin: 0; }
  fieldset { padding: 0; border: 0; }
  ul { padding: 0; list-style: none; }
  img, svg { max-width: 100%; }
}

@layer base {
  body {
    background: var(--paper); color: var(--ink);
    font-family: "Noto Sans", Arial, sans-serif;
    font-size: 1rem; line-height: 1.55;
  }
  h1, h2, .serif { font-family: "Newsreader", Georgia, serif; color: var(--ink-strong); }
  h1 { font-size: clamp(2rem, 6vw, 3.1rem); line-height: 1.08; font-weight: 700; letter-spacing: -0.01em; }
  h2 { font-size: 1.55rem; line-height: 1.2; font-weight: 600; }
  h3 { font-size: 1.05rem; line-height: 1.3; }
  .mono, .figure, input, .stat-value, td.num, .rate-note {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
  }
  a { color: var(--link); text-underline-offset: 0.18em; }
  ::selection { background: var(--btn-bg); color: var(--btn-ink); }
}

@layer layout {
  .page { padding-inline: 20px; max-width: 1160px; margin-inline: auto; }
  @media (min-width: 720px) { .page { padding-inline: 32px; } }
  .rule { border-top: 1px solid var(--line); }
  .rule-double { border-top: 3px double var(--line); }
  header.site-head { border-bottom: 3px double var(--line); }
  .head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 14px; }
  .wordmark { font-family: "Newsreader", Georgia, serif; font-weight: 700; font-size: 1.3rem; letter-spacing: 0.06em; color: var(--ink-strong); text-decoration: none; }
  .wordmark small { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.62rem; letter-spacing: 0.22em; color: var(--muted); font-weight: 400; }
  footer.site-foot { border-top: 3px double var(--line); margin-top: 56px; padding-block: 24px 40px; color: var(--muted); font-size: 0.9rem; }
  .hero { padding-block: 36px 28px; }
  .kicker { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
  .lede { font-size: 1.13rem; max-width: 38rem; margin-top: 14px; }
  .first-action { margin-top: 24px; border: 1px solid var(--line); background: var(--surface); padding: 20px; }
  .receipt { font-size: 0.88rem; color: var(--muted); margin-top: 10px; }
  .index-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 44px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .tool-list { border-bottom: 1px solid var(--line-soft); }
  .tool-row { display: grid; grid-template-columns: 3rem 1fr auto; gap: 6px 14px; align-items: baseline; padding-block: 13px; border-bottom: 1px solid var(--line-soft); }
  .tool-no { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
  .tool-name { font-weight: 700; font-size: 1.02rem; }
  .tool-what { color: var(--muted); font-size: 0.92rem; grid-column: 2; }
  .tool-open { grid-row: 1; grid-column: 3; font-weight: 500; white-space: nowrap; }
  .band { background: var(--band); color: var(--band-ink); margin-top: 48px; }
  .band .page { padding-block: 28px; }
  .band h2 { color: var(--band-ink); }
  .band a { color: var(--band-link); }
  .band .muted { color: var(--band-muted); }
  .calc-grid { display: grid; gap: 28px; margin-top: 28px; }
  @media (min-width: 900px) { .calc-grid { grid-template-columns: 1.05fr 0.95fr; align-items: start; } }
  .ledger-card { background: var(--surface); border: 1px solid var(--line); padding: 20px; }
  .results { position: sticky; top: 16px; }
  .stat-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
  .stat-table th, .stat-table td { text-align: left; padding-block: 9px; border-bottom: 1px solid var(--line-soft); font-size: 0.95rem; }
  .stat-table td.num { text-align: right; font-size: 1.02rem; }
  .verdict { border: 1px solid var(--line); border-left: 6px solid var(--accent); padding: 16px; background: var(--surface-2); }
  .verdict.good { border-left-color: var(--ok); }
  .verdict.bad { border-left-color: var(--error); }
}

@layer components {
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 12px 22px; border: 1px solid var(--btn-bg);
    background: var(--btn-bg); color: var(--btn-ink);
    font-family: "Noto Sans", Arial, sans-serif; font-size: 1rem; font-weight: 700;
    text-decoration: none; cursor: pointer; border-radius: 2px;
    transition: background-color 150ms ease, color 150ms ease;
  }
  .btn.secondary { background: transparent; color: var(--link); border-color: var(--line); }
  .theme-control { position: relative; }
  .theme-button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 2px;
    background: var(--surface); color: var(--ink-strong); cursor: pointer;
    transition: background-color 150ms ease;
  }
  .theme-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 180px;
    background: var(--surface); border: 1px solid var(--line); padding: 6px;
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.22);
  }
  .theme-menu [role="menuitemradio"] {
    display: flex; width: 100%; align-items: center; gap: 10px; min-height: 44px;
    padding: 8px 10px; border: 0; background: transparent; color: var(--ink);
    font: inherit; font-size: 0.95rem; cursor: pointer; text-align: left;
  }
  .theme-menu .is-current { font-weight: 700; }
  .theme-menu .is-current::after { content: "current"; margin-left: auto; font-size: 0.72rem; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }
  fieldset.group { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 20px; }
  legend.group-title { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); font-weight: 700; padding-right: 10px; }
  .field { margin-top: 14px; }
  .field label { display: block; font-weight: 500; font-size: 0.95rem; margin-bottom: 6px; }
  .field input, .field select {
    width: 100%; min-height: 48px; padding: 10px 12px; font-size: 1rem;
    background: var(--surface); color: var(--ink-strong);
    border: 1px solid var(--line); border-radius: 2px;
    font-variant-numeric: tabular-nums;
  }
  .field .hint { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
  .field .error-msg { display: none; font-size: 0.88rem; color: var(--error); margin-top: 6px; font-weight: 500; }
  .field.has-error input, .field.has-error select { border-color: var(--error); border-width: 2px; }
  .field.has-error .error-msg { display: block; }
  .check-field { display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; }
  .check-field input { width: 24px; height: 24px; margin-top: 2px; accent-color: var(--btn-bg); flex: none; }
  .rate-note { font-size: 0.85rem; background: var(--surface-2); border: 1px solid var(--line-soft); padding: 12px; margin-top: 8px; line-height: 1.6; }
  .spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 700ms linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .btn, .theme-button { transition: none; } }
}

@layer states {
  a:hover { color: var(--link-hover); }
  .btn:hover { background: var(--btn-bg-hover); }
  .btn.secondary:hover { background: var(--surface-2); color: var(--link-hover); }
  .theme-button:hover, .theme-menu [role="menuitemradio"]:hover { background: var(--surface-2); }
  a:focus-visible, .btn:focus-visible, .theme-button:focus-visible,
  .theme-menu [role="menuitemradio"]:focus-visible,
  input:focus-visible, select:focus-visible {
    outline: 3px solid var(--focus); outline-offset: 2px;
  }
  .btn:active, .theme-button:active { transform: translateY(1px); }
  .theme-menu [role="menuitemradio"]:active { background: var(--surface-2); }
  input:active, select:active { border-color: var(--ink-strong); }
  .btn:disabled, .theme-button:disabled, input:disabled, select:disabled {
    opacity: 0.55; cursor: not-allowed; transform: none;
  }
  .btn[aria-busy="true"] { cursor: progress; }
  input:user-invalid { border-color: var(--error); }
}
