/* Self-hosted fonts (latin subset, SIL OFL). Other glyphs fall back to the system stack in --font. */
@font-face { font-family: "Geist"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("../assets/fonts/geist-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Geist Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("../assets/fonts/geist-mono-latin-500.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 700; font-display: swap; src: url("../assets/fonts/montserrat-latin-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #f4f7fc;
  --ink: #1d1d1f;
  --ink-2: #424245;
  --muted: #6e6e73;
  --line: rgba(15, 23, 42, 0.07);
  --card-edge: #000;
  --line-2: rgba(15, 23, 42, 0.12);
  --accent: #0a6cff;
  --accent-2: #4fa3ff;
  --accent-ink: #0050c8;
  --accent-soft: #e9f2ff;
  --accent-soft-2: #dbe9ff;
  --brand-brown: #3f200c;
  --brand-blue: #004aac;
  --grad: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  --wash-0: #a9cbff;
  --wash-1: #cfe2ff;
  --wash-2: #e4efff;
  --side-bg: #fdfeff;
  --glass: rgba(247, 249, 252, 0.78);
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 18px rgba(16, 24, 40, 0.05);
  --shadow-card-hover: 0 2px 4px rgba(16, 24, 40, 0.05), 0 18px 40px rgba(16, 24, 40, 0.1);
  --shadow-pill: 0 1px 2px rgba(16, 24, 40, 0.08), 0 3px 10px rgba(16, 24, 40, 0.07);
  --spring: linear(0, 0.0941 5.6%, 0.2736 11.1%, 0.4548 16.7%, 0.6076 22.2%, 0.7255 27.8%, 0.8119 33.3%, 0.8732 38.9%, 0.9156 44.4%, 0.9444 50%, 0.9636 55.6%, 0.9764 61.1%, 0.9848 66.7%, 0.9902 72.2%, 0.9938 77.8%, 0.996 83.3%, 0.9975 88.9%, 0.9984 94.4%, 1 100%);
  --spring-dur: 587ms;
  --font: "Geist", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --side-w: 272px;
  --pad: clamp(16px, 3vw, 40px);
  /* chrome surfaces (redefined by the dark theme) */
  --side-glow: rgba(207, 226, 255, 0.55);
  --plate-bg: #fff;
  --plate-ink: #0b1e3f;
  --plate-ring: rgba(11, 30, 63, 0.14);
  --plate-ring-2: rgba(11, 30, 63, 0.28);
  --field-bg: rgba(255, 255, 255, 0.88);
  --field-bg-hover: #fff;
  --hover-tint: rgba(15, 23, 42, 0.04);
  --scroll-thumb: rgba(15, 23, 42, 0.14);
  --label: #6e6e73;
  --indicator-bg: #fff;
  --expand-bg: rgba(255, 255, 255, 0.94);
  --drawer-bg: #fff;
  --head-solid: rgba(247, 249, 252, 0.96);
  --badge-bg: #1d1d1f;
  --badge-ink: #fff;
  /* grain texture: a tile centred on 50% grey, overlay-blended. Light theme only. */
  --grain-tile: url("../assets/grain.png");
  --grain-opacity: 0.7;
  --grain-side-opacity: 0.05;
  color-scheme: light;
}

/* Dark theme (<html data-theme="dark">). Only the page chrome changes; demos keep their light stage. */
:root[data-theme="dark"] {
  --bg: #0a0e17;
  --surface: #111827;
  --surface-2: #0e1420;
  --ink: #f1f4f9;
  --ink-2: #c4cad6;
  --muted: #8a93a5;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --card-edge: rgba(255, 255, 255, 0.16);
  --accent: #3d8bff;
  --accent-2: #6cb2ff;
  --accent-ink: #9cc6ff;
  --accent-soft: rgba(61, 139, 255, 0.16);
  --accent-soft-2: rgba(61, 139, 255, 0.26);
  --brand-brown: #e9cdae;
  --brand-blue: #6aa6ff;
  --wash-0: rgba(10, 108, 255, 0.34);
  --wash-1: rgba(10, 108, 255, 0.16);
  --wash-2: #0d1525;
  --side-bg: rgba(13, 18, 29, 0.86);
  --glass: rgba(10, 14, 23, 0.78);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 22px rgba(0, 0, 0, 0.28);
  --shadow-card-hover: 0 2px 4px rgba(0, 0, 0, 0.35), 0 20px 44px rgba(0, 0, 0, 0.45);
  --shadow-pill: 0 1px 2px rgba(0, 0, 0, 0.35), 0 3px 10px rgba(0, 0, 0, 0.3);
  --side-glow: rgba(10, 108, 255, 0.14);
  --plate-bg: #172033;
  --plate-ink: #e7ecf5;
  --plate-ring: rgba(255, 255, 255, 0.1);
  --plate-ring-2: rgba(255, 255, 255, 0.22);
  --field-bg: rgba(255, 255, 255, 0.05);
  --field-bg-hover: rgba(255, 255, 255, 0.09);
  --hover-tint: rgba(255, 255, 255, 0.05);
  --scroll-thumb: rgba(255, 255, 255, 0.16);
  --label: #7c8597;
  --indicator-bg: #1a2336;
  --expand-bg: rgba(23, 32, 51, 0.94);
  --drawer-bg: #0e1420;
  --head-solid: rgba(10, 14, 23, 0.96);
  --badge-bg: #e7ecf5;
  --badge-ink: #0a0e17;
  /* no grain on dark */
  --grain-tile: none;
  color-scheme: dark;
}

@layer base {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--ink);
    font: 400 16px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
  }
  h1, h2, h3, p { margin: 0; }
  a { color: inherit; text-decoration: none; }
  button { font: inherit; color: inherit; }
  [hidden] { display: none !important; }
  .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
}

/* ---------- Shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100dvh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 14px 16px;
  background:
    radial-gradient(420px 260px at 0% 0%, var(--side-glow) 0%, transparent 70%),
    var(--side-bg);
  box-shadow: 1px 0 0 var(--line);
  z-index: 30;
  outline: none;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; }
.brand-mark { width: 32px; height: 32px; object-fit: contain; flex: none; }
.brand-text { display: flex; flex-direction: column; gap: 3px; line-height: 1; }
.wm { font: 700 17px/1 "Montserrat", var(--font); letter-spacing: -0.01em; white-space: nowrap; }
.wm-brewed { color: var(--brand-brown); }
.wm-ops { color: var(--brand-blue); }
.brand-sub { font-size: 12.5px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.socials { display: flex; align-items: center; gap: 8px; margin: -2px 0 2px; padding: 0 6px; list-style: none; }
/* Round social plates: lift on hover, press on :active. */
.social {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  padding: 0; border: 0; cursor: pointer;
  background: var(--plate-bg);
  color: var(--plate-ink);
  box-shadow: inset 0 0 0 1px var(--plate-ring), 0 10px 24px -18px rgba(6, 12, 26, 0.55);
  transition: transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1), color 180ms ease-out, box-shadow 180ms ease-out;
}
.social:hover {
  transform: translateY(-2px);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--plate-ring-2), 0 14px 28px -18px rgba(6, 12, 26, 0.6);
}
/* Theme toggle: shows the icon for the action (moon in light, sun in dark). */
.theme-toggle .i-sun, :root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
.theme-toggle svg { animation: theme-in 520ms var(--spring) both; }
@keyframes theme-in { from { opacity: 0; transform: rotate(-70deg) scale(0.5); } to { opacity: 1; transform: none; } }
.social:active { transform: scale(0.97); transition-duration: 100ms; }
.social:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.search {
  display: flex; align-items: center; gap: 8px;
  height: 36px;
  margin: 0 2px;
  padding: 0 8px 0 11px;
  border-radius: 10px;
  background: var(--field-bg);
  box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--muted);
  transition: box-shadow 160ms ease, color 160ms ease;
}
.search:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-soft); color: var(--accent); }
.search input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  font: 500 13.5px/1 var(--font); color: var(--ink);
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  font: 500 10.5px/1 var(--mono); color: var(--muted);
  padding: 4px 6px; border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--line-2);
}

.side-nav {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 6px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
  /* soft fade where the list scrolls under the edges */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 18px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 10px, #000 calc(100% - 18px), transparent 100%);
}
.side-group + .side-group { margin-top: 14px; }
.side-label {
  padding: 8px 10px 6px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--label);
}
.side-indicator {
  position: absolute;
  left: 6px; right: 6px; top: 0;
  height: 34px;
  border-radius: 10px;
  background: var(--indicator-bg);
  box-shadow: var(--shadow-pill), inset 0 0 0 1px rgba(10, 108, 255, 0.1);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--spring-dur) var(--spring), height var(--spring-dur) var(--spring), opacity 160ms ease;
}
.side-indicator.is-on { opacity: 1; }
.side-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 13.5px; font-weight: 500;
  color: var(--ink-2);
  transition: color 160ms ease, background-color 160ms ease, opacity 160ms ease;
}
.side-item:hover { background: var(--hover-tint); color: var(--ink); }
.side-item.is-active { background: transparent; color: var(--accent-ink); font-weight: 600; }
.side-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.side-ico { display: inline-grid; place-items: center; color: var(--label); transition: color 160ms ease; }
.side-item:hover .side-ico { color: var(--ink-2); }
.side-item.is-active .side-ico { color: var(--accent); }
.side-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-count {
  font: 500 11px/1 var(--mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.side-item.is-active .side-count { color: var(--accent); }
.side-item.is-dim { opacity: 0.42; }

.side-foot {
  margin: 0 2px;
  padding: 12px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(10, 108, 255, 0.08), rgba(79, 163, 255, 0.05));
  box-shadow: inset 0 0 0 1px rgba(10, 108, 255, 0.1);
}
.side-stat { font-size: 12.5px; color: var(--ink-2); }
.side-stat b { font-weight: 600; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.side-stat span { color: var(--muted); }
.side-free { margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.side-legal { display: flex; gap: 14px; margin: -6px 2px 0; padding: 0 12px; }
.side-legal a { font-size: 12px; color: var(--muted); text-decoration: none; transition: color 0.2s ease; }
.side-legal a:hover { color: var(--accent-ink); }
.side-legal a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Main ---------- */
.main { position: relative; min-width: 0; }
.wash {
  position: absolute;
  inset: 0 0 auto 0;
  height: 560px;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(760px 420px at 85% -10%, var(--wash-0) 0%, transparent 62%),
    radial-gradient(700px 380px at 20% -20%, var(--wash-1) 0%, transparent 62%),
    linear-gradient(180deg, var(--wash-2) 0%, var(--bg) 100%);
  opacity: 0.85;
}
.mbar { display: none; }
/* Grain over the page background, under the cards. */
.grain {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  background: var(--grain-tile) repeat;
  background-size: 160px;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
}
/* The sidebar and the top strip sit above .grain, so they carry their own grain layer. */
.sidebar::after, .coffee::after {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  pointer-events: none;
  background: var(--grain-tile) repeat;
  background-size: 160px;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
}
/* Overlay barely shows on near-white, so the sidebar uses a normal blend at low opacity. */
.sidebar::after { opacity: var(--grain-side-opacity); mix-blend-mode: normal; }

.pagehead {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px var(--pad) 18px;
  transition: background-color 240ms ease, box-shadow 240ms ease, padding 240ms ease;
  outline: none;
}
.pagehead.is-scrolled {
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 1px 0 var(--line);
}
.ph-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.ph-icon {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 13px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 1px 2px rgba(10, 108, 255, 0.25), 0 8px 18px rgba(10, 108, 255, 0.22);
}
.pagehead h1 {
  display: flex; align-items: baseline; gap: 10px;
  font-size: clamp(1.4rem, 2.2vw, 1.85rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 600;
}
.ph-count {
  font: 500 12.5px/1 var(--mono);
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 5px 8px;
  border-radius: 8px;
  letter-spacing: 0;
  white-space: nowrap;
}
.pagehead p { margin-top: 5px; color: var(--muted); font-size: 14px; }

.ghost-btn {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 0; border-radius: 10px;
  background: var(--field-bg);
  box-shadow: inset 0 0 0 1px var(--line-2);
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  cursor: pointer;
  transition: transform 90ms ease-out, background-color 160ms ease;
}
.ghost-btn:hover { background: var(--field-bg-hover); }
.ghost-btn:active { transform: scale(0.97); }
.ghost-btn[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent-soft); }
.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border: 0; border-radius: 11px;
  background: var(--field-bg);
  box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--ink-2);
  cursor: pointer;
  transition: transform 90ms ease-out;
}
.icon-btn:active { transform: scale(0.95); }

/* ---------- Library ---------- */
.library {
  position: relative;
  z-index: 1;
  padding: 6px var(--pad) 56px;
}
.sec-head { display: none; } /* the page header names the open section */
.is-filter .sec-head { display: block; margin: 12px 0 18px; }
.is-filter .sec-head h2 { display: flex; align-items: baseline; gap: 10px; font-size: 1.6rem; letter-spacing: -0.03em; font-weight: 600; }
.is-filter .sec-head p { margin-top: 6px; color: var(--muted); font-size: 14px; }
.sec-count { font: 500 12px/1 var(--mono); color: var(--accent-ink); background: var(--accent-soft); padding: 5px 8px; border-radius: 8px; }

.ml-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 18px;
}
.sec.is-entering .ml-card { animation: card-in 520ms var(--spring) backwards; animation-delay: calc(var(--i, 0) * 22ms); }
@keyframes card-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }

.ml-card {
  display: flex; flex-direction: column;
  padding: 8px;
  border-radius: 22px;
  background: var(--surface);
  border: 1.5px solid var(--card-edge);
  box-shadow: var(--shadow-card);
  transition: transform var(--spring-dur) var(--spring), box-shadow var(--spring-dur) var(--spring);
  /* offscreen cards skip rendering; the placeholder height matches a real card */
  content-visibility: auto;
  contain-intrinsic-size: auto 380px;
}
.ml-card:has(.ml-badges) { contain-intrinsic-size: auto 410px; }
.ml-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-hover); }
.ml-stage {
  aspect-ratio: 4 / 3;
  border-radius: 15px;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  isolation: isolate;
}
.ml-meta { padding: 14px 8px 4px; }
.ml-meta h3 { font-size: 15px; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; }
.ml-meta p { margin-top: 3px; font-size: 13px; color: var(--muted); line-height: 1.4; }
.ml-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 12px 4px 4px;
  margin-top: auto;
}
.ml-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 12px;
  border: 0; border-radius: 999px;
  font-size: 13px; font-weight: 600; letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 90ms ease-out, background-color 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}
.ml-btn:active { transform: scale(0.96); }
.ml-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ml-ico { display: inline-grid; place-items: center; }
.ml-btn-soft { background: var(--accent-soft); color: var(--accent-ink); }
.ml-btn-soft:hover { background: var(--accent-soft-2); }
.ml-btn-solid {
  background: var(--grad); color: #fff;
  box-shadow: 0 1px 2px rgba(10, 108, 255, 0.22), 0 6px 14px rgba(10, 108, 255, 0.2);
}
.ml-btn-solid:hover { filter: brightness(1.05); }
.ml-btn.is-done .ml-ico { animation: pop var(--spring-dur) var(--spring); }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Clickable stage -> preview modal */
.ml-stage-wrap { position: relative; border-radius: 15px; cursor: zoom-in; outline: none; }
.ml-stage-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ml-expand {
  position: absolute; top: 10px; right: 10px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--expand-bg);
  box-shadow: var(--shadow-pill), inset 0 0 0 1px var(--line);
  color: var(--ink-2);
  opacity: 0; transform: scale(0.88);
  transition: opacity 160ms ease, transform var(--spring-dur) var(--spring);
  pointer-events: none;
}
.ml-card:hover .ml-expand, .ml-stage-wrap:focus-visible .ml-expand { opacity: 1; transform: none; }
@media (hover: none) { .ml-expand { opacity: 1; transform: none; } }
/* App screens: the stage is a working app, so the expand button is the way into the preview */
.ml-card.is-live .ml-stage-wrap { cursor: default; }
.ml-card.is-live .ml-expand { opacity: 1; transform: none; pointer-events: auto; cursor: zoom-in; }
.ml-card.is-live .ml-expand:hover { color: var(--accent-ink); }
.ml-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.ml-badge {
  font: 600 11px/1 var(--font);
  padding: 5px 8px;
  border-radius: 7px;
  background: var(--badge-bg);
  color: var(--badge-ink);
  letter-spacing: 0.01em;
}

html:has(.viewer[open]) { overflow: hidden; }
.viewer {
  width: 100vw; height: 100dvh;
  max-width: 100vw; max-height: 100dvh;
  margin: 0; padding: 0; border: 0;
  background: transparent;
  overflow: hidden;
  transition: display 300ms allow-discrete, overlay 300ms allow-discrete;
}
.viewer[open] { display: grid; place-items: center; }
.viewer::backdrop {
  background: rgba(10, 16, 30, 0.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 260ms ease, display 300ms allow-discrete, overlay 300ms allow-discrete;
}
.viewer[open]::backdrop { opacity: 1; }
@starting-style { .viewer[open]::backdrop { opacity: 0; } }
.v-panel {
  width: min(94vw, calc(88dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  display: flex;
  background: var(--surface);
  border: 1.5px solid var(--card-edge);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(10, 20, 40, 0.35);
  overflow: hidden;
  opacity: 0;
  transform: scale(0.94);
  transition: transform 240ms ease, opacity 180ms ease;
}
.viewer[open] .v-panel { opacity: 1; transform: none; transition: transform 560ms var(--spring), opacity 200ms ease; }
@starting-style { .viewer[open] .v-panel { opacity: 0; transform: scale(0.6); } }
.v-stage {
  position: relative;
  height: 100%;
  aspect-ratio: 4 / 3;
  flex: none;
  overflow: hidden;
  background: var(--surface-2);
  border-right: 1.5px solid var(--card-edge);
}
.v-scaler { position: absolute; top: 0; left: 0; width: 560px; height: 420px; transform-origin: 0 0; }
.v-scaler iframe { display: block; width: 560px; height: 420px; border: 0; background: #fff; }
.v-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 12px;
  padding: 20px 20px 16px;
  overflow: hidden;
}
.v-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.v-cat {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12.5px; font-weight: 600;
  min-width: 0; overflow: hidden; white-space: nowrap;
}
.v-close { width: 34px; height: 34px; flex: none; }
.v-info h2 { font-size: 22px; line-height: 1.15; letter-spacing: -0.03em; font-weight: 600; }
.v-sub { margin-top: -6px; color: var(--muted); font-size: 14px; }
.v-badges:empty { display: none; }
.v-badges .ml-badges { margin-top: 0; }
.v-actions { padding: 0; margin-top: 2px; }
.v-prompt {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.v-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); margin-bottom: 6px; }
.v-prompt-text { font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.v-nav { display: flex; align-items: center; justify-content: space-between; }
.v-pos { font: 500 12px/1 var(--mono); color: var(--muted); }
@media (max-width: 900px) {
  .v-panel { width: 100vw; height: 100dvh; aspect-ratio: auto; flex-direction: column; border: 0; border-radius: 0; }
  .v-stage { width: 100%; height: auto; border-right: 0; border-bottom: 1.5px solid var(--card-edge); }
  .v-info { overflow-y: auto; }
  .v-prompt { flex: none; overflow: visible; }
}
@media (prefers-reduced-motion: reduce) {
  .v-panel, .viewer[open] .v-panel { transform: none; transition: opacity 200ms ease; }
}

.empty { position: relative; z-index: 1; padding: 40px var(--pad) 80px; text-align: center; }

/* ---------- Tip jar: banner above the grid + the GCash QR dialog ---------- */
/* A slim strip across the top of the main column; it scrolls away and the section header sticks. */
.coffee {
  position: relative; z-index: 22;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 8px var(--pad);
  background: linear-gradient(90deg, rgba(10, 108, 255, 0.1), rgba(79, 163, 255, 0.06)), var(--surface); /* opaque base for the grain */
  box-shadow: inset 0 -1px 0 rgba(10, 108, 255, 0.14);
}
.coffee-cup {
  flex: none; display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  color: var(--accent); background: var(--accent-soft);
}
.coffee-text { min-width: 0; font-size: 13.5px; line-height: 1.4; color: var(--ink-2); }
.coffee-text b { font-weight: 600; color: var(--ink); }
.coffee-text span { color: var(--muted); }
.coffee-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 15px;
  border: 0; border-radius: 999px;
  background: var(--grad); color: #fff;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(10, 108, 255, 0.22), 0 6px 14px rgba(10, 108, 255, 0.2);
  cursor: pointer;
  transition: transform 90ms ease-out, filter 160ms ease;
}
.coffee-btn:hover { filter: brightness(1.05); }
.coffee-btn:active { transform: scale(0.96); }

/* Coffee button: accent ring, a passing sheen, rising steam, spring lift on hover. */
#coffee-open {
  position: relative; overflow: hidden; isolation: isolate;
  box-shadow: 0 0 0 4px var(--accent-soft), 0 1px 2px rgba(10, 108, 255, 0.25), 0 8px 18px rgba(10, 108, 255, 0.26);
  transition: transform 420ms var(--spring), filter 160ms ease, box-shadow 220ms ease;
}
#coffee-open:hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 0 0 5px var(--accent-soft-2), 0 2px 4px rgba(10, 108, 255, 0.25), 0 12px 24px rgba(10, 108, 255, 0.3);
}
#coffee-open:active { transform: scale(0.96); transition-duration: 90ms; }
#coffee-open::after {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: coffee-sheen 5.2s ease-in-out 1.2s infinite;
  pointer-events: none;
}
@keyframes coffee-sheen { 0% { transform: translateX(-120%); } 22%, 100% { transform: translateX(120%); } }
.cup-steam { overflow: visible; }
.cup-steam .w { transform-box: fill-box; transform-origin: 50% 100%; animation: coffee-steam 2.4s ease-in-out infinite; opacity: 0; }
.cup-steam .w2 { animation-delay: 0.8s; }
.cup-steam .w3 { animation-delay: 1.6s; }
@keyframes coffee-steam {
  0% { opacity: 0; transform: translateY(2px) scaleY(0.6); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-3px) scaleY(1.1); }
}
@media (prefers-reduced-motion: reduce) {
  #coffee-open::after { animation: none; }
  .cup-steam .w { animation: none; opacity: 1; }
  #coffee-open:hover { transform: none; }
}
.coffee-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 640px) {
  .coffee { justify-content: space-between; padding: 8px 14px; }
  .coffee-cup, .coffee-text span { display: none; }
  .coffee-text { font-size: 13px; }
}

html:has(.tip[open]) { overflow: hidden; }
.tip {
  width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh;
  margin: 0; padding: 16px; border: 0;
  background: transparent;
  transition: display 300ms allow-discrete, overlay 300ms allow-discrete;
}
.tip[open] { display: grid; place-items: center; }
.tip::backdrop {
  background: rgba(10, 16, 30, 0.45);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 260ms ease, display 300ms allow-discrete, overlay 300ms allow-discrete;
}
.tip[open]::backdrop { opacity: 1; }
@starting-style { .tip[open]::backdrop { opacity: 0; } }
.tip-panel {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  width: min(380px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto;
  padding: 26px 24px 22px;
  border-radius: 24px;
  background: var(--surface);
  border: 1.5px solid var(--card-edge);
  box-shadow: 0 30px 90px rgba(10, 20, 40, 0.35);
  text-align: center;
  opacity: 0; transform: scale(0.94);
  transition: transform 240ms ease, opacity 180ms ease;
}
.tip[open] .tip-panel { opacity: 1; transform: none; transition: transform 560ms var(--spring), opacity 200ms ease; }
@starting-style { .tip[open] .tip-panel { opacity: 0; transform: scale(0.9) translateY(8px); } }
.tip-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; }
.tip-cup { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; color: #fff; background: var(--grad); box-shadow: 0 8px 18px rgba(10, 108, 255, 0.24); }
.tip h2 { margin-top: 14px; font-size: 21px; line-height: 1.2; font-weight: 600; letter-spacing: -0.025em; }
.tip-sub { margin-top: 6px; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.tip-qr {
  display: block; width: 236px; margin-top: 18px;
  border-radius: 16px; overflow: hidden;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-card);
}
.tip-qr img { display: block; width: 100%; height: auto; }
.tip-qr:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.tip-name { margin-top: 12px; font-size: 13px; color: var(--muted); }
.tip-name b { font-weight: 600; color: var(--ink); letter-spacing: 0.02em; }
.tip-save { margin-top: 14px; width: 100%; height: 40px; font-size: 13.5px; }
@media (prefers-reduced-motion: reduce) {
  .tip-panel, .tip[open] .tip-panel { transform: none; transition: opacity 200ms ease; }
}
.empty-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.empty-jumps { margin-top: 12px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; color: var(--muted); font-size: 14px; }
.empty-jumps p { width: 100%; margin-bottom: 4px; }
.jump {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 12px;
  border-radius: 999px;
  background: var(--plate-bg);
  box-shadow: var(--shadow-pill);
  color: var(--ink-2); font-size: 13px; font-weight: 500;
  transition: transform 90ms ease-out;
}
.jump:active { transform: scale(0.97); }
.jump svg { color: var(--accent); }
.jump span { font: 500 11px/1 var(--mono); color: var(--accent); }

.scrim { display: none; }

/* ---------- Phone + small tablet: the sidebar becomes a right-side drawer ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .mbar {
    position: relative; z-index: 21;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px var(--pad) 0;
  }
  .mbar .brand { padding: 0; }
  .mbar .brand-mark { width: 28px; height: 28px; }
  .pagehead { padding-top: 14px; padding-bottom: 14px; }
  .ph-icon { width: 38px; height: 38px; border-radius: 11px; }
  .ghost-btn .ml-lbl { display: none; }
  .ghost-btn { padding: 0 11px; }
  .sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: clamp(264px, 80vw, 320px);
    height: 100dvh;
    background: radial-gradient(420px 260px at 0% 0%, var(--side-glow) 0%, transparent 70%), var(--drawer-bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: -1px 0 0 var(--line), -24px 0 60px rgba(16, 24, 40, 0.16);
    transform: translateX(105%);
    visibility: hidden;
    transition: transform 560ms var(--spring), visibility 0s linear 560ms;
  }
  .drawer-open .sidebar { transform: none; visibility: visible; transition: transform 560ms var(--spring), visibility 0s; }
  .scrim {
    display: block;
    position: fixed; inset: 0; z-index: 29;
    background: rgba(16, 24, 40, 0.28);
    opacity: 0; pointer-events: none;
    transition: opacity 300ms ease;
  }
  .drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .drawer-open { overflow: hidden; }
  .search kbd { display: none; }
  .pagehead p { display: none; }
}
@media (max-width: 520px) {
  .ml-grid { gap: 14px; }
}

/* Filter mode (?cat= / ?id=): sections together, no chrome */
.is-filter .app { grid-template-columns: minmax(0, 1fr); }
.is-filter .sidebar, .is-filter .pagehead, .is-filter .mbar, .is-filter .scrim, .is-filter .coffee { display: none; }

@media (hover: none) and (pointer: coarse) {
  .pagehead.is-scrolled { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--head-solid); }
}
@media (prefers-reduced-motion: reduce) {
  .ml-card, .ml-card:hover { transition: none; transform: none; }
  .sec.is-entering .ml-card { animation: fade-in 200ms ease backwards; animation-delay: 0ms; }
  .side-indicator { transition: opacity 160ms ease; }
  .sidebar, .drawer-open .sidebar { transition: visibility 0s; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-transparency: reduce) {
  .sidebar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--drawer-bg); }
  .pagehead.is-scrolled { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--bg); }
}
