/* Design tokens and shared primitives — the single source every page loads.
   Light palette on :root, dark via prefers-color-scheme and the data-theme
   override set by lib/theme.js. */
:root{
  --bg:#f6f5f3; --panel:#ffffff; --panel-2:#f0eeea; --line:#dedad3;
  --ink:#1c1a17; --ink-2:#6c665d; --ink-3:#9a9289;
  --accent:#8a5a2b; --accent-ink:#ffffff;
  --shadow:0 1px 2px rgba(0,0,0,.06),0 8px 24px -12px rgba(0,0,0,.18);
  --radius:12px; --radius-s:8px; --radius-l:16px;
  /* a paint with no colour of its own — a medium, a varnish, a thinner */
  --hatch:repeating-linear-gradient(135deg,var(--panel-2) 0 7px,var(--line) 7px 11px);
  --ctl-h:36px; --ctl-big:48px;
  --focus-ring:0 0 0 3px color-mix(in srgb,var(--accent) 20%,transparent);
  --ok:#2f7d4f; --warn:#b0472f;
  --page-narrow:720px; /* the reading column: home and About */
}
/* the pointer decides the scale: finger targets when hover is a fiction */
@media (hover:none){ :root{--ctl-h:44px} }
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#131211; --panel:#1c1a19; --panel-2:#242120; --line:#332f2c;
    --ink:#f0ece7; --ink-2:#a49c92; --ink-3:#736b62;
    --accent:#d9a05b; --accent-ink:#1c1a19;
    --shadow:0 1px 2px rgba(0,0,0,.4),0 10px 30px -14px rgba(0,0,0,.7);
  }
}
:root[data-theme="dark"]{
  --bg:#131211; --panel:#1c1a19; --panel-2:#242120; --line:#332f2c;
  --ink:#f0ece7; --ink-2:#a49c92; --ink-3:#736b62;
  --accent:#d9a05b; --accent-ink:#1c1a19;
  --shadow:0 1px 2px rgba(0,0,0,.4),0 10px 30px -14px rgba(0,0,0,.7);
}

*{box-sizing:border-box}
html,body{margin:0}
/* short and tall pages keep the same width: the scrollbar's room is
   always reserved, so centred layouts never shift when it appears */
html{scrollbar-gutter:stable}
body{
  min-height:100vh;display:flex;flex-direction:column;
  background:var(--bg); color:var(--ink);
  font:15px/1.5 ui-sans-serif,system-ui,-apple-system,"Segoe UI",Inter,Roboto,Helvetica,Arial,sans-serif;
  -webkit-font-smoothing:antialiased;
  /* double-tap never zooms — the pinch stays free */
  touch-action:manipulation;
  -webkit-text-size-adjust:100%;text-size-adjust:100%;
  /* the page reaches under the notch and the home indicator
     (viewport-fit=cover): the flow keeps clear of the sides here, the
     sticky and fixed chrome pads its own edges */
  padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right);
}
button,input,select,textarea{font:inherit;color:inherit}
a{color:inherit}

/* ---------- the page ----------
   The one block between the banner and the tab bar, on every page: centred,
   full width from the first paint — as a flex child with auto margins it
   would otherwise shrink to its content and widen as the data arrives —
   and as tall as the screen so a short page still pins the bar below.
   A page takes the whole width unless its body sets `--page-max`; the
   reading pages share `--page-narrow`, one column for home and About.
   `.cols` lays a sidebar of `--page-side` beside the main column at the
   pointer, and stacks the two at the 860px topology break. */
.page{width:100%;max-width:var(--page-max,none);margin:0 auto;padding:20px;flex:1}
.page.cols{display:grid;grid-template-columns:var(--page-side,250px) 1fr;gap:24px;align-items:start}
@media (max-width:860px){
  /* pack the rows at the top: stretched auto rows would split the free height */
  .page{padding:14px}
  .page.cols{grid-template-columns:1fr;gap:12px;align-content:start}
  .page.cols>*{min-width:0} /* a grid item's auto min-width would let long content widen the page */
}

/* ---------- the control language: five roles ----------
   Underline means navigation; a button means an action. `.btn` alone is the
   secondary — the ordinary action; `.primary` is the screen's one engagement
   (one per screen, at most); `.tertiary` a quiet helper in a section head;
   `.danger` owns its colour at rest, `.filled` once confirmed. `.ibtn` is a
   named icon — bare at rest, `.frame` bordered (the one dialog close, the
   arrows), `.onimg` floating over a photo. */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:7px;
  min-height:var(--ctl-h);padding:0 12px;border:1px solid var(--line);
  background:var(--panel);color:var(--ink);border-radius:var(--radius-s);
  cursor:pointer;white-space:nowrap;text-decoration:none;font-size:14px;font-weight:550;
}
.btn:hover{border-color:var(--ink-3)}
.btn.primary{background:var(--ink);border-color:var(--ink);color:var(--bg);font-weight:600}
.btn.primary:hover{opacity:.86}
.btn.tertiary{border-color:transparent;background:none;color:var(--accent);font-weight:600}
.btn.tertiary:hover{background:var(--panel-2)}
.btn.danger{border-color:color-mix(in srgb,var(--warn) 45%,var(--line));color:var(--warn)}
.btn.danger:hover{border-color:var(--warn)}
.btn.danger.filled{background:var(--warn);border-color:var(--warn);color:#fff}
.btn.danger.filled:hover{opacity:.88}
.btn.big{min-height:var(--ctl-big);font-size:15px}
select.btn{padding-right:9px}

/* a select dressed as the control it is: our chevron, not the native arrow */
.selwrap{position:relative;display:flex;min-width:0}
.selwrap select{appearance:none;-webkit-appearance:none;width:100%;padding-right:30px}
.selwrap>svg{position:absolute;right:9px;top:50%;transform:translateY(-50%);pointer-events:none;color:var(--ink-2)}

.ibtn{
  display:inline-grid;place-items:center;width:var(--ctl-h);height:var(--ctl-h);flex:none;
  border:0;background:none;color:var(--ink-2);border-radius:var(--radius-s);
  cursor:pointer;line-height:0;padding:0;
}
.ibtn:hover{background:var(--panel-2);color:var(--ink)}
.ibtn.frame{border:1px solid var(--line);background:var(--panel)}
.ibtn.frame:hover{border-color:var(--ink-3);background:var(--panel)}
.ibtn.onimg{background:color-mix(in srgb,var(--panel) 85%,transparent);backdrop-filter:blur(6px)}
.ibtn.danger{border-color:color-mix(in srgb,var(--warn) 45%,var(--line));color:var(--warn)}
.ibtn.danger:hover{border-color:var(--warn);background:var(--panel);color:var(--warn)}
/* a trigger whose menu or popover is open holds its hover ground —
   after the variants, so the framed ones take it too */
.ibtn[aria-expanded="true"]{background:var(--panel-2);color:var(--ink)}
.ibtn.frame[aria-expanded="true"]{background:var(--panel-2);border-color:var(--ink-3)}
.btn[aria-expanded="true"]{background:var(--panel-2);border-color:var(--ink-3)}

.btn:disabled,.ibtn:disabled{opacity:.35;cursor:default;border-color:var(--line)}
.btn:focus-visible,.ibtn:focus-visible,.chip:focus-visible,.plink:focus-visible,
.tog:focus-visible,.mark:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* inline links: paint names, quiet doors — underlined, never actions */
.plink{border:0;background:none;padding:0;cursor:pointer;text-decoration:underline;text-underline-offset:2px;font-size:inherit;color:inherit;text-align:left}
.plink:hover{color:var(--accent)}

/* a flexible gap: pushes what follows to the row's far edge */
.sp{flex:1}
/* the overline heading every section shares */
.caps{margin:0;font-size:11px;font-weight:700;letter-spacing:.07em;text-transform:uppercase;color:var(--ink-3)}
/* quiet metadata line, and the note a section shows when it has nothing */
.pmeta{font-size:12px;color:var(--ink-3)}
.enote{margin:0;font-size:13px;color:var(--ink-3)}

/* the quiet counter inside a control's label */
.btn .n{color:var(--ink-3);font-variant-numeric:tabular-nums;font-weight:550}
.btn.primary .n{color:inherit;opacity:.7}

/* the little status pills — owned / to buy / wished — shared everywhere */
.vbadge{font-size:10.5px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--warn);
  border:1px solid color-mix(in srgb,var(--warn) 45%,var(--line));border-radius:99px;padding:1px 7px;white-space:nowrap}
.vbadge.vown{color:var(--ok);border-color:color-mix(in srgb,var(--ok) 45%,var(--line))}
.vbadge.vbuy{color:var(--accent);border-color:color-mix(in srgb,var(--accent) 45%,var(--line))}
.vbadge.vwish{color:var(--warn);border-color:color-mix(in srgb,var(--warn) 45%,var(--line))}

/* fields answer focus the same way everywhere */
input:focus,select:focus,textarea:focus{border-color:var(--accent);box-shadow:var(--focus-ring);outline:none}
/* selected text takes the site's accent, not the OS highlight colour —
   a preselected field must read as one chrome, not two */
::selection{background:color-mix(in srgb,var(--accent) 25%,transparent)}
/* Chrome repaints autofilled fields in its own green over our chrome:
   flood it back to the field's ground, on both themes */
input:-webkit-autofill,input:-webkit-autofill:hover,input:-webkit-autofill:focus{
  -webkit-box-shadow:inset 0 0 0 1000px var(--panel);
  -webkit-text-fill-color:var(--ink);
  caret-color:var(--ink);
}
input:-webkit-autofill:focus{-webkit-box-shadow:inset 0 0 0 1000px var(--panel),var(--focus-ring)}

@media (hover:none){
  input,select,textarea{font-size:16px} /* under 16px, iOS zooms on focus */
  .btn:active,.ibtn:active{background:var(--panel-2)}
  .btn.primary:active,.btn.danger.filled:active{opacity:.78}
}

/* Every dialog's ground — a panel in both themes, a bottom sheet under
   860px. A page says how wide it wants it at the pointer through --dlg-w,
   and through nothing else: the sheet is this rule's business. Setting
   `width` or `max-width` on a dialog's own id wins on specificity and
   leaves a strip of backdrop down one side of every phone, which is why
   the knob feeds max-width alone. */
dialog{
  --dlg-w:560px;
  border:1px solid var(--line);background:var(--panel);color:var(--ink);
  border-radius:var(--radius-l);padding:0;max-width:min(var(--dlg-w),92vw);width:100%;box-shadow:var(--shadow);
}
dialog::backdrop{background:rgba(0,0,0,.55);backdrop-filter:blur(2px)}
dialog code{background:var(--panel-2);border-radius:4px;padding:1px 5px;font-size:.92em}
@media (max-width:860px){
  dialog{
    width:100vw;max-width:100vw;margin:auto 0 0;
    border-radius:var(--radius-l) var(--radius-l) 0 0;border-left:0;border-right:0;border-bottom:0;
    max-height:calc(100dvh - 24px);
    padding-bottom:env(safe-area-inset-bottom);
  }
}

/* What any dialog is built from, wherever it lives. These serve the
   Réglages sheet too, which the tabbar partial puts on every page — a
   dialog's own look must sit in a sheet its pages actually load. */
.mwrap{position:relative;padding:18px 20px;display:flex;flex-direction:column;gap:10px;max-height:82vh;overflow:auto}
.mwrap h3{margin:0;font-size:17px;letter-spacing:-.01em;padding-right:44px}
.dclose{position:absolute;right:10px;top:10px;z-index:2}
.acts{display:flex;gap:8px;margin-top:auto;flex-wrap:wrap;align-items:center}
.vunres{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12.5px;color:var(--ink-2)}
@media (max-width:860px){
  .acts{gap:10px}
  .mwrap{max-height:calc(100dvh - 24px - env(safe-area-inset-bottom))}
}

/* the ⋯ / ⋮ action menu: a sheet under a thumb, a popover at the pointer */
#menudlg{--dlg-w:300px}
.menuin{display:flex;flex-direction:column;padding:8px}
.mgrab{display:none;width:36px;height:4px;border-radius:99px;background:var(--line);margin:2px auto 6px;flex:none}
.mhead{display:none;align-items:center;gap:8px;padding:0 0 4px 10px}
.mtitle{flex:1;font-size:14.5px;color:var(--ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.menuin hr{border:0;border-top:1px solid var(--line);margin:6px 0}
.mrow{
  display:flex;align-items:center;gap:10px;min-height:48px;padding:0 12px;
  border:0;background:none;border-radius:var(--radius-s);cursor:pointer;
  font-size:14.5px;text-align:left;
}
.mrow:hover{background:var(--panel-2)}
.mrow:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.mrow svg{flex:none;color:var(--ink-2)}
.mrow.mdanger svg{color:inherit}
.mrow .mgap{width:15px;flex:none}
.mrow:disabled{opacity:.35;cursor:default}
.mrow.mdanger{color:var(--warn)}

.mrow.mstrong{font-weight:650}
@media (min-width:861px){
  #menudlg{--dlg-w:260px}
  #menudlg::backdrop{background:none;backdrop-filter:none} /* a popover leaves the page readable */
  .mrow{min-height:40px;font-size:14px}
}
@media (max-width:860px){
  .mgrab{display:block}
  .mhead{display:flex}
  .mrow{min-height:52px}
}

/* facet pills — the catalogue's filters and the paint picker's, one look */
.chips{display:flex;flex-wrap:wrap;gap:6px}
.chip{
  display:inline-flex;align-items:center;gap:6px;min-height:30px;padding:2px 10px;border-radius:99px;
  border:1px solid var(--line);background:var(--panel);cursor:pointer;font-size:13px;
  transition:background .12s,border-color .12s,color .12s;
}
@media (hover:none){ .chip{min-height:40px} }
.chip:hover{border-color:var(--ink-3)}
.chip[aria-pressed="true"]{background:var(--ink);color:var(--bg);border-color:var(--ink)}
.chip .n{font-size:11px;color:var(--ink-3);font-variant-numeric:tabular-nums}
.chip[aria-pressed="true"] .n{color:inherit;opacity:.65}
.dot{width:14px;height:14px;border-radius:5px;flex:none;box-shadow:inset 0 0 0 1px rgba(128,128,128,.45);background:var(--panel-2)}
.chip .dot{width:11px;height:11px;border-radius:99px;background:none}
.chip.off{opacity:.35}

/* the paint chooser of a recipe step, and the inline delete confirmation —
   shared by the oath page and the recipes page */
.pbtn{
  display:inline-flex;align-items:center;gap:8px;border:1px solid var(--line);background:var(--panel);
  border-radius:var(--radius-s);min-height:var(--ctl-h);padding:0 9px;cursor:pointer;font-size:13.5px;min-width:0;max-width:100%;text-align:left;
}
.pbtn:hover{border-color:var(--ink-3)}
.pbtn .pn{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pbtn .pb{font-size:11.5px;color:var(--ink-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pbtn.unres{border-style:dashed;color:var(--ink-2)}
.confirm{
  display:flex;gap:8px;align-items:center;flex-wrap:wrap;font-size:13px;color:var(--warn);
  background:color-mix(in srgb,var(--warn) 8%,var(--panel));border:1px solid color-mix(in srgb,var(--warn) 40%,var(--line));
  border-radius:var(--radius-s);padding:8px 11px;margin:6px 0;
}

.empty{padding:70px 20px;text-align:center;color:var(--ink-2)}
.empty strong{display:block;color:var(--ink);font-size:16px;margin-bottom:6px}
.empty .eact{margin:14px 0 0}

#toast{
  position:fixed;left:50%;bottom:20px;transform:translate(-50%,14px);z-index:70;
  background:var(--ink);color:var(--bg);padding:11px 18px;border-radius:var(--radius);font-size:13.5px;
  box-shadow:var(--shadow);opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;
  max-width:min(560px,92vw);
}
#toast.on{opacity:1;transform:translate(-50%,0)}

/* a mix wears the accent: it is the oath's own colour, not a shelf's */
.vbadge.vmix{color:var(--accent);border-color:color-mix(in srgb,var(--accent) 45%,var(--line))}
.dot.nocol{background:var(--hatch)}
