/* cpm.rip — один скелет, у каждой сборной свой мир.
   Data (time, room, dates) always in a plain font; handwriting/chalk/code only for headers and decor. */

:root {
  --data-font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", monospace;
  --hand: "Neucha", "Comic Sans MS", cursive;
  --chalk: "Amatic SC", "Neucha", cursive;
  --phys: #FF6A2B;
  --ai: #8B7CFF;
  --radius: 18px;
}

/* ---------- root (cpm.rip), admin ---------- */
html[data-world="root"], html[data-world="admin"] {
  --bg: #F3F4F6; --surface: #FFFFFF; --ink: #14161A; --data: #14161A; --muted: #565C66;
  --line: #ECEEF1; --change: #C0392B; --accent-text: #14161A; --head-font: var(--data-font);
  --nav-bg: #14161A; --nav-ink: #C9CDD4; --nav-on: #FFFFFF;
}
html[data-world="root"][data-theme="dark"], html[data-world="admin"][data-theme="dark"] {
  --bg: #121418; --surface: #1C1F24; --ink: #ECEEF1; --data: #ECEEF1; --muted: #A3A9B3;
  --line: #2A2E35; --change: #FF8A7A; --accent-text: #ECEEF1;
  --nav-bg: #ECEEF1; --nav-ink: #565C66; --nav-on: #14161A;
}

/* ---------- physics: тетрадь в клетку (light) ---------- */
html[data-world="notebook"] {
  --bg: #FCFCF7; --surface: rgba(255, 255, 255, 0.72); --ink: #1D2A6B; --data: #14161A; --muted: #4E5778;
  --line: rgba(70, 110, 200, 0.22); --change: #C0392B; --accent-text: #1D2A6B; --head-font: var(--hand);
  --grid: rgba(70, 110, 200, 0.13); --margin: #E8837B;
  --nav-bg: #FCFCF7; --nav-ink: #4E5778; --nav-on: #1D2A6B;
}
/* physics: доска (dark) */
html[data-world="notebook"][data-theme="dark"] {
  --bg: #24332C; --surface: rgba(255, 255, 255, 0.05); --ink: #F1EFE6; --data: #F1EFE6; --muted: #B9C4B8;
  --line: rgba(241, 239, 230, 0.22); --change: #FFB37A; --accent-text: #F1EFE6; --head-font: var(--chalk);
  --grid: transparent; --margin: transparent;
  --nav-bg: #6E4B2C; --nav-ink: #F0E2CC; --nav-on: #FFFFFF;
}

/* ---------- AI: Jupyter ---------- */
html[data-world="jupyter"] {
  --bg: #FFFFFF; --surface: #F5F5F5; --ink: #1E1E1E; --data: #1E1E1E; --muted: #5F6368; --line: #E0E0E0;
  --in: #303F9F; --out: #BF360C; --warn-bg: #FDECEA; --warn: #8E1B1B; --change: #8E1B1B;
  --accent-text: #5B47E0; --head-font: var(--mono); --data-font: var(--mono);
  --nav-bg: #F5F5F5; --nav-ink: #5F6368; --nav-on: #1E1E1E;
}
html[data-world="jupyter"][data-theme="dark"] {
  --bg: #1E1E1E; --surface: #252526; --ink: #D4D4D4; --data: #D4D4D4; --muted: #A0A3A8; --line: #3A3A3C;
  --in: #8FA8FF; --out: #FF9A76; --warn-bg: #3B2323; --warn: #F4B8B8; --change: #F4B8B8;
  --accent-text: #A99DFF; --nav-bg: #252526; --nav-ink: #A0A3A8; --nav-on: #D4D4D4;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font-family: var(--data-font); font-size: 16px; line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
html[data-world="notebook"] body {
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 16px 16px;
}
html[data-world="notebook"][data-theme="dark"] body {
  background-image: radial-gradient(ellipse at 50% 30%, #2C3E35 0%, #24332C 70%);
  background-size: auto;
}
a { color: var(--accent-text); }
.wrap { max-width: 480px; margin: 0 auto; padding: 16px 16px 112px; position: relative; }
html[data-world="notebook"]:not([data-theme="dark"]) .wrap::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 34px; width: 2px; background: var(--margin); opacity: .55;
}
html[data-world="notebook"] .wrap > * { position: relative; }
html[data-world="notebook"]:not([data-theme="dark"]) .wrap { padding-left: 48px; }

/* ---------- top ---------- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.wordmark {
  display: inline-flex; align-items: flex-end; font-family: var(--mono); font-weight: 800; font-size: 20px;
  letter-spacing: -0.03em; line-height: 1; color: var(--data); text-decoration: none;
}
.wordmark svg { display: block; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1.5px solid var(--line);
  color: var(--data); text-decoration: none; background: var(--surface); white-space: nowrap;
}
.chip.on { background: var(--data); color: var(--bg); border-color: var(--data); }

h1, .h1 { font-family: var(--head-font); font-weight: 400; font-size: 30px; line-height: 1.1; margin: 4px 0 2px; color: var(--ink); }
html[data-world="notebook"][data-theme="dark"] h1 { font-weight: 700; font-size: 38px; letter-spacing: 0.02em; }
html[data-world="root"] h1, html[data-world="admin"] h1 { font-weight: 800; font-size: 26px; letter-spacing: -0.03em; }
html[data-world="jupyter"] h1 { font-size: 20px; font-weight: 700; }
.sub { font-family: var(--head-font); color: var(--muted); font-size: 20px; margin: 0 0 14px; }
html[data-world="jupyter"] .sub, html[data-world="root"] .sub, html[data-world="admin"] .sub { font-size: 14px; }
h2 { font-family: var(--head-font); font-weight: 400; font-size: 22px; margin: 22px 0 8px; color: var(--ink); }
html[data-world="notebook"][data-theme="dark"] h2 { font-weight: 700; font-size: 28px; }
html[data-world="root"] h2, html[data-world="admin"] h2, html[data-world="jupyter"] h2 { font-size: 16px; font-weight: 800; }
.hand { font-family: var(--hand); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.data { font-family: var(--data-font); color: var(--data); }
.big { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }

/* ---------- «Дано / Найти / Ответ» ---------- */
.problem { margin: 6px 0 10px; display: grid; gap: 8px; }
.problem .label { font-family: var(--head-font); font-size: 21px; text-decoration: underline; text-underline-offset: 4px; }
html[data-world="notebook"][data-theme="dark"] .problem .label { font-weight: 700; font-size: 26px; text-decoration: none; }
.problem .given { padding-left: 12px; }
.answer {
  display: inline-block; border: 2px solid var(--ink); border-radius: 4px; padding: 4px 14px;
  font-weight: 800; font-size: 28px; color: var(--data);
}
.was { text-decoration: line-through; text-decoration-color: var(--change); text-decoration-thickness: 2px; opacity: .8; }
.fix { color: var(--change); font-weight: 800; transform: rotate(-3deg); display: inline-block; }
.fix-note { font-family: var(--hand); color: var(--change); font-size: 17px; }
html[data-world="jupyter"] .fix-note { font-family: var(--mono); font-size: 13px; }
.cancel { color: var(--change); font-weight: 800; }

/* ---------- lists ---------- */
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
html[data-world="notebook"] .card { border-color: var(--line); }
.rows { display: grid; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row a { text-decoration: none; color: inherit; }
.row .t { font-weight: 800; color: var(--data); white-space: nowrap; }
.row .what { color: var(--data); }
.row.past { opacity: .5; }
.row.cancelled .what, .row.cancelled .t { text-decoration: line-through; text-decoration-color: var(--change); text-decoration-thickness: 2px; }

.day { padding: 10px 0 6px; border-bottom: 1px solid var(--line); }
.day.today { background: color-mix(in srgb, var(--change) 7%, transparent); border-radius: 10px; padding: 10px 8px 6px; }
.day .d { font-family: var(--head-font); font-size: 20px; color: var(--ink); display: flex; justify-content: space-between; }
html[data-world="notebook"][data-theme="dark"] .day .d { font-size: 24px; font-weight: 700; }
html[data-world="jupyter"] .day .d { font-size: 13px; font-weight: 700; }
.day .free { font-family: var(--hand); color: var(--muted); padding: 2px 0 6px 12px; }
html[data-world="jupyter"] .day .free { font-family: var(--mono); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border-radius: 999px; border: 2px solid var(--data); background: var(--data); color: var(--bg);
  font: 700 15px/1 var(--data-font); text-decoration: none; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--data); }
.btn.wide { width: 100%; }
.btns { display: grid; gap: 10px; margin-top: 14px; }
.grade-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 14px; }
.grade-chips a { min-width: 44px; min-height: 44px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; background: var(--surface); border: 1.5px solid var(--line); color: var(--data); font-weight: 700; text-decoration: none; }
.grade-chips a.on { background: var(--data); color: var(--bg); border-color: var(--data); }
label.pick { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
label.pick input { width: 22px; height: 22px; accent-color: var(--data); }

/* ---------- season = metro line ---------- */
.metro { position: relative; padding-left: 34px; margin-top: 10px; }
.metro::before { content: ""; position: absolute; left: 12px; top: 10px; bottom: 10px; width: 8px; border-radius: 4px; background: var(--phys); }
.station { position: relative; padding: 4px 0 18px; }
.station .dot { position: absolute; left: -30px; top: 4px; width: 24px; height: 24px; border-radius: 50%; background: #FFFFFF; border: 5px solid var(--phys); }
.station.camp .dot { border-color: #14161A; box-shadow: 0 0 0 3px #FFFFFF, 0 0 0 5px #14161A; }
.station.past .dot { background: #14161A; border-color: #14161A; }
.station.tentative .dot { border-style: dashed; }
.station .when { font-size: 13px; color: var(--muted); font-weight: 700; }
.station .name { font-weight: 800; color: var(--data); }
.station .hint { font-size: 14px; color: var(--muted); }
.here { display: inline-block; font-family: var(--hand); background: #1D2A6B; color: #FFFFFF; border-radius: 6px; padding: 0 8px; font-size: 16px; margin-bottom: 4px; }
.banner { background: #FF6A2B; color: #14161A; border-radius: 12px; padding: 10px 14px; font-weight: 700; margin: 8px 0 14px; }
html[data-world="notebook"][data-theme="dark"] .station .dot { background: #24332C; }
html[data-world="notebook"][data-theme="dark"] .station.past .dot { background: #F1EFE6; border-color: #F1EFE6; }
html[data-world="notebook"][data-theme="dark"] .here { background: #F1EFE6; color: #24332C; }

/* ---------- Jupyter cells ---------- */
.cell { display: grid; grid-template-columns: 62px 1fr; gap: 8px; margin: 10px 0; font-family: var(--mono); font-size: 14px; }
.cell .prompt { color: var(--in); font-size: 12px; padding-top: 9px; text-align: right; white-space: nowrap; }
.cell .prompt.out { color: var(--out); }
.cell .src { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; overflow-x: auto; }
.cell .res { padding: 8px 2px; overflow-x: auto; }
.warn { background: var(--warn-bg); color: var(--warn); border-radius: 4px; padding: 8px 10px; font-family: var(--mono); font-size: 13px; }
.df { border-collapse: collapse; font-family: var(--mono); font-size: 12.5px; width: 100%; }
.df th, .df td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.df th { color: var(--muted); font-weight: 700; }
.df tr.today td { background: color-mix(in srgb, var(--accent-text) 10%, transparent); }
.nan { color: var(--muted); }
.comment { color: var(--muted); }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; pointer-events: none;
}
.nav .bar {
  pointer-events: auto; width: 100%; max-width: 448px; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--nav-bg); border-radius: 30px; min-height: 58px; padding: 0 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
}
.nav a { display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--nav-ink); font-weight: 600; font-size: 14px; }
.nav a.on { color: var(--nav-on); font-weight: 800; }
html[data-world="notebook"]:not([data-theme="dark"]) .nav .bar { border: 2px solid #1D2A6B; border-radius: 14px; box-shadow: none; }
html[data-world="notebook"]:not([data-theme="dark"]) .nav a { font-family: var(--hand); font-size: 18px; font-weight: 400; }
html[data-world="notebook"]:not([data-theme="dark"]) .nav a.on { text-decoration: underline; text-decoration-color: #C0392B; text-underline-offset: 5px; }
html[data-world="notebook"][data-theme="dark"] .nav .bar { border-radius: 6px; border-top: 6px solid #5A3C22; box-shadow: 0 -2px 0 rgba(0,0,0,.25); }
html[data-world="notebook"][data-theme="dark"] .nav a { font-family: var(--chalk); font-size: 22px; font-weight: 700; }
html[data-world="jupyter"] .nav .bar { border-radius: 0; border: 1px solid var(--line); box-shadow: none; min-height: 48px; }
html[data-world="jupyter"] .nav a { font-family: var(--mono); font-size: 13px; }
html[data-world="jupyter"] .nav a.on::after { content: ".ipynb"; color: var(--muted); font-weight: 500; }
html[data-world="jupyter"] .nav a.on { background: var(--bg); border-top: 2px solid var(--accent-text); }

/* ---------- root picker ---------- */
.teams { display: grid; gap: 12px; margin-top: 12px; }
.team-card { display: block; text-decoration: none; border-radius: 20px; padding: 16px; min-height: 110px; }
.team-card.phys { background-color: #FCFCF7; border: 2px solid #1D2A6B; color: #1D2A6B;
  background-image: linear-gradient(rgba(70,110,200,.13) 1px, transparent 1px), linear-gradient(90deg, rgba(70,110,200,.13) 1px, transparent 1px);
  background-size: 16px 16px; }
.team-card.ai { background: #1E1E1E; color: #D4D4D4; font-family: var(--mono); }
.team-card .tn { font-size: 22px; font-weight: 800; display: block; margin-top: 10px; }
.team-card .tl { font-size: 14px; opacity: .85; }

/* ---------- 404 ---------- */
.tomb { text-align: center; padding-top: 40px; }

/* ---------- admin ---------- */
.adm table { width: 100%; border-collapse: collapse; font-size: 14px; }
.adm td, .adm th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.adm form.box { display: grid; gap: 10px; background: var(--surface); border-radius: 16px; padding: 14px; }
.adm label { display: grid; gap: 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.adm input, .adm select, .adm textarea { font: 16px var(--data-font); padding: 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg); color: var(--data); }
.adm select[multiple] { min-height: 160px; }
.ok { color: #1E7F45; font-weight: 700; } .bad { color: #C0392B; font-weight: 700; }
html[data-world="notebook"][data-theme="dark"] .station.camp .dot { border-color: #F1EFE6; box-shadow: 0 0 0 3px #24332C, 0 0 0 5px #F1EFE6; }
