/* ============================================================
   Lex · Personal Vocabulary PWA
   Palette: oxblood + sand-bone + warm gold + parchment ink
   © אופיר ברנס (Ofir Baranes) 2026
   ============================================================ */

:root {
  /* Base parchment + ink */
  --bg-0: #120808;
  --bg-1: #1a0d10;
  --bg-2: #241317;
  --bg-3: #2e181d;
  --paper: #f2e5cf;
  --paper-soft: #ebd8b9;
  --paper-deep: #d6c39c;

  /* Oxblood family */
  --ox-50: #fbe4e3;
  --ox-100: #d99996;
  --ox-300: #b14148;
  --ox-500: #7a1e2c;
  --ox-600: #5e1622;
  --ox-700: #3e0e16;
  --ox-glow: rgba(177, 65, 72, 0.45);

  /* Gold accents */
  --gold-100: #f3dba6;
  --gold-300: #d8b574;
  --gold-500: #b88a4a;
  --gold-700: #8a6432;

  /* Semantic */
  --good: #a7c08a;
  --good-deep: #5d7a3f;
  --warn: #d8b574;
  --bad: #c75b62;

  --text-1: #f7ecd6;
  --text-2: #d6c8ad;
  --text-3: #9c8c74;
  --text-dim: rgba(247, 236, 214, 0.42);

  --line: rgba(216, 181, 116, 0.18);
  --line-strong: rgba(216, 181, 116, 0.32);
  --glass: rgba(242, 229, 207, 0.06);
  --glass-soft: rgba(242, 229, 207, 0.035);
  --glass-strong: rgba(242, 229, 207, 0.10);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  --easing: cubic-bezier(.34, 1.56, .64, 1);
  --easing-soft: cubic-bezier(.4, 0, .2, 1);

  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 12px 36px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 14px 48px rgba(122, 30, 44, 0.5);

  --font-serif: 'Frank Ruhl Libre', Georgia, serif;
  --font-italic: 'Instrument Serif', Georgia, serif;
  --font-body: 'Heebo', -apple-system, system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;
}

/* ============== RESET ============== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; padding: 0; }
input, textarea, select { font-family: inherit; }
ul { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--ox-500); color: var(--paper); }

body {
  font-family: var(--font-body);
  color: var(--text-1);
  background:
    radial-gradient(ellipse at 80% -10%, rgba(122, 30, 44, 0.35), transparent 55%),
    radial-gradient(ellipse at -10% 110%, rgba(184, 138, 74, 0.18), transparent 60%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 40%, var(--bg-2) 100%);
  min-height: 100vh;
  padding: 0 16px 120px;
  max-width: 920px;
  margin: 0 auto;
  position: relative;
  overflow-x: hidden;
  font-size: 15px;
  line-height: 1.55;
}

/* ============== AMBIENT ============== */
.ambient-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.65;
}
.orb-1 {
  width: 420px; height: 420px;
  top: -120px; right: -120px;
  background: radial-gradient(circle, rgba(122, 30, 44, 0.55), transparent 70%);
  animation: float-a 22s ease-in-out infinite;
}
.orb-2 {
  width: 360px; height: 360px;
  bottom: -100px; left: -100px;
  background: radial-gradient(circle, rgba(184, 138, 74, 0.32), transparent 70%);
  animation: float-b 28s ease-in-out infinite;
}
.orb-3 {
  width: 280px; height: 280px;
  top: 45%; left: 40%;
  background: radial-gradient(circle, rgba(94, 22, 34, 0.35), transparent 70%);
  animation: float-c 30s ease-in-out infinite;
}
@keyframes float-a { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-30px, 40px) scale(1.08); } }
@keyframes float-b { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(40px, -30px) scale(1.06); } }
@keyframes float-c { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(30px, 20px) scale(0.92); } }

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* ============== TOPBAR ============== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 4px;
  margin-top: 4px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--ox-500), var(--ox-700));
  display: grid; place-items: center;
  color: var(--gold-100);
  box-shadow: 0 4px 14px rgba(122,30,44,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.5px;
  color: var(--paper);
}
.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.3px;
  margin-top: 2px;
}
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--text-2);
  transition: all 0.25s var(--easing-soft);
}
.icon-btn:hover { background: var(--glass-strong); color: var(--paper); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0) scale(0.96); }
.icon-btn.small { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.primary {
  background: linear-gradient(140deg, var(--ox-500), var(--ox-700));
  border-color: rgba(255,255,255,0.08);
  color: var(--gold-100);
}

/* ============== HERO ============== */
.hero {
  position: relative;
  z-index: 2;
  margin: 16px 0 28px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  min-height: 320px;
  display: flex;
  align-items: flex-end;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.hero-bg {
  position: absolute; inset: 0;
  background-image: url('hero_bg.png');
  background-size: cover;
  background-position: center;
  transform: scale(1.04);
  filter: saturate(1.05);
}
.hero-overlay {
  position: absolute; inset: 0;
  background:
    linear-gradient(105deg, rgba(18, 8, 8, 0.92) 0%, rgba(26, 13, 16, 0.55) 45%, rgba(26, 13, 16, 0.2) 100%),
    linear-gradient(0deg, rgba(18,8,8,0.75) 0%, transparent 60%);
}
.hero-content {
  position: relative;
  z-index: 1;
  padding: 28px 26px 30px;
  max-width: 580px;
}
.hero-eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: var(--gold-300);
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(184, 138, 74, 0.08);
  margin-bottom: 14px;
}
.hero-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(34px, 6.5vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.6px;
  margin: 0 0 12px;
  color: var(--paper);
  text-shadow: 0 2px 24px rgba(0,0,0,0.45);
}
.serif-italic {
  font-family: var(--font-italic);
  font-style: italic;
  font-weight: 400;
  color: var(--gold-100);
}
.hero-title-accent {
  background: linear-gradient(120deg, var(--gold-100), var(--gold-500));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  color: var(--text-2);
  font-size: 14.5px;
  line-height: 1.65;
  max-width: 460px;
  margin: 0 0 22px;
}
.hero-cta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============== BUTTONS ============== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 14px;
  background: linear-gradient(140deg, var(--ox-300), var(--ox-500) 70%, var(--ox-600));
  color: var(--paper);
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: 0.2px;
  box-shadow: 0 8px 24px rgba(122,30,44,0.45), inset 0 1px 0 rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.06);
  transition: transform 0.25s var(--easing), box-shadow 0.25s var(--easing-soft);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(122,30,44,0.6), inset 0 1px 0 rgba(255,255,255,0.18); }
.btn-primary:active { transform: translateY(0) scale(0.97); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 16px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--line-strong);
  color: var(--paper);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.25s var(--easing-soft);
}
.btn-ghost:hover { background: var(--glass-strong); border-color: var(--gold-500); }
.btn-ghost:active { transform: scale(0.97); }

.btn-mini {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--text-1);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.25s var(--easing-soft);
}
.btn-mini:hover { background: var(--glass-strong); border-color: var(--gold-500); color: var(--paper); }
.btn-mini.danger { color: var(--bad); border-color: rgba(199,91,98,0.3); }
.btn-mini.danger:hover { background: rgba(199,91,98,0.1); border-color: var(--bad); }

/* ============== KPI ============== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 22px;
  position: relative;
  z-index: 2;
}
.kpi-card {
  background: linear-gradient(165deg, var(--glass-strong), var(--glass-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 14px 12px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s var(--easing-soft);
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-500), transparent);
  opacity: 0.4;
}
.kpi-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.kpi-label {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-weight: 500;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 600;
  color: var(--paper);
  margin-top: 6px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-value.highlight { color: var(--gold-100); }
.kpi-note {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}
.kpi-spark {
  height: 22px;
  margin-top: 6px;
  opacity: 0.85;
}
.kpi-spark svg { width: 100%; height: 100%; display: block; }

/* ============== TABS ============== */
.tab-strip {
  display: flex;
  gap: 4px;
  background: var(--glass-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 18px;
  position: relative;
  z-index: 2;
  overflow-x: auto;
}
.tab {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
  transition: all 0.3s var(--easing-soft);
}
.tab:hover { color: var(--paper); }
.tab.is-active {
  background: linear-gradient(140deg, var(--ox-500), var(--ox-700));
  color: var(--paper);
  box-shadow: 0 4px 14px rgba(122,30,44,0.5);
}

.panel {
  position: relative;
  z-index: 2;
  animation: panel-in 0.4s var(--easing-soft) both;
}
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============== REVIEW AREA ============== */
.review-area { min-height: 380px; }

.card-stack {
  position: relative;
  perspective: 1400px;
}
.flashcard {
  background: linear-gradient(165deg, #fbf2dc, #ead8b6);
  color: #2a1814;
  border-radius: 22px;
  padding: 32px 26px;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  border: 1px solid rgba(184,138,74,0.4);
  box-shadow: 0 24px 64px rgba(0,0,0,0.45), 0 4px 0 var(--ox-500) inset;
  transform-style: preserve-3d;
  transition: transform 0.6s var(--easing);
  cursor: pointer;
}
.flashcard.is-flipped { transform: rotateY(180deg); }
.flashcard .face {
  position: absolute;
  inset: 32px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.flashcard .face.back { transform: rotateY(180deg); }
.flashcard .box-badge {
  position: absolute;
  top: 18px;
  inset-inline-start: 22px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.2px;
  color: var(--ox-500);
  background: rgba(122,30,44,0.08);
  border: 1px solid rgba(122,30,44,0.2);
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
}
.flashcard .speak-btn {
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
  width: 38px; height: 38px;
  border-radius: 12px;
  background: rgba(122,30,44,0.08);
  color: var(--ox-500);
  display: grid; place-items: center;
  transition: all 0.2s var(--easing-soft);
}
.flashcard .speak-btn:hover { background: var(--ox-500); color: var(--paper); transform: scale(1.05); }
.flashcard .face-eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: var(--gold-700);
  margin-bottom: 10px;
}
.flashcard .face-word {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(36px, 8vw, 56px);
  line-height: 1.05;
  color: var(--ox-700);
  margin: 0;
  letter-spacing: -0.5px;
}
.flashcard .face-example {
  font-family: var(--font-italic);
  font-style: italic;
  font-size: 16px;
  color: #5b3a30;
  margin-top: 14px;
  max-width: 380px;
}
.flashcard .face-cat {
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold-700);
  background: rgba(184,138,74,0.15);
  border-radius: 999px;
  padding: 4px 10px;
}
.flashcard .face-hint {
  position: absolute;
  bottom: 16px;
  font-size: 11px;
  color: var(--gold-700);
  letter-spacing: 0.5px;
  opacity: 0.75;
}

.review-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 16px;
}
.action-btn {
  padding: 14px 10px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.25s var(--easing-soft);
}
.action-btn small { font-size: 10px; font-weight: 400; color: var(--text-3); font-family: var(--font-mono); letter-spacing: 0.5px; }
.action-btn:hover { transform: translateY(-2px); }
.action-btn.again { border-color: rgba(199,91,98,0.3); }
.action-btn.again:hover { background: rgba(199,91,98,0.15); border-color: var(--bad); }
.action-btn.hard { border-color: rgba(216,181,116,0.3); }
.action-btn.hard:hover { background: rgba(216,181,116,0.15); border-color: var(--warn); }
.action-btn.good { border-color: rgba(167,192,138,0.3); }
.action-btn.good:hover { background: rgba(167,192,138,0.15); border-color: var(--good); }
.action-btn.easy { border-color: rgba(184,138,74,0.4); background: rgba(184,138,74,0.08); }
.action-btn.easy:hover { background: rgba(184,138,74,0.2); border-color: var(--gold-300); }

.review-progress {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-3);
}
.review-progress .bar {
  flex: 1;
  height: 4px;
  margin: 0 12px;
  background: var(--glass);
  border-radius: 2px;
  overflow: hidden;
}
.review-progress .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ox-500), var(--gold-500));
  transition: width 0.4s var(--easing-soft);
}

/* Empty review state */
.review-empty {
  padding: 40px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--glass-soft);
}
.review-empty img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  opacity: 0.85;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.3));
}
.review-empty h2 {
  font-family: var(--font-serif);
  margin: 14px 0 6px;
  font-size: 26px;
  color: var(--paper);
}
.review-empty p { color: var(--text-2); max-width: 420px; margin: 0 auto 18px; }

/* ============== LIBRARY ============== */
.library-controls {
  display: grid;
  grid-template-columns: 1fr 140px 140px;
  gap: 8px;
  margin-bottom: 14px;
}
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap svg {
  position: absolute;
  inset-inline-start: 12px;
  color: var(--text-3);
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  padding: 11px 14px 11px 38px;
  padding-inline-start: 38px;
  padding-inline-end: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--paper);
  font-size: 14px;
  transition: border-color 0.25s var(--easing-soft);
}
.search-wrap input:focus { outline: none; border-color: var(--gold-500); }
.select {
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--paper);
  font-size: 13.5px;
  appearance: none;
  cursor: pointer;
}
.select:focus { outline: none; border-color: var(--gold-500); }

.boxes-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}
.box-pill {
  background: var(--glass-soft);
  border: 1px solid var(--line);
  padding: 10px 8px;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s var(--easing-soft);
}
.box-pill:hover { background: var(--glass-strong); }
.box-pill .num {
  font-family: var(--font-mono);
  font-size: 22px;
  color: var(--paper);
  font-weight: 600;
}
.box-pill .lbl { font-size: 10.5px; color: var(--text-3); margin-top: 2px; letter-spacing: 0.5px; }
.box-pill .lbl strong { color: var(--gold-300); font-weight: 500; }

.library-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lib-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 14px;
  align-items: center;
  background: var(--glass-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  transition: all 0.25s var(--easing-soft);
}
.lib-item:hover { background: var(--glass-strong); border-color: var(--line-strong); }
.lib-item .lib-box {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--ox-500), var(--ox-700));
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--gold-100);
}
.lib-item .lib-word {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 17px;
  color: var(--paper);
}
.lib-item .lib-tr {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
  font-family: var(--font-mono);
  letter-spacing: 0.2px;
}
.lib-item .lib-meta { display: flex; gap: 6px; }
.lib-tag {
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(184,138,74,0.1);
  border: 1px solid rgba(184,138,74,0.25);
  color: var(--gold-300);
  letter-spacing: 0.3px;
}
.lib-actions { display: flex; gap: 4px; }
.lib-actions .icon-btn { width: 32px; height: 32px; border-radius: 9px; }

.lib-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-3);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}
.lib-empty img { width: 140px; opacity: 0.8; margin-bottom: 12px; }

/* ============== STATS ============== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stats-card {
  background: var(--glass-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.stats-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-500), transparent);
  opacity: 0.3;
}
.stats-wide { grid-column: span 2; }
.stats-card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.stats-card-head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--paper);
  font-weight: 500;
}
.stats-hint { font-size: 11px; color: var(--text-3); }

.heatmap-wrap { width: 100%; overflow: hidden; }
#heatmap { width: 100%; height: auto; display: block; }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--text-3);
  margin-top: 8px;
  justify-content: flex-end;
}
.hl-cell {
  width: 12px; height: 12px;
  border-radius: 3px;
  background: var(--glass);
  display: inline-block;
}
.hl-cell.l0 { background: rgba(242,229,207,0.06); }
.hl-cell.l1 { background: rgba(184,138,74,0.25); }
.hl-cell.l2 { background: rgba(184,138,74,0.45); }
.hl-cell.l3 { background: rgba(177,65,72,0.65); }
.hl-cell.l4 { background: var(--ox-300); }

#boxDonut { width: 160px; height: 160px; display: block; margin: 0 auto; }
.donut-legend {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 10px;
  font-size: 12px;
}
.donut-legend .dl-row { display: flex; align-items: center; gap: 8px; }
.donut-legend .dl-swatch { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend .dl-label { color: var(--text-2); flex: 1; }
.donut-legend .dl-val { font-family: var(--font-mono); color: var(--paper); }

#accChart { width: 100%; height: 140px; display: block; }

.insights { display: flex; flex-direction: column; gap: 8px; }
.insights li {
  display: flex;
  gap: 10px;
  font-size: 13px;
  color: var(--text-2);
  padding: 8px 10px;
  background: var(--glass-soft);
  border-radius: 10px;
  border-inline-start: 3px solid var(--gold-500);
}
.insights li strong { color: var(--paper); font-weight: 600; }

/* ============== SETTINGS ============== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.settings-card {
  background: var(--glass-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.settings-card h3 {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--paper);
  font-weight: 500;
}
.settings-desc { color: var(--text-3); font-size: 12.5px; margin: 0 0 14px; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--ox-300); }
.range-val {
  font-family: var(--font-mono);
  font-size: 22px;
  color: var(--gold-100);
  min-width: 40px;
  text-align: center;
  font-weight: 600;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip .x {
  font-size: 14px;
  color: var(--text-3);
  cursor: pointer;
  line-height: 1;
}
.chip .x:hover { color: var(--bad); }
.inline-add { display: flex; gap: 6px; }
.inline-add input {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--paper);
  font-size: 13px;
}
.inline-add input:focus { outline: none; border-color: var(--gold-500); }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; }

.footer-note {
  grid-column: span 2;
  text-align: center;
  color: var(--text-3);
  font-size: 11.5px;
  margin-top: 18px;
  letter-spacing: 0.2px;
}

/* ============== FAB ============== */
.fab {
  position: fixed;
  bottom: 22px;
  inset-inline-end: 22px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--ox-300), var(--ox-500) 70%, var(--ox-700));
  color: var(--paper);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-glow);
  z-index: 40;
  border: 1px solid rgba(255,255,255,0.1);
  transition: all 0.3s var(--easing);
}
.fab::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid var(--gold-500);
  opacity: 0.35;
  animation: fab-pulse 2.5s ease-in-out infinite;
}
@keyframes fab-pulse { 0%, 100% { transform: scale(1); opacity: 0.35; } 50% { transform: scale(1.15); opacity: 0; } }
.fab:hover { transform: scale(1.08) rotate(90deg); }
.fab:active { transform: scale(0.94); }

/* ============== SHEET ============== */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet[hidden] { display: none; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 4, 4, 0.7);
  backdrop-filter: blur(6px);
  animation: fade-in 0.3s var(--easing-soft);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-radius: 24px 24px 0 0;
  border: 1px solid var(--line);
  border-bottom: none;
  padding: 18px 20px 28px;
  overflow-y: auto;
  animation: sheet-up 0.45s var(--easing);
  box-shadow: 0 -10px 60px rgba(0,0,0,0.5);
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
  margin: 0 auto 14px;
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.sheet-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--paper);
  font-weight: 600;
}
.sheet-body { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.3px;
  font-weight: 500;
}
.field > span em { font-style: normal; color: var(--text-dim); font-size: 11px; }
.field input, .field textarea, .field select {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--paper);
  font-size: 14.5px;
  font-family: var(--font-body);
  resize: vertical;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--gold-500); background: rgba(184,138,74,0.05); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.about-body p { color: var(--text-2); margin: 0 0 12px; }
.about-body strong { color: var(--paper); font-weight: 600; }
.feature-list { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.feature-list li {
  padding: 8px 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text-2);
  font-size: 13.5px;
}
.about-foot {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  margin-top: 16px !important;
}

/* ============== TOAST ============== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(140deg, var(--ox-500), var(--ox-700));
  color: var(--paper);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-glow);
  z-index: 200;
  border: 1px solid rgba(255,255,255,0.08);
  animation: toast-in 0.4s var(--easing) both;
}
.toast[hidden] { display: none; }
@keyframes toast-in { from { transform: translate(-50%, 16px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ============== RESPONSIVE ============== */
@media (max-width: 720px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stats-wide { grid-column: auto; }
  .settings-grid { grid-template-columns: 1fr; }
  .footer-note { grid-column: auto; }
}
@media (max-width: 540px) {
  body { padding: 0 12px 100px; font-size: 14.5px; }
  .hero { min-height: 280px; }
  .hero-content { padding: 22px 20px 24px; }
  .library-controls { grid-template-columns: 1fr 1fr; }
  .library-controls .search-wrap { grid-column: span 2; }
  .review-actions { grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 26px; }
}
@media (max-width: 380px) {
  .brand-sub { display: none; }
  .hero-title { font-size: 30px; }
  .fab { width: 54px; height: 54px; bottom: 18px; inset-inline-end: 18px; }
  .lib-item { grid-template-columns: auto 1fr auto; }
  .lib-item .lib-meta { display: none; }
}
