/* Recall on the web: black and white, like the app. */
:root {
  --bg: #ffffff;
  --bg-2: #f5f5f7;
  --bg-3: #ececf0;
  --fg: #0a0a0a;
  --fg-2: #5c5c63;
  --fg-3: #8e8e95;
  --line: #e3e3e8;
  --accent: #0a0a0a;
  --on-accent: #ffffff;
  --good: #1f7a3a;
  --bad: #b3261e;
  --highlight: rgba(255, 214, 10, 0.32);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-2: #141416;
    --bg-3: #1f1f22;
    --fg: #f5f5f7;
    --fg-2: #a1a1a8;
    --fg-3: #6e6e75;
    --line: #2a2a2e;
    --accent: #f5f5f7;
    --on-accent: #000000;
    --good: #4cc26e;
    --bad: #ff6b60;
    --highlight: rgba(255, 214, 10, 0.28);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 6px; }
.noscript { padding: 24px; text-align: center; }

.boot { height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--fg);
  animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); font-weight: 500;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--bg-2); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover { opacity: 0.88; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-2); }
.btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 999px; border: 0; background: transparent;
  display: inline-grid; place-items: center; color: var(--fg-2);
}
.icon-btn:hover { background: var(--bg-2); color: var(--fg); }
.icon { width: 18px; height: 18px; flex: none; }

/* Sign in */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 32px 16px;
}
.login-card {
  width: min(880px, 100%); display: grid; grid-template-columns: 1fr auto; gap: 56px; align-items: center;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.login h1 { font-size: 40px; line-height: 1.1; letter-spacing: -0.02em; margin: 28px 0 12px; }
.login .lead { color: var(--fg-2); font-size: 17px; margin: 0 0 32px; max-width: 420px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.steps li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; }
.steps .num {
  width: 28px; height: 28px; border-radius: 999px; background: var(--bg-2);
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.steps b { font-weight: 600; }
.login .foot { margin-top: 32px; color: var(--fg-3); font-size: 13px; }
.login .foot a { color: var(--fg-2); }
.qr-wrap { display: grid; justify-items: center; gap: 14px; }
.qr {
  width: 280px; height: 280px; border-radius: 22px; background: #fff; padding: 14px;
  box-shadow: var(--shadow); border: 1px solid var(--line); position: relative; display: grid; place-items: center;
}
.qr svg { width: 100%; height: 100%; display: block; }
.qr .veil {
  position: absolute; inset: 0; border-radius: 22px; background: rgba(255, 255, 255, 0.92);
  display: grid; place-items: center; text-align: center; color: #0a0a0a; padding: 24px; gap: 12px; align-content: center;
}
.qr .veil .btn { background: #0a0a0a; color: #fff; border-color: #0a0a0a; }
.qr .check { width: 56px; height: 56px; }
.qr-status { color: var(--fg-2); font-size: 14px; display: flex; align-items: center; gap: 8px; min-height: 22px; }
.qr-status .spinner { width: 14px; height: 14px; }

/* Shell */
.shell { display: grid; grid-template-columns: 272px 1fr; height: 100vh; }
.scrim { display: none; }
.sidebar {
  border-right: 1px solid var(--line); background: var(--bg-2); overflow-y: auto;
  display: flex; flex-direction: column; min-width: 0;
}
.sidebar-head { padding: 16px 16px 8px; display: flex; align-items: center; justify-content: space-between; }
.search { margin: 4px 12px 12px; position: relative; }
.search input {
  width: 100%; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  padding: 0 12px 0 34px; outline: none;
}
.search input:focus { border-color: var(--fg-3); }
.search .icon { position: absolute; left: 10px; top: 9px; color: var(--fg-3); }
.tree { padding: 0 8px 16px; flex: 1; }
.tree-label { font-size: 12px; font-weight: 600; color: var(--fg-3); padding: 12px 10px 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.tree-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; text-decoration: none;
  color: var(--fg); min-width: 0; font-size: 14px;
}
.tree-row:hover { background: var(--bg-3); }
.tree-row.active { background: var(--accent); color: var(--on-accent); }
.tree-row.active .count, .tree-row.active .chev { color: var(--on-accent); opacity: 0.7; }
.tree-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tree-row .count { color: var(--fg-3); font-size: 12px; }
.chev {
  width: 18px; height: 18px; border: 0; background: none; padding: 0; color: var(--fg-3);
  display: grid; place-items: center; flex: none; border-radius: 4px;
}
.chev svg { width: 12px; height: 12px; transition: transform 0.15s; }
.chev.open svg { transform: rotate(90deg); }
.chev.none { visibility: hidden; }
.tree-children { margin-left: 14px; }
.user {
  border-top: 1px solid var(--line); padding: 12px 16px; display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.user .who { flex: 1; min-width: 0; }
.user .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user .who .sub { color: var(--fg-3); }
.avatar {
  width: 32px; height: 32px; border-radius: 999px; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-weight: 600; flex: none;
}

.main { overflow-y: auto; min-width: 0; }
.topbar { display: none; }
.page { max-width: 920px; margin: 0 auto; padding: 32px 40px 80px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--fg-3); font-size: 13px; margin-bottom: 8px; }
.crumbs a { color: var(--fg-2); text-decoration: none; }
.crumbs a:hover { color: var(--fg); text-decoration: underline; }
.page h1 { font-size: 32px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 6px; }
.meta { color: var(--fg-2); font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.04em; margin: 32px 0 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: var(--radius);
  background: var(--bg-2); text-decoration: none; min-height: 96px; border: 1px solid transparent;
}
.tile:hover { border-color: var(--line); background: var(--bg-3); }
.tile .t { font-weight: 600; }
.tile .s { color: var(--fg-2); font-size: 13px; }
.tile .icon { color: var(--fg-2); margin-bottom: 6px; }
.list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center;
  padding: 12px 16px; text-decoration: none; border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row:hover { background: var(--bg-2); }
.row .thumb {
  width: 56px; height: 72px; border-radius: 8px; background: var(--bg-3); object-fit: cover; border: 1px solid var(--line);
}
.row .t { font-weight: 600; }
.row .s { color: var(--fg-2); font-size: 13px; }
.row .right { color: var(--fg-3); font-size: 13px; text-align: right; }
.mastery { display: inline-flex; align-items: center; gap: 8px; }
.bar { width: 64px; height: 4px; border-radius: 99px; background: var(--bg-3); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--fg); }

.empty { text-align: center; color: var(--fg-2); padding: 64px 16px; }
.empty .icon { width: 40px; height: 40px; color: var(--fg-3); margin-bottom: 8px; }
.empty h2 { color: var(--fg); font-size: 20px; margin: 0 0 6px; }

/* Tabs */
.tabs {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--bg-2);
  margin: 24px 0 8px; flex-wrap: wrap;
}
.tabs a {
  padding: 6px 16px; border-radius: 999px; text-decoration: none; font-weight: 500; font-size: 14px; color: var(--fg-2);
}
.tabs a:hover { color: var(--fg); }
.tabs a.active { background: var(--bg); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* Summary */
.prose { font-family: var(--serif); font-size: 18px; line-height: 1.65; white-space: pre-line; }
.callout {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-top: 20px; background: var(--bg-2);
}
.callout h3 { margin: 0 0 8px; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.callout ul { margin: 0; padding-left: 20px; }
.callout li + li { margin-top: 8px; }
.callout .was { color: var(--fg-2); text-decoration: line-through; text-decoration-color: var(--fg-3); }
.sec { padding: 22px 0; border-top: 1px solid var(--line); }
.sec:first-of-type { border-top: 0; }
.sec h2 { font-size: 20px; margin: 0 0 8px; letter-spacing: -0.01em; }
.sec .src { font-size: 13px; color: var(--fg-3); margin-top: 8px; }
.linkish { background: none; border: 0; padding: 0; color: var(--fg-2); text-decoration: underline; text-underline-offset: 2px; font-size: 13px; }
.linkish:hover { color: var(--fg); }

/* Revise */
.points { list-style: none; margin: 0; padding: 0; }
.points li { border-top: 1px solid var(--line); }
.points li:first-child { border-top: 0; }
.point {
  width: 100%; text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start;
  padding: 12px 4px; background: none; border: 0; font-family: var(--serif); font-size: 17px; line-height: 1.5;
}
.point:hover { background: var(--bg-2); }
.point .pg { font-family: var(--sans); font-size: 12px; color: var(--fg-3); padding-top: 4px; white-space: nowrap; }

/* Flashcards */
.study { display: grid; justify-items: center; gap: 18px; margin-top: 16px; }
.study-top { width: min(640px, 100%); display: flex; align-items: center; justify-content: space-between; color: var(--fg-2); font-size: 14px; }
.progress { width: min(640px, 100%); height: 4px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--fg); transition: width 0.2s; }
.flash { width: min(640px, 100%); aspect-ratio: 3 / 2; perspective: 1400px; cursor: pointer; border: 0; padding: 0; background: none; }
.flash-inner { position: relative; width: 100%; height: 100%; transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1); transform-style: preserve-3d; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: 22px; background: var(--bg-2);
  border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; place-items: center; padding: 32px 40px;
  font-family: var(--serif); font-size: 24px; line-height: 1.4; text-align: center; overflow: auto;
}
.face.back { transform: rotateY(180deg); font-size: 21px; }
.face .hint { position: absolute; bottom: 14px; left: 0; right: 0; font: 12px var(--sans); color: var(--fg-3); }
.study-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.kbd { font-size: 12px; color: var(--fg-3); }
.kbd kbd { font: 11px var(--sans); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; }

/* Quiz */
.question { width: min(640px, 100%); }
.question .q { font-family: var(--serif); font-size: 23px; line-height: 1.4; margin: 0 0 18px; }
.options { display: grid; gap: 10px; }
.option {
  text-align: left; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; font-size: 16px;
}
.option:hover:not(:disabled) { background: var(--bg-2); }
.option .letter {
  width: 26px; height: 26px; border-radius: 999px; border: 1px solid var(--line); display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: var(--fg-2);
}
.option.right { border-color: var(--good); }
.option.right .letter { background: var(--good); border-color: var(--good); color: #fff; }
.option.wrong { border-color: var(--bad); }
.option.wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.option:disabled { cursor: default; }
.explain { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: var(--bg-2); font-size: 15px; }
.explain b { display: block; margin-bottom: 4px; }
.result { text-align: center; padding: 40px 0; }
.result .big { font-size: 56px; font-weight: 700; letter-spacing: -0.03em; }
.note-muted { color: var(--fg-3); font-size: 13px; text-align: center; }

/* Pages */
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.page-thumb {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg-2); padding: 0; position: relative;
  aspect-ratio: 3 / 4;
}
.page-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.page-thumb .n {
  position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, 0.66); color: #fff; font-size: 12px;
  padding: 2px 8px; border-radius: 99px;
}

/* Page viewer */
.viewer {
  position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.86); display: grid; grid-template-rows: auto 1fr;
  color: #fff;
}
.viewer-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; gap: 10px; }
.viewer-bar .icon-btn { color: #fff; }
.viewer-bar .icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.viewer-body { overflow: auto; display: grid; place-items: start center; padding: 0 16px 32px; }
.sheet { position: relative; width: min(900px, 100%); }
.sheet img { width: 100%; display: block; border-radius: 6px; background: #fff; }
.mark {
  position: absolute; border-radius: 6px; background: var(--highlight); box-shadow: 0 0 0 2px rgba(255, 196, 0, 0.9);
  pointer-events: none;
}
.pin {
  position: absolute; width: 26px; height: 26px; margin: -26px 0 0 -13px; border: 0; padding: 0; background: none;
}
.pin svg { width: 26px; height: 26px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }
.pin-note {
  position: absolute; z-index: 2; transform: translate(-50%, 8px); width: max-content; max-width: 260px;
  background: #fff; color: #0a0a0a; padding: 10px 12px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  white-space: pre-line;
}
.quote { max-width: 900px; margin: 0 auto 12px; color: rgba(255, 255, 255, 0.8); font-family: var(--serif); font-size: 16px; text-align: center; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--accent); color: var(--on-accent);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 40; box-shadow: var(--shadow);
}

.scan-help { max-width: 460px; margin: 0 auto; padding: 80px 16px; text-align: center; }
.scan-help h1 { font-size: 28px; margin: 24px 0 8px; }
.scan-help p { color: var(--fg-2); }

@media (max-width: 860px) {
  .login-card { grid-template-columns: 1fr; gap: 32px; justify-items: center; text-align: center; }
  .login h1 { font-size: 32px; }
  .login .lead { margin-left: auto; margin-right: auto; }
  .steps { text-align: left; max-width: 400px; }
  .brand { justify-content: center; }
  .qr-wrap { order: -1; }
  .qr { width: 240px; height: 240px; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 30; transform: translateX(-100%); transition: transform 0.2s; }
  .shell.menu .sidebar { transform: none; box-shadow: var(--shadow); }
  .shell.menu .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.3); z-index: 25; }
  .topbar {
    display: flex; align-items: center; gap: 8px; padding: 8px 8px; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; background: var(--bg); z-index: 10;
  }
  .page { padding: 20px 16px 64px; }
  .page h1 { font-size: 26px; }
  .row { grid-template-columns: 44px 1fr; }
  .row .thumb { width: 44px; height: 58px; }
  .row .right { display: none; }
  .face { font-size: 20px; padding: 24px; }
  .face.back { font-size: 18px; }
  .flash { aspect-ratio: 1 / 1; }
  .tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: fit-content; max-width: 100%; }
  .tabs a { flex: none; padding: 6px 13px; }
}
