/* «Урок» — design 1.0 (DOX-Design/urok-app, round 21). DOX's colours and pixel icons, made for reading on a phone.
 * Type: the lesson text in the phone's own font (17 px, line 1.6); numbers in the phone's rounded font (ui-rounded)
 * or JetBrains Mono — never in the pixel font, which misreads digits (5 looked like 8, 6 like б); DOX shows itself in
 * pixel icons. Shapes: soft and rounded. Bars: solid, no blur (DOX). Touch targets: 44 px and more.
 * Two palettes: dark (default) and light — html[data-theme="light"], set by main.js from Telegram's colorScheme.
 * One kind of content = one look: explanation — plain text; «Похоже на» — yellow box; «Где сравнение ломается» —
 * orange box with a broken (dashed) frame; a task — a question and option cards; an answer — a mint box. */

:root {
  color-scheme: dark;
  --bg: #06100a;
  --panel: #0a170e;
  --card: #0d1d12;
  --card-hi: #11261a;
  --bar: #06100a;             /* = Telegram's header (main.js BG) */
  --line: #1f4a2b;
  --line-soft: rgb(31 74 43 / .7);
  --head: #f0fbef;            /* headings */
  --text: #d6ffd0;            /* controls */
  --read: #e4f3e6;            /* long text: a calm near-white */
  --dim: #94c29d;
  --faint: #4a7354;           /* lines and unlit marks, not text */
  --quiet: #6f9a78;           /* the quietest text: week names, minutes, «Источник» (6:1) */
  --mint: #4fe765;            /* fills: the main button, done cells, «сегодня» */
  --accent: #4fe765;          /* labels, marks, icons */
  --hi: #c9ffcf;              /* answers, the current cell */
  --ink: #03140a;             /* text on a mint fill */
  --field: #03140a;
  --skull: #c9ffcf;
  --tip: #ffd75e;
  --warn: #ff8a1f;
  --warn-text: #ffc58f;
  --like-bg: rgb(255 215 94 / .07);  --like-line: rgb(255 215 94 / .38);
  --breaks-bg: rgb(255 138 31 / .07); --breaks-line: rgb(255 138 31 / .55);
  --ok-bg: rgb(79 231 101 / .09);     --ok-line: rgb(79 231 101 / .5);
  --bad-bg: rgb(255 138 31 / .08);    --bad-line: rgb(255 138 31 / .5);
  --pick-bg: rgb(201 255 207 / .07);
  --glow: 0 0 0 1px rgb(79 231 101 / .22), 0 10px 28px rgb(0 0 0 / .4);
  --main-shadow: 0 4px 18px rgb(79 231 101 / .22);

  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --num: ui-rounded, 'SF Pro Rounded', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Menlo', monospace;
  --mark: 'Pixelify Sans', 'Menlo', monospace;
  --r: 20px;    /* cards */
  --rb: 16px;   /* buttons, options, boxes */
  --tap: 44px;  /* the smallest touch target */
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --bar-h: calc(78px + var(--safe-b));
}

/* Light: DOX on paper — the same greens, deep enough to read on white; mint stays as the fill of the main button. */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f7f1;
  --panel: #e8f1e8;
  --card: #ffffff;
  --card-hi: #ffffff;
  --bar: #ffffff;             /* = Telegram's header (main.js BG_LIGHT) */
  --line: #cfe2d2;
  --line-soft: #d9e9db;
  --head: #0a1f11;
  --text: #0f2a18;
  --read: #17281c;
  --dim: #4f6a57;
  --faint: #93ab99;
  --quiet: #587260;
  --mint: #45e061;
  --accent: #10813a;
  --hi: #0b5a26;
  --ink: #03140a;
  --field: #ffffff;
  --skull: #0f2a18;
  --tip: #8a5a00;
  --warn: #b84f00;
  --warn-text: #8f3d00;
  --like-bg: #fff8dc;   --like-line: #f0d77a;
  --breaks-bg: #fff2e6; --breaks-line: #f2a05a;
  --ok-bg: #ebfaee;     --ok-line: #7fd892;
  --bad-bg: #fff2e6;    --bad-line: #f2a05a;
  --pick-bg: #f1fbf3;
  --glow: 0 0 0 1px rgb(16 129 58 / .25), 0 8px 22px rgb(10 40 20 / .1);
  --main-shadow: 0 3px 12px rgb(30 160 70 / .3);
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font: 17px/1.6 var(--sans);
  color: var(--read);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: rgb(79 231 101 / .3); }

.ico { display: inline-block; flex: none; vertical-align: -2px; }

/* ── the top line: DOX and today, or the progress of a sitting ── */
#top {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 8px 16px;
  background: var(--bar);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; font: 600 16px/1 var(--mono); color: var(--accent); letter-spacing: 3px; }
.skull { color: var(--skull); }
.skull .eye { fill: var(--faint); transition: fill .3s; }
.brand.lit .skull .eye, .skull.lit .eye { fill: var(--mint); }
html[data-theme="light"] .brand.lit .skull .eye, html[data-theme="light"] .skull.lit .eye { fill: #22c55e; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; font: 600 13px/1 var(--mono); color: var(--dim); background: var(--card); border: 1px solid var(--line); padding: 0 12px; border-radius: 999px; }
.chip.on { color: var(--ink); background: var(--mint); border-color: var(--mint); }
.close { flex: none; display: grid; place-items: center; width: var(--tap); height: var(--tap); margin-left: -6px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); color: var(--dim); font: 600 16px/1 var(--sans); cursor: pointer; }
.count { font: 600 13px/1 var(--mono); color: var(--dim); min-width: 5ch; text-align: right; font-variant-numeric: tabular-nums; }
/* the progress of a sitting: rounded cells, whole steps only */
.cells { flex: 1; display: flex; gap: 3px; height: 8px; min-width: 0; }
.cells i { flex: 1; min-width: 2px; background: var(--line); border-radius: 4px; }
.cells i.on { background: var(--mint); }
.cells i.now { background: var(--hi); box-shadow: 0 0 8px rgb(79 231 101 / .6); }
html[data-theme="light"] .cells i.now { background: var(--accent); box-shadow: 0 0 0 2px rgb(16 129 58 / .2); }

#view { padding: 20px 18px calc(var(--bar-h) + 28px); max-width: 620px; margin: 0 auto; }

/* ── the bottom bar ── */
#bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; gap: 12px; padding: 12px 16px calc(12px + var(--safe-b));
  background: var(--bar);
  border-top: 1px solid var(--line-soft);
}
#bar .btn { flex: 1; margin: 0; min-height: 54px; }
#bar .btn.main { flex: 1.6; }
#bar .gone { visibility: hidden; }
/* Typing (the retelling, the plan time, «Свой вариант»): the bottom bar steps aside while the keyboard is up, so it
 * never covers the field — whether Telegram shrinks the page above the keyboard or not. «Готово» on the keyboard (or a
 * tap anywhere outside the field — main.js design 1.0 blurs it) brings it back. It is hidden, not moved: a bar that
 * jumped on blur could lose the tap. */
@supports selector(:has(*)) {
  body:has(textarea:focus, input:focus) #bar { display: none; }
}

/* ── type ── */
h2 { font: 650 22px/1.32 var(--sans); margin: 6px 0 16px; color: var(--head); letter-spacing: -.2px; text-wrap: balance; }
h2.hook { font-size: 26px; line-height: 1.3; color: var(--hi); margin: 14px 0 18px; }
h2.q { font-size: 20px; line-height: 1.35; text-wrap: wrap; }
p { margin: 0 0 14px; }
.txt p { margin: 0 0 16px; }
.txt, .box, .opt, .phrase, h2 { overflow-wrap: break-word; }
.label { display: flex; align-items: flex-start; gap: 8px; font: 600 12px/1.4 var(--mono); color: var(--accent); text-transform: uppercase; letter-spacing: .6px; margin: 0 0 10px; }
.label .ico { margin-top: 1px; }
.dim { color: var(--dim); }
.warn { color: var(--warn); }
p.warn { color: var(--warn-text); }
.dim.right { text-align: right; font: 13px/1.4 var(--mono); margin-top: 8px; font-variant-numeric: tabular-nums; } /* the retelling's counter (not .opt.right) */
b { font-weight: 650; }
.hookmark { margin: 8px 0 14px; }
/* a hint: a small yellow note, not a line of yellow text */
.tip { color: var(--read); font-size: 15px; line-height: 1.5; padding: 10px 14px; border-radius: 12px; background: var(--like-bg); border-left: 3px solid var(--tip); }
html[data-theme="light"] .tip { border-left-color: #e2b437; }

/* ── cards and boxes: soft and rounded ── */
section.card {
  background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px; margin: 0 0 14px;
}
html:not([data-theme="light"]) section.card { background: linear-gradient(180deg, var(--card-hi), var(--card)); }
section.card.next { border-color: var(--accent); box-shadow: var(--glow); }
section.card h2 { margin-top: 2px; }
section.card .tip { margin-top: -2px; }
/* the streak: a big rounded number under the flame, the words beside it */
.streak { display: flex; gap: 16px; align-items: center; padding: 14px 18px; }
.streak .big { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 64px; font: 700 40px/1 var(--num); color: var(--accent); font-variant-numeric: tabular-nums; }
.streak .big > span { letter-spacing: -.5px; }
.streak > div:last-child { line-height: 1.4; font-size: 17px; color: var(--head); }
.streak > div:last-child .dim { font-size: 15px; margin-top: 4px; color: var(--dim); }
.streak .flame { color: var(--faint); }
.streak .big.lit .flame { color: var(--warn); filter: drop-shadow(0 0 6px rgb(255 138 31 / .55)); }
html[data-theme="light"] .streak .big.lit .flame { color: #ff7a00; filter: none; }

.box { padding: 14px 16px; margin: 18px 0; border-radius: var(--rb); background: var(--card); border: 1px solid var(--line); scroll-margin: 76px 0 calc(var(--bar-h) + 16px); }
.box p:last-child { margin-bottom: 0; }
.box .label { margin-bottom: 6px; }
.box.like { background: var(--like-bg); border-color: var(--like-line); }
.box.like .label { color: var(--tip); }
.box.breaks { background: var(--breaks-bg); border: 1.5px dashed var(--breaks-line); }
.box.breaks .label { color: var(--warn); }
.box.answer { background: var(--ok-bg); border-color: var(--ok-line); color: var(--hi); white-space: pre-line; }
.box.answer .label { color: var(--accent); }
.box.ok { background: var(--ok-bg); border-color: var(--ok-line); }
.box.ok b { color: var(--accent); }
.box.bad { background: var(--bad-bg); border-color: var(--bad-line); }
.box.bad b { color: var(--warn); }
.box.warn { background: var(--bad-bg); border-color: var(--bad-line); color: var(--warn-text); font-size: 15px; line-height: 1.5; }
.box.passage { white-space: pre-line; font-style: italic; border-left: 3px solid var(--accent); }
pre.code { font: 14px/1.55 var(--mono); background: var(--field); color: var(--hi); padding: 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--rb); -webkit-overflow-scrolling: touch; }
/* Python in a lesson (chat 9): the code, the field to change it, what Python printed */
pre.code, pre.out, textarea.code-edit { white-space: pre; tab-size: 4; }
.opts.mono .opt > span:last-child { font: 15px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
textarea.code-edit { display: block; width: 100%; box-sizing: border-box; margin: 10px 0; font: 15px/1.55 var(--mono); background: var(--field); color: var(--hi); padding: 12px; border: 1px solid var(--line); border-radius: var(--rb); overflow-x: auto; resize: vertical; min-height: 7em; }
.console { margin: 12px 0 18px; scroll-margin: 76px 0 calc(var(--bar-h) + 16px); }
pre.out { font: 14px/1.55 var(--mono); background: var(--panel); color: var(--hi); padding: 12px 14px; margin: 0 0 10px; overflow-x: auto; border: 1px dashed var(--line); border-radius: var(--rb); -webkit-overflow-scrolling: touch; }
.said { font-family: var(--mono); overflow-wrap: anywhere; }
.pystate { margin-top: 14px; }

ol.steps, ul.steps { padding-left: 26px; margin: 0 0 16px; }
ol.steps li, ul.steps li { margin: 0 0 12px; padding-left: 4px; }
ol.steps li::marker { color: var(--accent); font: 600 15px var(--mono); }
ul.steps li::marker { color: var(--accent); }

/* sources: one per line, each a full-width tap target; the « · » between them is not shown (only when there are links:
 * without them — main.js before design 1.0 — the text stays visible) */
.src { margin: 24px 0 0; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 14px; line-height: 1.5; color: var(--dim); }
.src:has(a) { font-size: 0; }
.src > span { display: block; font: 600 12px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .6px; color: var(--quiet); margin-bottom: 2px; }
.src a { display: flex; gap: 8px; align-items: baseline; min-height: var(--tap); padding: 11px 0; font: 14px/1.5 var(--sans); color: var(--dim); text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; overflow-wrap: anywhere; }
.src a::before { content: '↗'; flex: none; color: var(--accent); text-decoration: none; }

/* ── words of the glossary (chat 8): an underlined word opens its explanation from below ──
 * Was a <details> «Словарик урока»: it opened, but showed «[object HTMLElement]» (h() flattens one level only). */
.term { display: inline; padding: 0; margin: 0; border: none; background: none; color: inherit; font: inherit; line-height: inherit; text-align: inherit; cursor: pointer;
  text-decoration: underline dotted var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; -webkit-tap-highlight-color: rgb(79 231 101 / .25); }
.term:active { background: var(--pick-bg); border-radius: 4px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 12px 0 0; font-size: 15px; }
.term.chip { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--text); }
.words-btn { margin-top: 24px; }
.sheet-bg { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; background: rgb(0 0 0 / .5); animation: fade .15s ease-out; }
.sheet { width: 100%; max-width: 620px; max-height: 72vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 20px calc(20px + var(--safe-b)); background: var(--card-hi); border: 1px solid var(--line); border-bottom: none; border-radius: var(--r) var(--r) 0 0;
  box-shadow: 0 -10px 30px rgb(0 0 0 / .35); animation: rise .18s ease-out; }
.sheet.long { max-height: 82vh; }
.sheet h2 { margin-top: 0; }
.sheet .plain { color: var(--read); }
.example { color: var(--dim); font-size: 15px; line-height: 1.5; }
.example b { color: var(--tip); font-weight: 650; }
.dim.small { font-size: 14px; margin: 6px 0 0; }
.words { margin-top: 10px; }
.word { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.word:last-child { border-bottom: none; }
.word h3 { margin: 0 0 4px; font: 650 17px/1.3 var(--sans); color: var(--accent); }
.word p { margin: 0 0 4px; }
#top .title { flex: 1; font: 600 15px/1 var(--mono); color: var(--accent); letter-spacing: 1px; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-bg { animation: none; } }

.phrase { background: var(--card); border: 1px solid var(--line); border-radius: var(--rb); padding: 14px 16px 6px; margin: 12px 0; }
.phrase .en { color: var(--hi); margin-bottom: 6px; font-style: italic; }
.phrase p:last-child { margin-bottom: 8px; }

/* ── controls ── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 52px; margin: 14px 0 0; padding: 12px 16px;
  border: 1px solid var(--ok-line); border-radius: var(--rb); font: 650 17px/1.2 var(--sans); cursor: pointer;
  background: var(--ok-bg); color: var(--hi);
  scroll-margin: 76px 0 calc(var(--bar-h) + 16px);
}
.btn.main { background: var(--mint); color: var(--ink); border-color: var(--mint); box-shadow: var(--main-shadow); }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.sel, .btn.ghost.sel { background: var(--mint); color: var(--ink); border-color: var(--mint); }
.btn.small { display: inline-flex; width: auto; min-height: var(--tap); min-width: var(--tap); padding: 8px 12px; margin: 8px 8px 0 0; font: 600 16px/1 var(--num); font-variant-numeric: tabular-nums; }
.btn:disabled { opacity: .38; cursor: default; box-shadow: none; }
.btn:active:not(:disabled) { transform: scale(.98); }
.link { display: inline-flex; align-items: center; min-height: var(--tap); background: none; border: none; color: var(--accent); font: 600 15px/1.4 var(--sans); text-decoration: underline; text-underline-offset: 4px; padding: 0 2px; cursor: pointer; }
.row { display: flex; gap: 12px; scroll-margin: 76px 0 calc(var(--bar-h) + 16px); }
.row .btn { flex: 1; min-height: 56px; }
.row.wrap { flex-wrap: wrap; gap: 0; }

.opts { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.opt {
  display: flex; gap: 14px; align-items: flex-start; width: 100%; min-height: 58px; padding: 15px 16px;
  text-align: left; border: 1.5px solid var(--line); border-radius: var(--rb); font: 17px/1.45 var(--sans); cursor: pointer;
  background: var(--card); color: var(--read);
}
.opt > span:last-child { padding-top: 1px; }
.opt .key { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); font: 600 14px/1 var(--mono); color: var(--dim); }
.opt:active:not(:disabled) { background: var(--pick-bg); }
.opt.picked { border-color: var(--hi); background: var(--pick-bg); }
.opt.picked .key { background: var(--hi); color: var(--card); border-color: var(--hi); }
html:not([data-theme="light"]) .opt.picked .key { color: var(--ink); }
.opt.right { border-color: var(--accent); background: var(--ok-bg); }
.opt.right .key { background: var(--mint); color: var(--ink); border-color: var(--mint); }
.opt.wrong { border-color: var(--warn); background: var(--bad-bg); }
.opt.wrong .key { background: var(--warn); color: #fff; border-color: var(--warn); }
html:not([data-theme="light"]) .opt.wrong .key { color: var(--ink); }
.opt:disabled { cursor: default; opacity: .55; }
.opt.right:disabled, .opt.picked:disabled { opacity: 1; }

.field, textarea {
  display: block; width: 100%; margin: 14px 0 0; padding: 14px 16px;
  font: 17px/1.55 var(--sans); color: var(--read); background: var(--field);
  border: 1.5px solid var(--line); border-radius: var(--rb); outline: none;
  scroll-margin: 76px 0 24px;
}
.field::placeholder, textarea::placeholder { color: var(--quiet); }
.field:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgb(79 231 101 / .16); }
textarea { resize: vertical; min-height: 200px; }
input[type="time"].field { min-height: 64px; max-width: 200px; padding: 10px 16px; font: 600 30px/1.2 var(--num); font-variant-numeric: tabular-nums; text-align: center; -webkit-appearance: none; appearance: none; }
input[type="time"].field::-webkit-date-and-time-value { text-align: center; }

/* ── the list of lessons ── */
.list { margin-top: 28px; }
.list > .label { color: var(--dim); }
.week { margin: 0 0 18px; }
.wk { font: 600 12px/1 var(--mono); color: var(--quiet); text-transform: uppercase; letter-spacing: .6px; margin: 14px 0 10px 4px; }
.item {
  display: flex; gap: 12px; align-items: center; width: 100%; min-height: 52px; padding: 12px 14px; margin: 0 0 8px;
  text-align: left; border: 1px solid var(--line-soft); border-radius: var(--rb); font: 16px/1.4 var(--sans); cursor: pointer;
  background: var(--card); color: var(--read);
}
.item span:nth-child(2) { flex: 1; }
.item .mark { display: grid; place-items: center; width: 20px; color: var(--faint); font: 600 14px/1 var(--mono); }
.item.done .mark { color: var(--accent); }
.item.done span:nth-child(2) { color: var(--dim); }
.item.cur { border-color: var(--accent); border-width: 1.5px; }
.item.cur .mark { color: var(--accent); }
.item:disabled { cursor: default; opacity: .7; }
.item .dim { font: 600 13px/1 var(--num); font-variant-numeric: tabular-nums; color: var(--quiet); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } .btn:active:not(:disabled) { transform: none; } }
