:root {
  --bg: #14161c; --card: #1e212a; --line: #2c303b; --text: #e8eaf0; --dim: #9aa0ad;
  --acc: #7c9cff; --ok: #3ecf8e; --bad: #ff6b6b; --gold: #ffc857;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
header {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line);
}
#hud { flex: 1; display: flex; justify-content: flex-end; gap: 12px; color: var(--dim); font-size: 14px; white-space: nowrap; }
#hud b { color: var(--text); font-weight: 600; }
main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 32px); }
h1, h2 { margin: 8px 0 12px; line-height: 1.2; }
h2 { font-size: 20px; }
.dim { color: var(--dim); }
/* Language: everything is rendered in both languages, the body class picks what shows. */
body.lang-ru .pl, body.lang-pl .ru, body:not(.lang-ru) .ru1,
body.lang-pl .uiru, body:not(.lang-pl) .uipl { display: none; }
body.lang-both .ru { display: block; color: var(--dim); font-size: .88em; margin-top: 4px; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 12px 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }

button {
  font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; min-height: 48px; cursor: pointer; touch-action: manipulation;
  user-select: none; -webkit-user-select: none; text-align: left; width: 100%;
}
button:active { transform: scale(.98); }
button.primary { background: var(--acc); border-color: var(--acc); color: #0d1020; font-weight: 600; text-align: center; }
button.link { background: none; border: none; padding: 0; min-height: 0; width: auto; font-weight: 700; }
button.chip { width: auto; min-height: 36px; padding: 6px 12px; border-radius: 999px; font-size: 14px; }
button.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 18%, var(--card)); }
button.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 18%, var(--card)); }
button:disabled { cursor: default; }
@media (hover: hover) { button:not(:disabled):hover { border-color: var(--acc); } }

.opts { display: grid; gap: 10px; margin-top: 12px; }
.opts button b { color: var(--dim); margin-right: 8px; }
.explain { background: color-mix(in srgb, var(--acc) 10%, transparent); border-radius: 10px; padding: 10px 12px; margin-top: 12px; }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.bar > div { height: 100%; background: var(--ok); transition: width .3s ease; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.stats b { display: block; font-size: 24px; }
.big { font-size: 1.15em; }
.done-steps { color: var(--dim); font-size: .95em; padding-left: 1.4em; margin: 8px 0; }
.done-steps li { margin: 4px 0; }
.done-steps li::marker { color: var(--ok); }
.solved { color: var(--ok); font-weight: 600; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.inline { display: inline-block; }
label { display: block; margin-bottom: 10px; }
[data-tip-pl] { cursor: help; }
button[data-tip-pl] { cursor: pointer; }
[tabindex]:focus-visible, button:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
#tip {
  position: fixed; z-index: 10; max-width: min(300px, calc(100vw - 16px)); padding: 8px 12px;
  background: #2a2e3a; color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; line-height: 1.4; pointer-events: none; box-shadow: 0 6px 20px rgb(0 0 0 / .35);
}
#tip[hidden] { display: none; }
input {
  font: inherit; width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 17px;
}
table { width: 100%; border-collapse: collapse; }
td, th { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--dim); font-weight: 500; font-size: 14px; }
tr.me td { color: var(--gold); }
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }
.katex { font-size: 1.08em; }
.katex-display { overflow-x: auto; overflow-y: hidden; }
.err { color: var(--bad); min-height: 1.4em; margin: 8px 0; font-size: 15px; }
.bar.thin { height: 4px; margin: 0 0 12px; }
.lesson p { margin: 0 0 12px; }
.lesson p:last-child { margin-bottom: 0; }
.lesson-title { margin: 4px 0 12px; }
.check-label { font-size: 14px; margin-bottom: 4px; }
button.accent { border-color: var(--acc); }
button[aria-disabled="true"] { opacity: .45; }
#today { text-align: center; }
.pw-label { margin-top: 14px; }
.small { font-size: 14px; margin: 12px 0 0; }
form.box .row { margin-top: 4px; }
