/* ============================================================
   LearNova — stylesheet
   K-12 all-in-one study app. Design tokens & theme palettes
   ported from the sibling Nova Books app for visual consistency.
   ============================================================ */

:root {
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-read: 'Literata', Georgia, serif;
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.06);
  --shadow-2: 0 8px 30px rgba(0,0,0,.18);
  --ease: cubic-bezier(.22,.61,.36,1);
  --speed: .28s;
  --sidebar-w: 246px;
}

/* ---------- Theme palettes (ported from Nova Books) ---------- */
[data-theme="light"] {
  --bg: #f4f4f6;       --surface: #ffffff;   --surface-2: #f7f7f9;
  --ink: #1d1d22;      --ink-soft: #5a5a66;  --line: #e6e6ec;
  --accent: #6c5ce7;   --accent-ink: #ffffff;
  --page: #ffffff;     --page-ink: #20232a;
  --ok: #16a34a;       --warn: #d97706;      --danger: #dc2626;
}
[data-theme="sepia"] {
  --bg: #e7dcc6;       --surface: #f4ecd8;   --surface-2: #efe6cf;
  --ink: #43382a;      --ink-soft: #7a6a52;  --line: #ddd0b4;
  --accent: #b07b3e;   --accent-ink: #fff7e9;
  --page: #f7efdc;     --page-ink: #4a3f30;
  --ok: #5b7c1f;       --warn: #b9770e;      --danger: #b23b2e;
}
[data-theme="dark"] {
  --bg: #1a1b20;       --surface: #24262e;   --surface-2: #2b2e37;
  --ink: #e7e8ee;      --ink-soft: #a0a3b1;  --line: #34363f;
  --accent: #8b7bff;   --accent-ink: #11121a;
  --page: #24262e;     --page-ink: #d8dae3;
  --ok: #4ade80;       --warn: #fbbf24;      --danger: #f87171;
}
[data-theme="night"] {
  --bg: #000000;       --surface: #0c0d10;   --surface-2: #141519;
  --ink: #c7c9d1;      --ink-soft: #767986;  --line: #1d1f25;
  --accent: #5a8dff;   --accent-ink: #02040a;
  --page: #060708;     --page-ink: #a9acb6;
  --ok: #4ade80;       --warn: #fbbf24;      --danger: #f87171;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.hidden { display: none !important; }
.muted { color: var(--ink-soft); font-size: 13px; }
h1,h2,h3,h4 { letter-spacing: -.3px; }
a { color: var(--accent); }

/* ---------- Buttons (ported + extended) ---------- */
.btn {
  font-family: var(--font-ui); font-weight: 500; font-size: 14px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 14px; cursor: pointer; display: inline-flex; align-items: center;
  gap: 7px; color: var(--ink); background: transparent;
  transition: background .18s, transform .12s, border-color .18s, color .18s;
  user-select: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-outline { border-color: var(--line); background: var(--surface); }
.btn-outline:hover { background: var(--surface-2); }
.btn-icon { padding: 9px; border-radius: 50%; color: var(--ink-soft); }
.btn-icon:hover { color: var(--ink); background: var(--surface-2); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); }

/* ---------- Forms ---------- */
input[type="text"], input[type="search"], input[type="password"],
input[type="number"], input[type="date"], input[type="datetime-local"],
input[type="time"], select, textarea {
  font-family: var(--font-ui); font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s; width: 100%;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
label.field { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }

/* ---------- Range inputs (ported) ---------- */
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px;
  background: var(--line); outline: none; cursor: pointer; width: 100%; padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); box-shadow: var(--shadow-1); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border: none; border-radius: 50%; background: var(--accent); cursor: pointer;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px; background: var(--surface);
  border-bottom: 1px solid var(--line); z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px;
  background: linear-gradient(150deg, #0f1830, #1e2a4a);
  border-radius: 11px; overflow: hidden;
}
.brand-mark img { width: 30px; height: 30px; display: block; }
.brand-text { display: flex; flex-direction: column; justify-content: center; line-height: 1.05; }
.brand h1 { font-size: 20px; margin: 0; font-weight: 800; letter-spacing: -.5px; }
.brand h1 span { color: var(--accent); }
.brand-by { font-size: 11px; font-weight: 600; color: var(--ink-soft); letter-spacing: .3px; margin-top: 1px; }

.greeting { font-size: 14px; color: var(--ink-soft); margin-left: 4px; }
.greeting b { color: var(--ink); font-weight: 700; }
.greeting .edit-name { cursor: pointer; border-bottom: 1px dashed transparent; }
.greeting .edit-name:hover { border-bottom-color: var(--ink-soft); }

.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.hamburger { display: none; }

/* ============================================================
   APP BODY: sidebar + main
   ============================================================ */
.app-body { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 0; }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 14px 12px 30px; display: flex; flex-direction: column; gap: 3px;
}
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--ink-soft); font-weight: 700; margin: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--ink-soft);
  font-size: 14px; font-weight: 500; transition: background .15s, color .15s;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item .ico { width: 20px; height: 20px; flex-shrink: 0; display: grid; place-items: center; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 600; }
.nav-item .lock { margin-left: auto; font-size: 11px; opacity: .7; }

.main { overflow-y: auto; padding: 26px 30px 70px; min-height: 0; }
.view { max-width: 1080px; margin: 0 auto; }
.view-head { display: flex; align-items: center; gap: 14px; margin: 2px 0 22px; flex-wrap: wrap; }
.view-head h2 { margin: 0; font-size: 24px; font-weight: 700; }
.view-head .sub { color: var(--ink-soft); font-size: 14px; }
.view-head .grow { flex: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 16px; }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
@media (max-width: 760px){ .grid-2,.grid-3 { grid-template-columns: 1fr; } }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft); }
.pill.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.pill.danger { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.pill.accent { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

.premium-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; color: #6b4e00;
  background: linear-gradient(120deg,#ffe08a,#ffd24d); }

.empty { text-align: center; color: var(--ink-soft); padding: 40px 16px; }
.empty .ico { font-size: 44px; margin-bottom: 8px; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.hero {
  border-radius: var(--radius-lg); padding: 26px 28px; color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #ff8fb0));
  box-shadow: var(--shadow-2); margin-bottom: 18px;
}
.hero h2 { margin: 0 0 6px; font-size: 26px; color: #fff; }
.hero p { margin: 0; opacity: .92; }
.hero .streak { margin-top: 16px; display: inline-flex; gap: 8px; align-items: center;
  background: rgba(255,255,255,.18); padding: 8px 14px; border-radius: 999px; font-weight: 600; }

.tile { cursor: pointer; display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease); }
.tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); }
.tile .ico { font-size: 24px; width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 12px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.tile b { font-size: 15px; }
.tile .desc { font-size: 12.5px; color: var(--ink-soft); }

.mini-cal { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; }
.mini-cal .dow { font-size: 10px; text-align: center; color: var(--ink-soft); font-weight: 700; }
.mini-cal .d { aspect-ratio: 1; display: grid; place-items: center; font-size: 12px;
  border-radius: 8px; color: var(--ink-soft); }
.mini-cal .d.today { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.mini-cal .d.has { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--ink); }

/* ============================================================
   CALENDAR
   ============================================================ */
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--ink-soft); padding: 4px 0; }
.cal-cell { min-height: 92px; border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  cursor: pointer; background: var(--surface); transition: border-color .15s, background .15s; display: flex; flex-direction: column; gap: 4px; }
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.out { opacity: .4; }
.cal-cell.today .cal-num { background: var(--accent); color: var(--accent-ink); }
.cal-num { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; font-size: 12.5px; font-weight: 600; }
.cal-ev { font-size: 11px; padding: 2px 6px; border-radius: 5px; background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   NOTES
   ============================================================ */
.split { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
@media (max-width: 800px){ .split { grid-template-columns: 1fr; } }
.list-pane { display: flex; flex-direction: column; gap: 8px; }
.note-item { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; background: var(--surface); transition: border-color .15s, background .15s; }
.note-item:hover { background: var(--surface-2); }
.note-item.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.note-item .nt { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.note-item .np { font-size: 12px; color: var(--ink-soft); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft); }

/* ============================================================
   REMINDERS / TASKS
   ============================================================ */
.task { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface); }
.task + .task { margin-top: 8px; }
.task.done { opacity: .55; }
.task.done .tk-title { text-decoration: line-through; }
.task .tk-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line);
  cursor: pointer; flex-shrink: 0; display: grid; place-items: center; color: transparent; }
.task.done .tk-check { background: var(--ok); border-color: var(--ok); color: #fff; }
.task .tk-body { flex: 1; min-width: 0; }
.task .tk-title { font-weight: 600; font-size: 14px; }
.task .tk-meta { font-size: 12px; color: var(--ink-soft); }
.task .tk-meta.overdue { color: var(--danger); font-weight: 600; }
.task .tk-meta.soon { color: var(--warn); font-weight: 600; }

/* ============================================================
   CHAT (Tutor)
   ============================================================ */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 380px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px; }
.msg { max-width: 78%; padding: 11px 15px; border-radius: 16px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: var(--surface-2); color: var(--ink); border-bottom-left-radius: 5px; }
.msg.bot.thinking { opacity: .7; font-style: italic; }
.chat-input { display: flex; gap: 8px; margin-top: 12px; }
.chat-input textarea { flex: 1; min-height: 46px; max-height: 140px; }

/* ============================================================
   WORKSHEET / QUIZ
   ============================================================ */
.q-block { padding: 14px 0; border-bottom: 1px solid var(--line); }
.q-block:last-child { border-bottom: none; }
.q-stem { font-weight: 600; margin-bottom: 10px; }
.q-opts { display: flex; flex-direction: column; gap: 8px; }
.q-opt { display: flex; align-items: center; gap: 10px; padding: 10px 13px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer; transition: border-color .15s, background .15s; }
.q-opt:hover { border-color: var(--accent); }
.q-opt.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.q-opt.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.q-opt.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.q-opt .key { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.answer-line { border-bottom: 1.5px solid var(--line); height: 26px; margin: 6px 0; }
.ws-answers { margin-top: 18px; padding-top: 14px; border-top: 2px dashed var(--line); }
.score-big { font-size: 40px; font-weight: 800; color: var(--accent); }

/* ============================================================
   DIGITAL NOTEBOOK
   ============================================================ */
.canvas-pad { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; touch-action: none; display: block; width: 100%; }
.pad-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.swatch-color { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid var(--line); }
.swatch-color.sel { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }

/* ============================================================
   BOOKS / LESSONS + READER (story books, ported)
   ============================================================ */
.subject-card { cursor: pointer; }
.subject-card .ico { font-size: 26px; width: 50px; height: 50px; display: grid; place-items: center; border-radius: 12px; }
.lesson-body { font-family: var(--font-read); line-height: 1.7; font-size: 16px; }
.lesson-body h3 { font-family: var(--font-ui); margin-top: 1.4em; }
.lesson-body ul { padding-left: 1.3em; }
.lesson-body p { margin: .6em 0; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 22px; }
.book-card { cursor: pointer; display: flex; flex-direction: column; gap: 10px; }
.book-cover { position: relative; aspect-ratio: 2/3; border-radius: 8px; box-shadow: var(--shadow-1);
  overflow: hidden; transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease); background: var(--surface); }
.book-card:hover .book-cover { transform: translateY(-6px); box-shadow: var(--shadow-2); }
.book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gen-cover { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: space-between; padding: 16px 14px; color: #fff; }
.gen-cover .gc-title { font-family: 'Fraunces', serif; font-size: 18px; font-weight: 600; line-height: 1.2; }
.gen-cover .gc-author { font-size: 12px; opacity: .82; }
.book-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.18); }
.book-progress > i { display: block; height: 100%; background: var(--accent); }
.book-del { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.55); color: #fff; cursor: pointer; opacity: 0; transition: opacity .18s; display: grid; place-items: center; }
.book-card:hover .book-del { opacity: 1; }
.book-del:hover { background: #c0392b; }
.book-meta .bt { font-size: 14px; font-weight: 600; line-height: 1.25; display: block; }
.book-meta .ba { font-size: 12.5px; color: var(--ink-soft); }
.book-meta .bp { font-size: 11.5px; color: var(--accent); font-weight: 600; }

/* full-screen reader overlay (ported from Nova Books) */
.reader-screen { position: fixed; inset: 0; z-index: 70; background: var(--page); display: flex; flex-direction: column; }
.reader-bar { display: flex; align-items: center; gap: 10px; padding: 12px 18px; flex-shrink: 0; z-index: 5; }
.reader-top { background: var(--page); }
.reader-title { flex: 1; text-align: center; overflow: hidden; }
.reader-title span { display: block; font-size: 14px; font-weight: 600; color: var(--page-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-title small { font-size: 12px; color: var(--ink-soft); }
.reader-top-actions { display: flex; gap: 2px; }
.reader-top-actions .btn-icon { color: color-mix(in srgb, var(--page-ink) 60%, transparent); }
.reader-top-actions .btn-icon:hover { color: var(--page-ink); }
.bookmark-active { color: var(--accent) !important; }
.reader-stage { flex: 1; position: relative; display: flex; align-items: stretch; min-height: 0; }
.viewer { flex: 1; min-height: 0; }
.viewer iframe { border: none !important; }
.page-nav { border: none; background: transparent; cursor: pointer; color: color-mix(in srgb, var(--page-ink) 30%, transparent);
  width: 64px; display: grid; place-items: center; flex-shrink: 0; transition: color .18s, background .18s; }
.page-nav:hover { color: var(--page-ink); background: color-mix(in srgb, var(--page-ink) 5%, transparent); }
.reader-bottom { flex-direction: column; gap: 6px; padding: 8px 28px 16px; background: var(--page); }
.reader-status { display: flex; justify-content: space-between; width: 100%; font-size: 12px; color: var(--ink-soft); }

/* ============================================================
   DRAWERS (ported)
   ============================================================ */
.drawer { position: fixed; top: 0; bottom: 0; width: 340px; max-width: 86vw; background: var(--surface);
  z-index: 80; display: flex; flex-direction: column; box-shadow: var(--shadow-2); transition: transform var(--speed) var(--ease); }
.drawer-left { left: 0; transform: translateX(-102%); }
.drawer-right { right: 0; transform: translateX(102%); }
.drawer:not(.hidden) { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-tabs { display: flex; border-bottom: 1px solid var(--line); }
.drawer-tabs .tab { flex: 1; padding: 12px; border: none; background: transparent; cursor: pointer;
  font-family: var(--font-ui); font-size: 13.5px; font-weight: 500; color: var(--ink-soft); border-bottom: 2px solid transparent; }
.drawer-tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.drawer-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.toc-item { padding: 11px 20px; cursor: pointer; font-size: 13.5px; line-height: 1.4; border-left: 3px solid transparent;
  color: var(--ink-soft); transition: background .15s, color .15s; }
.toc-item:hover { background: var(--surface-2); color: var(--ink); }
.toc-item.current { color: var(--accent); border-left-color: var(--accent); background: var(--surface-2); }
.toc-item.sub { padding-left: 38px; font-size: 12.5px; }
.bm-item { padding: 13px 20px; cursor: pointer; border-bottom: 1px solid var(--line); position: relative; }
.bm-item:hover { background: var(--surface-2); }
.bm-item .bm-ex { font-size: 12.5px; color: var(--ink-soft); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bm-item .bm-date { font-size: 11px; color: var(--ink-soft); margin-top: 5px; }
.bm-item .bm-del { position: absolute; right: 14px; top: 13px; border: none; background: none; cursor: pointer; color: var(--ink-soft); font-size: 13px; opacity: 0; }
.bm-item:hover .bm-del { opacity: 1; }
.bm-del:hover { color: #c0392b; }
.drawer-empty { padding: 30px 20px; text-align: center; color: var(--ink-soft); font-size: 13px; }
.settings-body { padding: 22px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 26px; }
.setting-group label { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.theme-swatches { display: flex; gap: 12px; }
.swatch { width: 46px; height: 46px; border-radius: 11px; cursor: pointer; border: 2px solid var(--line); transition: transform .12s; }
.swatch:hover { transform: scale(1.06); }
.swatch.selected { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.swatch-light { background: #ffffff; } .swatch-sepia { background: #f4ecd8; }
.swatch-dark { background: #24262e; } .swatch-night { background: #060708; }
.seg-control { display: flex; background: var(--surface-2); border-radius: 10px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg { flex: 1; padding: 9px 8px; border: none; background: transparent; cursor: pointer; border-radius: 7px;
  font-family: var(--font-ui); font-size: 12.5px; color: var(--ink-soft); font-weight: 500; white-space: nowrap; }
.seg.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper input[type="range"] { flex: 1; }

/* in-book search panel (ported) */
.search-panel { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); width: 520px; max-width: 92vw;
  background: var(--surface); z-index: 85; border-radius: var(--radius); box-shadow: var(--shadow-2); overflow: hidden;
  display: flex; flex-direction: column; max-height: 70vh; }
.search-input-row { display: flex; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); gap: 8px; }
.search-results { overflow-y: auto; }
.sr-item { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; line-height: 1.5; }
.sr-item:hover { background: var(--surface-2); }
.sr-item mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--ink); border-radius: 3px; padding: 0 2px; }
.sr-empty { padding: 22px; text-align: center; color: var(--ink-soft); font-size: 13px; }

/* ============================================================
   CALCULATOR POPOVER
   ============================================================ */
.calc-popover { position: fixed; top: 64px; right: 22px; width: 280px; z-index: 90;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-2); padding: 14px; }
.calc-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.calc-display { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; text-align: right; margin-bottom: 12px; }
.calc-expr { font-size: 12px; color: var(--ink-soft); min-height: 16px; word-break: break-all; }
.calc-out { font-size: 28px; font-weight: 700; word-break: break-all; }
.calc-keys { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.calc-key { padding: 13px 0; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 600; cursor: pointer; color: var(--ink); transition: background .12s, transform .08s; }
.calc-key:hover { background: var(--surface-2); }
.calc-key:active { transform: scale(.94); }
.calc-key.op { color: var(--accent); }
.calc-key.eq { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.calc-key.fn { color: var(--ink-soft); }

/* ============================================================
   MODAL / SCRIM / TOAST
   ============================================================ */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 75; }
.modal { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 20px; }
.modal-box { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
  width: 100%; max-width: 460px; padding: 26px; max-height: 88vh; overflow-y: auto; }
.modal-box h3 { margin: 0 0 6px; font-size: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 12px 22px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  z-index: 120; box-shadow: var(--shadow-2); opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* pricing */
.price-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 700px){ .price-grid { grid-template-columns: 1fr; } }
.price-card { border: 1.5px solid var(--line); border-radius: var(--radius-lg); padding: 24px; }
.price-card.pro { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); position: relative; }
.price-card .amt { font-size: 34px; font-weight: 800; margin: 8px 0; }
.price-card ul { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 10px; }
.price-card li { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; }
.price-card li::before { content: "✓"; color: var(--ok); font-weight: 800; }
.price-card li.no { color: var(--ink-soft); }
.price-card li.no::before { content: "✕"; color: var(--ink-soft); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--ink) 18%, transparent); border-radius: 10px; border: 2px solid var(--surface); }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 250px; z-index: 82;
    transform: translateX(-104%); transition: transform var(--speed) var(--ease); }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: inline-flex; }
  .greeting { display: none; }
  .calc-label { display: none; }
  .main { padding: 18px 16px 70px; }
}

@media print {
  .topbar, .sidebar, .no-print { display: none !important; }
  body { overflow: visible; display: block; }
  .main { overflow: visible; padding: 0; }
  .card { box-shadow: none; border: none; }
}
