/* The board: a phone-width grid of what she saved, filters on top, one item at a time
   in a sheet. Same tokens as the mockup; Telegram's light or dark choice sets data-theme. */
:root {
  --paper: #ECEDE8; --surface: #FAFAF7; --raised: #FFFFFF; --ink: #1D211F; --muted: #626862; --line: #D6D9D1;
  --accent: #3B6A4E; --accent-ink: #FFFFFF; --accent-soft: #DCE7DE; --danger: #A23F2E; --pill: rgba(29,33,31,.10);
  --display: "Familjen Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #111311; --surface: #181B19; --raised: #202422; --ink: #E7E9E3; --muted: #9BA199; --line: #2E3330;
  --accent: #8EC29F; --accent-ink: #0E1A12; --accent-soft: #233429; --danger: #E28B78; --pill: rgba(231,233,227,.12);
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --paper: #111311; --surface: #181B19; --raised: #202422; --ink: #E7E9E3; --muted: #9BA199; --line: #2E3330;
  --accent: #8EC29F; --accent-ink: #0E1A12; --accent-soft: #233429; --danger: #E28B78; --pill: rgba(231,233,227,.12);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--surface); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { position: sticky; top: 0; z-index: 2; background: var(--raised); border-bottom: 1px solid var(--line);
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 10px max(14px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 9px; }
.top-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
h1 { font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -.015em; margin: 0; }
.count { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
#q { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--surface); font-size: 15px; }
#q::placeholder { color: var(--muted); }
.filters { display: flex; flex-direction: column; gap: 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; align-items: center; margin-inline: -2px; padding-inline: 2px; }
.chips::-webkit-scrollbar { display: none; }
.rowlab { flex: none; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); width: 64px; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-weight: 500; font-size: 13px; white-space: nowrap; }
.chip .n { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: 5px; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .7; }
.chip.pj[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.sub { font-size: 12px; padding: 3px 10px; }
.only { flex: none; font-size: 13px; font-weight: 600; color: var(--accent); }
.dot { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1px solid rgba(0,0,0,.14); padding: 0; }
.dot[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }

.grid-wrap { padding: 12px max(12px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 12px; }
.card { border: 0; background: none; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.thumb { aspect-ratio: 4 / 5; border-radius: 12px; overflow: hidden; position: relative; background: var(--line); margin-bottom: 4px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.card:hover .thumb { filter: brightness(.97); }
.card .t { font-weight: 600; font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.card .p { font-family: var(--mono); font-size: 11px; color: var(--muted); line-height: 1.3; }
.card .pjn { font-size: 12px; font-weight: 600; color: var(--accent); }
.card .pjn.none { color: var(--muted); font-weight: 500; }
.badge { position: absolute; left: 8px; top: 8px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--raised); color: var(--ink); }
.more { position: absolute; right: 8px; bottom: 8px; font-family: var(--mono); font-size: 11px; padding: 1px 7px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; }
.notice { text-align: center; color: var(--muted); padding: 40px 12px; margin: 0; max-width: 40ch; margin-inline: auto; }
.build { font-family: var(--mono); font-size: 10.5px; color: var(--muted); text-align: center; margin: 28px 0 0; opacity: .7; }

.noteart { width: 100%; height: 100%; background: var(--raised); display: flex; flex-direction: column; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: inherit; }
.noteart .bar { height: 36%; border-radius: 8px; flex: none; background: var(--accent-soft); }
.noteart q { font-size: 13.5px; line-height: 1.35; overflow: hidden; }
.noteart small { margin-top: auto; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

.sheet { position: fixed; inset: 0; z-index: 5; background: var(--surface); overflow-y: auto; overscroll-behavior: contain; }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 10px max(14px, env(safe-area-inset-left, 0px));
  background: var(--raised); border-bottom: 1px solid var(--line); }
.back { border: 0; background: var(--pill); border-radius: 9px; padding: 6px 12px; font-weight: 600; font-size: 14px; }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; background: var(--line); }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: none; width: 100%; max-height: 70vh; object-fit: contain; scroll-snap-align: center; background: var(--paper); }
.gallery .noteart { min-height: 260px; border: 0; border-radius: 0; padding: 20px; }
.gallery .noteart q { font-size: 20px; line-height: 1.3; }
.pager { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: center; padding-top: 6px; }
.sheet-body { max-width: 640px; margin: 0 auto; padding: 16px max(14px, env(safe-area-inset-right, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 16px; }
.sheet-body h2 { font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 2px; text-wrap: balance; overflow-wrap: anywhere; }
.path { font-family: var(--mono); font-size: 12px; }
.quote { margin: 0; border-left: 3px solid var(--accent); padding: 3px 0 3px 11px; font-size: 15px; overflow-wrap: anywhere; }
.quote small { display: block; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 2px; }
.facts, .edit { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 8px 12px; margin: 0; font-size: 14px; align-items: center; }
.facts { align-items: start; }
.facts dt, .edit label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: 2px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.sw { display: inline-flex; gap: 3px; vertical-align: -2px; margin-right: 6px; }
.sw i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.14); }
.edit select, .edit input { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: var(--raised); font-size: 15px; }
.newproj { display: flex; gap: 6px; grid-column: 2; }
.newproj input { flex: 1; }
.btn { border: 1px solid var(--line); background: var(--raised); border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 14px; text-decoration: none; color: var(--ink); display: inline-block; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.del { border: 1px solid var(--danger); color: var(--danger); background: transparent; }
.del.armed { background: var(--danger); color: var(--surface); }
.saved { font-size: 12px; color: var(--accent); min-height: 1em; }
