:root {
  --bg: #12151c;
  --card: #1b2030;
  --line: #2a3145;
  --text: #e8ecf4;
  --muted: #98a2b8;
  --accent: #5fd3a6;
  --accent-ink: #08241a;
  --warn: #e6b450;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

main { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; }

h1 { font-size: 1.1rem; margin: 0 0 16px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
h2 { font-size: 1.35rem; margin: 4px 0 2px; }
h3 { font-size: 1rem; margin: 24px 0 8px; color: var(--muted); font-weight: 600; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
}

.eyebrow { color: var(--muted); font-size: .85rem; margin: 0; }
.why { color: var(--muted); margin: 0 0 12px; }
.tag { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; }
.tag.opt { color: var(--warn); border-color: var(--warn); }

.task { margin: 12px 0; }
.task strong { display: block; }
.task ul { margin: 6px 0 0; padding-left: 20px; color: var(--muted); }

.links { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.links a {
  color: var(--accent); text-decoration: none; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; display: inline-flex; align-items: center;
}

.row { display: flex; gap: 12px; margin-top: 16px; }
button, .btn {
  font: inherit; min-height: 52px; padding: 0 16px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--text); flex: 1;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.small { min-height: 44px; flex: none; }
button:active { transform: scale(.98); }

.status { margin: 12px 0 0; color: var(--accent); font-weight: 600; }
.status.skipped { color: var(--muted); }

.notice { color: var(--muted); }

.weeks { list-style: none; margin: 0; padding: 0; }
.weeks li {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px; min-height: 52px;
  border-bottom: 1px solid var(--line);
}
.weeks li:last-child { border-bottom: 0; }
.weeks .wk { width: 3.2em; color: var(--muted); font-variant-numeric: tabular-nums; }
.weeks .name { flex: 1; }
.weeks .name small { display: block; color: var(--muted); }
.weeks .mark { width: 1.5em; text-align: center; }
.weeks li.current { background: rgba(95, 211, 166, .08); border-radius: 10px; }
.weeks li.done .mark { color: var(--accent); }
.weeks li.skipped { opacity: .55; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs { gap: 4px; }
.tab { flex: 1; min-height: 48px; padding: 0 2px; font-size: .8rem; min-width: 0; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 6px; font-size: .7rem; margin-left: 2px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.tile b { display: block; font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.tile b small { font-size: 1rem; color: var(--muted); font-weight: 400; }
.tile span { color: var(--muted); font-size: .8rem; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bars li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.bars .tname { grid-column: 1 / -1; font-size: .9rem; }
.bars .bar { height: 14px; }
.bars .nums { font-size: .85rem; color: var(--muted); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bars .nums em { font-style: normal; margin-left: 8px; color: var(--text); }
.bar { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.seg { display: inline-block; height: 100%; }
.seg.new { background: #6b7690; }
.seg.learning { background: var(--warn); }
.seg.mature { background: var(--accent); }
.legend { margin: 0 0 12px; font-size: .85rem; color: var(--muted); }
.legend .seg { width: 12px; height: 12px; border-radius: 3px; margin: 0 4px 0 12px; vertical-align: -1px; }
.legend .seg:first-child { margin-left: 0; }
.bigstat { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.bigstat b { font-size: 2.2rem; font-variant-numeric: tabular-nums; }
.bigstat span { color: var(--muted); }
.bars li.here .tname { color: var(--accent); font-weight: 600; }
.weeks li.weak { background: rgba(230, 180, 80, .12); border-radius: 10px; }
.weeks li.weak .rate { color: var(--warn); }
.rate { font-weight: 600; font-variant-numeric: tabular-nums; padding-right: 8px; }
.chart { width: 100%; height: auto; margin: 12px 0; }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .dot { fill: var(--accent); stroke: var(--bg); stroke-width: 1.5; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.entries .entry { display: block; padding: 12px 0; }
.entry .head { display: flex; align-items: center; gap: 12px; }
.entry .name { flex: 1; }
.entry .name small, .entry .score small { display: block; color: var(--muted); }
.entry .score { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.entry .note { margin: 8px 0 0; color: var(--muted); }
.mkcard { margin-top: 12px; }
.tab.on { background: var(--card); border-color: var(--accent); color: var(--accent); }

.files { list-style: none; margin: 0 0 12px; padding: 0; }
.files li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); min-height: 48px; }
.files li:last-child { border-bottom: 0; }
.files a, .files .linklike { flex: 1; color: var(--accent); text-decoration: none; text-align: left; overflow-wrap: anywhere; }
.linklike { border: 0; background: none; padding: 8px 0; min-height: 44px; font: inherit; cursor: pointer; }
.files small { color: var(--muted); white-space: nowrap; }
button.ghost { color: var(--muted); }
.btn.addfile { display: flex; align-items: center; justify-content: center; text-align: center; color: var(--text); margin: 0; }
.linkform { display: grid; gap: 8px; margin: 8px 0 12px; }
.linkform input, select {
  font: inherit; width: 100%; min-height: 48px; padding: 8px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}

.checklist { display: grid; gap: 8px; margin: 12px 0; }
.check { display: flex; align-items: center; gap: 12px; text-align: left; min-height: 56px; padding: 8px 14px; flex: none; }
.check .box {
  flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--line);
  display: grid; place-items: center; color: var(--accent-ink); font-weight: 700;
}
.check.on { border-color: var(--accent); }
.check.on .box { background: var(--accent); border-color: var(--accent); }
.check.on span:last-child { color: var(--muted); text-decoration: line-through; }

label.inline { display: flex; align-items: center; gap: 8px; margin: 0; min-height: 48px; }
label.inline input { width: 24px; min-height: 0; }
select { font: inherit; }
.cimg { max-width: 100%; max-height: 40vh; object-fit: contain; margin: 12px auto 0; border-radius: 10px; background: #fff; }
.verdict { margin: 0 0 8px; font-weight: 600; }
.verdict.ok { color: var(--accent); }
.verdict.no { color: var(--warn); }

/* Wide screens: use the room. On a phone everything stays one stacked column. */
@media (min-width: 1000px) {
  body { font-size: 17px; }
  main { max-width: 1240px; padding: 24px 32px 64px; }
  main.narrow { max-width: 720px; }
  .tabs { max-width: 620px; }
  .cols { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 28px; align-items: start; }
  .col.sticky { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; padding-right: 6px; }
  .flow { column-count: 2; column-gap: 28px; }
  .flow > * { break-inside: avoid; }
  .flow > h1 { column-span: all; }
  .card { padding: 20px; }
  .row button { min-height: 48px; }
}

.chips { margin: 8px 0 0; }
.chips .tag { margin: 0 6px 0 0; }
.chiprow { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { flex: 1; min-width: 70px; }
.chip.on { border-color: var(--accent); color: var(--accent); }
.card.planned { opacity: .6; }
.weeks .topic { display: block; padding: 0; border-bottom: 1px solid var(--line); }
.weeks .topic:last-child { border-bottom: 0; }
.rowbtn { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; min-height: 52px; padding: 8px 4px; border-radius: 0; flex: none; }
.rowbtn .name { flex: 1; }
.rowbtn .name small { display: inline; margin-left: 8px; color: var(--warn); }
.rowbtn .mark { width: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.topic.done .rowbtn .mark { color: var(--accent); }
.weeks .sub { padding: 0 0 8px 8px; }
.weeks .sub li { border: 0; padding: 2px 0; min-height: 0; }
.weeks .sub .check { width: 100%; min-height: 48px; }
.weeks .sub li.grp { padding: 14px 0 2px; min-height: 0; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.notice.file { font-size: .85rem; overflow-wrap: anywhere; }

button:disabled { opacity: .4; cursor: default; }
.card.study { min-height: 40vh; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.card.study[data-act] { cursor: pointer; }
.study .q { font-size: 1.35rem; font-weight: 600; }
.study .a { font-size: 1.15rem; color: var(--accent); }
.study hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.study .tap { margin: 16px 0 0; }
.grades button { min-height: 64px; }
.grades .again { border-color: var(--warn); color: var(--warn); }
.opts { display: grid; gap: 10px; }
.opt { text-align: left; padding: 14px 16px; height: auto; min-height: 56px; flex: none; }
.opt.right { border-color: var(--accent); background: rgba(95, 211, 166, .15); opacity: 1; }
.opt.wrong { border-color: var(--warn); background: rgba(230, 180, 80, .15); opacity: 1; }

label { display: block; color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
input[type="date"], textarea {
  font: inherit; width: 100%; min-height: 48px; padding: 8px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
textarea { min-height: 120px; font-family: ui-monospace, monospace; font-size: .8rem; }
.msg { margin: 8px 0 0; font-size: .9rem; color: var(--warn); }
