/* Book Nook — one stylesheet, no build step.
   Order: fonts, tokens (dark is the default, light is a choice), base, shell, components,
   signature moments (library, shelf, review stack, capture, queue, landing), view transitions,
   reduced motion. Modern CSS carries the design: @property, color-mix, container queries,
   scroll-driven animations, 3D transforms, view transitions. */

/* ---------- fonts (self-hosted, see fonts/LICENSE.md) ---------- */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("../fonts/inter-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("../fonts/inter-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: "Instrument Serif"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/instrument-serif-normal-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Instrument Serif"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/instrument-serif-normal-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: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap; src: url("../fonts/instrument-serif-italic-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap; src: url("../fonts/instrument-serif-italic-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; }

/* ---------- animatable custom properties ---------- */
@property --lamp-x { syntax: "<percentage>"; inherits: true; initial-value: 12%; }
@property --lamp-y { syntax: "<percentage>"; inherits: true; initial-value: -8%; }
@property --lamp-a { syntax: "<number>"; inherits: true; initial-value: 1; }
@property --n { syntax: "<integer>"; inherits: true; initial-value: 0; }
@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }

/* ---------- tokens: the nook at night ---------- */
:root {
  color-scheme: dark;
  --bg: #15110e;
  --bg-2: #1b1613;
  --bg-3: #221c17;
  --bg-4: #2b241e;
  --bg-5: #352c25;
  --ink: #f4ecdf;
  --ink-2: #cdbfab;
  --ink-3: #98897a;
  --line: rgba(244, 236, 223, 0.08);
  --line-2: rgba(244, 236, 223, 0.16);
  --amber: #f2a65a;
  --amber-2: #ffc078;
  --amber-ink: #1b1007;
  --amber-soft: rgba(242, 166, 90, 0.14);
  --amber-glow: rgba(242, 166, 90, 0.32);
  --ok: #7fd494;
  --ok-ink: #0e2a16;
  --ok-soft: rgba(127, 212, 148, 0.14);
  --warn: #f5c35b;
  --warn-ink: #2b1d03;
  --warn-soft: rgba(245, 195, 91, 0.14);
  --danger: #ff8577;
  --danger-ink: #2d0b07;
  --danger-soft: rgba(255, 133, 119, 0.14);
  --info: #93bdff;
  --info-ink: #0b1a33;
  --info-soft: rgba(147, 189, 255, 0.14);
  --focus: #ffc078;
  --wood: #5a3a22;
  --wood-2: #3e2817;
  --wood-edge: #7a5231;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.2);
  --shadow-2: 0 10px 30px -12px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-3: 0 30px 60px -24px rgba(0, 0, 0, 0.85), 0 8px 20px -8px rgba(0, 0, 0, 0.5);
  --cover-shadow: 0 18px 30px -16px rgba(0, 0, 0, 0.9), 0 6px 10px -6px rgba(0, 0, 0, 0.6);
  --glass: rgba(27, 22, 19, 0.72);
  --grain-opacity: 0.07;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --topbar-h: 58px;
  --tab-h: 64px;
  --sidebar-w: 256px;
  --content-max: 1160px;
  --gutter: 18px;
  --control-h: 46px;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 160ms;
  --t-med: 320ms;
  --t-slow: 600ms;
}

/* ---------- tokens: the nook by daylight ---------- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4ecdf;
  --bg-2: #f9f3e9;
  --bg-3: #fffcf6;
  --bg-4: #ede3d3;
  --bg-5: #e3d7c4;
  --ink: #1d1710;
  --ink-2: #5a4d3f;
  --ink-3: #85766a;
  --line: rgba(29, 23, 16, 0.09);
  --line-2: rgba(29, 23, 16, 0.18);
  --amber: #c2511a;
  --amber-2: #a33f0e;
  --amber-ink: #fff8ef;
  --amber-soft: rgba(194, 81, 26, 0.12);
  --amber-glow: rgba(242, 166, 90, 0.38);
  --ok: #1d7f45;
  --ok-ink: #ffffff;
  --ok-soft: rgba(29, 127, 69, 0.12);
  --warn: #a15d05;
  --warn-ink: #ffffff;
  --warn-soft: rgba(245, 195, 91, 0.28);
  --danger: #b4281c;
  --danger-ink: #ffffff;
  --danger-soft: rgba(180, 40, 28, 0.12);
  --info: #1f4fb8;
  --info-ink: #ffffff;
  --info-soft: rgba(31, 79, 184, 0.12);
  --focus: #c2511a;
  --wood: #a9743f;
  --wood-2: #7d5330;
  --wood-edge: #c8905a;
  --shadow-1: 0 1px 2px rgba(29, 23, 16, 0.08), 0 0 0 1px rgba(29, 23, 16, 0.04);
  --shadow-2: 0 10px 30px -14px rgba(29, 23, 16, 0.3), 0 2px 6px rgba(29, 23, 16, 0.06);
  --shadow-3: 0 30px 60px -24px rgba(29, 23, 16, 0.4), 0 8px 20px -8px rgba(29, 23, 16, 0.15);
  --cover-shadow: 0 18px 30px -16px rgba(29, 23, 16, 0.55), 0 6px 10px -6px rgba(29, 23, 16, 0.3);
  --glass: rgba(249, 243, 233, 0.78);
  --grain-opacity: 0.05;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { min-height: 100dvh; overflow-x: hidden; }

/* lamplight: a warm glow that drifts, and a touch of cooler light from the other corner */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(70vmax 55vmax at var(--lamp-x) var(--lamp-y), color-mix(in srgb, var(--amber-glow) calc(100% * var(--lamp-a)), transparent), transparent 62%),
    radial-gradient(50vmax 40vmax at 100% 100%, color-mix(in srgb, var(--info) 9%, transparent), transparent 60%),
    var(--bg);
  animation: lamp 28s ease-in-out infinite alternate;
}
/* paper grain, drawn by the browser from a few bytes of SVG */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
}
@keyframes lamp {
  0% { --lamp-x: 12%; --lamp-y: -8%; --lamp-a: 1; }
  50% { --lamp-x: 22%; --lamp-y: 4%; --lamp-a: 0.8; }
  100% { --lamp-x: 8%; --lamp-y: 10%; --lamp-a: 1.05; }
}

a { color: var(--amber); text-decoration: none; text-underline-offset: 0.16em; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.1; letter-spacing: -0.012em; font-weight: 650; text-wrap: balance; }
h1 { font-family: var(--font-display); font-weight: 400; font-size: 2.4rem; letter-spacing: -0.01em; }
h1 em { font-style: italic; color: var(--amber); }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.015em; line-height: 1.02; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, video, svg { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
pre { margin: 0; }
small { font-size: 0.875rem; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 8px; }
h1:focus { outline: none; }
::selection { background: var(--amber-soft); color: var(--ink); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.skip { position: absolute; left: 12px; top: -64px; z-index: 100; padding: 10px 14px; background: var(--amber); color: var(--amber-ink); border-radius: var(--radius-sm); font-weight: 600; }
.skip:focus { top: 12px; }

.muted { color: var(--ink-2); }
.subtle { color: var(--ink-3); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.8125rem; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stack { display: grid; gap: 12px; }
.stack-lg { display: grid; gap: 22px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- brand ---------- */
.logo {
  --s: 28px;
  width: var(--s);
  height: var(--s);
  border-radius: calc(var(--s) * 0.28);
  background: linear-gradient(145deg, var(--amber-2), var(--amber) 55%, color-mix(in srgb, var(--amber) 70%, black));
  position: relative;
  flex-shrink: 0;
  display: inline-block;
  box-shadow: 0 6px 16px -6px var(--amber-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.logo::before, .logo::after { content: ""; position: absolute; top: 22%; bottom: 22%; width: 16%; border-radius: 2px; background: #fff6ea; }
.logo::before { left: 24%; }
.logo::after { left: 46%; opacity: 0.8; }
.logo-lg { --s: 56px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); font-family: var(--font-display); font-size: 1.6rem; line-height: 1; text-decoration: none; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .brand-nook { font-style: italic; color: var(--amber); }

/* The boot screen is styled inline in index.html so it paints before this file; only the pulse lives here. */
.boot .logo { animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* ---------- app shell ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 var(--gutter);
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-bottom: 1px solid var(--line);
  view-transition-name: topbar;
}
.topbar .brand { font-size: 1.4rem; }
.topnav { display: flex; align-items: center; gap: 6px; }
.topnav a:not(.btn) { padding: 8px 12px; border-radius: var(--radius-pill); color: var(--ink-2); font-weight: 500; font-size: 0.9375rem; white-space: nowrap; }
@media (max-width: 479px) { .topbar .brand { font-size: 1.25rem; gap: 8px; } .topnav a.btn { display: none; } .topnav { gap: 2px; } }
.topnav a:not(.btn):hover { background: var(--bg-4); text-decoration: none; color: var(--ink); }
.topnav a:not(.btn).active { color: var(--ink); background: var(--bg-4); }
.topbar-tools { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-3) 70%, transparent);
  color: var(--ink-2);
  transition: background-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.icon-btn:hover { background: var(--bg-4); color: var(--ink); }
.icon-btn:active { transform: scale(0.94); }
.theme-toggle .icon { transition: transform var(--t-slow) var(--ease-spring); }
.theme-toggle:hover .icon { transform: rotate(25deg); }

.sidebar { display: none; }

.content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 22px var(--gutter) calc(var(--tab-h) + 32px + env(safe-area-inset-bottom));
  view-transition-name: main;
}
.content-narrow { max-width: 480px; }

/* bottom tab bar with a sliding lamp under the active tab */
.tabbar {
  --i: 0;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding: 0 6px env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-top: 1px solid var(--line);
  view-transition-name: tabbar;
}
.tabbar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 6px;
  width: calc((100% - 12px) / 5);
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--amber);
  box-shadow: 0 6px 18px var(--amber-glow);
  translate: calc(var(--i) * 100%) 0;
  transition: translate var(--t-med) var(--ease-out);
}
.tabbar:has(a:nth-child(2).active) { --i: 1; }
.tabbar:has(a:nth-child(3).active) { --i: 2; }
.tabbar:has(a:nth-child(4).active) { --i: 3; }
.tabbar:has(a:nth-child(5).active) { --i: 4; }
.tabbar a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--tab-h);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-3);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color var(--t-fast);
}
.tabbar a:hover { text-decoration: none; }
.tabbar a.active { color: var(--amber); }
.tabbar a .icon { transition: transform var(--t-med) var(--ease-spring); }
.tabbar a.active .icon { transform: translateY(-2px) scale(1.08); }
.tabbar .tab-add .icon-wrap {
  width: 46px;
  height: 38px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--amber-2), var(--amber));
  color: var(--amber-ink);
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px -8px var(--amber-glow), var(--shadow-1);
  transition: transform var(--t-med) var(--ease-spring);
}
.tabbar .tab-add:active .icon-wrap { transform: scale(0.94); }
.tabbar .tab-add span:last-child { color: var(--ink-3); }
.tabbar .tab-add.active span:last-child { color: var(--amber); }
.nav-badge {
  position: absolute;
  top: 9px;
  left: calc(50% + 5px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--amber);
  color: var(--amber-ink);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg-2);
  animation: pop-in var(--t-med) var(--ease-spring);
}

.banner { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px var(--gutter); font-size: 0.8125rem; font-weight: 500; text-align: center; border-bottom: 1px solid var(--line); }
.banner-demo { background: var(--warn-soft); color: var(--ink); }
.banner-wake { background: var(--info-soft); color: var(--ink); }
.banner .icon { flex-shrink: 0; color: var(--amber); }

/* ---------- desktop shell ---------- */
@media (min-width: 900px) {
  .app { flex-direction: row; align-items: stretch; }
  .app > .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 26px;
    width: var(--sidebar-w);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 24px 16px 22px;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg-2) 75%, transparent);
    backdrop-filter: blur(20px);
    view-transition-name: sidebar;
  }
  .sidebar .brand { padding: 0 10px; font-size: 1.7rem; }
  .sidenav { display: grid; gap: 4px; }
  .sidenav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 12px;
    color: var(--ink-2);
    font-weight: 500;
    text-decoration: none;
    transition: background-color var(--t-fast), color var(--t-fast);
  }
  .sidenav a:hover { background: var(--bg-4); color: var(--ink); text-decoration: none; }
  .sidenav a.active { background: var(--bg-3); color: var(--ink); box-shadow: var(--shadow-1); font-weight: 600; }
  .sidenav a.active::before { content: ""; position: absolute; left: -16px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--amber); box-shadow: 0 0 14px var(--amber-glow); }
  .sidenav a.active .icon { color: var(--amber); }
  .sidenav .nav-badge { position: static; margin-left: auto; box-shadow: none; }
  .sidenav .tab-add .icon-wrap { display: contents; }
  .sidebar-foot { margin-top: auto; display: grid; gap: 10px; padding: 0 4px; }
  .sidebar-user { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px; border-radius: 12px; color: var(--ink); }
  .sidebar-user:hover { background: var(--bg-4); text-decoration: none; }
  .sidebar-user .meta { min-width: 0; display: grid; }
  .sidebar-user strong { font-size: 0.875rem; font-weight: 600; }
  .sidebar-user small { color: var(--ink-3); font-size: 0.75rem; }
  .sidebar-tools { display: flex; align-items: center; gap: 8px; }
  .topbar { display: none; }
  .topbar-anon { display: flex; }
  .tabbar { display: none; }
  .content { padding: 44px 44px 64px; }
  .content-narrow { max-width: 520px; margin-top: 4vh; }
  h1 { font-size: 3rem; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-h);
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--bg-4);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--t-fast), transform var(--t-fast) var(--ease-spring), box-shadow var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; background: var(--bg-5); }
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; transform: none; }
.btn .icon { flex-shrink: 0; }
.btn-primary {
  background: linear-gradient(145deg, var(--amber-2), var(--amber));
  color: var(--amber-ink);
  box-shadow: 0 8px 22px -10px var(--amber-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-primary:hover { background: linear-gradient(145deg, var(--amber-2), var(--amber-2)); box-shadow: 0 10px 26px -8px var(--amber-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.btn-secondary { background: var(--amber-soft); color: var(--amber); }
.btn-secondary:hover { background: color-mix(in srgb, var(--amber-soft) 70%, var(--amber) 30%); color: var(--ink); }
.btn-ghost { background: transparent; border-color: var(--line-2); }
.btn-ghost:hover { background: var(--bg-4); }
.btn-plain { background: transparent; color: var(--ink-2); padding-inline: 10px; }
.btn-plain:hover { background: var(--bg-4); color: var(--ink); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--danger-ink); }
.btn-success { background: var(--ok); color: var(--ok-ink); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.875rem; border-radius: 10px; }
.btn-lg { min-height: 54px; padding: 0 22px; font-size: 1.0625rem; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-icon.btn-sm { width: 36px; }
.btn-pill { border-radius: var(--radius-pill); }
label.btn { cursor: pointer; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
#pick-camera:focus-visible ~ * label[for="pick-camera"], #pick-files:focus-visible ~ * label[for="pick-files"] { outline: 2px solid var(--focus); outline-offset: 3px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions-end { justify-content: flex-end; }

.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--bg-4); gap: 2px; position: relative; }
.seg button, .seg a { min-height: 36px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font-weight: 600; font-size: 0.875rem; display: inline-flex; align-items: center; gap: 6px; transition: background-color var(--t-fast), color var(--t-fast); }
.seg button[aria-pressed="true"], .seg a.active, .seg button[aria-checked="true"] { background: var(--bg-3); color: var(--ink); box-shadow: var(--shadow-1); }
.seg .btn-icon { width: 40px; padding: 0; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field > span, .field label, .label { font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 0.8125rem; color: var(--ink-3); font-weight: 400; }
:where(input:not([type="file"]):not([type="checkbox"]):not([type="radio"]), select, textarea) {
  width: 100%;
  min-height: var(--control-h);
  padding: 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--bg-2);
  color: var(--ink);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background-color var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
:where(input:not([type="file"]), select, textarea):focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); background: var(--bg-3); }
select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2398897a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; }
textarea { resize: vertical; min-height: 90px; }
.input-wrap { position: relative; }
.input-wrap .icon-lead { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.input-wrap input.has-lead { padding-left: 42px; }
.input-wrap .input-trail { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.input-wrap input.has-trail { padding-right: 46px; }

/* ---------- surfaces ---------- */
.card {
  background: color-mix(in srgb, var(--bg-3) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-1);
}
.card-lg { padding: 22px; border-radius: var(--radius-lg); }
.card-glass { background: var(--glass); backdrop-filter: blur(16px); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title { font-size: 1rem; font-weight: 650; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }
.page-head { display: grid; gap: 8px; margin-bottom: 22px; }
.page-head .lead { color: var(--ink-2); max-width: 58ch; font-size: 1.0625rem; }
.page-head-row { display: flex; align-items: center; justify-content: flex-start; gap: 12px; }
.page-head-row .count-pill { transform: translateY(2px); }
.page-head-tight { margin-bottom: 14px; }
.lead-short { font-size: 0.9375rem; }
.link-btn { border: 0; background: transparent; padding: 0; color: var(--amber); font: inherit; font-size: 0.9375rem; text-decoration: underline; text-underline-offset: 0.16em; cursor: pointer; }
.eyebrow { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber); }

/* ---------- chips & badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: var(--radius-pill); background: var(--bg-4); color: var(--ink-2); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-queued { background: var(--warn-soft); color: var(--warn); }
.chip-queued .dot { animation: pulse 1.6s ease-in-out infinite; }
.chip-done { background: var(--ok-soft); color: var(--ok); }
.chip-failed { background: var(--danger-soft); color: var(--danger); }
.chip-info { background: var(--info-soft); color: var(--info); }
.chip-accent { background: var(--amber-soft); color: var(--amber); }
:root[data-theme="light"] .chip-queued { color: var(--warn); }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.75); } }
.count-pill { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 8px; border-radius: 12px; background: var(--amber); color: var(--amber-ink); font-size: 0.75rem; font-weight: 700; }

/* ---------- notices & toasts ---------- */
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--bg-4); color: var(--ink); font-size: 0.9375rem; margin: 0 0 14px; border: 1px solid var(--line); animation: rise var(--t-med) var(--ease-out); }
.notice .icon { flex-shrink: 0; margin-top: 2px; }
.notice .notice-body { flex: 1; min-width: 0; white-space: pre-line; }
.notice .notice-body a { font-weight: 600; }
.notice .btn { margin-left: auto; align-self: center; }
.notice-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice-error .icon { color: var(--danger); }
.notice-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.notice-ok .icon { color: var(--ok); }
.notice-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.notice-info .icon { color: var(--info); }
.notice-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice-warn .icon { color: var(--warn); }
.notice-tight { margin: 8px 0 0; padding: 8px 10px; font-size: 0.875rem; }

.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab-h) + 14px + env(safe-area-inset-bottom)); z-index: 60; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 520px;
  width: 100%;
  padding: 10px 10px 10px 14px;
  border-radius: 14px;
  background: var(--glass);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-3);
  color: var(--ink);
  font-size: 0.9375rem;
  animation: toast-in var(--t-med) var(--ease-spring);
}
.toast .icon { color: var(--ok); flex-shrink: 0; }
.toast-error .icon { color: var(--danger); }
.toast-info .icon { color: var(--info); }
.toast-text { flex: 1; min-width: 0; }
.toast-action { border: 0; background: var(--amber-soft); color: var(--amber); font-weight: 700; padding: 8px 12px; border-radius: 10px; }
.toast-action:hover { background: var(--amber); color: var(--amber-ink); }
.toast-close { border: 0; background: transparent; color: var(--ink-3); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; }
.toast-close:hover { background: var(--bg-4); color: var(--ink); }
@keyframes toast-in { from { transform: translateY(16px) scale(0.96); } to { transform: none; } }
@media (min-width: 900px) { .toasts { bottom: 20px; left: var(--sidebar-w); } }

/* ---------- empty & loading ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 44px 20px; border: 1px dashed var(--line-2); border-radius: var(--radius-lg); color: var(--ink-2); background: color-mix(in srgb, var(--bg-3) 50%, transparent); }
.empty .empty-icon { width: 60px; height: 60px; border-radius: 20px; background: var(--amber-soft); color: var(--amber); display: grid; place-items: center; margin-bottom: 6px; box-shadow: 0 0 40px -10px var(--amber-glow); }
.empty h2 { color: var(--ink); font-size: 1.25rem; font-family: var(--font-display); font-weight: 400; }
.empty p { max-width: 38ch; }
.empty .actions { justify-content: center; margin-top: 10px; }

.skeleton { position: relative; overflow: hidden; background: var(--bg-4); border-radius: 8px; min-height: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 8%, transparent), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skeleton-text { height: 14px; }
.skeleton-title { height: 20px; width: 60%; }
.skeleton-cover { aspect-ratio: 2 / 3; border-radius: 8px; }
.skeleton-card { height: 96px; border-radius: var(--radius); }

/* ---------- progress ---------- */
.progress { height: 6px; border-radius: 999px; background: var(--bg-4); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--amber), var(--amber-2)); transition: width 600ms var(--ease-out); box-shadow: 0 0 12px var(--amber-glow); }
.progress.ok > span { background: var(--ok); box-shadow: none; }
.progress.warn > span { background: var(--warn); box-shadow: none; }
.progress.indeterminate > span { width: 40% !important; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
.meter { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--ink-3); }
.meter .progress { flex: 1; height: 5px; }

/* counting numbers, no JS: an animatable integer custom property */
.count { --n: 0; display: inline-block; font-variant-numeric: tabular-nums; counter-reset: n var(--n); }
.count::after { content: counter(n); }
.count.live { transition: --n 900ms var(--ease-out); }
.bump { animation: bump var(--t-med) var(--ease-spring); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

.avatar { --s: 40px; width: var(--s); height: var(--s); border-radius: 50%; background: linear-gradient(145deg, var(--amber-2), var(--amber)); color: var(--amber-ink); display: grid; place-items: center; font-weight: 700; font-size: calc(var(--s) * 0.42); flex-shrink: 0; text-transform: uppercase; box-shadow: 0 8px 20px -8px var(--amber-glow); }
.avatar-lg { --s: 72px; }

/* ---------- generic motion ---------- */
/* Entrances move, they never hide: the end state is the default state, so a paused timeline,
   a background tab or a crawler still sees the content. */
@keyframes rise { from { transform: translateY(10px); } to { transform: none; } }
@keyframes pop-in { from { transform: scale(0.6); } to { transform: scale(1); } }
.rise { animation: rise var(--t-med) var(--ease-out) both; }
.stagger > * { animation: rise var(--t-slow) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 50ms); }

/* =====================================================================
   LIBRARY: covers with depth
   ===================================================================== */
.toolbar { display: grid; gap: 10px; margin-bottom: 18px; container-type: inline-size; }
.toolbar form { display: contents; }
.toolbar-row { display: flex; gap: 8px; align-items: center; }
.toolbar select { min-width: 0; }
.toolbar .sort-wrap { flex: 1 1 110px; min-width: 0; }
.toolbar .sort-dir { flex: 0 0 auto; padding-inline: 12px; }
.toolbar .seg { flex: 0 0 auto; }
.toolbar .input-wrap input.has-trail { padding-right: 52px; }
.toolbar .input-trail { right: 5px; }
@media (max-width: 479px) {
  .toolbar .sort-dir { width: var(--control-h); padding: 0; justify-content: center; }
  .toolbar .sort-dir-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .toolbar .seg .btn-icon { width: 36px; }
}
.result-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; color: var(--ink-3); font-size: 0.875rem; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 24px 16px; perspective: 1400px; }
.book-grid.list { grid-template-columns: 1fr; gap: 10px; perspective: none; }
@media (min-width: 900px) { .book-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 30px 22px; } }

.book { position: relative; display: grid; gap: 10px; align-content: start; view-transition-name: var(--vt); animation: rise var(--t-slow) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 35ms); }
/* List view. Phones: cover | title, author, meta (wrapping, never cut) | actions.
   Wide screens: one aligned table row per book under a column header. */
.book-grid.list { gap: 6px; }
.book-grid.list .book {
  grid-template-columns: 44px minmax(0, 1fr) 36px;
  grid-template-areas: "cover copy actions";
  align-items: center; gap: 2px 14px; padding: 8px 8px 8px 8px;
  background: color-mix(in srgb, var(--bg-3) 92%, transparent); border: 1px solid var(--line); border-radius: 12px; animation: none;
}
.book-grid.list .book:hover { border-color: var(--line-2); background: color-mix(in srgb, var(--bg-4) 92%, transparent); }
.book-grid.list .cover { grid-area: cover; width: 44px; box-shadow: var(--shadow-1); transform: none !important; border-radius: 4px; }
.book-grid.list .cover::before, .book-grid.list .cover::after { display: none; }
.book-grid.list .cover-fallback { padding: 4px; }
.book-grid.list .cover-title { font-size: 0.5rem; }
.book-grid.list .cover-by { display: none; }
.book-grid.list .book-copy { grid-area: copy; text-align: left; justify-items: start; }
.book-grid.list .book-copy h2 { -webkit-line-clamp: 3; line-clamp: 3; font-size: 0.9375rem; }
.book-grid.list .book-copy .by { white-space: normal; overflow-wrap: anywhere; }
.book-grid.list .book-meta { display: flex; margin-top: 2px; }
.book-grid.list .m-src { display: none; }
.book-grid.list .book-menu, .book-grid.list .book-more-wrap { grid-area: actions; justify-self: end; }
.book-grid.list .book-menu { position: static; background: transparent; box-shadow: none; transform: none; color: var(--ink-3); }
.book-grid.list .book-menu:hover { color: var(--danger, #e5484d); }
.list-head { display: none; }
@media (hover: none) {
  .book-grid.list .book { padding-right: 8px; }
  .book-grid.list .book-more-wrap { position: relative; right: auto; bottom: auto; }
}
@media (min-width: 760px) {
  .book-grid.list .book, .list-head {
    grid-template-columns: 40px minmax(0, 2.4fr) minmax(0, 1.5fr) 3.5rem 9.5rem 36px;
    grid-template-areas: "cover title author year isbn actions";
    column-gap: 16px;
  }
  .book-grid.list .book { padding: 6px 8px; }
  .book-grid.list .cover { width: 40px; }
  .book-grid.list .book-copy, .book-grid.list .book-meta { display: contents; }
  .book-grid.list .book-copy h2 { grid-area: title; -webkit-line-clamp: 2; line-clamp: 2; }
  .book-grid.list .book-copy .by { grid-area: author; font-size: 0.875rem; -webkit-line-clamp: 2; line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
  .book-grid.list .m-year { grid-area: year; font-variant-numeric: tabular-nums; font-size: 0.8125rem; }
  .book-grid.list .m-isbn { grid-area: isbn; font-variant-numeric: tabular-nums; font-size: 0.8125rem; }
  .book-grid.list .m-label { display: none; }
  .list-head { display: grid; padding: 0 9px 6px; margin-bottom: 2px; border-bottom: 1px solid var(--line); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
  .list-head > span:nth-child(1) { grid-area: cover; } .list-head > span:nth-child(2) { grid-area: title; }
  .list-head > span:nth-child(3) { grid-area: author; } .list-head > span:nth-child(4) { grid-area: year; }
  .list-head > span:nth-child(5) { grid-area: isbn; } .list-head > span:nth-child(6) { grid-area: actions; }
}

/* the cover: a face, a spine edge on the left, a sheen that follows the pointer */
.cover {
  --rx: 0deg;
  --ry: 0deg;
  --mx: 50%;
  --my: 40%;
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 4px 10px 10px 4px;
  background:
    radial-gradient(120% 90% at 30% 20%, color-mix(in srgb, var(--cover, var(--amber)) 100%, white 12%), transparent 60%),
    linear-gradient(165deg, var(--cover, var(--amber)) 0%, color-mix(in srgb, var(--cover, var(--amber)) 65%, black) 100%);
  color: #fff6ec;
  box-shadow: var(--cover-shadow);
  transform-style: preserve-3d;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform var(--t-slow) var(--ease-out), box-shadow var(--t-med);
  will-change: transform;
}
.cover.tilting { transition: transform 80ms linear, box-shadow var(--t-med); box-shadow: 0 34px 50px -24px rgba(0, 0, 0, 0.9), 0 10px 18px -8px rgba(0, 0, 0, 0.6); }
.book:hover .cover:not(.tilting) { transform: rotateX(4deg) rotateY(-8deg) translateY(-4px); }
/* spine edge: a slab at the left, rotated into the third dimension */
.cover::before {
  content: "";
  position: absolute;
  top: 1px;
  bottom: 1px;
  left: 0;
  width: 14px;
  border-radius: 3px 0 0 3px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--cover, var(--amber)) 45%, black), color-mix(in srgb, var(--cover, var(--amber)) 80%, black) 60%, color-mix(in srgb, var(--cover, var(--amber)) 55%, black));
  transform-origin: left center;
  transform: rotateY(-90deg) translateX(-1px);
  backface-visibility: visible;
}
/* page block on the right */
.cover::after {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  right: -5px;
  width: 6px;
  border-radius: 0 3px 3px 0;
  background: repeating-linear-gradient(180deg, #efe6d4 0 1px, #cfc4b0 1px 2px);
  transform: translateZ(-2px);
  opacity: 0.9;
}
.cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  z-index: 1;
  opacity: 0;
  filter: blur(14px) saturate(1.2);
  transform: scale(1.06);
  transition: opacity var(--t-slow) var(--ease-out), filter var(--t-slow) var(--ease-out), transform var(--t-slow) var(--ease-out);
}
.cover-img.loaded { opacity: 1; filter: blur(0) saturate(1); transform: scale(1); }
.cover:has(.cover-img.loaded) .cover-fallback { visibility: hidden; }
.cover-sheen {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(60% 50% at var(--mx) var(--my), rgba(255, 255, 255, 0.22), transparent 70%),
    linear-gradient(100deg, rgba(255, 255, 255, 0.06), transparent 30%, rgba(0, 0, 0, 0.18) 100%);
  opacity: 0.7;
  mix-blend-mode: soft-light;
}
.cover-fallback { position: absolute; inset: 0; z-index: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; padding: 14px 12px 14px 18px; }
.cover-title { font-family: var(--font-display); font-size: 1.15rem; line-height: 1.05; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); text-wrap: balance; }
.cover-by { font-size: 0.72rem; opacity: 0.85; line-height: 1.3; }
.book-copy { display: grid; gap: 2px; min-width: 0; }
.book-copy h2 { font-size: 0.9375rem; font-weight: 600; line-height: 1.25; }
.book-copy .by { font-size: 0.8125rem; color: var(--ink-3); }
.book-meta { display: none; flex-wrap: wrap; gap: 4px 10px; font-size: 0.75rem; color: var(--ink-3); margin-top: 4px; }
.book-menu { position: absolute; top: 8px; right: 8px; z-index: 3; width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--glass); backdrop-filter: blur(8px); color: var(--ink); box-shadow: var(--shadow-1); display: grid; place-items: center; opacity: 0; transition: opacity var(--t-fast), transform var(--t-fast); transform: translateY(-4px); }
.book:hover .book-menu, .book:focus-within .book-menu, .book-menu:focus-visible { opacity: 1; transform: none; }
.book-more-wrap { display: none; position: relative; }
.book-more { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-3); display: grid; place-items: center; }
.book-actions { position: absolute; right: 0; bottom: 36px; z-index: 5; display: flex; gap: 6px; padding: 6px; border-radius: 12px; background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--line-2); box-shadow: var(--shadow-3); animation: pop-in var(--t-fast) var(--ease-out); }
@media (hover: none) {
  .book-menu { display: none; }
  .book-more-wrap { display: block; position: absolute; right: 0; bottom: 0; }
  .book { padding-right: 32px; }
  .book-grid.list .book { padding-right: 44px; }
}
.book-confirm { position: absolute; inset: 0; z-index: 4; display: grid; align-content: center; justify-items: center; gap: 10px; padding: 12px; text-align: center; background: var(--glass); backdrop-filter: blur(12px); border-radius: var(--radius); font-size: 0.875rem; animation: pop-in var(--t-fast) var(--ease-out); }
.book-confirm .actions { justify-content: center; gap: 8px; }
.book-grid.list .book-confirm { position: static; grid-column: 1 / -1; background: transparent; backdrop-filter: none; padding: 4px 0 0; }
.load-more { display: flex; justify-content: center; margin-top: 28px; }

/* =====================================================================
   SHELF: the collection as spines on wood
   ===================================================================== */
.shelf-wall {
  --slot: 210px;
  --plank: 14px;
  --gap: 34px;
  --scale: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: var(--gap) 3px;
  padding: 10px 18px calc(var(--plank) + 16px);
  margin: 0 -4px;
  background:
    repeating-linear-gradient(180deg,
      transparent 0 calc(var(--slot) + 10px),
      var(--wood-edge) calc(var(--slot) + 10px) calc(var(--slot) + 11px),
      var(--wood) calc(var(--slot) + 11px) calc(var(--slot) + 10px + var(--plank) * 0.5),
      var(--wood-2) calc(var(--slot) + 10px + var(--plank) * 0.5) calc(var(--slot) + 10px + var(--plank)),
      transparent calc(var(--slot) + 10px + var(--plank)) calc(var(--slot) + var(--gap)));
  background-size: 100% calc(var(--slot) + var(--gap));
  background-position: 0 0;
  container-type: inline-size;
}
.shelf-wall .slot { height: var(--slot); display: flex; align-items: flex-end; }
@media (min-width: 900px) { .shelf-wall { --slot: 250px; --scale: 1.25; gap: var(--gap) 5px; padding: 10px 28px calc(var(--plank) + 16px); } .spine span { font-size: 1rem; } .spine.wide span { font-size: 1.1rem; } .spine.thin span { font-size: 0.85rem; } }
.spine {
  --c: var(--amber);
  --w: 34px;
  --h: 180px;
  position: relative;
  flex: 0 0 calc(var(--w) * var(--scale));
  width: calc(var(--w) * var(--scale));
  height: calc(var(--h) * var(--scale));
  border: 0;
  padding: 16px 0 12px;
  border-radius: 3px 3px 1px 1px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22), transparent 30%, rgba(0, 0, 0, 0.1) 70%, rgba(0, 0, 0, 0.35)),
    var(--c);
  color: #fff6ec;
  box-shadow: inset -3px 0 0 rgba(0, 0, 0, 0.28), 0 10px 14px -10px rgba(0, 0, 0, 0.7);
  cursor: pointer;
  text-align: center;
  overflow: hidden;
  transform-origin: bottom center;
  transition: transform var(--t-med) var(--ease-spring), box-shadow var(--t-med), filter var(--t-fast);
  view-transition-name: var(--vt);
}
.spine::before, .spine::after { content: ""; position: absolute; left: 15%; right: 15%; height: 2px; background: rgba(255, 230, 190, 0.55); border-radius: 2px; }
.spine::before { top: 9px; }
.spine::after { bottom: 7px; }
.spine:hover, .spine:focus-visible { transform: translateY(-14px) rotate(-2deg); box-shadow: inset -3px 0 0 rgba(0, 0, 0, 0.28), 0 24px 30px -14px rgba(0, 0, 0, 0.8); filter: brightness(1.1); z-index: 2; }
.spine span {
  display: block;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: var(--font-display);
  font-size: 0.86rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: calc(var(--h) * var(--scale) - 36px);
  margin: 0 auto;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}
.spine.wide span { font-size: 0.95rem; }
.spine.thin span { font-size: 0.72rem; }
.spine .spine-by { font-family: var(--font-ui); font-size: 0.6rem; opacity: 0.8; letter-spacing: 0.04em; }
@keyframes shelve { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: none; } }
.shelf-peek {
  position: sticky;
  bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom));
  margin-top: 36px;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-3);
  animation: rise var(--t-med) var(--ease-out);
}
.shelf-peek .cover { width: 56px; flex: none; transform: none !important; }
.shelf-peek .cover::before, .shelf-peek .cover::after { display: none; }
.shelf-peek .meta { min-width: 0; display: grid; gap: 2px; }
.shelf-peek strong { font-size: 1rem; }
@media (min-width: 900px) { .shelf-peek { bottom: 16px; } }

/* =====================================================================
   REVIEW: a stack of cards you swipe through
   ===================================================================== */
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.review-progress { display: grid; gap: 6px; margin-bottom: 18px; }
.review-progress .progress { height: 4px; }
.review-progress .text-xs { color: var(--ink-3); display: flex; justify-content: space-between; }
.review-keys { display: none; gap: 14px; align-items: center; color: var(--ink-3); font-size: 0.8125rem; margin-top: 12px; }
.review-keys kbd { font: 600 0.75rem var(--font-ui); padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--ink-2); box-shadow: 0 1px 0 var(--line-2); }
@media (hover: hover) and (pointer: fine) { .review-keys { display: flex; } }

.stack { position: relative; display: grid; isolation: isolate; perspective: 1200px; }
.stack > * { grid-area: 1 / 1; }
.stack-card { --i: 0; --dx: 0; --rot: 0deg; --yes: 0; --no: 0; transform-origin: 50% 100%; transition: transform var(--t-med) var(--ease-out), opacity var(--t-med); touch-action: pan-y; }
.stack-card[data-depth="1"] { transform: translateY(12px) scale(0.96); opacity: 0.85; pointer-events: none; z-index: 2; }
.stack-card[data-depth="2"] { transform: translateY(24px) scale(0.92); opacity: 0.6; pointer-events: none; z-index: 1; }
.stack-card[data-depth="0"] { z-index: 3; transform: translateX(calc(var(--dx) * 1px)) rotate(var(--rot)); cursor: grab; }
.stack-card[data-depth="0"] > .review { background: var(--bg-3); }
.stack-card[aria-hidden="true"] { background: var(--bg-3); }
.stack-card[aria-hidden="true"] > * { visibility: hidden; }
.stack-card.dragging { transition: none; cursor: grabbing; }
.stack-card.fly-right { transform: translateX(120vw) rotate(24deg); opacity: 0; transition: transform var(--t-slow) var(--ease-out), opacity var(--t-slow); }
.stack-card.fly-left { transform: translateX(-120vw) rotate(-24deg); opacity: 0; transition: transform var(--t-slow) var(--ease-out), opacity var(--t-slow); }
.stack-card.decided-yes { animation: decide-yes var(--t-slow) var(--ease-out) both; }
.stack-card.decided-no { animation: decide-no var(--t-slow) var(--ease-out) both; }
@keyframes decide-yes { 30% { transform: translateX(16px) rotate(2deg) scale(1.02); } 100% { transform: translateX(120vw) rotate(20deg); opacity: 0; } }
@keyframes decide-no { 30% { transform: translateX(-16px) rotate(-2deg) scale(1.02); } 100% { transform: translateX(-120vw) rotate(-20deg); opacity: 0; } }
.stack-card.enter { animation: card-enter var(--t-slow) var(--ease-spring) both; }
@keyframes card-enter { from { transform: translateY(12px) scale(0.96); } to { transform: none; } }
.stamp {
  position: absolute;
  top: 18px;
  z-index: 5;
  padding: 6px 12px;
  border: 3px solid currentColor;
  border-radius: 10px;
  font: 800 1.1rem var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
  background: var(--glass);
}
.stamp-yes { left: 18px; color: var(--ok); transform: rotate(-12deg); opacity: var(--yes); }
.stamp-no { right: 18px; color: var(--danger); transform: rotate(12deg); opacity: var(--no); }

.review { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.review-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.raw { position: relative; padding: 12px 14px 12px 18px; border-radius: 12px; background: var(--bg-4); color: var(--ink-2); font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.8125rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.raw::before { content: ""; position: absolute; left: 8px; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--amber); opacity: 0.7; }
.review form { display: grid; gap: 12px; }
.review-fields { display: grid; gap: 12px; }
.review-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.review-actions .btn-accept { grid-column: 1 / -1; }
.review-queue { display: grid; gap: 6px; margin-top: 22px; }
.review-queue h2 { font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.review-queue button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--bg-3) 92%, transparent); color: var(--ink); text-align: left; transition: transform var(--t-fast), border-color var(--t-fast); }
.review-queue button:hover { border-color: var(--line-2); transform: translateX(4px); }
.review-queue .q-title { font-weight: 600; font-size: 0.9375rem; }
.review-queue .q-by { font-size: 0.8125rem; color: var(--ink-3); }
.review-queue .chip { margin-left: auto; }
.review-done { animation: fade 400ms ease; }
@keyframes fade { from { transform: translateY(4px); } to { transform: none; } }

/* "Is it this book?" */
.suggestion { display: grid; gap: 12px; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: color-mix(in srgb, var(--amber-soft) 50%, var(--bg-4)); }
.suggestion h3 { font-size: 1.25rem; font-family: var(--font-display); font-weight: 400; }
.suggestion-body { display: flex; gap: 14px; align-items: center; }
.suggestion-cover { flex: none; width: 64px; height: 96px; aspect-ratio: auto; transform: none !important; animation: cover-in var(--t-slow) var(--ease-spring) both; animation-delay: 120ms; }
.suggestion-cover::before, .suggestion-cover::after { display: none; }
.suggestion-cover .cover-fallback { padding: 8px 6px; }
.suggestion-cover .cover-title { font-size: 0.72rem; }
.suggestion-cover .cover-by { font-size: 0.55rem; }
@keyframes cover-in { from { transform: translateX(-24px) rotateY(30deg); } to { transform: none; } }
.suggestion-copy { min-width: 0; display: grid; gap: 2px; }
.suggestion-title { font-weight: 650; font-size: 1.0625rem; line-height: 1.3; }
.suggestion-by { color: var(--ink-2); font-size: 0.9375rem; }
.suggestion-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.suggestion-actions .btn { min-width: 0; padding-left: 10px; padding-right: 10px; }
.suggestion-foot { display: flex; gap: 8px; justify-content: flex-end; }

.filed-strip { margin-bottom: 14px; }
.filed-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
.filed-strip.open .filed-head { margin-bottom: 8px; }
.filed-head h2 { font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.filed-toggle { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; border: 0; background: transparent; padding: 6px 4px 6px 0; color: var(--ink-2); text-align: left; border-radius: 8px; }
.filed-toggle h2 { white-space: nowrap; }
.filed-head > a { white-space: nowrap; flex: none; }
@media (max-width: 479px) { .filed-latest { display: none; } }
.filed-toggle .chip { min-height: 20px; padding: 0 7px; }
.filed-latest { font-size: 0.8125rem; color: var(--ink-3); min-width: 0; }
.filed-list[hidden] { display: none; }
.review-top .text-xs { display: none; }
.raw { max-height: 6.2em; overflow: auto; }
@media (min-width: 900px) { .review-top .text-xs { display: inline; } .raw { max-height: none; } }
.filed-list { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px; scrollbar-width: thin; }
.filed-item { flex: 0 0 180px; scroll-snap-align: start; display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--bg-3) 92%, transparent); min-width: 0; }
.filed-title { font-weight: 600; font-size: 0.9375rem; }
.filed-by { font-size: 0.8125rem; color: var(--ink-3); }
.filed-item .chip { justify-self: start; margin-top: 4px; }

@media (min-width: 900px) {
  .review-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr); gap: 28px; align-items: start; }
  .review-queue { margin-top: 0; }
  .review-fields { grid-template-columns: 1fr 1fr; }
  .review-fields .field-title { grid-column: 1 / -1; }
  .review-actions { display: flex; justify-content: flex-end; }
  .review-actions .btn-accept { order: 3; min-width: 180px; }
  .suggestion-actions { display: flex; justify-content: flex-end; }
  .suggestion-actions .btn-primary { min-width: 180px; }
}

/* =====================================================================
   ADD PHOTOS: a capture area that feels like a camera
   ===================================================================== */
.capture {
  position: relative;
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 300px;
  padding: 28px 20px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(60% 50% at 50% 35%, var(--amber-soft), transparent 70%),
    color-mix(in srgb, var(--bg-3) 92%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  text-align: center;
  transition: box-shadow var(--t-med), border-color var(--t-med), transform var(--t-med) var(--ease-out);
}
.capture::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 2px dashed var(--line-2);
  border-radius: calc(var(--radius-lg) - 8px);
  pointer-events: none;
  transition: border-color var(--t-med), inset var(--t-med) var(--ease-out);
}
.capture.over { border-color: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft), 0 0 60px -10px var(--amber-glow), var(--shadow-2); transform: scale(1.01); }
.capture.over::before { border-color: var(--amber); inset: 8px; }
.capture > * { position: relative; z-index: 1; }
.capture-iris { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; color: var(--amber); background: conic-gradient(from 0deg, var(--amber-soft), transparent 40%, var(--amber-soft) 60%, transparent 100%); box-shadow: inset 0 0 0 3px var(--line-2), 0 0 40px -8px var(--amber-glow); animation: iris 8s linear infinite; }
.capture-iris .icon { animation: iris-back 8s linear infinite; }
@keyframes iris { to { transform: rotate(360deg); } }
@keyframes iris-back { to { transform: rotate(-360deg); } }
.capture h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.6rem; }
.capture p { color: var(--ink-2); max-width: 36ch; }
.capture .choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 6px; }
.capture input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 2; font-size: 0; }
.capture .choices { position: relative; z-index: 3; }
.upload-help { font-size: 0.875rem; color: var(--ink-3); text-align: center; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; }
.tile { --i: 0; position: relative; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: var(--bg-4); border: 1px solid var(--line); box-shadow: var(--shadow-1); animation: tile-in var(--t-slow) var(--ease-spring) both; animation-delay: calc(var(--i) * 45ms); }
@keyframes tile-in { from { transform: translateY(24px) rotate(-4deg) scale(0.9); } to { transform: none; } }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile .tile-remove { position: absolute; top: 6px; right: 6px; z-index: 2; width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(20, 16, 12, 0.72); color: #fff; display: grid; place-items: center; backdrop-filter: blur(6px); }
.tile .tile-retry { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 12px; border: 0; border-radius: 10px; background: var(--bg-3); color: var(--ink); font-size: 0.8125rem; font-weight: 600; box-shadow: var(--shadow-2); }
.tile .tile-state { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 6px 8px; line-height: 1.3; background: linear-gradient(0deg, rgba(20, 16, 12, 0.82), rgba(20, 16, 12, 0)); color: #fff; font-size: 0.6875rem; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.tile .tile-state .progress { height: 3px; background: rgba(255, 255, 255, 0.25); margin-top: 4px; }
.tile .tile-state .progress > span { background: #fff; box-shadow: none; }
.tile.failed { outline: 2px solid var(--danger); outline-offset: -2px; }
.tile.failed .tile-state { background: linear-gradient(0deg, color-mix(in srgb, var(--danger) 85%, black) 0%, transparent); }
.tile.failed .tile-state .truncate { white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile.ready-empty { display: grid; place-items: center; color: var(--ink-3); border-style: dashed; border-color: var(--line-2); background: transparent; box-shadow: none; animation: none; }
/* the scanning sweep over a queued photo */
.tile.scanning::after { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, transparent 0%, rgba(255, 200, 120, 0.05) 40%, rgba(255, 220, 160, 0.65) 50%, rgba(255, 200, 120, 0.05) 60%, transparent 100%); background-size: 100% 220%; animation: sweep 2.2s ease-in-out infinite; mix-blend-mode: screen; }
.tile.scanning img { filter: saturate(0.7) brightness(0.85); }
@keyframes sweep { 0% { background-position: 0 -110%; } 100% { background-position: 0 110%; } }
.tile.done img { animation: tile-done var(--t-slow) var(--ease-out); }
@keyframes tile-done { 0% { filter: brightness(1.6) saturate(1.4); } 100% { filter: none; } }
.fly-book { position: fixed; z-index: 80; width: 14px; height: 20px; border-radius: 2px 3px 3px 2px; background: linear-gradient(145deg, var(--amber-2), var(--amber)); box-shadow: inset 2px 0 0 rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.4); pointer-events: none; }

.sticky-bar { position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 10px); z-index: 5; display: flex; gap: 10px; align-items: center; padding: 10px; margin-top: 16px; background: var(--glass); backdrop-filter: blur(16px); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow-3); animation: rise var(--t-med) var(--ease-out); }
.sticky-bar .btn-primary { flex: 1; }
@media (min-width: 900px) { .sticky-bar { bottom: 16px; } }
.camera { background: #0d0a08; border-radius: var(--radius); padding: 10px; display: grid; gap: 10px; }
.camera video { width: 100%; border-radius: 10px; background: #000; max-height: 420px; object-fit: cover; }
.camera .actions { justify-content: center; }
.kind-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.queue-summary { position: relative; display: grid; gap: 10px; padding: 16px 18px; border-radius: var(--radius); background: linear-gradient(135deg, color-mix(in srgb, var(--amber-soft) 80%, var(--bg-3)), var(--bg-3)); border: 1px solid color-mix(in srgb, var(--amber) 25%, transparent); overflow: hidden; }
.queue-summary strong { font-size: 1.15rem; font-family: var(--font-display); font-weight: 400; }
.queue-summary .text-sm { color: var(--ink-2); }
.counters { display: flex; gap: 18px; flex-wrap: wrap; }
.counter { display: grid; gap: 2px; min-width: 80px; }
.counter .count { font-family: var(--font-display); font-size: 2.2rem; line-height: 1; color: var(--ink); }
.counter small { color: var(--ink-3); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; }

/* =====================================================================
   QUEUE
   ===================================================================== */
.job-groups { display: grid; gap: 18px; }
.job-group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 6px 0 8px; }
.job-group-head h2 { font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.jobs { display: grid; gap: 10px; }
.job { position: relative; display: grid; gap: 10px; padding: 14px; animation: rise var(--t-med) var(--ease-out) both; }
.job.reading { border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.job.reading::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; border: 1px solid var(--amber); opacity: 0; animation: ring 2.4s ease-out infinite; pointer-events: none; }
@keyframes ring { 0% { opacity: 0.6; transform: scale(1); } 100% { opacity: 0; transform: scale(1.03); } }
.job-head { display: flex; align-items: center; gap: 10px; }
.job-head .job-title { font-size: 0.9375rem; font-weight: 600; }
.job-head .job-time { font-size: 0.8125rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.job-head .chip { margin-left: auto; }
.job-thumb { width: 44px; height: 44px; border-radius: 10px; background: var(--bg-4); color: var(--ink-3); display: grid; place-items: center; flex-shrink: 0; overflow: hidden; }
.job-thumb img { width: 100%; height: 100%; object-fit: cover; }
.job.reading .job-thumb { position: relative; }
.job.reading .job-thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, rgba(255, 220, 160, 0.7) 50%, transparent 70%); background-size: 100% 220%; animation: sweep 2.2s ease-in-out infinite; mix-blend-mode: screen; }
.job-line { font-size: 0.875rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.job-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.job-steps li { display: grid; gap: 5px; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink-3); }
.job-steps li::before { content: ""; display: block; height: 4px; border-radius: 2px; background: var(--bg-5); }
.job-steps li.done { color: var(--ok); }
.job-steps li.done::before { background: var(--ok); }
.job-steps li.now { color: var(--amber); }
.job-steps li.now::before { background: linear-gradient(90deg, var(--amber), var(--amber-2), var(--amber)); background-size: 200% 100%; animation: flow 1.6s linear infinite; box-shadow: 0 0 10px var(--amber-glow); }
@keyframes flow { to { background-position: -200% 0; } }
.job-steps li.failed { color: var(--danger); }
.job-steps li.failed::before { background: var(--danger); }
.job-found { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.job-found li { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; animation: rise var(--t-med) var(--ease-out) both; }
.job-found li strong { font-weight: 600; }
.job-found li .note { margin-left: auto; white-space: nowrap; font-size: 0.75rem; color: var(--ink-3); }
.job-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.job-foot .btn { min-height: 36px; }
.finished-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 14px 16px; }
.finished-summary .counter .count { font-size: 1.8rem; }

/* =====================================================================
   LANDING
   ===================================================================== */
.hero { display: grid; gap: 30px; padding: 14px 0 30px; }
.hero h1 { font-size: clamp(2.8rem, 11vw, 5rem); max-width: 13ch; }
.hero .lead { font-size: 1.0625rem; color: var(--ink-2); max-width: 46ch; margin-top: 16px; }
.hero .actions { margin-top: 24px; }
.hero > div:first-child > * { animation: rise var(--t-slow) var(--ease-out) both; }
.hero > div:first-child > :nth-child(2) { animation-delay: 80ms; }
.hero > div:first-child > :nth-child(3) { animation-delay: 160ms; }
.hero > div:first-child > :nth-child(4) { animation-delay: 240ms; }

/* the stage: a shelf gets read, spine by spine, and lands in a library */
.stage { position: relative; border-radius: var(--radius-lg); background: color-mix(in srgb, var(--bg-3) 90%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow-3); padding: 22px 18px 18px; overflow: hidden; display: grid; gap: 22px; animation: rise var(--t-slow) var(--ease-out) both; animation-delay: 200ms; }
.stage::before { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 40% at 50% 0%, var(--amber-soft), transparent 70%); pointer-events: none; }
.stage-shelf { position: relative; display: flex; align-items: flex-end; justify-content: center; gap: 5px; height: 150px; padding: 0 10px 12px; }
.stage-shelf::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 12px; border-radius: 2px; background: linear-gradient(180deg, var(--wood-edge), var(--wood) 40%, var(--wood-2)); box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.6); }
.stage-shelf > span { --d: 0s; display: flex; align-items: flex-start; justify-content: center; padding-top: 10px; width: var(--w, 30px); height: var(--h); border-radius: 3px 3px 0 0; background: var(--c); color: #fff6ec; font-family: var(--font-display); font-size: 0.72rem; letter-spacing: 0.04em; writing-mode: vertical-rl; white-space: nowrap; overflow: hidden; box-shadow: inset -3px 0 0 rgba(0, 0, 0, 0.2); animation: light-up 9s ease-in-out infinite; animation-delay: var(--d); }
@keyframes light-up {
  0%, 8% { filter: brightness(0.6) saturate(0.7); box-shadow: inset -3px 0 0 rgba(0, 0, 0, 0.2); }
  12% { filter: brightness(1.45) saturate(1.2); box-shadow: inset -3px 0 0 rgba(0, 0, 0, 0.2), 0 0 24px var(--amber-glow); transform: translateY(-6px); }
  18%, 85% { filter: brightness(1) saturate(1); box-shadow: inset -3px 0 0 rgba(0, 0, 0, 0.2); transform: none; }
  100% { filter: brightness(0.6) saturate(0.7); }
}
.stage-scan { position: absolute; top: 0; bottom: 12px; left: 10px; width: 3px; border-radius: 2px; background: var(--amber-2); box-shadow: 0 0 18px 4px var(--amber-glow); animation: scan 9s ease-in-out infinite; }
@keyframes scan { 0% { left: 4%; opacity: 0; } 4% { opacity: 1; } 40% { left: 96%; opacity: 1; } 46% { opacity: 0; left: 96%; } 100% { opacity: 0; left: 4%; } }
.stage-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.stage-grid i { --d: 0s; display: block; aspect-ratio: 2 / 3; border-radius: 2px 5px 5px 2px; background: linear-gradient(165deg, var(--c), color-mix(in srgb, var(--c) 60%, black)); box-shadow: var(--shadow-1); animation: land 9s var(--ease-spring) infinite; animation-delay: var(--d); }
@keyframes land { 0%, 12% { opacity: 0; transform: translateY(-40px) scale(0.6) rotate(-10deg); } 20% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }
.stage-caption { position: relative; display: flex; align-items: center; justify-content: space-between; font-size: 0.8125rem; color: var(--ink-3); }
.stage-caption .count { color: var(--amber); font-family: var(--font-display); font-size: 1.4rem; }

.steps { display: grid; gap: 14px; }
.step { display: grid; grid-template-columns: 48px 1fr; gap: 16px; align-items: start; padding: 18px; border-radius: var(--radius); background: color-mix(in srgb, var(--bg-3) 85%, transparent); border: 1px solid var(--line); }
.step .step-icon { width: 48px; height: 48px; border-radius: 16px; background: var(--amber-soft); color: var(--amber); display: grid; place-items: center; box-shadow: 0 0 30px -8px var(--amber-glow); }
.step h2 { font-size: 1.2rem; font-family: var(--font-display); font-weight: 400; margin-bottom: 4px; }
.step p { color: var(--ink-2); font-size: 0.9375rem; }
.quick-actions { display: grid; gap: 12px; }
.quick { display: flex; align-items: center; gap: 14px; padding: 16px; color: var(--ink); text-decoration: none; transition: transform var(--t-med) var(--ease-spring), box-shadow var(--t-med), border-color var(--t-med); }
.quick:hover { text-decoration: none; box-shadow: var(--shadow-2); transform: translateY(-3px); border-color: var(--line-2); }
.quick .step-icon { flex-shrink: 0; }
.quick strong { display: block; font-weight: 650; }
.quick small { color: var(--ink-3); }
.quick .icon-trail { margin-left: auto; color: var(--ink-3); transition: transform var(--t-fast); }
.quick:hover .icon-trail { transform: translateX(4px); }
@media (min-width: 900px) {
  .hero { grid-template-columns: 1.05fr 0.95fr; align-items: center; gap: 56px; padding: 30px 0 56px; }
  .stage-shelf { height: 200px; }
  .stage-shelf span { font-size: 0.85rem; }
  .steps { grid-template-columns: repeat(3, 1fr); gap: 20px; }
  .step { grid-template-columns: 1fr; gap: 12px; }
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
}
/* reveal the steps as they scroll into view, where supported */
@supports (animation-timeline: view()) {
  .steps .step { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% entry 40%; }
}

/* ---------- auth ---------- */
.auth-card { display: grid; gap: 18px; }
.auth-card h1 { font-size: 2.4rem; }
.auth-card form { display: grid; gap: 14px; }
.auth-card .foot { font-size: 0.9375rem; color: var(--ink-2); text-align: center; }
.auth-head { display: grid; gap: 8px; margin-bottom: 6px; }
.demo-hint { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--warn-soft); color: var(--ink); font-size: 0.875rem; }
.demo-hint .icon { color: var(--amber); }
.demo-hint .btn { margin-left: auto; }

/* ---------- account ---------- */
.account-card { display: flex; align-items: center; gap: 16px; }
.account-card .meta { min-width: 0; display: grid; gap: 2px; }
.account-card h2 { font-size: 1.5rem; font-family: var(--font-display); font-weight: 400; }
.account-card small { color: var(--ink-3); }
.kv { display: grid; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 0.9375rem; }
.kv > div:first-child { border-top: 0; padding-top: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.theme-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-pick button { display: grid; gap: 8px; justify-items: start; padding: 12px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--ink); text-align: left; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.theme-pick button[aria-pressed="true"] { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.theme-pick .swatch { width: 100%; height: 44px; border-radius: 8px; border: 1px solid var(--line); }
.theme-pick .swatch-dark { background: linear-gradient(135deg, #15110e, #2b241e 60%, #f2a65a 140%); }
.theme-pick .swatch-light { background: linear-gradient(135deg, #f4ecdf, #fffcf6 60%, #c2511a 160%); }

/* ---------- misc ---------- */
#blazor-error-ui { display: none; position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom)); z-index: 100; padding: 12px 14px; border-radius: 12px; background: var(--danger); color: var(--danger-ink); box-shadow: var(--shadow-3); align-items: center; gap: 12px; font-size: 0.9375rem; }
#blazor-error-ui a { color: inherit; font-weight: 600; text-decoration: underline; }
#blazor-error-ui .dismiss { margin-left: auto; background: transparent; border: 0; color: inherit; font-size: 1rem; padding: 4px 8px; }

/* ---------- view transitions between routes ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 260ms; }
::view-transition-old(main) { animation: vt-out 200ms var(--ease-out) both; }
::view-transition-new(main) { animation: vt-in 320ms var(--ease-out) both; }
::view-transition-old(topbar), ::view-transition-new(topbar), ::view-transition-old(tabbar), ::view-transition-new(tabbar), ::view-transition-old(sidebar), ::view-transition-new(sidebar) { animation: none; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(12px); } }

/* ---------- reduced motion: everything still works, nothing moves ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  body::before { animation: none; }
  .cover, .book:hover .cover { transform: none !important; }
  .stack-card.fly-right, .stack-card.fly-left { display: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
