/* ═══════════════════════════════════════════════════════════
   CARRERA DE LECTURA — Dark Academia × Cottagecore
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Parchment & ink (Dark Academia) */
  --paper:        #ece1c8;
  --paper-2:      #e2d4b3;
  --paper-3:      #d8c89e;
  --paper-deep:   #c8b685;
  --ink:          #1f1812;
  --ink-2:        #463528;
  --ink-3:        #6e5640;
  --ink-soft:     #8c7359;

  --rule:         rgba(31, 24, 18, 0.18);
  --rule-2:       rgba(31, 24, 18, 0.32);
  --rule-soft:    rgba(31, 24, 18, 0.08);

  /* Identity colors — leather-bound */
  --a-spine:      #2a3c5c;   /* midnight blue leather (Nicolás) */
  --a-spine-2:    #3b5379;
  --a-spine-deep: #1a2840;
  --a-foil:       #c9a85a;   /* gilt foil */
  --a-tint:       #d8d2c4;
  --a-tint-deep:  #5a6a89;

  --b-spine:      #6b2018;   /* oxblood leather (Martín) */
  --b-spine-2:    #8c2f23;
  --b-spine-deep: #4a140e;
  --b-foil:       #c9a85a;
  --b-tint:       #ddd2c4;
  --b-tint-deep:  #8a3528;

  /* Accents */
  --brass:        #b08642;
  --brass-deep:   #8a6628;
  --brass-light:  #d6b46e;
  --forest:       #4a5c3a;
  --forest-2:     #6a7e54;
  --moss:         #7d8a5e;
  --rust:         #a35430;
  --plum:         #5a3a4c;

  /* System */
  --radius:       4px;
  --radius-sm:    3px;
  --radius-lg:    8px;
  --shadow-1:     0 1px 2px rgba(31,24,18,0.08), 0 2px 8px rgba(31,24,18,0.06);
  --shadow-2:     0 2px 6px rgba(31,24,18,0.12), 0 8px 24px rgba(31,24,18,0.10);
  --shadow-deep:  0 1px 0 rgba(255,245,220,0.4) inset, 0 8px 24px rgba(31,24,18,0.18);
  --inset-paper:  inset 0 0 0 1px rgba(31,24,18,0.06), inset 0 1px 0 rgba(255,250,235,0.6);
}

/* ── Density tweak ── */
:root[data-density="cozy"]   { --space: 1.25rem; --book-card-pad: 1.1rem 1.25rem; }
:root[data-density="comfy"]  { --space: 1.5rem;  --book-card-pad: 1.4rem 1.5rem; }
:root[data-density="ample"]  { --space: 2rem;    --book-card-pad: 1.75rem 2rem; }
:root { --space: 1.5rem; --book-card-pad: 1.4rem 1.5rem; }

/* ── Type pairing tweak ── */
:root { --font-display: 'Cormorant Garamond', Georgia, serif;
        --font-body:    'EB Garamond', Georgia, serif;
        --font-mono:    'JetBrains Mono', ui-monospace, monospace; }

html, body { height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  font-feature-settings: "kern", "liga", "onum";
  background-image:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(176, 134, 66, 0.08), transparent 70%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(74, 92, 58, 0.06), transparent 70%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 0.12  0 0 0 0 0.09  0 0 0 0 0.07  0 0 0 0.045 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* Selection */
::selection { background: var(--brass); color: var(--paper); }

/* ── SCREENS ── */
.screen { display: none; }
.screen.active { display: block; }

/* ── LOGIN ── */
#loginScreen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2rem; background: var(--paper);
  background-image:
    radial-gradient(circle at 50% 20%, rgba(176,134,66,0.10), transparent 60%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.13  0 0 0 0 0.10  0 0 0 0 0.07  0 0 0 0.05 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  transition: opacity .35s ease, transform .35s ease;
}
#loginScreen.hiding { opacity: 0; transform: translateY(-12px); pointer-events: none; }
#loginScreen.hidden { display: none; }

.login-mark {
  font-family: var(--font-display);
  font-size: 11px; letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--ink-3);
  display: flex; align-items: center; gap: 0.75rem;
}
.login-mark::before, .login-mark::after {
  content: ""; height: 1px; width: 32px; background: var(--rule-2);
}
.login-title {
  font-family: var(--font-display);
  font-size: 56px; font-weight: 500;
  letter-spacing: -0.01em;
  font-style: italic;
  color: var(--ink);
  text-align: center;
  line-height: 1.05;
}
.login-title .amp { color: var(--brass); font-style: italic; font-weight: 400; }
.login-sub {
  font-family: var(--font-display);
  font-size: 17px; color: var(--ink-3);
  font-style: italic;
  margin-top: -0.25rem;
}

.user-cards { display: flex; gap: 1.25rem; flex-wrap: wrap; justify-content: center; margin-top: 0.5rem; }
.user-card {
  background: var(--paper-2);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  gap: 0.85rem; min-width: 200px;
  position: relative;
  box-shadow: var(--inset-paper), var(--shadow-1);
  transition: transform .2s ease, box-shadow .2s ease;
}
.user-card::before {
  content: ""; position: absolute; inset: 6px; border: 1px solid var(--rule);
  border-radius: 2px; pointer-events: none;
}
.user-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }

.avatar {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 22px; font-weight: 500; letter-spacing: 0.04em;
  position: relative;
  box-shadow: 0 0 0 1px var(--rule-2), 0 4px 12px rgba(31,24,18,0.18);
}
.avatar::after {
  content: ""; position: absolute; inset: 4px; border-radius: 50%;
  border: 1px solid rgba(255,245,220,0.25);
  pointer-events: none;
}
.av-a { background: linear-gradient(160deg, var(--a-spine-2), var(--a-spine-deep)); color: var(--a-foil); }
.av-b { background: linear-gradient(160deg, var(--b-spine-2), var(--b-spine-deep)); color: var(--b-foil); }

.user-card .uname {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 500; letter-spacing: 0.01em;
}
.user-card .ucount {
  font-family: var(--font-mono);
  font-size: 10.5px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.12em;
}

/* ── MAIN SCREEN ── */
#mainScreen {
  opacity: 0; transform: translateY(8px);
  transition: opacity .4s ease .1s, transform .4s ease .1s;
}
#mainScreen.visible { opacity: 1; transform: none; }

/* ── TOP BAR (gilt nameplate) ── */
.top-bar {
  position: sticky; top: 0; z-index: 50;
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule-2);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1.75rem; gap: 1rem;
  box-shadow: 0 1px 0 rgba(255,245,220,0.4) inset, 0 4px 18px rgba(31,24,18,0.06);
}
.top-bar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 2px;
  background: linear-gradient(to right, transparent, var(--brass) 20%, var(--brass) 80%, transparent);
  opacity: 0.5;
}
.top-left { display: flex; align-items: center; gap: 14px; }
.user-badge { display: flex; align-items: center; gap: 10px; }
.mini-av {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 12px; font-weight: 500; letter-spacing: 0.04em;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px var(--rule-2);
}
.top-name {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 500; letter-spacing: 0.01em;
}
.top-title {
  font-family: var(--font-display);
  font-size: 18px; font-style: italic; font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  white-space: nowrap;
  display: flex; align-items: center; gap: 0.6rem;
}
.top-title .ornament { color: var(--brass); font-style: normal; font-size: 14px; }
.top-right { display: flex; align-items: center; gap: 6px; }

#syncStatus {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--ink-3);
  white-space: nowrap;
  letter-spacing: 0.06em; text-transform: uppercase;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--paper);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-family: var(--font-display);
  font-size: 14px; cursor: pointer; color: var(--ink);
  transition: all .15s;
}
.btn:hover { background: var(--paper-3); border-color: var(--ink-3); }
.btn-primary {
  background: var(--ink); color: var(--paper);
  border-color: var(--ink);
  font-weight: 500;
}
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-brass {
  background: var(--brass); color: var(--paper);
  border-color: var(--brass-deep);
  font-weight: 500;
}
.btn-brass:hover { background: var(--brass-deep); }

.export-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer; color: var(--ink-3);
  transition: all .15s;
  white-space: nowrap;
}
.export-btn:hover { background: var(--paper-3); color: var(--ink); border-color: var(--rule-2); }
.export-btn .exp-label { display: inline; }
@media(max-width:760px) { .export-btn .exp-label { display: none; } .export-btn { padding: 5px 8px; } }

/* ── LAYOUT ── */
.content-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  min-height: calc(100vh - 65px);
  max-width: 1500px;
  margin: 0 auto;
}
@media(min-width: 1000px) {
  .content-wrap {
    grid-template-columns: minmax(440px, 520px) 1fr;
    align-items: start;
  }
}

.col-left {
  padding: 1.75rem;
  border-right: 1px solid var(--rule);
  position: sticky; top: 65px;
  max-height: calc(100vh - 65px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-2) transparent;
}
.col-left::-webkit-scrollbar { width: 6px; }
.col-left::-webkit-scrollbar-thumb { background: var(--rule-2); border-radius: 3px; }
@media(max-width: 999px) {
  .col-left { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--rule); padding: 1.25rem; }
}
.col-right { padding: 1.75rem; }
@media(max-width: 999px) { .col-right { padding: 1.25rem; } }

/* ── CARDS (parchment plates) ── */
.card {
  background: var(--paper-2);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.25rem;
  position: relative;
  box-shadow: var(--shadow-1);
}
.card-deep {
  background: var(--paper-3);
  border-color: var(--rule-2);
}
.card-tower {
  padding: 1.6rem 1.5rem 1.4rem;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(31,24,18,0.06), transparent 70%),
    var(--paper-2);
}

.sec-label {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.18em;
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.6rem;
}
.sec-label::after {
  content: ""; flex: 1; height: 1px; background: var(--rule);
}
.sec-label .ornament { color: var(--brass); font-size: 11px; }
.view-toggle {
  display: inline-flex; gap: 1px;
  border: 1px solid var(--rule-2); border-radius: 3px; overflow: hidden;
  background: var(--paper);
  margin-left: 0.25rem;
  flex-shrink: 0;
}
.view-toggle button {
  background: transparent; border: 0;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 9px; cursor: pointer; color: var(--ink-3);
  letter-spacing: 0.08em; text-transform: uppercase;
  transition: all .15s;
}
.view-toggle button.active { background: var(--ink); color: var(--paper); }

/* ── HEADER OF DASHBOARD ── */
.dashboard-header {
  margin-bottom: 1.5rem;
  text-align: center;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.dashboard-header::after {
  content: "✦"; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
  background: var(--paper); padding: 0 10px; color: var(--brass); font-size: 12px;
}
.dashboard-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.2em;
  margin-bottom: 0.4rem;
}
.dashboard-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 32px; font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.1;
}

/* ═══════════════════════════════════════════════════════════
   THE BOOK TOWER (V1 — Vertical Stacks)
   ═══════════════════════════════════════════════════════════ */

.race-stage {
  display: flex; align-items: flex-end; justify-content: center;
  gap: 3.5rem; min-height: 280px;
  padding: 2rem 1rem 1.5rem;
  position: relative;
}
@media(max-width: 540px) { .race-stage { gap: 1.25rem; padding: 1.25rem 0.5rem; } }

/* Wood desk surface beneath towers */
.race-stage::after {
  content: "";
  position: absolute;
  left: 8%; right: 8%; bottom: 1.1rem; height: 14px;
  background:
    linear-gradient(180deg,
      #6b4a2b 0%,
      #4a321d 60%,
      #2c1d10 100%);
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(255,210,150,0.18) inset,
    0 -1px 0 rgba(255,210,150,0.10) inset,
    0 6px 20px rgba(31,24,18,0.30);
  z-index: 0;
}
.race-stage::before {
  /* wood grain */
  content: "";
  position: absolute; left: 8%; right: 8%; bottom: 1.1rem; height: 14px;
  background-image:
    repeating-linear-gradient(90deg,
      rgba(255,210,150,0.08) 0px, transparent 1px, transparent 8px,
      rgba(0,0,0,0.10) 9px, transparent 10px, transparent 22px);
  z-index: 1;
  pointer-events: none;
  border-radius: 2px;
}

.racer {
  display: flex; flex-direction: column; align-items: center;
  position: relative;
  z-index: 2;
  flex: 1;
  max-width: 260px;
}

.crown-row { height: 36px; display: flex; align-items: flex-end; justify-content: center; }
.crown {
  font-size: 24px; line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(176,134,66,0.4));
  animation: crownGlow 2.4s ease-in-out infinite alternate;
}
@keyframes crownGlow {
  from { filter: drop-shadow(0 2px 4px rgba(176,134,66,0.3)); transform: translateY(0); }
  to   { filter: drop-shadow(0 4px 8px rgba(176,134,66,0.6)); transform: translateY(-2px); }
}

.racer-name {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px; font-weight: 500;
  margin-bottom: 0.85rem;
  letter-spacing: 0.01em;
}

.tower {
  display: flex; flex-direction: column-reverse;
  align-items: center;
  gap: 1px;
  position: relative;
  margin-bottom: 6px;
}

/* Each spine = book */
.book-item {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
}

.spine {
  position: relative;
  border-radius: 2px;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255,245,220,0.18),
    inset 0 -1px 0 rgba(0,0,0,0.18),
    0 1px 1px rgba(0,0,0,0.20);
  transform-origin: bottom center;
  transition: transform .25s ease;
}
.book-item:hover .spine { transform: translateY(-2px) scale(1.02); }

.spine::before {
  /* leather grain */
  content: "";
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(90deg,
      rgba(255,255,255,0.04) 0px, transparent 0.5px, transparent 4px,
      rgba(0,0,0,0.06) 4.5px, transparent 5px, transparent 12px),
    radial-gradient(ellipse at 30% 50%, rgba(255,245,220,0.12), transparent 60%);
  pointer-events: none;
}
.spine::after {
  /* gilt rule top + bottom */
  content: "";
  position: absolute; inset: 2px 4px;
  border-top: 1px solid rgba(201,168,90,0.5);
  border-bottom: 1px solid rgba(201,168,90,0.5);
  pointer-events: none;
  opacity: 0.7;
}

.spine-cover {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  border-radius: 2px;
  opacity: 0.92;
  mix-blend-mode: multiply;
}
.spine-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  writing-mode: vertical-rl; text-orientation: mixed;
  font-family: var(--font-display);
  font-weight: 600; letter-spacing: 0.05em;
  line-height: 1;
  color: rgba(232, 210, 160, 0.90);
  text-shadow: 0 1px 0 rgba(0,0,0,0.55);
  overflow: hidden; padding: 5px 1px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}
/* Tower books lie flat — spine text runs horizontally along the spine */
.spine-label-flat {
  writing-mode: horizontal-tb;
  padding: 1px 6px;
  letter-spacing: 0.08em;
}
.spine-band {
  position: absolute;
  left: 4px; right: 4px;
  height: 2px;
  background: linear-gradient(to right,
    rgba(201,168,90,0.0), rgba(201,168,90,0.7) 20%, rgba(201,168,90,0.7) 80%, rgba(201,168,90,0.0));
  opacity: 0.6;
}
.spine-band.top { top: 30%; }
.spine-band.bottom { bottom: 30%; }

/* In-progress = ghost spine with bookmark */
.spine-ghost {
  position: relative;
  border-radius: 2px;
  border: 1.5px dashed currentColor;
  background: rgba(255,255,255,0.18);
  overflow: visible;
}
.spine-ghost-fill {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: currentColor;
  opacity: 0.55;
  border-radius: 0 0 1px 1px;
}
.spine-ghost::before {
  content: "";
  position: absolute; inset: 0;
  background: currentColor; opacity: 0.10;
  border-radius: 1px;
  pointer-events: none;
}
.spine-bookmark {
  position: absolute;
  top: -3px; right: 4px;
  width: 4px; height: 14px;
  background: var(--rust);
  box-shadow: 0 1px 1px rgba(0,0,0,0.3);
  z-index: 3;
}
.spine-bookmark::after {
  content: "";
  position: absolute; bottom: -4px; left: 0; right: 0;
  border-top: 4px solid var(--rust);
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
}

.racer-av {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 13px; font-weight: 500;
  margin-top: 14px;
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--rule-2), 0 3px 8px rgba(31,24,18,0.18);
  position: relative;
}
.leader .racer-av {
  box-shadow: 0 0 0 2px var(--brass), 0 0 0 3px var(--paper-2), 0 4px 12px rgba(176,134,66,0.4);
}
.racer-score {
  font-family: var(--font-mono);
  font-size: 10.5px; color: var(--ink-3);
  margin-top: 8px; text-align: center;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.racer-score .num {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 500;
  color: var(--ink); display: block;
  letter-spacing: 0;
  text-transform: none;
}

/* Tower tooltip — rendered via a single body-level element (see JS)
   so it can never be clipped by overflow or hover transforms */
.book-tip {
  display: none;
}
.book-tip.global-tip {
  display: block;
  position: fixed;
  left: 0; top: 0;
  transform: none;
  background: var(--paper);
  border: 1px solid var(--ink-3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  pointer-events: none;
  opacity: 0; transition: opacity .12s;
  z-index: 600;
  min-width: 160px; max-width: 220px;
  white-space: normal;
  box-shadow: var(--shadow-2);
}
.book-tip.global-tip.visible { opacity: 1; }
.book-tip strong {
  display: block;
  font-family: var(--font-display);
  font-size: 14px; font-weight: 500;
  margin-bottom: 2px; line-height: 1.2;
}
.book-tip .tip-author {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink-3); font-size: 12px; margin-bottom: 4px;
}
.book-tip .tip-pages {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}
.book-tip-cover {
  display: block;
  width: 56px; height: 80px;
  object-fit: cover;
  border-radius: 2px;
  margin: 0 auto 6px;
  border: 1px solid var(--rule-2);
  box-shadow: 0 2px 6px rgba(31,24,18,0.2);
}

/* ═══════════════════════════════════════════════════════════
   THE BOOK TOWER (V2 — Horizontal Bookshelf)
   ═══════════════════════════════════════════════════════════ */

.race-stage[data-layout="shelf"] {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 1.5rem 0.5rem 1rem;
  min-height: auto;
}
.race-stage[data-layout="shelf"]::before,
.race-stage[data-layout="shelf"]::after { display: none; }

/* ═══ SHELF CASE — walnut bookshelf variant (from proposal) ═══ */
.shelfcase-wrap {
  width: 100%;
  position: relative;
}
.shelfcase {
  position: relative;
  border-radius: 3px;
  padding: 18px 12px 0;
  background: linear-gradient(180deg, #E8DEC4 0%, #D9CCAB 100%);
  background-image:
    linear-gradient(180deg, rgba(0,0,0,0.05), transparent 30%, transparent 70%, rgba(0,0,0,0.08)),
    repeating-linear-gradient(90deg, rgba(120,90,50,0.04) 0 2px, transparent 2px 14px);
  box-shadow: inset 0 0 60px rgba(60,40,20,0.18);
}
.shelfcase-molding {
  height: 14px;
  background: linear-gradient(180deg, #6B4A2C 0%, #4A311B 50%, #3A2613 100%);
  box-shadow: inset 0 1px 0 rgba(255,200,140,0.18), 0 2px 0 rgba(0,0,0,0.35);
  border-radius: 2px 2px 0 0;
  position: relative;
}
.shelfcase-molding::before {
  content: ""; position: absolute; left: 0; right: 0; top: 5px; height: 1px;
  background: rgba(255,200,140,0.18);
}
.shelfcase-molding::after {
  content: ""; position: absolute; left: 0; right: 0; top: 9px; height: 1px;
  background: rgba(0,0,0,0.32);
}
.shelfcase-interior {
  background:
    linear-gradient(180deg, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.18) 8%, rgba(0,0,0,0) 18%, rgba(0,0,0,0) 82%, rgba(0,0,0,0.18) 92%, rgba(0,0,0,0.42) 100%),
    linear-gradient(90deg, #4A2D17 0%, #5C381E 30%, #5C381E 70%, #4A2D17 100%);
  background-color: #4A2D17;
  padding: 22px 10px 26px;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.45), inset 0 8px 22px rgba(0,0,0,0.55), inset 0 -4px 8px rgba(0,0,0,0.4);
  overflow: hidden;
}
.shelfcase-grain {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0.35; mix-blend-mode: overlay; pointer-events: none;
}
.shelfcase-knot {
  position: absolute; right: 18%; top: 42%; width: 34px; height: 24px;
  background: radial-gradient(ellipse, #2A1808 0%, transparent 70%);
  opacity: 0.55; pointer-events: none;
}
.shelfcase-row {
  display: flex; align-items: flex-end; justify-content: center;
  gap: 6px;
  position: relative; z-index: 2;
}
.shelfcase-books {
  display: flex; align-items: flex-end;
  gap: 0;
  padding: 8px 4px 0;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.shelfcase-books::-webkit-scrollbar { display: none; }
.shelfcase-book {
  position: relative;
  flex-shrink: 0;
  border-radius: 2px 2px 1px 1px;
  margin-inline: 1px;
  overflow: visible;
  transition: transform .2s ease;
}
.shelfcase-book:hover { transform: translateY(-5px); z-index: 6; }
.shelfcase-book.ghost:hover { transform: translateY(-3px); }
.shelfcase-book .spine-label {
  color: rgba(255,243,222,0.92);
  text-shadow: 0 1px 1px rgba(0,0,0,0.45);
  font-weight: 600;
}
.shelfcase-book.ghost .spine-label { text-shadow: none; opacity: 0.9; }
.shelfcase-divider {
  width: 22px; height: 30px;
  flex-shrink: 0;
  margin-inline: 10px; margin-bottom: 4px;
  background: linear-gradient(180deg, #C8A24A 0%, #8B6A1F 60%, #5C4515 100%);
  border: 1px solid rgba(0,0,0,0.45);
  border-radius: 2px;
  box-shadow: inset 0 1px 0 rgba(255,230,170,0.5), 0 2px 4px rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-style: italic; font-size: 10px; font-weight: 700;
  color: #2A1808;
  align-self: flex-end;
}
.shelfcase-plank {
  position: absolute; left: 0; right: 0; bottom: 0; height: 18px;
  background: linear-gradient(180deg, #6B4A2C 0%, #4A311B 40%, #2E1B0E 100%);
  box-shadow: inset 0 1px 0 rgba(255,200,140,0.22), inset 0 -2px 0 rgba(0,0,0,0.55), 0 8px 22px -6px rgba(0,0,0,0.6);
  z-index: 3;
}
.shelfcase-plank::before {
  content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 1px;
  background: rgba(0,0,0,0.4);
}
.shelfcase-plank::after {
  content: ""; position: absolute; left: 0; right: 0; top: 8px; height: 0.5px;
  background: rgba(255,200,140,0.18);
}
.shelfcase-plates {
  display: grid; grid-template-columns: 1fr 1fr;
  margin-top: 14px; padding-inline: 8px;
}
.shelfcase-plate {
  text-align: center;
  border-top: 1px solid var(--rule-2);
  padding: 8px 10px 0;
}
.shelfcase-plate-side {
  font-family: var(--font-mono);
  font-size: 9px; color: var(--ink-3);
  letter-spacing: 0.18em; text-transform: uppercase;
}
.shelfcase-plate-name {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 600; font-style: italic;
  letter-spacing: -0.01em;
  margin-top: 2px; color: var(--ink);
}
.shelfcase-plate-stats {
  font-family: var(--font-mono);
  font-size: 10.5px; color: var(--ink-2);
  margin-top: 2px;
}
.be-img { flex-shrink: 0; filter: drop-shadow(0 10px 16px rgba(0,0,0,0.55)); }

/* ═══ SHELF ROWS (legacy simple variant, kept for reference) ═══ */
.shelf-row {
  display: flex; flex-direction: column;
  align-items: stretch;
  margin-bottom: 1.5rem;
  position: relative;
}
.shelf-row:last-child { margin-bottom: 0.5rem; }

.shelf-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.65rem;
  padding: 0 0.25rem;
}
.shelf-header-left { display: flex; align-items: center; gap: 0.7rem; }
.shelf-header .racer-av {
  width: 30px; height: 30px;
  font-size: 11px;
  margin: 0;
  border-width: 1.5px;
}
.shelf-header .racer-name { margin: 0; font-size: 17px; }
.shelf-header .crown { font-size: 18px; }
.shelf-header-right {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.shelf-header-right .num {
  font-family: var(--font-display);
  font-size: 15px; color: var(--ink);
  margin-right: 0.3em;
}

.shelf-board {
  position: relative;
  background:
    linear-gradient(180deg,
      #6b4a2b 0%,
      #4a321d 70%,
      #2c1d10 100%);
  border-radius: 3px;
  padding: 12px 14px 8px;
  min-height: 90px;
  box-shadow:
    inset 0 1px 0 rgba(255,210,150,0.16),
    inset 0 -1px 0 rgba(0,0,0,0.4),
    0 6px 18px rgba(31,24,18,0.28);
  overflow: hidden;
}
.shelf-board::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(90deg,
      rgba(255,210,150,0.07) 0px, transparent 1px, transparent 14px,
      rgba(0,0,0,0.10) 15px, transparent 16px, transparent 38px);
  pointer-events: none;
}
.shelf-board::after {
  /* shelf front edge highlight */
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.4));
  pointer-events: none;
}

.shelf-books {
  display: flex; align-items: flex-end;
  gap: 1px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.shelf-books::-webkit-scrollbar { height: 4px; }
.shelf-books::-webkit-scrollbar-thumb { background: rgba(255,210,150,0.3); border-radius: 2px; }

.shelf-book {
  position: relative;
  flex-shrink: 0;
  border-radius: 1px 1px 2px 2px;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255,245,220,0.20),
    inset -1px 0 0 rgba(0,0,0,0.20),
    0 2px 4px rgba(0,0,0,0.30);
  transition: transform .2s ease, margin .2s ease;
  cursor: default;
  /* slight tilt by varying transform */
}
.shelf-book:hover { transform: translateY(-6px); margin-right: 2px; z-index: 5; }
.shelf-book::before {
  /* leather/cloth grain */
  content: "";
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(0deg,
      rgba(255,255,255,0.04) 0px, transparent 0.5px, transparent 3px,
      rgba(0,0,0,0.05) 3.5px, transparent 4px, transparent 9px);
  pointer-events: none;
}
.shelf-book::after {
  content: "";
  position: absolute; inset: 3px 2px;
  border-top: 1px solid rgba(201,168,90,0.45);
  border-bottom: 1px solid rgba(201,168,90,0.45);
  pointer-events: none;
}
.shelf-book .spine-cover { opacity: 0.85; }
.shelf-book .spine-label {
  color: rgba(232, 210, 160, 0.92);
}
.shelf-book.ghost .spine-label.ghost-label {
  color: currentColor;
  text-shadow: none;
  opacity: 0.85;
  font-weight: 500;
}
.shelf-book.ghost {
  border: 1.5px dashed currentColor;
  background: rgba(236, 225, 200, 0.25);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}
.shelf-book.ghost::after { display: none; }
.shelf-book.ghost .spine-ghost-fill {
  background: currentColor;
  opacity: 0.5;
}

/* ═══════════════════════════════════════════════════════════
   RIVAL CALLOUT — Now reading + gap
   ═══════════════════════════════════════════════════════════ */

.rival-card {
  background: var(--paper-3);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-top: 1rem;
  position: relative;
  display: grid;
  gap: 0.7rem;
}
.rival-eyebrow {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--ink-3);
  letter-spacing: 0.18em; text-transform: uppercase;
  display: flex; align-items: center; gap: 0.5rem;
}
.rival-eyebrow::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.rival-line {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px; color: var(--ink);
  line-height: 1.3;
}
.rival-line .num {
  font-style: normal;
  font-weight: 600;
  color: var(--brass-deep);
  background: linear-gradient(180deg, transparent 60%, rgba(176,134,66,0.22) 60%);
  padding: 0 0.1em;
}
.rival-now {
  display: flex; gap: 0.75rem; align-items: center;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--rule);
}
.rival-now-cover {
  width: 30px; height: 44px;
  background: var(--paper-deep);
  border-radius: 2px;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--rule-2);
  box-shadow: 0 1px 3px rgba(31,24,18,0.18);
}
.rival-now-text {
  flex: 1; min-width: 0;
}
.rival-now-text .label {
  font-family: var(--font-mono);
  font-size: 9.5px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.14em;
  margin-bottom: 1px;
}
.rival-now-text .title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  line-height: 1.2;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rival-now-text .progress {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--ink-2);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════
   STATS — Ledger style
   ═══════════════════════════════════════════════════════════ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 1px;
  background: var(--rule-2);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.stat-card {
  background: var(--paper-2);
  padding: 0.85rem 1rem;
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 9px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.14em;
  margin-bottom: 5px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 500;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.01em;
}
.stat-sub {
  font-family: var(--font-mono);
  font-size: 9px; color: var(--ink-3);
  margin-top: 4px;
  letter-spacing: 0.06em;
}

/* ═══════════════════════════════════════════════════════════
   READING RHYTHM (replaces the chart)
   ═══════════════════════════════════════════════════════════ */

.rhythm-card { padding: 1.4rem 1.5rem 1.5rem; }
.rhythm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-top: 0.5rem;
}
.rhythm-cell {
  padding: 0.6rem 0.85rem;
  border-right: 1px solid var(--rule);
}
.rhythm-cell:last-child { border-right: none; }
.rhythm-cell .who {
  font-family: var(--font-display);
  font-size: 14px; font-style: italic;
  margin-bottom: 0.4rem;
  display: flex; align-items: center; gap: 0.35rem;
}
.rhythm-cell .who::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}
.rhythm-cell.a .who::before { background: var(--a-spine); }
.rhythm-cell.b .who::before { background: var(--b-spine); }
.rhythm-pace {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 500;
  color: var(--ink);
  line-height: 1.1;
}
.rhythm-pace .unit {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--ink-3);
  margin-left: 4px; letter-spacing: 0.04em;
}
.rhythm-streak {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--ink-3);
  margin-top: 0.25rem;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.rhythm-streak strong {
  color: var(--ink); font-family: var(--font-display); font-size: 13px;
}

/* Reading days dot grid */
.rhythm-dots {
  display: grid;
  grid-template-columns: repeat(auto-fill, 12px);
  gap: 3px;
  margin-top: 0.6rem;
}
.rhythm-dot {
  width: 12px; height: 12px;
  border-radius: 2px;
  background: var(--rule);
  transition: transform .15s;
}
.rhythm-dot.a-1 { background: rgba(42,60,92,0.30); }
.rhythm-dot.a-2 { background: rgba(42,60,92,0.55); }
.rhythm-dot.a-3 { background: rgba(42,60,92,0.80); }
.rhythm-dot.a-4 { background: var(--a-spine); }
.rhythm-dot.b-1 { background: rgba(107,32,24,0.30); }
.rhythm-dot.b-2 { background: rgba(107,32,24,0.55); }
.rhythm-dot.b-3 { background: rgba(107,32,24,0.80); }
.rhythm-dot.b-4 { background: var(--b-spine); }
.rhythm-dot:hover { transform: scale(1.4); z-index: 2; }
.rhythm-dots-row { margin-bottom: 0.8rem; }
.rhythm-dots-label {
  font-family: var(--font-mono);
  font-size: 9.5px; color: var(--ink-3);
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.rhythm-foot {
  display: flex; justify-content: space-between;
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--rule);
  font-family: var(--font-mono);
  font-size: 10px; color: var(--ink-3);
  letter-spacing: 0.04em;
}
.rhythm-toggle {
  display: inline-flex; gap: 1px;
  border: 1px solid var(--rule-2); border-radius: 3px; overflow: hidden;
  background: var(--paper);
}
.rhythm-toggle button {
  background: transparent; border: 0;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 9.5px; cursor: pointer; color: var(--ink-3);
  letter-spacing: 0.08em; text-transform: uppercase;
  transition: all .15s;
}
.rhythm-toggle button.active { background: var(--ink); color: var(--paper); }

/* ═══════════════════════════════════════════════════════════
   TASTE CARD (genre profile)
   ═══════════════════════════════════════════════════════════ */

.taste-card {
  position: relative;
  background:
    linear-gradient(135deg, var(--paper-2), var(--paper-3));
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.2rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.taste-card::before {
  /* gilt corner ornament */
  content: "✦";
  position: absolute; top: 8px; right: 12px;
  color: var(--brass);
  font-size: 14px;
}
.taste-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 0.85rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--rule);
}
.taste-name {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px; line-height: 1;
}
.taste-rank {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--ink-3);
  letter-spacing: 0.14em; text-transform: uppercase;
}
.taste-rank .num {
  font-family: var(--font-display);
  font-size: 18px; color: var(--ink);
}
.taste-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
}
.taste-stat {
  display: flex; justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dotted var(--rule);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
}
.taste-stat .key { color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.1em; }
.taste-stat .val {
  font-family: var(--font-display);
  font-size: 14px; color: var(--ink);
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   CHALLENGE / RECOMMENDATIONS / QUEUED
   ═══════════════════════════════════════════════════════════ */

.challenge-banner {
  background: linear-gradient(135deg, var(--ink), var(--ink-2));
  color: var(--paper);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--ink);
}
.challenge-banner::before {
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.85  0 0 0 0 0.7  0 0 0 0 0.42  0 0 0 0.05 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  pointer-events: none;
}
.challenge-banner > * { position: relative; }
.challenge-eyebrow {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--brass-light);
  letter-spacing: 0.2em; text-transform: uppercase;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 0.5rem;
}
.challenge-eyebrow::after {
  content: ""; flex: 1; height: 1px; background: rgba(176,134,66,0.4);
}
.challenge-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px; font-weight: 500;
  line-height: 1.15;
  margin-bottom: 0.35rem;
}
.challenge-sub {
  font-family: var(--font-display);
  font-size: 13px;
  color: rgba(236, 225, 200, 0.75);
  margin-bottom: 0.85rem;
}
.challenge-progress {
  height: 8px;
  background: rgba(0,0,0,0.4);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(176,134,66,0.3);
}
.challenge-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brass), var(--brass-light));
  border-radius: 4px;
  transition: width .6s ease;
}
.challenge-foot {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(236, 225, 200, 0.65);
  margin-top: 6px;
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════════════════ */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--rule-2);
  margin-bottom: 1.25rem;
  gap: 0;
}
.tab {
  padding: 0.55rem 1.1rem;
  font-family: var(--font-display);
  font-size: 16px; font-style: italic;
  cursor: pointer; color: var(--ink-3);
  border: none; background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: all .15s;
  letter-spacing: 0.01em;
}
.tab:hover { color: var(--ink); }
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--brass);
  font-weight: 500;
}

/* ── FORMS ── */
.form-row { display: flex; gap: 8px; margin-bottom: 0.65rem; }
.form-row input, .form-row textarea, .form-row select {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  background: var(--paper);
  color: var(--ink);
}
.form-row textarea { resize: vertical; min-height: 72px; font-family: var(--font-display); font-style: italic; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
  outline: none; border-color: var(--brass); box-shadow: 0 0 0 2px rgba(176,134,66,0.15);
}

.field-label {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.14em;
  margin: 0.6rem 0 0.4rem;
}

.meta-preview {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 0.65rem; display: none;
  font-family: var(--font-body);
  font-size: 13px;
}
.meta-preview.visible { display: block; }
.meta-row {
  display: flex; justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px dotted var(--rule);
}
.meta-row:last-child { border-bottom: none; }
.meta-key {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.1em;
}
.loading-meta {
  font-family: var(--font-display);
  color: var(--ink-3); font-style: italic; font-size: 13px;
}

.star-row { display: flex; gap: 6px; margin-bottom: 0.65rem; }
.star {
  font-size: 24px; cursor: pointer;
  color: var(--rule-2);
  transition: color .12s, transform .1s;
  font-family: var(--font-display);
  line-height: 1;
}
.star:hover { transform: scale(1.1); }
.star.on { color: var(--brass); }

.pages-inline {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 0.65rem;
  font-family: var(--font-mono);
  font-size: 10px; color: var(--ink-3);
  letter-spacing: 0.1em; text-transform: uppercase;
}
.pages-inline input {
  width: 120px; padding: 9px 12px;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  background: var(--paper);
  color: var(--ink);
  text-transform: none; letter-spacing: 0;
}

.status-toggle {
  display: flex; gap: 0;
  margin-bottom: 1rem;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.status-btn {
  flex: 1; padding: 9px;
  font-family: var(--font-display);
  font-size: 14px; cursor: pointer;
  background: var(--paper);
  border: none; color: var(--ink-3);
  font-style: italic;
  transition: all .15s;
}
.status-btn:not(:last-child) { border-right: 1px solid var(--rule-2); }
.status-btn.active {
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  font-style: normal;
  font-family: var(--font-display);
}

.progress-hint {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: 0.65rem;
  line-height: 1.5;
  padding: 8px 12px 8px 14px;
  background: var(--paper);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--brass);
}

/* ═══════════════════════════════════════════════════════════
   BOOK LIST
   ═══════════════════════════════════════════════════════════ */

.filter-row {
  display: flex; gap: 6px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filter-btn {
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 10px; cursor: pointer;
  color: var(--ink-3);
  letter-spacing: 0.1em; text-transform: uppercase;
  transition: all .15s;
}
.filter-btn:hover { color: var(--ink); border-color: var(--rule-2); }
.filter-btn.active {
  background: var(--ink); color: var(--paper);
  border-color: var(--ink);
}

.book-card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 10px;
  display: flex; gap: 14px;
  position: relative;
  transition: all .15s;
}
.book-card:hover { border-color: var(--rule-2); box-shadow: var(--shadow-1); }
.book-card.in-progress {
  border-style: solid;
  background: var(--paper-2);
  cursor: pointer;
  border-left: 3px solid var(--brass);
}
.book-card.in-progress:hover { background: var(--paper-3); }
.book-card.finished-clickable { cursor: pointer; }
.book-card.finished-clickable:hover { background: var(--paper-3); }

.book-cover, .book-cover-ph {
  width: 48px; height: 70px;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(31,24,18,0.18);
}
.book-cover { object-fit: cover; }
.book-cover-ph {
  background: var(--paper-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  border: 1px solid var(--rule-2);
  color: var(--ink-3);
}

.book-info { flex: 1; min-width: 0; }
.book-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px;
}
.book-title {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.005em;
}
.book-author {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px; color: var(--ink-3);
  margin-top: 1px;
}
.chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.chip {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-3);
  background: var(--paper);
  padding: 2px 8px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.chip-progress {
  background: rgba(74,92,58,0.12);
  color: var(--forest);
  border-color: rgba(74,92,58,0.35);
}
.chip-done {
  background: rgba(176,134,66,0.15);
  color: var(--brass-deep);
  border-color: rgba(176,134,66,0.35);
}
.progress-bar-wrap {
  margin-top: 8px;
  background: var(--paper-deep);
  border-radius: 3px; height: 5px; overflow: hidden;
  border: 1px solid var(--rule);
}
.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .4s;
}
.stars-d { display: flex; gap: 2px; margin-top: 6px; }
.star-d { font-size: 13px; color: var(--brass); line-height: 1; }
.star-d.empty { color: var(--rule); }

.book-comment {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13.5px;
  color: var(--ink-2);
  margin-top: 8px;
  border-left: 2px solid var(--brass);
  padding-left: 10px;
  line-height: 1.4;
}

.owner-badge {
  font-family: var(--font-mono);
  font-size: 8.5px;
  padding: 2px 7px;
  border-radius: 8px;
  white-space: nowrap;
  letter-spacing: 0.1em; text-transform: uppercase;
}
.badge-a { background: rgba(42,60,92,0.12); color: var(--a-spine); border: 1px solid rgba(42,60,92,0.3); }
.badge-b { background: rgba(107,32,24,0.10); color: var(--b-spine); border: 1px solid rgba(107,32,24,0.3); }

.del-btn {
  background: none; border: none; cursor: pointer;
  color: var(--ink-3); font-size: 18px; opacity: 0.5;
  padding: 0 2px; line-height: 1;
  transition: all .15s;
}
.del-btn:hover { opacity: 1; color: #a32d2d; }

.finish-btn {
  background: transparent;
  border: 1px solid var(--forest);
  border-radius: var(--radius-sm);
  padding: 4px 11px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  cursor: pointer;
  color: var(--forest);
  letter-spacing: 0.1em; text-transform: uppercase;
  transition: all .15s;
}
.finish-btn:hover { background: var(--forest); color: var(--paper); }
.finish-btn.reopen { border-color: var(--rule-2); color: var(--ink-3); }
.finish-btn.reopen:hover { background: var(--ink-3); color: var(--paper); border-color: var(--ink-3); }

.tap-hint {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--ink-3);
  margin-top: 6px;
  letter-spacing: 0.04em;
}

/* Reactions */
.reactions {
  display: flex; gap: 4px; flex-wrap: wrap;
  margin-top: 8px;
}
.reaction-pill {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 1px 8px 1px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
  transition: all .15s;
  color: var(--ink-2);
}
.reaction-pill:hover { background: var(--paper-3); border-color: var(--rule-2); }
.reaction-pill.mine { background: rgba(176,134,66,0.15); border-color: rgba(176,134,66,0.4); }
.reaction-pill .emoji { font-size: 12px; }
.reaction-pill .count { font-weight: 500; }

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--ink-3);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
}
.empty-state::before {
  content: "❦";
  display: block;
  font-size: 24px;
  color: var(--brass);
  margin-bottom: 0.5rem;
  font-style: normal;
}

/* ═══════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(31,24,18,0.55);
  align-items: center; justify-content: center;
  z-index: 200; display: none;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--paper);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 340px;
  max-width: calc(100vw - 2rem);
  box-shadow: var(--shadow-2);
  position: relative;
}
.modal-box::before {
  content: ""; position: absolute; inset: 6px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  pointer-events: none;
}
.modal-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px; font-weight: 500;
  margin-bottom: 1rem;
  position: relative;
}
.modal-box input, .modal-box textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  background: var(--paper-2);
  color: var(--ink);
  margin-bottom: 1rem;
  position: relative;
}
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; position: relative; }

/* ═══════════════════════════════════════════════════════════
   TWEAKS PANEL
   ═══════════════════════════════════════════════════════════ */

.tweaks-panel {
  position: fixed;
  bottom: 1.25rem; right: 1.25rem;
  width: 280px;
  background: var(--paper);
  border: 1px solid var(--ink-2);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  z-index: 90;
  display: none;
  box-shadow: var(--shadow-2);
  font-family: var(--font-body);
}
.tweaks-panel.open { display: block; }
.tweaks-panel::before {
  content: ""; position: absolute; inset: 5px;
  border: 1px solid var(--rule);
  border-radius: 2px; pointer-events: none;
}
.tweaks-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.85rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.tweaks-title {
  font-family: var(--font-display);
  font-size: 15px; font-style: italic; font-weight: 500;
}
.tweaks-close {
  background: none; border: none;
  cursor: pointer; color: var(--ink-3);
  font-size: 18px; line-height: 1;
}
.tweaks-section { margin-bottom: 0.85rem; position: relative; }
.tweaks-section:last-child { margin-bottom: 0; }
.tweaks-label {
  font-family: var(--font-mono);
  font-size: 9.5px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.14em;
  margin-bottom: 0.4rem;
}
.tweaks-row { display: flex; gap: 4px; flex-wrap: wrap; }
.tweaks-chip {
  flex: 1;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 5px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
  color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  transition: all .15s;
  white-space: nowrap;
}
.tweaks-chip:hover { color: var(--ink); border-color: var(--rule-2); }
.tweaks-chip.active {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.tweaks-toggle-btn {
  position: fixed;
  bottom: 1.25rem; right: 1.25rem;
  width: 42px; height: 42px;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
  z-index: 89;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-2);
  transition: transform .2s ease;
}
.tweaks-toggle-btn:hover { transform: rotate(90deg) scale(1.05); }

/* ═══════════════════════════════════════════════════════════
   TOAST + DEV PANEL (preserved styling, dark academia tweaks)
   ═══════════════════════════════════════════════════════════ */

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--brass);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  display: none;
  z-index: 999;
  box-shadow: var(--shadow-2);
}
.toast.show {
  display: block;
  animation: fadeIn .25s;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* DEV PANEL */
.dev-btn {
  background: transparent;
  border: 1px solid var(--rule);
  cursor: pointer; color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  transition: all .15s;
  letter-spacing: 0.06em;
}
.dev-btn:hover { background: var(--paper-3); color: var(--ink); border-color: var(--rule-2); }
.dev-screen {
  position: fixed; inset: 0; z-index: 300;
  background: var(--paper);
  display: none; flex-direction: column;
}
.dev-screen.open { display: flex; }
.dev-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1.75rem;
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule-2);
  flex-shrink: 0;
}
.dev-title {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
}
.dev-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  background: rgba(163,45,45,0.1); color: #a32d2d;
  border: 1px solid rgba(163,45,45,0.4);
  border-radius: 3px;
  padding: 2px 7px;
  letter-spacing: 0.1em; text-transform: uppercase;
}
.dev-close {
  background: var(--paper); border: 1px solid var(--rule-2);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-family: var(--font-display); font-size: 14px;
  cursor: pointer; color: var(--ink);
}
.dev-close:hover { background: var(--paper-3); }
.dev-body {
  flex: 1; overflow-y: auto;
  padding: 1.5rem;
  max-width: 960px; width: 100%;
  margin: 0 auto;
}
.dev-section { margin-bottom: 2rem; }
.dev-section-title {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 500; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.14em;
  margin-bottom: 0.85rem;
}
.snapshot-list { display: flex; flex-direction: column; gap: 8px; }
.snapshot-card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
}
.snapshot-info { flex: 1; min-width: 0; }
.snapshot-label {
  font-family: var(--font-display);
  font-size: 15px;
}
.snapshot-meta {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--ink-3);
  margin-top: 2px;
  letter-spacing: 0.04em;
}
.snapshot-actions { display: flex; gap: 6px; flex-shrink: 0; }
.snap-btn {
  background: var(--paper); border: 1px solid var(--rule-2);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
  color: var(--ink-3);
  letter-spacing: 0.06em; text-transform: uppercase;
  transition: all .15s;
}
.snap-btn:hover { background: var(--paper-3); color: var(--ink); border-color: var(--ink-3); }
.snap-btn.danger { border-color: rgba(163,45,45,0.5); color: #a32d2d; }
.snap-btn.danger:hover { background: rgba(163,45,45,0.1); border-color: #a32d2d; }
.snap-btn.primary {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.snap-btn.primary:hover { background: var(--ink-2); }

.log-table { width: 100%; border-collapse: collapse; }
.log-table th {
  text-align: left; padding: 7px 10px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  color: var(--ink-3); font-weight: 500; font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.log-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--rule);
  vertical-align: top;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
}
.log-table tr:last-child td { border-bottom: none; }
.log-type {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 2px;
  letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid var(--rule-2);
}
.log-book-add { background: rgba(42,60,92,0.10); color: var(--a-spine); border-color: rgba(42,60,92,0.3); }
.log-book-del { background: rgba(163,45,45,0.10); color: #a32d2d; border-color: rgba(163,45,45,0.3); }
.log-book-fin { background: rgba(74,92,58,0.10); color: var(--forest); border-color: rgba(74,92,58,0.3); }
.log-session  { background: rgba(176,134,66,0.10); color: var(--brass-deep); border-color: rgba(176,134,66,0.3); }
.log-name     { background: rgba(90,58,76,0.10); color: var(--plum); border-color: rgba(90,58,76,0.3); }
.log-restore  { background: rgba(74,92,58,0.10); color: var(--forest); border-color: rgba(74,92,58,0.3); }

/* PIN modal */
.pin-overlay {
  position: fixed; inset: 0;
  background: rgba(31,24,18,0.6);
  z-index: 400;
  align-items: center; justify-content: center;
  display: none;
  backdrop-filter: blur(3px);
}
.pin-box {
  background: var(--paper);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  padding: 2rem;
  width: 300px;
  text-align: center;
  box-shadow: var(--shadow-2);
}
.pin-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px; margin-bottom: 0.4rem;
}
.pin-sub {
  font-family: var(--font-display);
  font-size: 14px; font-style: italic;
  color: var(--ink-3); margin-bottom: 1.5rem;
}
.pin-dots { display: flex; gap: 14px; justify-content: center; margin-bottom: 1.5rem; }
.pin-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--rule-2);
  transition: background .15s;
}
.pin-dot.filled { background: var(--ink); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pin-key {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font-display);
  font-size: 18px; font-weight: 500;
  cursor: pointer;
  color: var(--ink);
  transition: all .15s;
}
.pin-key:hover { background: var(--paper-3); border-color: var(--rule-2); }
.pin-key:active { transform: scale(0.95); }
.pin-error {
  font-family: var(--font-mono);
  color: #a32d2d; font-size: 11px;
  margin-top: 0.85rem; min-height: 18px;
  letter-spacing: 0.06em;
}
