/* =============================================================
   MathIndex — style.css

   Architecture
   ────────────
   1. Theme tokens   — CSS custom properties for dark/light
   2. Reset          — box-sizing, margin, padding
   3. Layout         — body, shell, header, sidebar, main
   4. Components     — search, home hero, branch cards, formula cards
   5. Animations     — keyframes, entrance effects
   6. Utilities      — scrollbars, responsive, motion

   To add a new theme: duplicate the [data-theme="light"] block,
   give it a new attribute value, and toggle it in app.js.
   ============================================================= */


/* ── 1. Theme tokens ──────────────────────────────────────── */

:root {
  /* Dark theme (default) */
  --bg:          #080808;
  --sidebar:     #0F0F0F;
  --border:      #1E1E1E;
  --text:        #E8E8EA;
  --muted:       #7E7E8A;
  --hover:       #161616;
  --active-bg:   #1C1C1C;
  --active-text: #F4F4F5;
  --paper:       #F9F7F2;
  --paper-line:  #E8E4D9;
  --paper-text:  #111111;
  --paper-muted: #7A7066;
  --badge:       #161616;
  --accent:      #9CA3AF;
  --shadow:      rgba(0,0,0,.70);
  --glow:        rgba(255,255,255,.025);
}

[data-theme="light"] {
  --bg:          #F0F2F7;
  --sidebar:     #FFFFFF;
  --border:      #E1E7EF;
  --text:        #0F172A;
  --muted:       #64748B;
  --hover:       #F7F9FC;
  --active-bg:   #EEF2FF;
  --active-text: #4F46E5;
  --paper:       #FFFFFF;
  --paper-line:  #EDE9E0;
  --paper-text:  #0F0F0F;
  --paper-muted: #7A7066;
  --badge:       #EEF2F7;
  --accent:      #6366F1;
  --shadow:      rgba(0,0,0,.09);
  --glow:        rgba(99,102,241,.08);
}


/* ── 2. Reset ─────────────────────────────────────────────── */

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
}


/* ── 3. Layout ────────────────────────────────────────────── */

/* ── Header ── */
.hdr {
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}

/* Left section (logo + breadcrumb) — flex:1 for centering */
.hdr-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.logo {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -.03em;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  padding: 4px 7px;
  border-radius: 7px;
  transition: background .14s;
}
.logo:hover { background: var(--hover); }

.logo-s {
  font-size: 22px;
  line-height: 1;
  color: var(--accent);
}
.logo-label { font-size: 13px; font-weight: 700; }

.vdiv { width: 1px; height: 18px; background: var(--border); flex-shrink: 0; }

.breadcrumb {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  min-width: 0;
}
.breadcrumb-root { flex-shrink: 0; }
.breadcrumb-sep  { width: 12px; height: 12px; flex-shrink: 0; opacity: .5; }
.breadcrumb b    { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }

/* Right section (badge + theme btn) — flex:1 + flex-end for centering */
.hdr-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
  flex-shrink: 0;
}

.hdr-badge {
  font-size: 10.5px;
  color: var(--muted);
  background: var(--badge);
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
  border: 1px solid var(--border);
}

.icon-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--badge);
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .14s, color .14s, border-color .14s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--text); border-color: var(--accent); }
.icon-btn svg { width: 14px; height: 14px; }

/* ── Shell (sidebar + main) ── */
.shell { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 192px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px 0 16px;
}

.sb-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .10em;
  color: var(--muted);
  padding: 12px 14px 5px;
  opacity: .6;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  /* left 2px margin + 2px transparent border = flush with sidebar border */
  padding: 6px 10px 6px 10px;
  margin: 1px 6px 1px 2px;
  border-radius: 0 6px 6px 0;
  border-left: 2px solid transparent;
  cursor: pointer;
  color: var(--muted);
  transition: background .12s, color .12s, border-color .12s;
  user-select: none;
  outline: none;
}
.sb-item:hover  { background: var(--hover); color: var(--text); }
.sb-item:focus  { background: var(--hover); }
.sb-item.active {
  background: var(--active-bg);
  color: var(--active-text);
  font-weight: 600;
  border-left-color: currentColor;
}

.sb-dot   { width: 6px; height: 6px; border-radius: 2px; flex-shrink: 0; }
.sb-name  { flex: 1; font-size: 12px; }
.sb-count { font-size: 10px; opacity: .4; }

/* ── Main content area ── */
.main { flex: 1; overflow-y: auto; padding: 0 24px 36px; }

/* ── Branch page header ── */
.branch-hdr       { padding: 22px 0 16px; }
.branch-hdr-title { display: flex; align-items: center; gap: 8px; }
.branch-hdr-dot   { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.branch-title     { font-size: 16px; font-weight: 700; letter-spacing: -.025em; }
.branch-desc      { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ── Formula grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 10px;
}

/* Category sub-header */
.cat-hdr {
  grid-column: 1 / -1;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  padding: 16px 0 7px;
  border-bottom: 1px solid var(--border);
}
.cat-hdr:first-child { padding-top: 0; }

/* Branch group divider in "All Formulas" view */
.grp-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-bottom: 6px;
}
.grp-dot  { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.grp-name { font-size: 11px; font-weight: 700; color: var(--text); letter-spacing: .01em; }
.grp-line { flex: 1; height: 1px; background: var(--border); }


/* ── 4. Components ────────────────────────────────────────── */

/* ── Search bar ── */
/* Center the search: fixed width, hdr-left and hdr-right each take flex:1 */
.search-wrap {
  position: relative;
  flex: 0 0 340px;
}

.search-input {
  width: 100%;
  height: 32px;
  background: var(--badge);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  padding: 0 52px 0 32px;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus {
  border-color: var(--accent);
  background: var(--hover);
  box-shadow: 0 0 0 3px var(--glow);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  display: flex;
}
.search-icon svg { width: 13px; height: 13px; }

/* Keyboard shortcut hint — fades out when search is active */
.search-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  pointer-events: none;
  font-family: inherit;
  line-height: 1.6;
  opacity: 1;
  transition: opacity .15s;
  white-space: nowrap;
}
.search-wrap:focus-within .search-kbd { opacity: 0; }

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--sidebar);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 48px var(--shadow);
  z-index: 200;
  overflow: hidden;
  display: none;
  max-height: 320px;
  overflow-y: auto;
}
.search-results.open { display: block; }

.sr-section {
  padding: 8px 12px 3px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
}

.sr-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background .1s;
}
.sr-item:hover,
.sr-item.focused { background: var(--hover); }

.sr-dot   { width: 6px; height: 6px; border-radius: 2px; flex-shrink: 0; }
.sr-label { flex: 1; font-size: 12.5px; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-sub   { font-size: 10.5px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.sr-empty { padding: 16px 12px; font-size: 12px; color: var(--muted); text-align: center; }

/* ── Home hero ── */
.home-hero {
  position: relative;
  text-align: center;
  padding: 52px 24px 40px;
  overflow: hidden;
}

.home-hero-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 320px;
  background: radial-gradient(ellipse at center, var(--glow) 0%, transparent 68%);
  pointer-events: none;
}

.home-eyebrow {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--accent);
  margin-bottom: 14px;
  position: relative;
  animation: fadeUp .4s ease-out both;
}

.home-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -.045em;
  line-height: 1.12;
  color: var(--text);
  margin-bottom: 16px;
  position: relative;
  animation: fadeUp .4s ease-out .06s both;
}

.home-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  position: relative;
  animation: fadeUp .4s ease-out .12s both;
  background: var(--badge);
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: 99px;
}

.home-meta b { color: var(--text); font-weight: 600; }

.home-meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Branch navigation cards (home grid) ── */
.bc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  padding: 0 0 8px;
  animation: fadeIn .3s ease-out .18s both;
}

.bc-card {
  background: var(--sidebar);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  user-select: none;
  outline: none;
  animation: fadeUp .4s ease-out both;
  animation-delay: calc(var(--i, 0) * 45ms + 200ms);
  position: relative;
}
.bc-card:hover,
.bc-card:focus {
  transform: translateY(-3px);
  box-shadow: 0 14px 40px var(--shadow);
  border-color: var(--bc-color, var(--accent));
}

.bc-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  line-height: 1;
  margin-bottom: 13px;
  flex-shrink: 0;
}

.bc-name    { font-size: 13px; font-weight: 700; letter-spacing: -.02em; color: var(--text); margin-bottom: 4px; }
.bc-desc    { font-size: 10.5px; color: var(--muted); line-height: 1.45; margin-bottom: 16px; }
.bc-footer  { display: flex; align-items: center; justify-content: space-between; }
.bc-count   { font-size: 10px; font-weight: 600; color: var(--muted); background: var(--badge); padding: 2px 7px; border-radius: 99px; border: 1px solid var(--border); }

.bc-arrow {
  color: var(--muted);
  display: flex;
  align-items: center;
  transition: color .16s, transform .2s ease;
}
.bc-arrow svg { width: 14px; height: 14px; }
.bc-card:hover .bc-arrow,
.bc-card:focus .bc-arrow { color: var(--bc-color, var(--text)); transform: translateX(4px); }

/* ── Formula card ── */
.card {
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-left: 3px solid var(--branch-color, var(--paper-line));
  border-radius: 8px;
  overflow: hidden;
  transition: transform .16s ease, box-shadow .16s ease;
  box-shadow: 0 1px 4px var(--shadow);
  animation: fadeUp .28s ease-out both;
  animation-delay: calc(var(--ci, 0) * 16ms);
  cursor: pointer;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--shadow);
}

.card-top { padding: 9px 12px 7px; border-bottom: 1px solid var(--paper-line); }
.card-name { font-size: 11.5px; font-weight: 600; color: var(--paper-text); letter-spacing: -.01em; }
.card-tag  { font-size: 9.5px; color: var(--paper-muted); margin-top: 1px; font-style: italic; }

.card-body {
  padding: 16px 14px;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* KaTeX overrides — keep formulas in dark ink on the paper card */
.card-body .katex         { color: var(--paper-text) !important; }
.card-body .katex-display { overflow: hidden !important; margin: 0 !important; }

/* Search highlight — briefly outlines a card after navigating to it */
.card.highlight {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}


/* ── 5. Animations ────────────────────────────────────────── */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}


/* ── Modal popup ──────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .58);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .18s ease-out both;
}
.modal-overlay.closing {
  animation: fadeIn .15s ease-in reverse both;
  pointer-events: none;
}
.modal-overlay.closing .modal {
  animation: fadeUp .15s ease-in reverse both;
}

.modal {
  background: var(--sidebar);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(920px, 100%);
  height: min(600px, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 40px 100px rgba(0,0,0,.65);
  animation: fadeUp .22s ease-out both;
  position: relative;
  outline: none;
}
/* Branch-colored accent strip at top edge */
.modal::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--modal-accent, var(--accent));
  border-radius: 14px 14px 0 0;
  z-index: 1;
  pointer-events: none;
}

/* ── Modal header ── */
.modal-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 14px 0; /* 3px top = account for accent strip */
  height: 51px;        /* 48px + 3px accent */
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  border: none;
  background: none;
  font-family: inherit;
  transition: background .12s, color .12s;
  user-select: none;
  height: 28px;
  flex-shrink: 0;
}
.modal-back:hover { background: var(--hover); color: var(--text); }
.modal-back svg { width: 12px; height: 12px; }

.modal-vdiv { width: 1px; height: 16px; background: var(--border); flex-shrink: 0; }

.modal-branch-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.modal-branch-dot { width: 6px; height: 6px; border-radius: 2px; flex-shrink: 0; }

.modal-hdr-sep {
  width: 12px; height: 12px;
  color: var(--muted);
  opacity: .4;
  flex-shrink: 0;
}

.modal-title {
  flex: 1;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -.025em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-close-x {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--badge);
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.modal-close-x:hover { background: var(--hover); color: var(--text); }
.modal-close-x svg { width: 12px; height: 12px; }

/* ── Modal body (2-column) ── */
.modal-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Left: large formula on paper background */
.modal-formula-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  border-right: 1px solid var(--border);
  padding: 36px 44px;
  overflow: hidden;
  min-width: 0;
}

.modal-formula-render {
  font-size: 1.45rem;
  color: var(--paper-text);
  max-width: 100%;
  overflow: hidden;
}
.modal-formula-render .katex          { color: var(--paper-text) !important; }
.modal-formula-render .katex-display  { margin: 0 !important; overflow: hidden !important; }

.modal-formula-tag {
  margin-top: 18px;
  font-size: 11px;
  color: var(--paper-muted);
  font-style: italic;
}

/* Right: info panel */
.modal-info {
  width: 296px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.modal-section { padding-bottom: 20px; }

.modal-section-title {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .10em;
  color: var(--muted);
  padding-bottom: 9px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-vars-list { display: flex; flex-direction: column; gap: 10px; }

.modal-var-row { display: flex; align-items: baseline; gap: 10px; }

.modal-var-sym {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  min-width: 24px;
  flex-shrink: 0;
  font-family: 'KaTeX_Math', 'Computer Modern', serif;
}

.modal-var-def {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.modal-placeholder {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  opacity: .75;
  line-height: 1.6;
}

.modal-desc-text {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.65;
}

/* Action buttons — placeholder for future features */
.modal-actions {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.modal-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  color: var(--muted);
  background: var(--badge);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: not-allowed;
  opacity: .55;
  white-space: nowrap;
}
.modal-action-btn svg { width: 11px; height: 11px; }


/* ── 6. Utilities ─────────────────────────────────────────── */

/* Thin scrollbars */
::-webkit-scrollbar       { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Responsive — collapse sidebar, drop search width, stack grid */
@media (max-width: 680px) {
  .sidebar           { width: 148px; }
  .sb-name           { font-size: 11px; }
  .main              { padding: 0 14px 28px; }
  .grid              { grid-template-columns: 1fr; }
  .logo-label        { display: none; }
  .search-wrap       { flex: 1; min-width: 0; }
  .breadcrumb        { display: none; }
  .hdr-badge         { display: none; }
  .home-title        { font-size: 22px; }

  /* Modal: sheet from bottom on mobile */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%;
    height: 88vh;
    border-radius: 14px 14px 0 0;
    animation: slideUp .26s ease-out both;
  }
  .modal-overlay.closing .modal { animation: slideUp .18s ease-in reverse both; }
  .modal-body                   { flex-direction: column; }
  .modal-formula-area           { border-right: none; border-bottom: 1px solid var(--border); flex: 0 0 auto; min-height: 180px; padding: 24px; }
  .modal-info                   { width: 100%; }
  .modal-branch-label,
  .modal-hdr-sep                { display: none; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ── Settings panel ──────────────────────────────────────── */

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.52);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .18s ease-out both;
}
.settings-overlay.closing {
  animation: fadeIn .15s ease-in reverse both;
  pointer-events: none;
}
.settings-overlay.closing .settings-panel {
  animation: fadeUp .15s ease-in reverse both;
}

.settings-panel {
  background: var(--sidebar);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(640px, 100%);
  max-height: min(88vh, 700px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 40px 100px rgba(0,0,0,.55);
  animation: fadeUp .22s ease-out both;
}

.settings-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 48px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-title {
  flex: 1;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}

.settings-body {
  overflow-y: auto;
  flex: 1;
  padding: 0;
}

.settings-section {
  padding: 22px 22px 20px;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-child { border-bottom: none; }

.settings-section-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-badge-coming {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: var(--badge);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 99px;
}

.settings-section-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 14px;
}

.settings-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  line-height: 1.55;
  min-height: 80px;
}
.settings-textarea::placeholder { color: var(--muted); }
.settings-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }

.settings-submit-btn {
  margin-top: 10px;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: opacity .14s;
}
.settings-submit-btn:hover { opacity: .85; }
.settings-submit-btn:disabled { opacity: .5; cursor: default; }

.settings-submit-note {
  font-size: 11.5px;
  margin-top: 8px;
  min-height: 18px;
  color: var(--muted);
}
.settings-submit-note.error   { color: #EF4444; }
.settings-submit-note.success { color: #10B981; }

/* Changelog */
.changelog-list { display: flex; flex-direction: column; gap: 0; }

.changelog-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.changelog-item:last-child { border-bottom: none; padding-bottom: 0; }

.changelog-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  margin-top: 4px;
}
.changelog-dot.new { background: var(--accent); }

.changelog-version {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.changelog-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* Units grid */
.units-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.unit-option { display: contents; }
.unit-option input { display: none; }

.unit-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: not-allowed;
  opacity: .45;
  background: var(--bg);
  user-select: none;
}
.unit-name { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.unit-sub  { font-size: 10.5px; color: var(--muted); }

@media (max-width: 680px) {
  .settings-overlay { padding: 0; align-items: flex-end; }
  .settings-panel {
    width: 100%;
    max-height: 88vh;
    border-radius: 14px 14px 0 0;
    animation: slideUp .26s ease-out both;
  }
  .settings-overlay.closing .settings-panel { animation: slideUp .18s ease-in reverse both; }
  .units-grid { grid-template-columns: 1fr; }
}


/* Respect user's reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  .card, .bc-card    { transition: none; animation: none; }
  .bc-arrow          { transition: none; }
  .home-eyebrow,
  .home-title,
  .home-meta,
  .bc-grid           { animation: none; }
  .modal-overlay,
  .modal             { animation: none; }
}
