/* Evolved PW Tools — design tokens (from the Tome Refining Reference) and the site shell.
   Tokens live here and only here; pages reference them as var(--…). */
:root {
  --bg: #f4f0e6; --surface: #fcfaf5; --fg: #2a241b; --muted: #6f6656; --line: #dcd3c2;
  --accent: #8a5a1c; --accent-soft: #f1e3c9; --gate: #9b2f2f; --gate-soft: #f6e1e1;
  --ok: #3f8a4a; --ok-soft: #e4f1e5;
  --display: "Cinzel", "Times New Roman", serif; --body: "Nunito Sans", system-ui, sans-serif; --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #17150f; --surface: #211e16; --fg: #ebe4d6; --muted: #a39a88; --line: #3a352b;
  --accent: #d9a65a; --accent-soft: #3a2f1c; --gate: #e07a7a; --gate-soft: #3d2222;
  --ok: #7fcb8a; --ok-soft: #1e3222; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #17150f; --surface: #211e16; --fg: #ebe4d6; --muted: #a39a88; --line: #3a352b;
  --accent: #d9a65a; --accent-soft: #3a2f1c; --gate: #e07a7a; --gate-soft: #3d2222;
  --ok: #7fcb8a; --ok-soft: #1e3222; color-scheme: dark }

/* Base */
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; line-height: 1.5; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: 0.02em; }
h1 { font-weight: 600; font-size: 1.9rem; text-wrap: balance; }
h2 { font-weight: 500; font-size: 1.15rem; }
p { margin: 0; max-width: 65ch; }
a { color: var(--accent); }
.lede { color: var(--muted); }
.muted { color: var(--muted); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.gate { background: var(--gate-soft); color: var(--gate); }
.pill.ext { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }

/* Shell: sticky sidebar on the left, one main column. Rules are scoped so tool pages' own styles are untouched. */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.shell > main { min-width: 0; max-width: 980px; padding: 40px clamp(16px, 4vw, 56px) 64px; display: flex; flex-direction: column; gap: 40px; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; padding: 28px 20px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { font-family: var(--display); font-weight: 600; font-size: 1.05rem; line-height: 1.2; letter-spacing: 0.02em; }
.brand a { color: inherit; text-decoration: none; }
.brand small { display: block; font-family: var(--body); font-weight: 400; font-size: 12px; color: var(--muted); letter-spacing: 0; margin-top: 2px; }
.group { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; margin: 0 0 6px; }
#site-nav ul { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 2px; }
#site-nav ul:last-child { margin-bottom: 0; }
#site-nav a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--fg); text-decoration: none; font-weight: 600; font-size: 14px; }
#site-nav a:hover, #site-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
a.ext::after { content: ' ↗'; color: var(--muted); font-weight: 400; }
.foot { margin-top: auto; font-size: 12px; color: var(--muted); }
.menu-toggle { display: none; font: inherit; font-weight: 600; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); cursor: pointer; }
.menu-toggle:focus-visible, #site-nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Tool pages' shared header chrome: a settings strip (picker) and summary tiles. Page-specific controls inside them stay per page. */
.picker { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.picker label { font-weight: 600; }
.num { font: inherit; font-family: var(--mono); font-weight: 500; width: 4.5em; padding: 5px 8px; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; }
.num:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.tile .k { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.tile .v { font-family: var(--mono); font-size: 1.5rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--muted); }
.tile.gate { border-color: var(--gate); background: var(--gate-soft); }
.tile.gate .v { color: var(--gate); }

/* Landing page directory */
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tool { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; }
.tool:hover { border-color: var(--accent); }
.tool h3 { font-size: 1rem; font-weight: 600; color: var(--accent); }
.tool p { font-size: 14px; color: var(--muted); }
.tool .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.page-home section { display: flex; flex-direction: column; gap: 14px; }
.page-home header { display: flex; flex-direction: column; gap: 10px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .page-tool .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 14px 16px; gap: 10px; }
  .page-tool .menu-toggle { display: inline-block; }
  .page-tool .sidebar:not(.open) #site-nav, .page-tool .sidebar:not(.open) .foot { display: none; }
  .page-tool .sidebar.open #site-nav, .page-tool .sidebar.open .foot { flex: 0 0 100%; }
}
