:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c2330;
  --muted: #5d6778;
  --line: #d9dde5;
  --accent: #2457d6;
  --accent-text: #ffffff;
  --good: #1f8a4c;
  --bad: #c43b3b;
  --warn: #b7791f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --card: #1b2029;
    --text: #e6e9ef;
    --muted: #9aa4b5;
    --line: #2d3442;
    --accent: #6c93ff;
    --accent-text: #0b1020;
    --good: #4cc27e;
    --bad: #ef6d6d;
    --warn: #e0a84a;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
#app { max-width: 640px; margin: 0 auto; padding: 12px 16px 48px; }
h1 { font-size: 1.5rem; margin: 8px 0 4px; }
h2 { font-size: 1.2rem; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.tagline { margin: 0 0 8px; font-size: 1.05rem; color: var(--text); }
.topbar { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.topbar .title { font-weight: 600; flex: 1; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin: 12px 0;
}
button, .btn, label.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
button.primary, .btn.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
button.danger { color: var(--bad); }
button.block, .btn.block { display: flex; width: 100%; margin: 8px 0; }
button:disabled { opacity: 0.5; cursor: default; }
button.linkbtn {
  display: block; margin: 4px auto 0; min-height: 44px; padding: 8px 12px;
  border: 0; background: transparent; color: var(--accent);
  font-weight: 500; text-decoration: underline;
}
input[type="file"] { display: none; }
input[type="date"], textarea, input[type="number"] {
  font: inherit;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 1.4rem; }
.error { color: var(--bad); font-weight: 600; }
.note { color: var(--warn); }
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  margin-right: 6px;
}
.badge.core { color: var(--accent); border-color: var(--accent); }
.list-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  justify-content: space-between; text-align: left;
  margin: 8px 0; min-height: 56px;
}
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; }
.flashcard { min-height: 220px; }
.flashcard .q { font-size: 1.2rem; font-weight: 600; margin: 8px 0 0; }
.flashcard .a { font-size: 1.15rem; margin: 0 0 8px; }
.cite { border-top: 1px solid var(--line); margin-top: 12px;
  padding-top: 10px; color: var(--muted); font-size: 0.9rem; }
.cite .snip { font-style: italic; margin-top: 4px; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ratings button { min-height: 56px; padding: 6px; }
.r1 { border-color: var(--bad); }
.r3 { border-color: var(--warn); }
.r4 { border-color: var(--good); }
.r5 { border-color: var(--accent); }
.progressbar { height: 8px; background: var(--line); border-radius: 4px;
  overflow: hidden; margin: 4px 0 12px; }
.progressbar > div { height: 100%; background: var(--accent); }
.lesson table { border-collapse: collapse; margin: 8px 0; width: 100%; }
.lesson th, .lesson td { border: 1px solid var(--line); padding: 6px 8px;
  text-align: left; }
.lesson ul { padding-left: 22px; }
#syncmark {
  position: fixed; right: 10px; bottom: 10px; z-index: 10;
  background: var(--warn); color: #fff; font-size: 0.8rem;
  font-weight: 700; padding: 4px 10px; border-radius: 999px;
}
#syncmark[hidden] { display: none; }
input[type="email"], input[type="password"] {
  font: inherit; min-height: 44px; padding: 8px 10px; width: 100%;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); margin-bottom: 8px;
}
.menu { position: relative; }
.menu-btn {
  width: 40px; height: 40px; min-height: 40px; padding: 0;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--muted);
}
.menu-btn:hover { color: var(--text); background: var(--bg); }
.menu-btn svg { width: 24px; height: 24px; }
.menu-drop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  width: 14rem; padding: 4px 0;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.menu-email {
  padding: 8px 16px; font-size: 0.8rem; color: var(--muted);
  border-bottom: 1px solid var(--line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu-item {
  display: block; width: 100%; text-align: left;
  min-height: 44px; padding: 10px 16px;
  border: 0; border-radius: 0; background: transparent;
  color: var(--text); font: inherit; font-weight: 500; cursor: pointer;
}
.menu-item:hover { background: var(--bg); }
