/* Layout: one narrow column like a phone, a bottom tab bar with a big "+" in the middle.
   Look: clean exercise-book paper with a mint tint, ink text, one light-green accent, highlighter yellow only to mark key words. */
:root {
  --paper: #F2F8F0;
  --card: #FFFFFF;
  --ink: #18202E;
  --ink-soft: #5A6475;
  --line: #DCE7D8;
  --accent: #8FD683;
  --accent-ink: #12301A;
  --accent-soft: #E0F3DB;
  --accent-text: #2E7A2A;
  --marker: #FFE27A;
  --marker-ink: #18202E;
  --danger: #C92A2A;
  --danger-soft: #FCEBEB;
  --warn-soft: #FFF4D6;
  --shadow: 0 1px 2px rgba(24, 32, 46, .06), 0 4px 16px rgba(24, 32, 46, .06);
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 14px;
  --tabbar-h: 68px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111813; --card: #1A231C; --ink: #E9EDF3; --ink-soft: #A3ADBD; --line: #2B3A2E;
    --accent: #8FD683; --accent-ink: #12301A; --accent-soft: #1F3A22; --accent-text: #9EE092;
    --marker: #6B5A12; --marker-ink: #FFF6CC; --danger: #FF8787; --danger-soft: #3A1E22; --warn-soft: #3A3218;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111813; --card: #1A231C; --ink: #E9EDF3; --ink-soft: #A3ADBD; --line: #2B3A2E;
  --accent: #8FD683; --accent-ink: #12301A; --accent-soft: #1F3A22; --accent-text: #9EE092;
  --marker: #6B5A12; --marker-ink: #FFF6CC; --danger: #FF8787; --danger-soft: #3A1E22; --warn-soft: #3A3218;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }
.mark { background: linear-gradient(transparent 45%, var(--marker) 45%, var(--marker) 92%, transparent 92%); color: inherit; padding: 0 .1em; }

/* Shell */
.shell {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom, 0px));
}
.screen { display: flex; flex-direction: column; gap: 22px; }
.topbar { display: flex; align-items: center; gap: 12px; }
.topbar h1 { flex: 1; min-width: 0; }
.brand { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; color: var(--accent-text); letter-spacing: .01em; }
.back { border: 0; background: var(--card); box-shadow: var(--shadow); width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.back svg { width: 22px; height: 22px; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.tabbar-inner { max-width: 560px; margin: 0 auto; height: var(--tabbar-h); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.tab { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .8rem; color: var(--ink-soft); padding: 8px; }
.tab svg { width: 26px; height: 26px; }
.tab[aria-current="page"] { color: var(--accent-text); font-weight: 700; }
.tab-add { width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: var(--shadow); transform: translateY(-14px); }
.tab-add svg { width: 30px; height: 30px; }

/* Buttons */
.btn { border: 0; border-radius: 12px; padding: 14px 18px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; flex: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 140px; }

/* Review banner: the main thing to do today */
.review-banner {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  border: 0; border-radius: var(--radius); padding: 18px; background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow);
}
.review-banner .count { font-family: var(--font-display); font-size: 2.2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.review-banner .txt { flex: 1; min-width: 0; }
.review-banner .txt strong { display: block; font-size: 1.05rem; }
.review-banner .txt span { opacity: .85; font-size: .9rem; }
.done-banner { border-radius: var(--radius); padding: 16px 18px; background: var(--accent-soft); color: var(--ink); }

/* Search */
.search { position: relative; }
.search input { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 15px 16px 15px 48px; font-size: 1rem; }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--ink-soft); }

/* Subjects */
.subjects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.subject-btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 14px; text-align: left;
  display: flex; align-items: center; gap: 10px; font-weight: 700; min-height: 54px;
}
.subject-btn[aria-pressed="true"] { border-color: var(--accent-text); background: var(--accent-soft); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }

/* Note list */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.note-item {
  display: flex; gap: 14px; align-items: center; width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 14px;
}
.note-item .thumb { width: 52px; height: 64px; border-radius: 6px; flex: none; background: var(--paper); border: 1px solid var(--line); overflow: hidden; display: grid; place-items: center; }
.note-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.note-item .thumb .lines { width: 70%; display: flex; flex-direction: column; gap: 6px; }
.note-item .thumb .lines i { display: block; height: 3px; border-radius: 2px; background: var(--line); }
.note-item .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.note-item .meta strong { font-size: 1rem; line-height: 1.3; overflow-wrap: anywhere; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; padding: 3px 9px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); color: var(--ink-soft); white-space: nowrap; }
.chip .dot { width: 8px; height: 8px; }
.chip-warn { background: var(--warn-soft); border-color: transparent; color: var(--ink); }
.chip-ok { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.chip-bad { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.empty { text-align: center; padding: 28px 16px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--ink-soft); display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* Note reader */
.note-body { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; line-height: 1.65; overflow-wrap: anywhere;
  background-image: linear-gradient(var(--card) 0 0); }
.note-body h3 { margin: 18px 0 6px; }
.note-body h3:first-child { margin-top: 0; }
.note-body p + p { margin-top: 10px; }
.note-body ul { margin: 8px 0; padding-left: 22px; }
.note-photos { display: flex; flex-direction: column; gap: 12px; }
.note-photos img { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }
.action-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.action-row .btn { width: 100%; }
.linkish { border: 0; background: none; color: var(--ink-soft); text-decoration: underline; padding: 8px 0; font-size: .9rem; align-self: flex-start; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .label { font-weight: 700; font-size: .95rem; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 14px; font-size: 1rem; }
textarea.input { min-height: 120px; resize: vertical; }
.hint { font-size: .85rem; color: var(--ink-soft); }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 10px 14px; display: inline-flex; gap: 8px; align-items: center; min-height: 44px; }
.pick button[aria-pressed="true"] { border-color: var(--accent-text); background: var(--accent-soft); font-weight: 700; }
.photo-drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px 16px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; background: var(--card); cursor: pointer; }
.photo-drop svg { width: 40px; height: 40px; color: var(--accent-text); }
.photo-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.previews { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.previews img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); max-width: 100%; }
.card-pair { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px; }
.card-pair .input { padding: 11px 12px; }
.card-pair-head { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--ink-soft); }
.icon-btn { border: 0; background: none; color: var(--ink-soft); padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }

/* Big choice cards (Add screen) */
.choices { display: flex; flex-direction: column; gap: 12px; }
.choice { display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 20px 18px; box-shadow: var(--shadow); }
.choice .ico { width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.choice .ico svg { width: 28px; height: 28px; }
.choice .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice strong { font-size: 1.08rem; }

/* Study */
.study { display: flex; flex-direction: column; gap: 18px; min-height: calc(100vh - 140px); }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s ease; }
.flash {
  flex: 1; min-height: 300px; border: 1px solid var(--line); background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  padding: 28px 22px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 16px; width: 100%;
}
.flash .side { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); font-weight: 700; }
.flash .q { font-family: var(--font-display); font-size: 1.45rem; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.flash .a { font-size: 1.15rem; line-height: 1.5; overflow-wrap: anywhere; padding-top: 14px; border-top: 1px dashed var(--line); width: 100%; }
.flash .think { color: var(--ink-soft); font-size: .95rem; }
.grade { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grade button { border: 0; border-radius: 14px; padding: 12px 6px; font-weight: 700; min-height: 68px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1.2; }
.grade button span { font-weight: 400; font-size: .78rem; opacity: .85; }
.g-again { background: var(--danger-soft); color: var(--danger); }
.g-almost { background: var(--warn-soft); color: var(--ink); }
.g-knew { background: var(--accent); color: var(--accent-ink); }
.big-ok { text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; padding: 30px 8px; }
.big-ok .num { font-family: var(--font-display); font-size: 3.4rem; font-weight: 800; color: var(--accent-text); line-height: 1; font-variant-numeric: tabular-nums; }
.tip { background: var(--warn-soft); border-radius: var(--radius); padding: 14px 16px; font-size: .95rem; text-align: left; width: 100%; }
.tip strong { display: block; margin-bottom: 2px; }

/* Me */
.profile { display: flex; gap: 14px; align-items: center; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--marker); color: var(--marker-ink); display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; flex: none; }
.menu { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.menu button { border: 0; background: none; text-align: left; display: flex; align-items: center; gap: 12px; padding: 16px; border-top: 1px solid var(--line); min-height: 56px; width: 100%; }
.menu button:first-child { border-top: 0; }
.menu button .grow { flex: 1; min-width: 0; }
.menu button svg { width: 20px; height: 20px; color: var(--ink-soft); flex: none; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: .78rem; font-weight: 700; padding: 2px 9px; font-variant-numeric: tabular-nums; }
.deck-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 14px; }
.deck-item .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

/* Science */
.science { display: flex; flex-direction: column; gap: 12px; }
.sci-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.sci-card .how { font-size: .9rem; color: var(--ink-soft); }
.sources { font-size: .85rem; color: var(--ink-soft); display: flex; flex-direction: column; gap: 6px; }
.sources a { color: var(--accent-text); }

/* Sheet (in-page dialogs) */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--card); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 22px max(16px, env(safe-area-inset-right, 0px)) calc(22px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 14px; max-height: 90vh; overflow-y: auto;
}
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 12px; z-index: 50; font-weight: 700; max-width: calc(100% - 32px); text-align: center; }

/* Free recall */
.recall-grid { display: flex; flex-direction: column; gap: 14px; }

/* Welcome */
.welcome-hero { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.welcome-hero h1 { font-size: 2rem; }

.demo-flag { font-size: .78rem; color: var(--ink-soft); text-align: center; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (min-width: 460px) { .subjects { grid-template-columns: repeat(4, minmax(0, 1fr)); } .subject-btn { flex-direction: column; align-items: flex-start; } }

/* fixes after phone test */
.review-banner > svg { width: 26px; height: 26px; flex: none; }
.deck-item .ico svg { width: 26px; height: 26px; display: block; }
.action-row > .btn:first-child { grid-column: 1 / -1; }
