/* AIAPGET 2027 Recall Master — Earthy-Green Light/Dark Mobile-First Theme */
:root {
  color-scheme: light;
  --bg: #F2F6F3;
  --surface: #FFFFFF;
  --ink: #13221B;
  --muted: #58695F;
  --line: #D7E1DB;
  --accent: #1D6A50;
  --accent-ink: #FFFFFF;
  --accent-soft: #DDEEE6;
  --due: #9A4F00;
  --due-soft: #FBE8CC;
  --late: #A7261E;
  --late-soft: #F8DDD9;
  --blue: #1D5B9E;
  --blue-soft: #DCEAFB;
  --purple: #6B3FA0;
  --purple-soft: #EDE3FA;
  --font-display: "Space Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --nav-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1511; --surface: #15201A; --ink: #E5EEE9; --muted: #92A39A; --line: #27352E;
    --accent: #52C29B; --accent-ink: #06130D; --accent-soft: #1B3A2E;
    --due: #EBA655; --due-soft: #3A2A12; --late: #F29389; --late-soft: #3D1D1A;
    --blue: #79B3F5; --blue-soft: #182C42;
    --purple: #B992F5; --purple-soft: #2A1D3D;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0D1511; --surface: #15201A; --ink: #E5EEE9; --muted: #92A39A; --line: #27352E;
  --accent: #52C29B; --accent-ink: #06130D; --accent-soft: #1B3A2E;
  --due: #EBA655; --due-soft: #3A2A12; --late: #F29389; --late-soft: #3D1D1A;
  --blue: #79B3F5; --blue-soft: #182C42;
  --purple: #B992F5; --purple-soft: #2A1D3D;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  padding-top: max(14px, env(safe-area-inset-top, 0px));
  padding-bottom: calc(var(--nav-h) + max(28px, env(safe-area-inset-bottom, 0px)));
  padding-left: max(14px, env(safe-area-inset-left, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
}

[hidden]:not([hidden="until-found" i]) { display: none !important; }

.wrap { max-width: 920px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; }
h1 { font-size: 22px; line-height: 1.15; letter-spacing: -0.01em; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

.eyebrow { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.sub { color: var(--muted); margin: 3px 0 0; font-size: 13px; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.main-stack { display: flex; flex-direction: column; gap: 22px; }
section { display: flex; flex-direction: column; gap: 10px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.list > li:first-child { border-top: 0; }
.list > li.col-item { flex-direction: column; align-items: stretch; gap: 4px; }

.grow { flex: 1 1 180px; min-width: 0; }
.name { font-weight: 600; overflow-wrap: anywhere; }
.meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.field-lbl { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }

.link-title {
  background: none; border: 0; padding: 0; text-align: left;
  font-weight: 600; color: var(--ink); font-size: 15px; overflow-wrap: anywhere;
}
.link-title:hover { color: var(--accent); text-decoration: underline; }

.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; flex: 1 1 90px; min-width: 82px; }
.stat b { display: block; font-family: var(--font-display); font-size: 21px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.hot b { color: var(--due); }
.stat.bad b { color: var(--late); }

.pill {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.pill.today { background: var(--due-soft); color: var(--due); }
.pill.late { background: var(--late-soft); color: var(--late); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.purple { background: var(--purple-soft); color: var(--purple); }
.pill.muted { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none;
}
.btn.small { min-height: 34px; padding: 0 11px; font-size: 13px; }
.btn.tiny { min-height: 28px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn.icon-btn { min-height: 36px; min-width: 36px; padding: 0 8px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; }
.btn.warn { color: var(--late); border-color: var(--late); }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-actions.center { justify-content: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; }
form .full, .grid-2 .full { grid-column: 1 / -1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-1 { display: grid; grid-template-columns: 1fr; gap: 10px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; min-width: 0; }
input[type="text"], input[type="url"], input[type="date"], input[type="number"], input[type="search"], input:not([type]), select, textarea {
  min-height: 40px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); width: 100%; min-width: 0;
}
textarea { min-height: 76px; resize: vertical; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.check-row { display: flex; flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; font-weight: 400; cursor: pointer; }
.check-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; }
.chip {
  min-height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 5px;
}
.chip small { font-weight: 400; color: var(--muted); }
.chip.done { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip.done small { color: var(--accent); }
.chip.today { border-color: var(--due); color: var(--due); background: var(--due-soft); }
.chip.today small { color: var(--due); }
.chip.late { border-color: var(--late); color: var(--late); background: var(--late-soft); }
.chip.late small { color: var(--late); }

.day { padding: 10px 14px; border-top: 1px solid var(--line); }
.day:first-child { border-top: 0; }
.day .when { font-weight: 600; font-size: 13px; }
.day .what { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.empty { padding: 18px 14px; display: flex; flex-direction: column; gap: 12px; }
.empty p { margin: 0; max-width: 60ch; }
.note { font-size: 13px; color: var(--muted); max-width: 68ch; margin: 0; }

.track { isolation: isolate; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; text-align: center; font-size: 12px; color: var(--muted); position: relative; }
.track div { position: relative; padding-top: 22px; }
.track div::before { content: ""; position: absolute; top: 6px; left: 50%; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--accent); }
.track div::after { content: ""; position: absolute; top: 10px; left: 50%; width: 100%; height: 2px; background: var(--line); z-index: -1; }
.track div:last-child::after { display: none; }
.track b { display: block; color: var(--ink); font-family: var(--font-display); font-size: 14px; }

.status-line { font-size: 13px; color: var(--muted); min-height: 18px; }
.status-line.ok { color: var(--accent); }
.status-line.err { color: var(--late); }

.cal-block { padding: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.cal-block:first-child { border-top: 0; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cal-title { font-weight: 600; font-size: 15px; }
details.setup { font-size: 13px; color: var(--muted); }
details.setup summary { cursor: pointer; font-weight: 500; color: var(--ink); }

/* Filter Pills & Segmented Tabs */
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill-btn {
  min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; font-weight: 600; color: var(--muted);
}
.pill-btn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.seg-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 4px; background: var(--bg); border-radius: 10px; border: 1px solid var(--line); }
.seg-btn { min-height: 34px; border: 0; background: transparent; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 6px; }
.seg-btn.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

/* Study Timer */
.timer-card { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.timer-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.timer-clock { font-family: var(--font-display); font-size: 32px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; margin: 2px 0; }

.floating-timer {
  position: fixed;
  right: 14px;
  bottom: calc(var(--nav-h) + max(10px, env(safe-area-inset-bottom, 0px)));
  z-index: 40;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}
.floating-timer.running { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ft-clock { font-family: var(--font-display); font-variant-numeric: tabular-nums; }

/* Google Calendar-Style Month, Week/3-Day, Day & Event Bars */
.cal-panel { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.cal-month-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.gcal-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gcal-weekdays { display: grid; grid-template-columns: repeat(7, minmax(92px, 1fr)); text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; padding-bottom: 4px; }
.gcal-grid { display: grid; grid-template-columns: repeat(7, minmax(92px, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.gcal-cell {
  min-height: 95px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--surface); padding: 4px; display: flex; flex-direction: column; gap: 3px; cursor: pointer;
  min-width: 0;
}
@media (min-width: 640px) { .gcal-cell { min-height: 115px; } }
.gcal-cell.gcal-empty { background: var(--bg); cursor: default; }
.gcal-cell.is-today { background: var(--due-soft); }
.gcal-day-num {
  align-self: flex-start; border: 0; background: transparent; padding: 1px 6px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums;
}
.gcal-cell.is-today .gcal-day-num { background: var(--due); color: #FFFFFF; }
.gcal-events { display: flex; flex-direction: column; gap: 3px; min-width: 0; width: 100%; }
.gcal-ev {
  display: block; width: 100%; text-align: left; border: 0; border-radius: 5px; padding: 3px 6px;
  font-size: 11px; font-weight: 600; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gcal-ev.ev-done { background: var(--accent-soft); color: var(--accent); text-decoration: line-through; opacity: 0.85; }
.gcal-ev.ev-today { background: var(--due-soft); color: var(--due); border-left: 3px solid var(--due); }
.gcal-ev.ev-late { background: var(--late-soft); color: var(--late); border-left: 3px solid var(--late); }
.gcal-ev.ev-soon { background: var(--blue-soft); color: var(--blue); border-left: 3px solid var(--blue); }
.gcal-ev.ev-test { background: var(--purple-soft); color: var(--purple); border-left: 3px solid var(--purple); }
.gcal-more {
  border: 0; background: var(--bg); color: var(--muted); border-radius: 4px; padding: 2px 5px;
  font-size: 11px; font-weight: 600; text-align: left; width: 100%;
}

.gcal-cols-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gcal-cols { display: grid; gap: 8px; }
.gcal-cols.cols-3 { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
.gcal-cols.cols-7 { grid-template-columns: repeat(7, minmax(125px, 1fr)); }
.gcal-col {
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); min-height: 220px;
  display: flex; flex-direction: column; overflow: hidden;
}
.gcal-col.is-today { border-color: var(--due); }
.gcal-col-head {
  border: 0; border-bottom: 1px solid var(--line); background: var(--surface); padding: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%;
}
.gcal-col.is-today .gcal-col-head { background: var(--due-soft); }
.gcal-col-head b { font-family: var(--font-display); font-size: 18px; }
.gcal-col-body { padding: 6px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.gcal-day-full { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--bg); }
.gcal-day-stack { display: flex; flex-direction: column; gap: 6px; }
.gcal-day-stack .gcal-ev { padding: 8px 10px; font-size: 13px; }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--accent); }
.dot.amber { background: var(--due); }
.dot.red { background: var(--late); }
.dot.blue { background: var(--blue); }
.dot.purple { background: var(--purple); }
.cal-legend { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; font-size: 12px; color: var(--muted); padding-top: 4px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.cal-inline-tasks {
  margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
}
.bottom-sheet {
  width: 100%; max-width: 680px; max-height: 82vh; overflow-y: auto;
  background: var(--surface); border-top-left-radius: 18px; border-top-right-radius: 18px;
  padding: 12px 16px max(24px, env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 24px rgba(0,0,0,0.2);
}
.sheet-handle { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 10px; }
.sheet-list { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; }

/* Syllabus Tracker Spreadsheet */
.sub-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.sub-chip {
  flex: none; min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.sub-chip small { color: var(--muted); font-weight: 400; }
.sub-chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.sub-chip.active small { color: var(--accent-ink); opacity: 0.9; }

.filter-bar { padding: 10px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-bar input[type="search"] { flex: 1 1 200px; }
.filter-bar select { flex: 0 1 180px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.syl-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 820px; }
.syl-table th, .syl-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.syl-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--bg); position: sticky; top: 0; }
.td-chapter { min-width: 210px; max-width: 280px; }
.td-formula { white-space: nowrap; }
.td-test { min-width: 140px; }
.cell-select, .cell-date { min-height: 32px !important; padding: 2px 6px !important; font-size: 12px; width: auto; min-width: 112px; }
.mini-chip {
  min-height: 28px; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.mini-chip.done { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.mini-chip.today { background: var(--due-soft); border-color: var(--due); color: var(--due); }
.mini-chip.late { background: var(--late-soft); border-color: var(--late); color: var(--late); }

/* Study Vault Modal & Flashcard / Quiz UI */
.vault-modal {
  position: fixed; inset: 0; z-index: 70; background: var(--bg);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.vault-inner { max-width: 760px; width: 100%; margin: 0 auto; flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 12px 14px; gap: 12px; position: relative; }
.vault-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.vault-title { font-size: 19px; line-height: 1.2; }
.vault-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-bottom: 18px; }
.vault-section { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }

.mastery-wrap { display: flex; flex-direction: column; gap: 6px; }
.mastery-counts { font-size: 13px; font-weight: 600; }
.dot-txt.know { color: var(--accent); }
.dot-txt.unsure { color: var(--due); }
.dot-txt.dont { color: var(--late); }
.mastery-bar { display: flex; height: 9px; border-radius: 999px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.mastery-bar .seg { height: 100%; }
.mastery-bar .seg.know { background: var(--accent); }
.mastery-bar .seg.unsure { background: var(--due); }
.mastery-bar .seg.dont { background: var(--late); }
.mastery-bar .seg.unseen { background: var(--line); }

.fc-stage { display: flex; flex-direction: column; gap: 12px; }
.fc-card {
  min-height: 210px; background: var(--surface); border: 2px solid var(--line); border-radius: 14px;
  padding: 20px; display: flex; flex-direction: column; justify-content: center; cursor: pointer;
  transition: border-color 0.15s ease;
}
.fc-card:hover { border-color: var(--accent); }
.fc-card .fc-back { display: none; }
.fc-card.flipped { border-color: var(--accent); background: var(--accent-soft); }
.fc-card.flipped .fc-front { display: none; }
.fc-card.flipped .fc-back { display: block; }
.fc-text { font-size: 17px; font-weight: 500; margin-top: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }

.rate-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rate-row .btn { flex-direction: column; gap: 2px; min-height: 52px; }
.rate-row small { font-size: 11px; font-weight: 400; opacity: 0.85; }
.rate-dont { background: var(--late-soft); border-color: var(--late); color: var(--late); }
.rate-unsure { background: var(--due-soft); border-color: var(--due); color: var(--due); }
.rate-know { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.qz-question { font-size: 16px; font-weight: 600; white-space: pre-wrap; }
.qz-options { display: flex; flex-direction: column; gap: 8px; }
.qz-opt {
  text-align: left; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); font-size: 14px; min-height: 44px;
}
.qz-opt.correct { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.qz-opt.wrong { background: var(--late-soft); border-color: var(--late); color: var(--late); }
.qz-exp { padding: 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 14px; }

.import-overlay {
  position: absolute; inset: 0; z-index: 10; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; padding: 12px;
}
.import-card {
  width: 100%; max-width: 560px; background: var(--surface); border-radius: 14px; border: 1px solid var(--line);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: 90%; overflow-y: auto;
}
.prompt-pre {
  margin: 6px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line);
  font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all;
}

/* Gemini AI Study Generator, Markdown, Mind Map, Slides & Doubt Solver */
.seg-tabs-5 { grid-template-columns: repeat(5, 1fr); }
.ai-card { border-color: var(--accent); }
.ai-source-box { padding: 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.ai-btn-grid { display: flex; gap: 6px; flex-wrap: wrap; }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.ai-loading { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--accent); font-weight: 600; }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.md-body { font-size: 14px; line-height: 1.55; display: flex; flex-direction: column; gap: 8px; }
.md-h { margin: 4px 0 0; font-family: var(--font-display); color: var(--accent); }
.md-p { margin: 0; }
.md-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.md-quote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 6px; font-size: 13px; }
.md-table-wrap { overflow-x: auto; }
.md-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.md-table th { background: var(--bg); font-weight: 600; }

.doubt-chat {
  max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
  padding: 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line);
}
.chat-msg { padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.chat-msg.user { background: var(--accent-soft); align-self: flex-end; max-width: 92%; }
.chat-msg.assistant { background: var(--surface); border: 1px solid var(--line); }

.mermaid-scroll {
  overflow: auto; max-height: 420px; padding: 10px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line); touch-action: pan-x pan-y pinch-zoom;
}
.mermaid-box svg { max-width: none; height: auto; transition: transform 0.15s ease; }

.slide-stage { display: flex; flex-direction: column; gap: 10px; }
.slide-card {
  padding: 16px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.slide-script { font-size: 13px; color: var(--muted); padding-top: 8px; border-top: 1px dashed var(--line); }

/* Bottom Navigation Bar (Android One-Handed Ergonomics) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}
.nav-btn {
  border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 600; padding: 4px 2px;
}
.nav-btn .nav-ico { font-size: 18px; line-height: 1; }
.nav-btn.active { color: var(--accent); }

@media (max-width: 520px) {
  form, .grid-2 { grid-template-columns: 1fr; }
  .seg-tabs { grid-template-columns: repeat(2, 1fr); }
  .seg-tabs-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
