/* ============================================================================
   Inspiration Board — theme tokens, layout, cards
   Two themes (Paper / Ink) + tweakable accent, type, texture, card style.
   ========================================================================== */

:root {
  /* type — overridden by typography tweak */
  --font-ui: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Hanken Grotesk', system-ui, sans-serif;
  --font-quote: 'Newsreader', Georgia, serif;
  --font-mono: 'Space Mono', ui-monospace, monospace;

  /* accent — overridden by tweak */
  --accent: oklch(0.72 0.11 66);
  --accent-ink: oklch(0.78 0.12 70);

  --radius: 14px;
  --gap: 22px;
  --col-w: 340px;        /* driven by zoom */
  --tile: 300px;         /* grid tile size, driven by zoom */
}

/* ---- Paper (default, warm quiet) ---------------------------------------- */
:root,
[data-theme="paper"] {
  --bg:           oklch(0.964 0.006 82);
  --bg-deep:      oklch(0.935 0.008 82);
  --surface:      oklch(0.995 0.003 85);
  --surface-2:    oklch(0.972 0.005 82);
  --text:         oklch(0.245 0.008 62);
  --text-muted:   oklch(0.515 0.010 62);
  --text-faint:   oklch(0.660 0.010 62);
  --border:       oklch(0.885 0.006 76);
  --border-strong:oklch(0.800 0.008 70);
  --shadow-color: 40 35 25;
  --accent-use:   var(--accent);
  --placeholder-a:oklch(0.90 0.012 70);
  --placeholder-b:oklch(0.85 0.016 70);
  --scrim:        rgba(250 248 244 / 0.72);
}

/* ---- Ink (dark, moody, ambient) ----------------------------------------- */
[data-theme="ink"] {
  --bg:           oklch(0.205 0.014 264);
  --bg-deep:      oklch(0.165 0.014 264);
  --surface:      oklch(0.248 0.016 264);
  --surface-2:    oklch(0.288 0.018 264);
  --text:         oklch(0.935 0.006 90);
  --text-muted:   oklch(0.660 0.014 264);
  --text-faint:   oklch(0.515 0.014 264);
  --border:       oklch(0.330 0.018 264);
  --border-strong:oklch(0.430 0.022 264);
  --shadow-color: 0 0 0;
  --accent-use:   var(--accent-ink);
  --placeholder-a:oklch(0.30 0.020 264);
  --placeholder-b:oklch(0.255 0.022 268);
  --scrim:        rgba(18 20 30 / 0.72);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { overflow: hidden; }      /* board scrolls internally */

::selection { background: color-mix(in oklab, var(--accent-use) 30%, transparent); }

button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
:is(a, button, input):focus-visible {
  outline: 2px solid var(--accent-use);
  outline-offset: 2px;
}

/* ============================================================================
   App shell
   ========================================================================== */
.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

/* texture layer */
.app::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.9;
  background-image: var(--texture-img, none);
  background-size: var(--texture-size, auto);
  mix-blend-mode: var(--texture-blend, normal);
}
[data-texture="grain"] .app::before {
  --texture-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  --texture-size: 160px;
  opacity: 0.035;
}
[data-texture="grid"] .app::before {
  --texture-img:
    repeating-linear-gradient(to right, color-mix(in oklab,var(--text) 7%,transparent) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(to bottom, color-mix(in oklab,var(--text) 7%,transparent) 0 1px, transparent 1px 40px);
  opacity: 0.5;
}
[data-texture="dots"] .app::before {
  --texture-img: radial-gradient(color-mix(in oklab,var(--text) 12%,transparent) 1px, transparent 1.4px);
  --texture-size: 22px 22px;
  opacity: 0.55;
}

/* ============================================================================
   Top bar
   ========================================================================== */
.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}
.brand { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand h1 {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.01em;
  line-height: 1;
}
.brand .sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  text-transform: uppercase;
}

.topbar .spacer { flex: 1; }

/* search */
.search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}
.search input {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px 9px 34px;
  width: 220px;
  outline: none;
  transition: border-color .15s, width .2s, background .15s;
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus { border-color: var(--accent-use); width: 270px; }
.search .ic {
  position: absolute;
  left: 13px;
  color: var(--text-faint);
  pointer-events: none;
  display: flex;
}

/* tool buttons */
.tools { display: flex; align-items: center; gap: 8px; }
.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  transition: border-color .15s, color .15s, background .15s, transform .1s;
}
.tbtn:hover { color: var(--text); border-color: var(--border-strong); }
.tbtn:active { transform: translateY(1px); }
.tbtn[data-active="1"] {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}
.tbtn.icon { padding: 0; width: 38px; justify-content: center; }
.tbtn svg { display: block; }

.zoom {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
}
.zoom button {
  width: 34px; height: 38px;
  border: 0; background: transparent;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.zoom button:hover { color: var(--text); background: var(--surface-2); }
.zoom .lvl {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  min-width: 40px;
  text-align: center;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  height: 38px;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
}

/* ============================================================================
   Filter rail (types + active facets)
   ========================================================================== */
.subbar {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 26px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  overflow-x: auto;
  scrollbar-width: none;
}
.subbar::-webkit-scrollbar { display: none; }
.chips { display: flex; align-items: center; gap: 7px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: all .14s;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip[data-active="1"] {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .75; }
.chip .ct { font-family: var(--font-mono); font-size: 10px; opacity: .6; }

.facet {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 8px 0 12px;
  border-radius: 999px;
  border: 1px solid var(--accent-use);
  color: var(--accent-use);
  background: color-mix(in oklab, var(--accent-use) 12%, transparent);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}
.facet button {
  border: 0; background: transparent; color: inherit;
  display: flex; padding: 2px; border-radius: 50%;
}
.facet button:hover { background: color-mix(in oklab, var(--accent-use) 25%, transparent); }

.divider-v { width: 1px; height: 22px; background: var(--border); flex: none; }
.subbar .label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  flex: none;
}

/* ============================================================================
   Board (scroll area) + layouts
   ========================================================================== */
.board-wrap {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow: auto;
  scroll-behavior: smooth;
}
.board-wrap::-webkit-scrollbar { width: 12px; height: 12px; }
.board-wrap::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--text) 18%, transparent);
  border: 4px solid transparent; background-clip: content-box; border-radius: 8px;
}
.board {
  padding: 30px 26px 120px;
  min-height: 100%;
}

/* frame wraps each card: owns layout placement + focus affordance */
.frame { position: relative; }
.expand {
  position: absolute;
  top: 9px; right: 9px;
  z-index: 8;
  width: 30px; height: 30px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--scrim);
  backdrop-filter: blur(6px);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transform: scale(.9);
  transition: opacity .15s, transform .15s, color .15s;
}
.frame:hover .expand { opacity: 1; transform: none; }
.expand:hover { color: var(--text); border-color: var(--border-strong); }
@media (hover: none) { .expand { opacity: .85; } }

/* --- mosaic (CSS columns) --- */
.board.mosaic {
  column-width: var(--col-w);
  column-gap: var(--gap);
}
.board.mosaic .frame {
  break-inside: avoid;
  margin-bottom: var(--gap);
  width: 100%;
}

/* --- grid (uniform tiles) --- */
.board.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr));
  gap: var(--gap);
  align-content: start;
}
.board.grid .frame { height: var(--tile); }
.board.grid .card { height: 100%; }
.board.grid .card .card-body { overflow: hidden; }
.board.grid .card .note-text { -webkit-line-clamp: 2; }
.board.grid .photo-card .ph { flex: 1; }
.board.grid .video-card .video-poster { aspect-ratio: auto; flex: 1; }

/* --- scattered (free pinboard) --- */
.board.scatter {
  position: relative;
  min-height: 1600px;
}
.board.scatter .frame {
  position: absolute;
  width: var(--col-w);
  transition: box-shadow .2s;
  cursor: grab;
}
.board.scatter .frame.dragging { cursor: grabbing; z-index: 50 !important; }
.board.scatter .frame.dragging .card { box-shadow: 0 20px 50px rgb(var(--shadow-color) / .3); }

.empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--text-faint);
  font-family: var(--font-mono); font-size: 13px;
}

/* ============================================================================
   Card — shared
   ========================================================================== */
.card {
  position: relative;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .2s, border-color .2s, transform .15s;
}
/* card style: raised */
[data-cardstyle="raised"] .card {
  border-color: transparent;
  box-shadow: 0 1px 2px rgb(var(--shadow-color) / .06),
              0 8px 24px rgb(var(--shadow-color) / .10);
}
[data-cardstyle="raised"] .card:hover {
  box-shadow: 0 2px 4px rgb(var(--shadow-color) / .08),
              0 16px 40px rgb(var(--shadow-color) / .16);
}
/* card style: hairline */
[data-cardstyle="hairline"] .card:hover { border-color: var(--border-strong); }

.card.clickable { cursor: pointer; }

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 15px 0;
}
.type-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.type-tag .glyph {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-use);
}
.card-head .date {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
}

.card-body { padding: 12px 15px 4px; flex: 1; }

.note-text {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 9px;
  padding: 10px 15px 14px;
}
.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  background: transparent;
  border: 0;
  padding: 0;
  transition: color .14s;
}
.tag:hover { color: var(--accent-use); }
.tag::before { content: "#"; opacity: .5; }

.source {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  text-decoration: none;
  white-space: nowrap;
}
.source:hover { color: var(--accent-use); }
.source svg { width: 12px; height: 12px; }

/* ============================================================================
   Card — media specifics
   ========================================================================== */

/* striped image placeholder */
.ph {
  position: relative;
  width: 100%;
  background:
    repeating-linear-gradient(
      135deg,
      var(--placeholder-a) 0 10px,
      var(--placeholder-b) 10px 20px);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}
.ph::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(160deg,
     color-mix(in oklab, var(--ph-tint, transparent) 55%, transparent),
     transparent 60%);
  mix-blend-mode: overlay;
}
.ph .ph-cap {
  position: relative;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--scrim);
  backdrop-filter: blur(3px);
  padding: 5px 9px;
  margin: 10px;
  border-radius: 6px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  max-width: calc(100% - 20px);
}
.ph .ph-cap .arrow { color: var(--accent-use); }
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---- data loading / local-preview onboarding ---- */
.loader, .onboard {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 30px; text-align: center;
}
.loader .spin {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--accent-use);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader .lt, .onboard .ot { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); }
.onboard {
  border: 1.5px dashed var(--border-strong);
  border-radius: 18px;
  margin: 40px;
  inset: 0;
  background: var(--surface);
  transition: border-color .15s, background .15s;
}
.onboard.over { border-color: var(--accent-use); background: var(--surface-2); }
.onboard h2 {
  font-family: var(--font-ui); font-weight: 600; font-size: 22px; margin: 0; color: var(--text);
}
.onboard p { font-family: var(--font-body); font-size: 14px; color: var(--text-muted); max-width: 460px; line-height: 1.55; margin: 0; }
.onboard .pick {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-ui); font-weight: 500; font-size: 14px;
  color: var(--bg); background: var(--text);
  border: 0; border-radius: 11px; padding: 12px 20px;
}
.onboard .pick:hover { background: var(--accent-use); }
.onboard code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 8px; color: var(--text-muted);
  user-select: all;
}
.onboard .glyph { color: var(--accent-use); }

/* video poster */
.video-poster {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background:
    repeating-linear-gradient(135deg, var(--placeholder-a) 0 10px, var(--placeholder-b) 10px 20px);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.video-poster iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-poster .video-thumb {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
/* soft scrim over the still so the play button reads on bright frames;
   sits above the thumbnail but below the controls (which carry z-index:1) */
.video-poster:has(.video-thumb)::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgb(0 0 0 / .04), rgb(0 0 0 / .22));
  pointer-events: none;
}
.video-poster .stamp { z-index: 1; }
.play-btn {
  position: relative;
  z-index: 1;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 0;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgb(var(--shadow-color) / .25);
  transition: transform .15s, background .15s;
}
.play-btn:hover { transform: scale(1.07); }
.video-poster .stamp {
  position: absolute;
  right: 10px; bottom: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  background: var(--scrim);
  padding: 3px 7px; border-radius: 6px;
}

/* audio player */
.audio {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 15px 4px;
}
.audio .pp {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--accent-use);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s, border-color .15s;
}
.audio .pp:hover { transform: scale(1.05); border-color: var(--accent-use); }
.audio .wave {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2.5px;
  height: 40px;
  min-width: 0;
}
.audio .wave.seekable {
  cursor: pointer;
  touch-action: none;
  border-radius: 4px;
}
.audio .wave.seekable:focus-visible {
  outline: 2px solid var(--accent-use);
  outline-offset: 3px;
}
.audio .wave i {
  flex: 1;
  min-width: 2px;
  border-radius: 2px;
  background: var(--border-strong);
  transition: background .1s, transform .1s;
  transform-origin: center;
  pointer-events: none;
}
.audio .wave i.on { background: var(--accent-use); }
.audio .wave.seekable:hover i { background: var(--text-faint); }
.audio .wave.seekable:hover i.on { background: var(--accent-use); }
.audio .meta {
  flex: none;
  text-align: right;
}
.audio .meta .t {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}
.audio-piece {
  padding: 2px 15px 2px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.audio-perf {
  padding: 0 15px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

/* quote */
.quote {
  padding: 18px 18px 6px;
}
/* optional still above a quote (e.g. a film intertitle frame). Shown whole —
   no crop — so on-screen text in the frame stays intact. */
.quote-figure {
  background: #000;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: center;
}
.quote-figure img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
}
.board.grid .quote-card .quote-figure { flex: none; }
.board.grid .quote-card .quote-figure img { max-height: 150px; }
.quote blockquote {
  margin: 0;
  font-family: var(--font-quote);
  font-style: italic;
  font-size: 20px;
  line-height: 1.42;
  color: var(--text);
  text-wrap: pretty;
  /* preserve line breaks in verse (newlines in the item text); prose quotes
     have none so they're unaffected, runs of spaces still collapse */
  white-space: pre-line;
}
.quote blockquote .mark {
  color: var(--accent-use);
  font-size: 1.25em;
  line-height: inherit;
  vertical-align: -0.06em;
  margin: 0 1px;
}
.quote .attr {
  margin-top: 13px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}
.quote .attr b { color: var(--text-muted); font-weight: 500; }

/* note (plain text thought) */
.note-card .card-body { padding-top: 16px; }
.note-big {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.45;
  color: var(--text);
  margin: 0;
  text-wrap: pretty;
}

/* link card */
.linkrow {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 15px 2px;
}
.linkrow .lt {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 15.5px;
  line-height: 1.3;
  color: var(--text);
}
.linkrow .lx {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.linkrow .ld {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-use);
}

/* podcast */
.pod-head { display: flex; gap: 13px; padding: 14px 15px 6px; align-items: center; }
.pod-head .pp {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--accent-use); display: flex; align-items: center; justify-content: center;
  transition: transform .12s, border-color .15s;
}
.pod-head .pp:hover { transform: scale(1.05); border-color: var(--accent-use); }
.pod-head .pi { min-width: 0; }
.pod-head .show { font-family: var(--font-ui); font-weight: 500; font-size: 14px; color: var(--text); }
.pod-head .ep { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
.eq { display: flex; align-items: flex-end; gap: 3px; height: 22px; padding: 6px 15px 0; }
.eq i {
  width: 3px; border-radius: 2px; background: var(--border-strong);
  height: 30%;
}
.eq.playing i { background: var(--accent-use); animation: eqbounce 0.9s ease-in-out infinite; }
.eq i:nth-child(2){ animation-delay: .1s } .eq i:nth-child(3){ animation-delay: .25s }
.eq i:nth-child(4){ animation-delay: .4s } .eq i:nth-child(5){ animation-delay: .15s }
.eq i:nth-child(6){ animation-delay: .3s } .eq i:nth-child(7){ animation-delay: .05s }
.eq i:nth-child(8){ animation-delay: .35s } .eq i:nth-child(9){ animation-delay: .2s }
@keyframes eqbounce { 0%,100%{ height: 25% } 50%{ height: 100% } }
@media (prefers-reduced-motion: reduce){ .eq.playing i { animation: none; height: 60%; } }

/* ============================================================================
   Focus / gallery mode
   ========================================================================== */
.focus {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: color-mix(in oklab, var(--bg-deep) 88%, black);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
}
.focus-top {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 26px;
  color: var(--text-muted);
}
.focus-top .counter { font-family: var(--font-mono); font-size: 12px; letter-spacing: .05em; }
.focus-top .ftitle { font-family: var(--font-ui); font-size: 13px; color: var(--text-faint); }
.focus-top .x {
  margin-left: auto;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); display: flex; align-items: center; justify-content: center;
}
.focus-top .x:hover { color: var(--text); border-color: var(--border-strong); }
.focus-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 0 20px 30px;
  min-height: 0;
}
.focus-stage .nav {
  flex: none;
  width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s, color .15s, border-color .15s;
}
.focus-stage .nav:hover { color: var(--text); border-color: var(--border-strong); transform: scale(1.06); }
.focus-card {
  width: min(620px, 78vw);
  max-height: 100%;
  overflow: auto;
  scrollbar-width: none;
}
.focus-card::-webkit-scrollbar { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .focus-card { animation: focuspop .3s cubic-bezier(.2,.8,.3,1) both; }
  @keyframes focuspop { from { transform: translateY(12px) scale(.99) } to { transform: none } }
}
.focus-card .card {
  box-shadow: 0 30px 80px rgb(var(--shadow-color) / .35);
  border-color: var(--border);
}
.focus-card .quote blockquote { font-size: 28px; }
.focus-card .note-big { font-size: 24px; }
.focus-card .ph { min-height: 300px; }
@media (max-width: 720px) {
  .focus-stage .nav { width: 42px; height: 42px; }
  .focus-card { width: 86vw; }
}

/* keyboard hint */
.kbd-hint {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 11px; color: var(--text-faint);
  display: flex; gap: 14px; align-items: center;
}
.kbd-hint kbd {
  font-family: var(--font-mono);
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px; color: var(--text-muted);
  background: var(--surface);
}

/* fade-in for cards on (re)layout */
@media (prefers-reduced-motion: no-preference) {
  .board.mosaic .card, .board.grid .card { animation: cardin .4s cubic-bezier(.2,.8,.3,1) both; }
  @keyframes cardin { from { transform: translateY(7px) } to { transform: none } }
}

/* ============================================================================
   Responsive shell
   ========================================================================== */
@media (min-width: 821px) and (max-width: 900px) {
  .topbar { gap: 14px; }
  .topbar > .back-btn { flex: 0 0 38px; }
  .search input { width: 180px; }
  .search input:focus { width: 200px; }
  .tools { flex: none; }
}

@media (max-width: 820px) {
  .topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "back brand"
      "search search"
      "tools tools";
    gap: 10px 12px;
    padding: 14px max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left));
  }
  .back-btn { grid-area: back; align-self: center; }
  .brand { grid-area: brand; align-self: center; }
  .brand h1 { white-space: nowrap; }
  .topbar .spacer { display: none; }
  .search { grid-area: search; width: 100%; }
  .search input,
  .search input:focus { width: 100%; }
  .tools {
    grid-area: tools;
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }
  .tools > * { flex: none; }
  .sort-btn {
    width: 38px;
    padding: 0;
    justify-content: center;
  }
  .sort-btn .btn-label { display: none; }
  .tbtn.icon { flex: 0 0 38px; }
  .zoom button { width: 32px; }

  .subbar {
    padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
    -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 28px), transparent 100%);
            mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 28px), transparent 100%);
  }
  .chip { height: 38px; }

  .board {
    padding: 18px max(14px, env(safe-area-inset-right)) calc(80px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
}

@media (max-width: 720px) {
  .board.scatter { min-height: 100% !important; }
  .board.scatter .frame {
    position: relative;
    left: auto !important;
    top: auto !important;
    width: calc(100% - 12px);
    margin: 0 auto var(--gap);
    cursor: default;
  }
  .focus-top {
    padding: calc(12px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  }
  .focus-stage {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 0 max(14px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
  .focus-card {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    max-height: 100%;
  }
  .focus-stage > .nav:first-child {
    grid-column: 1;
    grid-row: 2;
    justify-self: end;
  }
  .focus-stage > .nav:last-child {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
  }
  .focus-stage .nav { width: 44px; height: 44px; }
  .focus-card .ph { min-height: 200px; }
  .focus-card .quote blockquote { font-size: 24px; }
  .focus-card .note-big { font-size: 21px; }
  .kbd-hint { display: none; }
}

@media (max-width: 640px) {
  .board.mosaic {
    column-count: 1;
    column-width: auto;
  }
  .board.grid { grid-template-columns: minmax(0, 1fr); }
  .board.grid .frame { height: min(var(--tile), calc(100vw - 28px)); }
}

@media (max-width: 480px) {
  .topbar { padding-top: max(12px, env(safe-area-inset-top)); }
  .brand h1 { font-size: 18px; }
  .subbar .label { display: none; }
  .board { padding-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .board-wrap { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
