:root {
  --ink: #101820;
  --ink-soft: #3a4653;
  --paper: #f3f6f9;
  --card: #ffffff;
  --line: #d7dee7;
  --accent: #0f766e;
  --accent-2: #115e59;
  --mark-teach: #f5d76e;
  --mark-reprove: #86efac;
  --mark-correct: #93c5fd;
  --mark-educate: #fdba74;
  --mark-memo: #f9a8d4;
  --danger: #b42318;
  --ok: #067647;
  --shadow: 0 10px 30px rgba(16, 24, 32, 0.08);
  --nav-h: 64px;
  --top-h: 56px;
  --radius: 18px;
  --font: "Outfit", system-ui, sans-serif;
  --serif: "Literata", Georgia, serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, #d9f3ef 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #ffe8b8 0%, transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; }
a { color: var(--accent); }
.app-shell { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + 18px); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  backdrop-filter: blur(14px);
  background: rgba(243, 246, 249, 0.86);
  border-bottom: 1px solid rgba(215, 222, 231, 0.7);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: -0.02em;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 10px;
  background: linear-gradient(145deg, #0f766e, #134e4a);
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.35);
}
.page { padding: 14px 14px 28px; max-width: 720px; margin: 0 auto; }
h1, h2, h3 { letter-spacing: -0.03em; margin: 0 0 10px; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--ink-soft); font-size: 0.92rem; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.grid-books {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (min-width: 520px) {
  .grid-books { grid-template-columns: repeat(4, 1fr); }
}
.book-tile {
  appearance: none; border: 1px solid var(--line); background: var(--card);
  border-radius: 16px; min-height: 92px; padding: 10px;
  text-align: left; box-shadow: var(--shadow); cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: transform .15s ease, border-color .15s ease;
}
.book-tile:active { transform: scale(0.98); }
.book-tile.has { border-color: #99f6e4; background: linear-gradient(180deg, #fff, #f0fdfa); }
.book-tile .name { font-weight: 650; font-size: 0.92rem; line-height: 1.2; }
.book-tile .meta { font-size: 0.75rem; color: var(--ink-soft); }
.section-label {
  margin: 18px 4px 8px; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-soft); font-weight: 700;
}
.tabs-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: var(--nav-h);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs-bottom button {
  border: 0; background: transparent; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 0.68rem; font-weight: 600;
}
.tabs-bottom button.active { color: var(--accent-2); }
.tabs-bottom svg { width: 22px; height: 22px; }
.btn {
  appearance: none; border: 0; border-radius: 14px;
  background: var(--accent); color: #fff; font-weight: 650;
  padding: 12px 16px; cursor: pointer;
}
.btn.secondary { background: #e8eef4; color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; background: #fff; color: var(--ink);
}
.field textarea { min-height: 110px; resize: vertical; font-family: var(--serif); line-height: 1.45; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 6px 10px; font-size: 0.78rem; font-weight: 650;
  background: #ecfeff; color: #115e59; border: 1px solid #99f6e4;
}
.list-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-item .title { font-weight: 650; }
.auth-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 20px;
}
.auth-card { width: min(420px, 100%); }
.auth-card .brand { margin-bottom: 18px; }
.ref-link {
  color: var(--accent-2); font-weight: 650; text-decoration: underline;
  text-decoration-thickness: 2px; text-underline-offset: 2px;
}
.mark-teach { background: linear-gradient(transparent 55%, var(--mark-teach) 55%); }
.mark-reprove { background: linear-gradient(transparent 55%, var(--mark-reprove) 55%); }
.mark-correct { background: linear-gradient(transparent 55%, var(--mark-correct) 55%); }
.mark-educate { background: linear-gradient(transparent 55%, var(--mark-educate) 55%); }
.mark-memo { background: linear-gradient(transparent 55%, var(--mark-memo) 55%); }
.toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px;
}
.toolbar .swatch {
  width: 28px; height: 28px; border-radius: 999px; border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line); cursor: pointer;
}
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px);
  transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 999px;
  font-size: 0.85rem; z-index: 50; opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; }
.empty {
  text-align: center; padding: 28px 12px; color: var(--ink-soft);
}
.legal { font-size: 0.92rem; line-height: 1.55; }
.legal h2 { margin-top: 18px; }
.badge {
  font-size: 0.7rem; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: #eef2f7; color: var(--ink-soft);
}
.hidden { display: none !important; }
.chapter-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px;
}
.chapter-grid button {
  border: 1px solid var(--line); background: #fff; border-radius: 12px;
  padding: 10px 0; font-weight: 650;
}
.chapter-grid button.done { background: #ccfbf1; border-color: #5eead4; }
.q-box { margin-bottom: 10px; }
.q-box label { font-size: 0.82rem; color: var(--ink-soft); }
.note-body {
  font-family: var(--serif); line-height: 1.55; white-space: pre-wrap;
}
.flash-card {
  min-height: 160px; display: grid; place-items: center; text-align: center;
  font-family: var(--serif); font-size: 1.15rem; padding: 18px;
}
.flash-card .reveal { margin-top: 12px; font-family: var(--font); font-size: 0.9rem; color: var(--accent-2); }
