/* IGD Games Academy — две темы оформления.
   Тема задаётся классом на <html>: t-red (красно-чёрная) или t-cyan (бело-циановая).
   Все цвета — переменные, поэтому страницы не знают, какая тема включена. */

/* Цвета тем — в tokens.css (подключается перед этим файлом). */

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* иначе display: grid/flex у классов перебивает hidden */
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 44px 44px;
  color: var(--text);
  /* --lang-font — Noto для японского, корейского, китайского, хинди (templatetags/igd_i18n.py) */
  font-family: "Exo 2", var(--lang-font, system-ui), system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  transition: background-color .4s ease, color .4s ease;
}
a { color: var(--accent); }
code, pre { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }
h1, h2 { font-family: var(--display); font-weight: var(--display-weight); letter-spacing: .4px; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* Скошенные углы в красной теме, скругления в циановой.
   clip-path режет углы; в циановой теме --cut = 0, и остаётся border-radius. */
.cut {
  border-radius: var(--radius);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}
.cut-sm, .btn, .nav-btn, input, select, textarea, .test, .messages li, .friendly, .banner-ok, .chip {
  border-radius: calc(var(--radius) * .7);
  clip-path: polygon(var(--cut-sm) 0, 100% 0, 100% calc(100% - var(--cut-sm)), calc(100% - var(--cut-sm)) 100%, 0 100%, 0 var(--cut-sm));
}
.t-cyan .chip { border-radius: 99px; }

/* ---------- каркас ---------- */
.layout { display: flex; flex-wrap: wrap; min-height: 100vh; position: relative; z-index: 1; }
.sidebar {
  flex: 1 1 230px; max-width: 100%;
  background: var(--panel); border-inline-end: 1px solid var(--line);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 8px;
}
.t-cyan .sidebar { background: rgba(255, 255, 255, .78); backdrop-filter: blur(12px); }
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 0 6px; margin-bottom: 14px; }
.logo-mark {
  width: 42px; height: 42px; display: grid; place-items: center; flex: none;
  background: var(--accent-strong); color: var(--on-accent);
  font-family: var(--display); font-weight: var(--display-weight); font-size: 15px;
  animation: pulse 2.6s ease-in-out infinite;
}
.logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.logo-text b { font-family: var(--display); font-weight: var(--display-weight); font-size: 17px; color: var(--text); letter-spacing: .5px; }
.logo-text small { color: var(--muted); font-weight: 600; font-size: 12px; }
.nav-btn {
  display: flex; align-items: center; min-height: 42px; padding: 0 14px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  transition: background .2s, color .2s;
}
.nav-btn:hover { color: var(--text); background: var(--panel-2); }
.nav-btn.active { background: var(--accent-strong); color: var(--on-accent); }
.nav-btn.disabled { opacity: .4; pointer-events: none; }
.sidebar .spacer { flex: 1; min-height: 12px; }
.sidebar .who { color: var(--muted); font-size: 13px; text-align: center; margin-bottom: 6px; }
.role-badge {
  display: inline-block; background: var(--panel-2); color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--line); border-radius: 99px;
  padding: 1px 9px; font-size: 12px; font-weight: 700;
}

/* переключатель темы */
.theme-switch { display: flex; gap: 6px; margin-top: 8px; }
.theme-switch button, .motion-toggle {
  flex: 1; min-height: 40px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  background: var(--panel-2); color: var(--muted); border: 0; box-shadow: inset 0 0 0 1px var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: calc(var(--radius) * .7);
}
.theme-switch button[aria-pressed="true"] { background: var(--accent-strong); color: var(--on-accent); box-shadow: none; }
.motion-toggle { width: 100%; margin-top: 6px; flex: none; }
.swatch { width: 11px; height: 11px; flex: none; }
.swatch.red { background: #e0102e; box-shadow: 0 0 0 2px #09090b; }
.swatch.cyan { background: #00b8d4; border-radius: 50%; box-shadow: 0 0 0 2px #ffffff; }

.main { flex: 999 1 560px; min-width: 0; padding: 28px clamp(16px, 3vw, 44px) 56px; }
.panel { background: none; padding: 0; }
.panel-inner { min-height: 70vh; }

/* ---------- кнопки и формы ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: none; border: 0;
  background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line);
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 1px var(--accent); }
.btn.lime { background: var(--accent-strong); color: var(--on-accent); box-shadow: none; }
.btn.lime:hover { box-shadow: 0 0 24px var(--glow); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea {
  font: inherit; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { font-family: "JetBrains Mono", monospace; width: 100%; }
.form-card { max-width: 440px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); padding: 26px; }
.form-card p { display: flex; flex-direction: column; gap: 4px; margin: 0 0 14px; }
.form-card input { width: 100%; }
.helptext, .form-card ul { color: var(--muted); font-size: 12px; }
.errorlist { color: var(--bad); padding-inline-start: 18px; }

.messages { list-style: none; padding: 0; margin: 0 0 18px; }
.messages li { background: var(--panel); box-shadow: inset 3px 0 0 var(--accent-strong), inset 0 0 0 1px var(--line); padding: 10px 14px; margin-bottom: 6px; white-space: pre-line; }
.messages li.warning, .messages li.error { box-shadow: inset 3px 0 0 var(--bad), inset 0 0 0 1px var(--line); }

/* ---------- карточки ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card {
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--line);
  padding: 22px; display: flex; flex-direction: column; gap: 12px;
  border-radius: var(--radius);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  transition: transform .25s ease, box-shadow .25s ease, background .3s ease;
  animation: rise .7s cubic-bezier(.2, .7, .2, 1) both;
}
.grid > .card:nth-child(2) { animation-delay: .07s; }
.grid > .card:nth-child(3) { animation-delay: .14s; }
.grid > .card:nth-child(n+4) { animation-delay: .2s; }
.card:hover { transform: translateY(-3px); background: var(--panel-2); }
.t-cyan .card:hover { box-shadow: inset 0 0 0 1px var(--line), 0 14px 40px rgba(0, 120, 140, .15); }
.card h3 { margin: 0; font-size: 20px; font-weight: 800; }
.card .grow { flex: 1; }
.progress { height: 6px; background: var(--line); overflow: hidden; border-radius: calc(var(--radius) * 2); }
.progress > span {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent), var(--accent-strong));
  background-size: 200% 100%; animation: flow 3s linear infinite;
}
.lock { color: var(--warn); font-weight: 700; }

/* главный экран */
.hero {
  position: relative; overflow: hidden; margin-bottom: 28px;
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--line);
  padding: clamp(24px, 4vw, 48px);
  border-radius: var(--radius);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}
.t-cyan .hero { background: rgba(255, 255, 255, .8); backdrop-filter: blur(10px); box-shadow: inset 0 0 0 1px var(--line), 0 10px 34px rgba(0, 80, 100, .10); }
.hero::after {   /* бегущая полоса-скан */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--accent-strong), transparent);
  animation: scan 4s linear infinite;
}
.hero-inner { position: relative; display: flex; flex-wrap: wrap; gap: 36px; align-items: center; }
.hero-text { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.hero-text p { margin: 0; font-size: 17px; color: var(--muted); max-width: 520px; }
.eyebrow { font-size: 13px; font-weight: 800; letter-spacing: 3px; text-transform: uppercase; color: var(--accent); }
.hero h1 { font-size: clamp(34px, 4.4vw, 52px); line-height: 1.08; margin: 0; }
.shine {
  background: linear-gradient(100deg, var(--text) 0%, var(--text) 38%, var(--accent-strong) 50%, var(--text) 62%, var(--text) 100%);
  background-size: 260% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 6s linear infinite;
}
.code-card {
  flex: 1 1 360px; min-width: 0; background: var(--code-bg); color: var(--code-text); overflow: hidden;
  box-shadow: 0 0 0 1px var(--line), 0 20px 50px rgba(0, 0, 0, .3);
}
.code-card .head { display: flex; justify-content: space-between; gap: 10px; padding: 11px 16px; border-bottom: 1px solid rgba(255, 255, 255, .08); font: 13px "JetBrains Mono", monospace; color: #c9d3d8; }
.code-card pre { margin: 0; padding: 18px 20px; font-size: 15px; line-height: 1.75; white-space: pre-wrap; }
.code-card .kw { color: #ff6b81; }
.t-cyan .code-card .kw { color: #4fd8ec; }
.code-card .fn { color: #ffa36b; }
.t-cyan .code-card .fn { color: #7fe9ff; }
.code-card .cm { color: #8b8b97; }
.caret { display: inline-block; width: 8px; height: 17px; background: var(--rain); vertical-align: -3px; animation: blink 1s steps(1) infinite; }

/* ---------- список задач курса ---------- */
.module { margin-bottom: 24px; }
.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.task-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--line);
  text-decoration: none; color: var(--text);
  border-radius: calc(var(--radius) * .7);
  clip-path: polygon(var(--cut-sm) 0, 100% 0, 100% calc(100% - var(--cut-sm)), calc(100% - var(--cut-sm)) 100%, 0 100%, 0 var(--cut-sm));
  transition: background .2s, transform .15s;
}
.task-item:hover { background: var(--panel-2); transform: translateX(3px); }
.task-item .state { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); flex: none; }
.task-item.solved .state { background: var(--accent-strong); color: var(--on-accent); box-shadow: none; }
.task-item.locked { opacity: .45; pointer-events: none; }

/* ---------- страница задачи ---------- */
.task-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 18px; align-items: start; }
.task-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.box {
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); padding: 16px;
  border-radius: var(--radius);
  clip-path: polygon(var(--cut-sm) 0, 100% 0, 100% calc(100% - var(--cut-sm)), calc(100% - var(--cut-sm)) 100%, 0 100%, 0 var(--cut-sm));
}
.box h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 10px; }
.video { position: relative; padding-top: 56.25%; overflow: hidden; background: #000; border-radius: calc(var(--radius) * .7); }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.theory pre, .hint pre { background: var(--code-bg); color: var(--code-text); padding: 10px 12px; overflow-x: auto; border-radius: calc(var(--radius) * .5); }
.theory code, .hint code { background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); padding: 1px 5px; border-radius: 4px; }
.theory pre code { padding: 0; background: none; box-shadow: none; }
.theory blockquote { margin: 10px 0; padding: 8px 12px; background: var(--warn-bg); color: var(--text); border-radius: calc(var(--radius) * .5); }
.editor-wrap .CodeMirror { height: 340px; font-family: "JetBrains Mono", monospace; font-size: 14px; border-radius: calc(var(--radius) * .5); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.status { font-size: 13px; color: var(--muted); margin-inline-start: auto; }
.status.waiting { color: var(--accent); font-weight: 600; animation: igd-pulse 1.2s ease-in-out infinite; }
@keyframes igd-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .status.waiting { animation: none; } }
.console {
  background: var(--code-bg); color: var(--code-text); padding: 12px; margin: 0;
  font: 13px/1.5 "JetBrains Mono", monospace; white-space: pre-wrap;
  min-height: 70px; max-height: 260px; overflow: auto; border-radius: calc(var(--radius) * .5);
}
.console .err { color: #ff8a80; }
.console .muted { color: #8b9aa3; }
.friendly { background: var(--warn-bg); box-shadow: inset 3px 0 0 var(--warn); padding: 10px 12px; margin-top: 10px; }
.tests { display: grid; gap: 6px; margin-top: 10px; }
.test { background: var(--panel-2); padding: 8px 10px; font-size: 13px; box-shadow: inset 3px 0 0 var(--line); }
.test.ok { box-shadow: inset 3px 0 0 var(--ok); }
.test.fail { box-shadow: inset 3px 0 0 var(--bad); background: var(--bad-bg); }
.test pre { margin: 4px 0 0; font-size: 12px; white-space: pre-wrap; }
.test .err { color: var(--bad); }
.eco-search { margin: 0; }
.eco-top { gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.eco-dialogs { display: grid; gap: 8px; max-width: 760px; }
.eco-dialog {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; text-decoration: none; color: var(--text);
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); border-radius: calc(var(--radius) * .6);
}
.eco-dialog:hover, .eco-dialog.unread { box-shadow: inset 0 0 0 1px var(--accent); }
.eco-dialog-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.eco-dialog-body .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eco-dialog-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.eco-chat-head { margin-bottom: 10px; max-width: 320px; }
.eco-chat { max-width: 760px; height: min(60vh, 560px); overflow-y: auto; display: block; }
#chat-list { display: flex; flex-direction: column; gap: 8px; }
.msg { align-self: flex-start; max-width: 78%; padding: 8px 12px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line);
  border-radius: calc(var(--radius) * .7); }
.msg.mine { align-self: flex-end; background: var(--glow); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg small { display: block; font-size: 11px; margin-top: 2px; text-align: end; }
.eco-chat-form { display: flex; gap: 8px; max-width: 760px; margin-top: 10px; align-items: stretch; }
.eco-chat-form textarea { flex: 1; font-family: inherit; resize: vertical; }
.center { text-align: center; }
.check.eco-reason { display: flex; padding: 4px 0; }
/* галочки и кружки — без скошенных углов и отступов полей ввода */
.check input[type=radio], .check input[type=checkbox] { clip-path: none; padding: 0; width: auto; accent-color: var(--accent-strong); }
.legal-links { font-size: 11px; color: var(--muted); padding: 0 6px; margin: 4px 0; }
.legal-links a { color: var(--muted); }
.legal { max-width: 820px; }
.legal .draft { border-inline-start: 3px solid var(--warn); background: var(--warn-bg); padding: 10px 14px; }
[dir="rtl"] .eco-chat-form textarea.plain { direction: rtl; unicode-bidi: plaintext; }
.eco-actions { justify-content: center; gap: 8px; }
.eco-sub { margin: 8px 0 2px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.eco-person {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; text-decoration: none; color: var(--text);
  background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); border-radius: calc(var(--radius) * .6);
}
.eco-person:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.eco-req { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.eco-req .eco-person { flex: 1 1 140px; }
.eco-found { display: grid; gap: 8px; max-width: 420px; }
.eco-study { margin-top: 18px; }
.eco-study h2 { margin-top: 0; }
.nav-badge {
  margin-inline-start: 8px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: inline-grid; place-items: center; font-size: 12px; font-weight: 800;
  background: var(--accent-strong); color: var(--on-accent);
}
.nav-btn.active .nav-badge { background: var(--on-accent); color: var(--accent-strong); }
.banner-ok { background: var(--ok-bg); box-shadow: inset 0 0 0 1px var(--ok); color: var(--ok); padding: 12px 14px; margin-top: 10px; font-weight: 800; animation: rise .5s ease both; }
.hint { border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 8px; }
details summary { cursor: pointer; font-weight: 700; }

/* ---------- терминал и вкладки ---------- */
.term { background: var(--code-bg); padding: 8px 10px; border-radius: calc(var(--radius) * .5); min-height: 120px; }
.term .xterm { height: 100%; }
/* xterm.js меряет шрифт элементом на left: -9999em; в RTL то, что левее экрана, прокручивается — страница становилась шириной ~140 000 px (нашёл Кай). contain: paint обрезает такие элементы по рамке терминала. */
.xterm { contain: paint; }
.term-tall { min-height: 420px; }
.term-hint { font-size: 12px; margin: 8px 0 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 16px; }
.tab {
  min-height: 42px; padding: 0 18px; font: inherit; font-weight: 700; cursor: pointer; border: 0;
  background: var(--panel); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line);
  border-radius: calc(var(--radius) * .7);
  clip-path: polygon(var(--cut-sm) 0, 100% 0, 100% calc(100% - var(--cut-sm)), calc(100% - var(--cut-sm)) 100%, 0 100%, 0 var(--cut-sm));
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--accent-strong); color: var(--on-accent); box-shadow: none; }

.git-graph { background: var(--code-bg); border-radius: calc(var(--radius) * .5); padding: 6px 4px; min-height: 80px; max-height: 360px; overflow: auto; }
.git-graph p { padding: 10px; color: #8b9aa3; }
.git-graph p code { background: rgba(255,255,255,.08); color: #e8eef1; }

/* ---------- таблицы ---------- */
table { width: 100%; border-collapse: collapse; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.bar { height: 6px; background: var(--line); min-width: 80px; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--bad); }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.chip { display: inline-block; padding: 3px 9px; font-size: 12px; font-weight: 700; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); margin: 2px 2px 2px 0; }
.chip.on { background: var(--accent-strong); color: var(--on-accent); box-shadow: none; }
.chip button { all: unset; cursor: pointer; }

/* ---------- матричный дождь (canvas рисует static/js/theme.js) ---------- */
#matrix { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: var(--rain-opacity); }

/* ---------- анимации ---------- */
@keyframes shine { 0% { background-position: 130% 0; } 100% { background-position: -130% 0; } }
@keyframes scan { 0% { transform: translateY(0); } 100% { transform: translateY(520px); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--glow); } 50% { box-shadow: 0 0 0 7px transparent; } }
@keyframes rise { 0% { opacity: 0; transform: translateY(12px); } 100% { opacity: 1; transform: none; } }
@keyframes flow { 0% { background-position: 0 0; } 100% { background-position: 200% 0; } }
@keyframes blink { 50% { opacity: 0; } }

/* выключатель анимаций и системная настройка «уменьшить движение» */
.no-motion *, .no-motion *::before, .no-motion *::after { animation: none !important; transition: none !important; }
.no-motion #matrix { display: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #matrix { display: none; }
}

@media (max-width: 900px) {
  .sidebar { flex-direction: row; flex-wrap: wrap; border-inline-end: 0; border-bottom: 1px solid var(--line); padding: 12px; }
  .logo { flex: 1 1 100%; margin-bottom: 4px; }
  .nav-btn { flex: 1 1 150px; }
  .sidebar .spacer { display: none; }
  .theme-switch, .motion-toggle, .sidebar .who, .sidebar form, .sidebar > .btn { flex: 1 1 200px; }
  .main { padding: 16px; }
  .task-layout { grid-template-columns: minmax(0, 1fr); }
  table { display: block; overflow-x: auto; }
}

/* ---------- Уголок дизайнеров: пиксель-арт редактор ---------- */
.px-app { display: grid; grid-template-columns: 200px minmax(0, 1fr) 290px; gap: 16px; align-items: start; }
.px-app .box { margin: 0; }
.px-tools { display: flex; flex-direction: column; gap: 6px; }
.px-tools hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.px-sub { font-size: 12px; color: var(--muted); margin: 6px 0 4px; }
.px-tool, .px-toggle {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font: inherit; font-size: 14px; font-weight: 600; text-align: start; cursor: pointer;
  min-height: 34px; padding: 0 10px; color: var(--text);
  background: var(--panel-2); border: 0; box-shadow: inset 0 0 0 1px var(--line);
}
.px-toggle { font-size: 13px; min-height: 32px; }
.px-tool:hover, .px-toggle:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.px-tool[aria-pressed="true"], .px-toggle[aria-pressed="true"] { background: var(--accent-strong); color: var(--on-accent); box-shadow: none; }
.px-tool kbd, .term-hint kbd {
  font-family: ui-monospace, monospace; font-size: 11px; padding: 1px 6px;
  border-radius: 4px; background: rgba(127, 127, 127, .18); color: inherit;
}
.px-pair { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.px-zoom { min-width: 36px; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.px-center { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.px-optbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; font-size: 13px; }
.px-optbar label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.px-optbar select { padding: 4px 6px; }
.px-refbox { display: inline-flex; align-items: center; gap: 6px; }
.px-touch-only { display: none; }
@media (pointer: coarse) { .px-touch-only { display: flex; } }
.px-stage-box { padding: 12px; min-width: 0; }
.px-stage {
  display: flex; overflow: auto; height: clamp(300px, 62vh, 680px); padding: 16px; touch-action: none;  /* высота постоянная: при щипке ничего не прыгает */
  background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line);
}
.px-wrap {
  position: relative; margin: auto; flex: none; cursor: crosshair; line-height: 0;
  background: repeating-conic-gradient(#c7c7cc 0 25%, #f2f2f4 0 50%) 0 0 / 16px 16px;  /* шахматка = прозрачность */
  box-shadow: 0 0 0 1px var(--line);
}
.px-wrap[data-tool="picker"] { cursor: copy; }
.px-wrap[data-tool="fill"] { cursor: cell; }
.px-wrap[data-tool="select"] { cursor: default; }
.px-wrap[data-pan] { cursor: grab; }
.px-wrap canvas { position: absolute; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; }
#px-onion, #px-ref, #px-grid { pointer-events: none; }
.px-statusbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
#px-msg { color: var(--accent); }
.px-timeline { padding: 12px; }
.px-timeline-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.px-timeline-head h3 { margin: 0 6px 0 0; }
.px-dur { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-left: auto; }
.px-dur input { width: 74px; padding: 4px 6px; }
.px-frames { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.px-frame {
  position: relative; flex: none; width: 52px; height: 52px; padding: 3px; border: 0; cursor: pointer;
  background: repeating-conic-gradient(#c7c7cc 0 25%, #f2f2f4 0 50%) 0 0 / 8px 8px; box-shadow: inset 0 0 0 1px var(--line);
}
.px-frame canvas { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; display: block; }
.px-frame span { position: absolute; right: 2px; bottom: 1px; font-size: 10px; font-weight: 700; color: #fff; text-shadow: 0 0 3px #000; }
.px-frame.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.px-frame.playing { outline: 2px solid #00e436; }
.px-side { display: flex; flex-direction: column; gap: 16px; }
.px-current { display: flex; align-items: center; gap: 8px; }
.px-big { width: 42px; height: 42px; flex: none; border: 0; cursor: pointer; box-shadow: inset 0 0 0 1px var(--line), 0 0 0 2px var(--panel); }
#px-primary { outline: 2px solid var(--accent); outline-offset: 2px; }
.px-hex { width: 90px; margin-left: auto; font-family: ui-monospace, monospace; padding: 6px 8px; }
.px-modes { display: flex; gap: 6px; margin: 10px 0 6px; }
.px-slider { display: grid; grid-template-columns: 16px 1fr 44px; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 4px 0; }
.px-slider b { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.px-slider input[type="range"] { width: 100%; height: 12px; -webkit-appearance: none; appearance: none; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line); }
.px-slider input.px-hue { background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.px-slider input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 18px; border-radius: 3px; background: #fff; box-shadow: 0 0 0 1px #000; }
.px-slider input[type="range"]::-moz-range-thumb { width: 14px; height: 18px; border-radius: 3px; background: #fff; border: 1px solid #000; }
.px-readout { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace; margin-top: 6px; }
.px-palrow { margin-bottom: 8px; }
.px-palette { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.px-swatch { aspect-ratio: 1; min-width: 22px; border: 0; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .35); }
.px-swatch:hover { transform: scale(1.12); }
.px-swatch.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.px-big.transparent, .px-swatch.transparent { background: repeating-conic-gradient(#c7c7cc 0 25%, #f2f2f4 0 50%) 0 0 / 10px 10px; }
#px-transparent { width: 30px; height: 30px; flex: none; margin-left: auto; }
.px-note { font-size: 12px; grid-column: 1 / -1; margin: 0; }
.px-layers { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.px-layer { display: flex; align-items: center; gap: 6px; padding: 4px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; }
.px-layer.on { box-shadow: inset 0 0 0 2px var(--accent); }
.px-eye { width: 30px; height: 28px; border: 0; background: none; color: var(--text); cursor: pointer; font-size: 15px; }
.px-lname { flex: 1; min-width: 0; padding: 4px 6px; background: transparent; border: 0; color: var(--text); font: inherit; font-size: 13px; }
.px-lname:focus { background: var(--panel); outline: 1px solid var(--accent); }
.px-previews { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.px-previews figure { margin: 0; text-align: center; }
.px-previews canvas, .px-tilecanvas { display: block; image-rendering: pixelated; max-width: 100%; background: repeating-conic-gradient(#c7c7cc 0 25%, #f2f2f4 0 50%) 0 0 / 8px 8px; }
.px-previews figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.px-num { width: 64px; padding: 5px 6px; }
.px-file { position: relative; overflow: hidden; }
.px-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.px-keys { margin-top: 12px; }
.studio-tabs { margin-bottom: 14px; }
.px-quickpal { display: none; gap: 4px; overflow-x: auto; margin-top: 8px; padding-bottom: 2px; }
.px-quickpal .px-swatch { flex: none; width: 44px; height: 44px; }
@media (pointer: coarse), (max-width: 760px) { .px-quickpal { display: flex; } }
@media (pointer: coarse) {
  .px-app .btn.small, .px-tool, .px-toggle, .px-eye { min-height: 44px; min-width: 44px; }
  .px-app select, .px-app input[type="number"], .px-hex { min-height: 44px; }
  .px-swatch { min-width: 44px; min-height: 44px; }
  .px-big, #px-transparent { width: 48px; height: 48px; }
}
@media (max-width: 1280px) {
  .px-app { grid-template-columns: 168px minmax(0, 1fr); }
  .px-side { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
}
@media (max-width: 760px) {
  .px-app { grid-template-columns: minmax(0, 1fr); }
  .px-tools { flex-direction: row; flex-wrap: wrap; }
  .px-tools h3, .px-tools hr, .px-tools .px-sub { display: none; }
  .px-tool kbd, .px-keys { display: none; }
  .px-dur { margin-left: 0; }
}

/* задание курса пиксель-арта */
.pxt-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.pxt-layout .box { margin: 0; }
.pxt-side { display: flex; flex-direction: column; gap: 16px; }
.pxt-theory { max-height: 640px; overflow: auto; }
.pxt-target { display: block; max-width: 100%; image-rendering: pixelated; background: repeating-conic-gradient(#c7c7cc 0 25%, #f2f2f4 0 50%) 0 0 / 12px 12px; }
.pxt-note { font-size: 12px; margin: 8px 0 0; }
.pxt-got { font-size: 12px; margin-top: 2px; }
.px-example { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 12px 0; }
.px-example img { image-rendering: pixelated; image-rendering: crisp-edges; max-width: 100%; height: auto; background: repeating-conic-gradient(#c7c7cc 0 25%, #f2f2f4 0 50%) 0 0 / 10px 10px; }
.px-example figcaption { flex-basis: 100%; font-size: 13px; color: var(--muted); }
.px-example-error { color: var(--accent); }
@media (max-width: 980px) { .pxt-layout { grid-template-columns: minmax(0, 1fr); } }

/* векторный редактор */
.vec-svg { display: block; margin: auto; flex: none; background: #fff; box-shadow: 0 0 0 1px var(--line); touch-action: none; cursor: default; }
.vec-svg[data-tool="rect"], .vec-svg[data-tool="ellipse"], .vec-svg[data-tool="line"], .vec-svg[data-tool="pen"] { cursor: crosshair; }
.vec-svg [data-id] { cursor: move; }
.vec-box { fill: none; stroke: #29adff; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.vec-grip { fill: #fff; stroke: #29adff; cursor: nwse-resize; }
.vec-grip[data-grip="n"], .vec-grip[data-grip="s"] { cursor: ns-resize; }
.vec-grip[data-grip="e"], .vec-grip[data-grip="w"] { cursor: ew-resize; }
.vec-grip[data-grip="ne"], .vec-grip[data-grip="sw"] { cursor: nesw-resize; }
.vec-node { fill: #fff; stroke: #e0102e; cursor: move; }
.vec-handle { fill: #29adff; stroke: #fff; cursor: pointer; }
.vec-hline { stroke: #29adff; pointer-events: none; }
.vec-marquee { fill: rgba(41, 173, 255, .12); stroke: #29adff; pointer-events: none; }
.vec-code { width: 100%; min-height: 160px; margin-top: 10px; font: 12px/1.5 ui-monospace, monospace; background: var(--code-bg, #111); color: var(--code-text, #ddd); border: 1px solid var(--line); padding: 10px; resize: vertical; }
.vec-props { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; font-size: 13px; color: var(--muted); }
.vec-props input[type="color"] { width: 44px; height: 32px; padding: 0; border: 0; background: none; cursor: pointer; }
.vec-span2 { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
@media (pointer: coarse) {
  .px-lname { min-height: 44px; }
  .vec-props input[type="color"], #vec-bgcolor { width: 52px; height: 44px; }
}

/* Телефон: длинный `код` в тексте урока переносится, колонки сетки не растягивают страницу шире экрана
   (min-width: 0 — элемент сетки по умолчанию не уже своего содержимого, отсюда горизонтальная прокрутка) */
.theory :not(pre) > code, .hint :not(pre) > code { overflow-wrap: anywhere; }
.theory, .hint { overflow-wrap: break-word; min-width: 0; }
.task-layout > *, .task-col > * { min-width: 0; }
.tabs { flex-wrap: wrap; }

/* ===== Главная (вошедший) и личный кабинет ===== */
.small { font-size: 12px; }
.dash { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: stretch; margin: 8px 0 26px; }
.dash-hello { display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.dash-hello h1 { margin: 0; font-size: clamp(28px, 3.4vw, 40px); overflow-wrap: anywhere; }
.level-line { display: grid; grid-template-columns: auto minmax(60px, 1fr) auto; gap: 10px; align-items: center; font-size: 14px; }
.level-line .progress { height: 8px; }
.stat-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; justify-content: center; }
.stat b { font-family: var(--display); font-weight: var(--display-weight); font-size: 26px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.hot b { color: var(--accent); }
.stat.hot b::after { content: " 🔥"; font-size: 18px; }
.continue { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; background: var(--panel); color: var(--text); text-decoration: none;
            box-shadow: inset 0 0 0 1px var(--line), 0 0 0 0 var(--glow); border-radius: var(--radius); transition: box-shadow .2s, transform .2s; }
.continue:hover { box-shadow: inset 0 0 0 1px var(--accent), 0 0 24px var(--glow); transform: translateY(-2px); }
.continue b { font-size: 18px; }

.home-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.feed-item { background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--radius); padding: 14px 16px; border-inline-start: 3px solid var(--line); }
.feed-item.kind-course { border-inline-start-color: var(--accent-strong); }
.feed-item.kind-update { border-inline-start-color: var(--ok); }
.feed-item.kind-event { border-inline-start-color: var(--warn); }
.feed-item.pinned { box-shadow: inset 0 0 0 1px var(--accent); }
.feed-item h3 { margin: 6px 0 4px; font-size: 17px; }
.feed-item h3 a { color: var(--text); text-decoration: none; }
.feed-item h3 a:hover { color: var(--accent); }
.feed-meta { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }
.feed-body { color: var(--muted); font-size: 14px; }
.feed-body p { margin: 0; }
.course-list { display: flex; flex-direction: column; gap: 8px; }
.course-row { display: flex; flex-direction: column; padding: 10px 14px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line);
              border-radius: var(--radius); color: var(--text); text-decoration: none; transition: background .2s; }
.course-row:hover { background: var(--panel-2); }
.course-row .muted { font-size: 13px; }

.profile-head { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 340px); gap: 20px; align-items: center; margin: 8px 0 22px; }
.avatar { width: 84px; height: 84px; display: grid; place-items: center; background: var(--accent-strong); color: var(--on-accent);
          font-family: var(--display); font-size: 40px; border-radius: var(--radius); }
.profile-id { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.profile-id h1 { margin: 0; overflow-wrap: anywhere; }
.profile-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }

.radar-wrap { max-width: 400px; margin: 0 auto; }
.radar { width: 100%; height: auto; display: block; overflow: visible; }
.radar-ring { fill: none; stroke: var(--line); stroke-width: 1; }
.radar-ring.outer { stroke-width: 1.5; }
.radar-axis { stroke: var(--line); stroke-width: 1; }
.radar-area { fill: var(--glow); stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.radar-dot { fill: var(--accent); }
.radar-label { fill: var(--text); font-size: 13px; font-weight: 700; }
.radar-pct { fill: var(--muted); font-weight: 600; font-size: 12px; }
@media (prefers-reduced-motion: no-preference) {
  .radar-area { transform-origin: 200px 200px; animation: radar-grow .8s cubic-bezier(.2, .8, .2, 1) both; }
}
@keyframes radar-grow { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.skill-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.skill-list li { display: grid; grid-template-columns: 96px minmax(40px, 1fr) 110px; gap: 10px; align-items: center; font-size: 14px; }
.skill-list .muted { font-size: 12px; text-align: end; }

.heat { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat-col, .heat-days { display: grid; grid-template-rows: repeat(7, 12px); gap: 3px; }
.heat-days span { font-size: 9px; line-height: 12px; color: var(--muted); width: 18px; }
.heat-cell { display: inline-block; width: 12px; height: 12px; border-radius: 2px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }
.heat-cell.l1 { background: color-mix(in srgb, var(--accent-strong) 30%, var(--panel-2)); box-shadow: none; }
.heat-cell.l2 { background: color-mix(in srgb, var(--accent-strong) 55%, var(--panel-2)); box-shadow: none; }
.heat-cell.l3 { background: color-mix(in srgb, var(--accent-strong) 80%, var(--panel-2)); box-shadow: none; }
.heat-cell.l4 { background: var(--accent-strong); box-shadow: 0 0 6px var(--glow); }
.heat-cell.future { visibility: hidden; }
.heat-legend { display: flex; gap: 3px; align-items: center; margin-top: 6px; }
.recent { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
/* subgrid: все строки — колонки одной сетки, поэтому полосы прогресса одинаковой длины */
.my-courses { display: grid; grid-template-columns: minmax(120px, 220px) minmax(60px, 1fr) auto auto; column-gap: 12px; }
.my-course { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center;
             padding: 8px 0; border-top: 1px solid var(--line); }
.my-course:first-child { border-top: 0; }
.my-course .btn { justify-self: end; }

@media (max-width: 900px) {
  .dash, .home-cols, .profile-grid { grid-template-columns: minmax(0, 1fr); }
  .profile-head { grid-template-columns: auto minmax(0, 1fr); }
  .profile-head .stat-tiles { grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .my-courses { grid-template-columns: minmax(0, 1fr) auto; }
  .my-course { grid-template-columns: subgrid; }
  .my-course .progress { grid-column: 1 / -1; grid-row: 2; }
  .my-course .btn, .my-course .chip { grid-column: 1 / -1; justify-self: start; }
}
@media (max-width: 480px) {
  .profile-head .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .skill-list li { grid-template-columns: 80px minmax(30px, 1fr) 92px; }
}


/* Переключатель языка (боковая панель) */
.lang-switch { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: center; margin-bottom: 10px; }
.lang-label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.lang-switch select { width: 100%; padding: 6px 8px; font: inherit; font-size: 14px; background: var(--panel-2); color: var(--text);
                      border: 0; box-shadow: inset 0 0 0 1px var(--line); border-radius: calc(var(--radius) * .5); }
.lang-switch noscript { grid-column: 1 / -1; }
/* В CJK и деванагари нет заглавных — разрядка для «ЗАГОЛОВКОВ» им только мешает */
:lang(ja) .eyebrow, :lang(ko) .eyebrow, :lang(zh-hant) .eyebrow, :lang(hi) .eyebrow,
:lang(ja) .box h3, :lang(ko) .box h3, :lang(zh-hant) .box h3, :lang(hi) .box h3 { letter-spacing: .5px; }

/* пометка о переводе урока */
.content-note { margin: 0 0 12px; padding: 8px 12px; border-inline-start: 3px solid var(--accent, #e11d48); background: rgba(127,127,127,.08); font-size: .9em; }

/* ---------- письмо справа налево (иврит): <html dir="rtl"> ставит base.html ----------
   Раскладка уже на логических свойствах (margin-inline-start и т. п.) и flex — они зеркалятся сами.
   Код, терминал, вывод программ и редакторы остаются слева направо: программа читается слева направо на любом языке. */
[dir="rtl"] .task-item:hover { transform: translateX(-3px); }
[dir="rtl"] pre, [dir="rtl"] code, [dir="rtl"] kbd, [dir="rtl"] samp,
[dir="rtl"] textarea, [dir="rtl"] .xterm, [dir="rtl"] .term, [dir="rtl"] .CodeMirror, [dir="rtl"] .git-graph,
[dir="rtl"] #pixel-app, [dir="rtl"] #vector-app, [dir="rtl"] .ltr { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] pre, [dir="rtl"] textarea { text-align: left; }
/* Текст курсов и новостей, у которого ещё нет перевода на иврит, — по-русски или по-английски. Направление такого абзаца
   браузер берёт по его первой «сильной» букве: кириллица и латиница идут слева направо, иврит — справа налево. */
[dir="rtl"] :is(p, li, h2, h3, h4, td, th, summary, blockquote, figcaption, .muted, .card-title) { unicode-bidi: plaintext; text-align: start; }
/* стрелки «назад/вперёд» в шаблонах (<span class="arr">←</span>): в RTL «назад» смотрит вправо */
[dir="rtl"] .arr { display: inline-block; transform: scaleX(-1); }

/* ---------- Эко-система: профиль ---------- */
.eco-card {
  display: grid; gap: 18px; padding: 22px;
  grid-template-columns: minmax(220px, 1.2fr) minmax(200px, 1fr) minmax(160px, .8fr);
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--radius);
}
.eco-main { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.eco-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.eco-name h1 { margin: 0; }
.eco-bio { margin: 0; max-width: 36ch; }
.avatar-img { width: var(--s, auto); border-radius: 50%; object-fit: cover; flex: none; box-shadow: 0 0 0 3px var(--line); }
.avatar-letter {
  display: grid; place-items: center; width: var(--s); height: var(--s);
  background: var(--accent-strong); color: var(--on-accent); font-family: var(--display); font-size: calc(var(--s) * .42);
}
.eco-friends, .eco-links { display: flex; flex-direction: column; gap: 8px; }
.eco-friends h2 { margin: 0 0 4px; font-size: 18px; }
.eco-link {
  display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; text-decoration: none; color: var(--text);
  background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); border-radius: calc(var(--radius) * .6);
  overflow-wrap: anywhere;
}
.eco-link:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.eco-link span { color: var(--accent); font-size: 13px; }
.eco-form { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.eco-form h3 { margin-top: 0; }
.eco-form textarea.plain { font-family: inherit; }
.eco-contacts { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; gap: 8px 10px; align-items: center; }
.eco-err { grid-column: 1 / -1; margin: -4px 0 4px; }
.err { color: var(--bad); }
.eco-search { margin: 0; }
.eco-top { gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.eco-dialogs { display: grid; gap: 8px; max-width: 760px; }
.eco-dialog {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; text-decoration: none; color: var(--text);
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); border-radius: calc(var(--radius) * .6);
}
.eco-dialog:hover, .eco-dialog.unread { box-shadow: inset 0 0 0 1px var(--accent); }
.eco-dialog-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.eco-dialog-body .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eco-dialog-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.eco-chat-head { margin-bottom: 10px; max-width: 320px; }
.eco-chat { max-width: 760px; height: min(60vh, 560px); overflow-y: auto; display: block; }
#chat-list { display: flex; flex-direction: column; gap: 8px; }
.msg { align-self: flex-start; max-width: 78%; padding: 8px 12px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line);
  border-radius: calc(var(--radius) * .7); }
.msg.mine { align-self: flex-end; background: var(--glow); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg small { display: block; font-size: 11px; margin-top: 2px; text-align: end; }
.eco-chat-form { display: flex; gap: 8px; max-width: 760px; margin-top: 10px; align-items: stretch; }
.eco-chat-form textarea { flex: 1; font-family: inherit; resize: vertical; }
.center { text-align: center; }
.check.eco-reason { display: flex; padding: 4px 0; }
/* галочки и кружки — без скошенных углов и отступов полей ввода */
.check input[type=radio], .check input[type=checkbox] { clip-path: none; padding: 0; width: auto; accent-color: var(--accent-strong); }
.legal-links { font-size: 11px; color: var(--muted); padding: 0 6px; margin: 4px 0; }
.legal-links a { color: var(--muted); }
.legal { max-width: 820px; }
.legal .draft { border-inline-start: 3px solid var(--warn); background: var(--warn-bg); padding: 10px 14px; }
[dir="rtl"] .eco-chat-form textarea.plain { direction: rtl; unicode-bidi: plaintext; }
.eco-actions { justify-content: center; gap: 8px; }
.eco-sub { margin: 8px 0 2px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.eco-person {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; text-decoration: none; color: var(--text);
  background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); border-radius: calc(var(--radius) * .6);
}
.eco-person:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.eco-req { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.eco-req .eco-person { flex: 1 1 140px; }
.eco-found { display: grid; gap: 8px; max-width: 420px; }
.eco-study { margin-top: 18px; }
.eco-study h2 { margin-top: 0; }
.nav-badge {
  margin-inline-start: 8px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: inline-grid; place-items: center; font-size: 12px; font-weight: 800;
  background: var(--accent-strong); color: var(--on-accent);
}
.nav-btn.active .nav-badge { background: var(--on-accent); color: var(--accent-strong); }
.check { display: inline-flex; gap: 6px; align-items: center; }
@media (max-width: 900px) {
  .eco-card { grid-template-columns: minmax(0, 1fr); }
  .eco-contacts { grid-template-columns: minmax(0, 1fr); }
}

/* «О себе» — обычный текст, а не код: в RTL пишется справа налево (общее правило выше делает textarea ltr) */
[dir="rtl"] .eco-form textarea.plain { direction: rtl; unicode-bidi: plaintext; }

/* ---------- достижения и рейтинг друзей (эко-система, этап 5) ---------- */
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 8px 0 18px; }
.ach-grid.compact { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.ach {
  display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--radius); border-inline-start: 3px solid var(--line);
}
.ach-icon { font-size: 26px; line-height: 1; flex: none; width: 34px; text-align: center; }
.ach-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ach-text small { font-size: 12px; }
.ach-text .progress { margin-top: 4px; }
.ach-bronze { border-inline-start-color: #c07a3e; }
.ach-silver { border-inline-start-color: #9aa7b4; }
.ach-gold { border-inline-start-color: #e2b33c; }
.ach.locked { opacity: .62; }
.ach.locked .ach-icon { filter: grayscale(1); }
.ach-news { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ach-news li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.ach-news .eco-person { flex: 0 1 auto; }
.ach-news-text { flex: 1 1 180px; }
.tabs-row { gap: 8px; margin: 6px 0 14px; }
.rating { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; max-width: 640px; }
.rating-row { display: flex; align-items: center; gap: 12px; padding: 6px 10px; background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line); border-radius: var(--radius); }
.rating-row.me { box-shadow: inset 0 0 0 2px var(--accent); }
.rating-row .eco-person { flex: 1; min-width: 0; box-shadow: none; background: transparent; }
.rating-place { font-family: var(--display); font-weight: var(--display-weight); font-size: 20px; width: 2ch; text-align: center; flex: none; }
.rating-row.top1 .rating-place { color: #e2b33c; }
.rating-row.top2 .rating-place { color: #9aa7b4; }
.rating-row.top3 .rating-place { color: #c07a3e; }
.rating-xp { flex: none; white-space: nowrap; }
/* всплывашка «Новое достижение» (static/js/achievements.js) */
.ach-toasts { position: fixed; inset-block-end: 16px; inset-inline-end: 16px; display: grid; gap: 8px; z-index: 50;
  max-width: min(340px, calc(100vw - 32px)); }
.ach-toast, .ach-toast:hover { text-decoration: none; color: var(--text); }
.ach-toast { box-shadow: 0 8px 30px rgba(0,0,0,.35), inset 0 0 0 1px var(--accent); animation: ach-in .35s ease-out; }
.ach-toast .ach-text b::before { content: attr(data-kicker); display: block; font-size: 11px; color: var(--accent);
  text-transform: uppercase; letter-spacing: .6px; }
@keyframes ach-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.no-motion .ach-toast { animation: none; }
@media (prefers-reduced-motion: reduce) { .ach-toast { animation: none; } }

/* ---------- связи и группы (эко-система, этап 5.2) ---------- */
.tie-chips { justify-content: center; gap: 6px; }
.tie-chips .chip { text-decoration: none; color: inherit; }
.tie-chips .chip.on { color: var(--on-accent); }
.tie-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; max-width: 520px; }
.tie-box > .muted.small { flex-basis: 100%; text-align: center; margin: 0; }
.tie-details > summary { list-style: none; cursor: pointer; }
.tie-details > summary::-webkit-details-marker { display: none; }
.tie-details[open] > summary { box-shadow: inset 0 0 0 1px var(--accent); }
.tie-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.tie-what { flex: 1 1 160px; }
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.group-card { display: flex; flex-direction: column; gap: 4px; padding: 12px; background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line); text-decoration: none; color: var(--text); }
.group-card:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.group-card b { font-size: 17px; }
.group-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.group-head h1 { margin: 0; }
.together-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.run-prog { display: flex; flex-direction: column; gap: 4px; min-width: 110px; flex: 0 1 180px; }
/* только для экранного диктора: подпись поля есть, но на экране её не видно */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0; }
.clan-new { margin-bottom: 14px; }
.empire-steps { margin: 0 0 8px; padding-inline-start: 22px; display: grid; gap: 6px; }
.empire-steps li.done { color: var(--muted); }

/* этап 5.4: рейды на боссов */
.boss-list { display: grid; gap: 14px; }
.boss-card { display: flex; gap: 16px; align-items: flex-start; }
.boss-card h1, .boss-card h2 { margin-top: 0; }
.boss-icon { font-size: 56px; line-height: 1; flex: none; filter: drop-shadow(0 0 10px var(--accent-strong)); }
.boss-main { flex: 1; min-width: 0; }
.boss-hp { height: 14px; background: var(--line); overflow: hidden; border-radius: calc(var(--radius) * 2); margin-top: 8px; }
.boss-hp > span { display: block; height: 100%; background: var(--bad); transition: width .6s ease; }
.boss-dead .boss-icon { filter: grayscale(1); opacity: .5; }
.raid-form fieldset { border: 0; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.raid-form legend { font-weight: 700; margin-bottom: 4px; }
.raid-hit { margin: 4px 0; }
@media (max-width: 480px) { .boss-icon { font-size: 40px; } .boss-card { gap: 10px; } }

/* этап 6: монеты и мини-игры */
.wallet { direction: ltr; unicode-bidi: isolate; display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; font-weight: 800; }
.coin { display: inline-flex; align-items: center; gap: 4px; }
.coin i { display: inline-block; width: 1em; height: 1em; border-radius: 50%; flex: none;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25), inset 0 2px 0 rgba(255, 255, 255, .35); }
.coin-gold i { background: radial-gradient(circle at 35% 30%, #fff3b0, #e2b33c 45%, #a8781a); }
.coin-silver i { background: radial-gradient(circle at 35% 30%, #ffffff, #c3c9d1 45%, #7d8590); }
.coin-copper i { background: radial-gradient(circle at 35% 30%, #ffd2b0, #c56f3c 45%, #7d3f1c); }
.stat-wallet { text-decoration: none; color: inherit; }
.stat-wallet b { font-size: 18px; }
.wallet-big { font-size: 28px; margin: 6px 0; }
.coin-log { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; }
.coin-log li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.coin-log li b { margin-inline-start: auto; }
.game-card { text-decoration: none; color: inherit; }
.game-card:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.ty-head { align-items: center; gap: 12px; flex-wrap: wrap; }
.ty-timer { font-family: var(--display); font-size: 34px; min-width: 2ch; margin-inline-start: auto; }
.ty-text { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 19px; line-height: 1.7; max-height: 10.5em; overflow: hidden;
  padding: 12px; margin: 12px 0; background: var(--panel-2); border-radius: var(--radius); white-space: pre-wrap; word-break: break-word; }
.ty-text .ok { color: var(--ok); }
.ty-text .bad { color: var(--bad); background: var(--bad-bg); text-decoration: underline; }
.ty-text .cur { box-shadow: inset 0 -3px 0 var(--accent); }
.ty-input { width: 100%; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 17px; }
#typing-app .ty-text[dir="rtl"], #typing-app .ty-input[dir="rtl"] { direction: rtl; }
@media (max-width: 480px) { .ty-text { font-size: 16px; } .ty-timer { font-size: 26px; } }
.invite-row { gap: 8px; flex-wrap: nowrap; }
.invite-row input { flex: 1; min-width: 0; }

/* батл-пасс */
.pass-bar { height: 16px; }
.pass-bar > span { background: var(--accent-strong); }
.quest-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.quest-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel-2); border-radius: var(--radius); }
.quest-list li b { margin-inline-start: auto; }
.quest-list li.done { box-shadow: inset 0 0 0 1px var(--ok); }
.quest-list li.done b { color: var(--ok); }
.quest-icon { font-size: 20px; }
.pass-track { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.pass-node { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 8px; background: var(--panel-2);
  border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--line); opacity: .6; text-align: center; }
.pass-node.reached { opacity: 1; box-shadow: inset 0 0 0 2px var(--accent); }
.pass-node.claimed { opacity: .85; box-shadow: inset 0 0 0 1px var(--ok); }
.pass-lvl { font-family: var(--display); font-size: 24px; }
.pass-prize .wallet { justify-content: center; }
.pass-node.just { animation: pass-pop .7s ease both; }
@keyframes pass-pop { 0% { transform: scale(.85); } 60% { transform: scale(1.08); box-shadow: 0 0 28px var(--glow); } 100% { transform: scale(1); } }
.no-motion .pass-node.just { animation: none; }
@media (prefers-reduced-motion: reduce) { .pass-node.just { animation: none; } }

/* магазин: рамки, цвет ника, титулы, значки (games/shop.py) */
.person-name { display: inline-flex; flex-direction: column; min-width: 0; }
.nick-title { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .02em; }
.nick-title.big { font-size: 14px; margin: 2px 0 0; color: var(--accent); }
.ava-frame { position: relative; display: inline-flex; border-radius: 50%; flex: none; }
.ava-frame.fr-pixel .avatar-img { border-radius: 6px; box-shadow: 0 0 0 3px var(--accent), 4px 4px 0 3px var(--line); }
.ava-frame.fr-neon .avatar-img { box-shadow: 0 0 0 2px var(--accent), 0 0 14px 4px var(--glow); }
.ava-frame.fr-fire::before { content: ""; position: absolute; inset: -4px; border-radius: 50%;
  background: conic-gradient(#ff3d00, #ffb300, #ff6d00, #ffea00, #ff3d00); animation: fr-spin 2.4s linear infinite; }
.ava-frame.fr-fire .avatar-img { position: relative; box-shadow: none; }
.ava-frame.fr-crown .avatar-img { box-shadow: 0 0 0 3px #e2b33c, 0 0 10px 2px rgba(226, 179, 60, .5); }
.ava-frame.fr-crown::after { content: "👑"; position: absolute; top: -.75em; left: 50%; transform: translateX(-50%) rotate(-12deg);
  font-size: clamp(14px, 40%, 44px); line-height: 1; }
.ava-frame.big.fr-crown { margin-top: 34px; }
.ava-frame.big.fr-crown::after { font-size: 46px; top: -40px; }
@keyframes fr-spin { to { transform: rotate(360deg); } }
.no-motion .ava-frame.fr-fire::before, .no-motion .nick.nk-rainbow { animation: none; }
@media (prefers-reduced-motion: reduce) { .ava-frame.fr-fire::before, .nick.nk-rainbow { animation: none; } }
.nick.nk-red { color: #e8344a; } .nick.nk-orange { color: #f07b16; } .nick.nk-gold { color: #d9a21b; }
.nick.nk-green { color: #22a85a; } .nick.nk-cyan { color: #10a7bb; } .nick.nk-blue { color: #4a78f0; }
.nick.nk-violet { color: #9a5cf5; } .nick.nk-pink { color: #e9549f; }
.nick.nk-rainbow { background: linear-gradient(90deg, #ff4d5e, #f5c542, #4cd97b, #3ad0e0, #a66bff, #ff4d5e);
  background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: nk-flow 4s linear infinite; }
@keyframes nk-flow { to { background-position: 300% 0; } }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.shop-item { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 10px; text-align: center;
  background: var(--panel-2); border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--line); }
.shop-item.worn { box-shadow: inset 0 0 0 2px var(--ok); }
.shop-item.locked { opacity: .6; }
.shop-preview { min-height: 64px; display: grid; place-items: center; padding-top: 8px; }
.shop-preview .nick { font-size: 18px; overflow-wrap: anywhere; }
.shop-badge { font-size: 34px; }
.shop-name { font-weight: 700; font-size: 13px; }
.shop-buy summary { list-style: none; cursor: pointer; }
.shop-buy summary::-webkit-details-marker { display: none; }
.shop-buy[open] summary { display: none; }
.shop-buy form { display: grid; gap: 6px; justify-items: center; }
.shop-buy p { margin: 0; }
.coin-spent { color: var(--muted); }

/* батл-пасс: ряд для подписчиков и вещи только из него */
.pass-premium { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; margin-top: 4px; padding-top: 8px;
  border-top: 1px dashed var(--line); }
.pass-premium.claimed { opacity: .85; }
.pass-pro { font-size: 11px; font-weight: 800; letter-spacing: .06em; color: #7fd8ff; }
.small-badge { font-size: 24px; }
.pass-sub summary { cursor: pointer; font-weight: 700; }
.pass-sub .paywall { margin-top: 10px; }
.nick.nk-aurora { background: linear-gradient(90deg, #3ad0e0, #4cd97b, #a66bff, #3ad0e0); background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: nk-flow 6s linear infinite; }
.ava-frame.fr-star .avatar-img { box-shadow: 0 0 0 3px #7fd8ff, 0 0 0 6px rgba(127, 216, 255, .25), 0 0 18px 4px rgba(127, 216, 255, .45); }
.ava-frame.fr-legend::before { content: ""; position: absolute; inset: -5px; border-radius: 50%;
  background: conic-gradient(#e2b33c, #fff3b0, #a66bff, #3ad0e0, #e2b33c); animation: fr-spin 5s linear infinite; }
.ava-frame.fr-legend .avatar-img { position: relative; box-shadow: none; }
.ava-frame.fr-legend::after { content: "✦"; position: absolute; top: -.6em; right: -.2em; color: #fff3b0; text-shadow: 0 0 6px #e2b33c; }
.no-motion .nick.nk-aurora, .no-motion .ava-frame.fr-legend::before { animation: none; }
@media (prefers-reduced-motion: reduce) { .nick.nk-aurora, .ava-frame.fr-legend::before { animation: none; } }

/* Код-забег: программа слева, трасса справа; на телефоне — друг под другом */
.cr-app { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; margin-top: 12px; }
@media (max-width: 820px) { .cr-app { grid-template-columns: minmax(0, 1fr); } }
.cr-code, .cr-canvas, .cr-stderr, .cr-rules pre { direction: ltr; }
.cr-textarea { width: 100%; min-height: 340px; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 14px;
  background: var(--code-bg); color: var(--code-text); border: 1px solid var(--line); padding: 10px; tab-size: 4; }
.cr-code .CodeMirror { height: 360px; font-family: "JetBrains Mono", monospace; font-size: 14px; border: 1px solid var(--line); }
.cr-buttons { gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.cr-seed { width: 8em; }
.cr-track { padding: 10px; display: grid; gap: 8px; justify-items: center; }
.cr-canvas { width: 100%; max-width: 300px; height: auto; aspect-ratio: 300 / 420; background: var(--code-bg); border: 1px solid var(--line); }
.cr-controls { gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.cr-pos { font-variant-numeric: tabular-nums; min-width: 9ch; }
.cr-result { margin-top: 12px; }
.cr-message.ok { color: var(--ok); font-weight: 700; }
.cr-message.bad { color: var(--bad); font-weight: 700; }
.cr-stderr { max-height: 220px; overflow: auto; white-space: pre-wrap; }
.cr-linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; font: inherit; }

/* подсказка к непрошедшему тесту: что проверяет тест и вид расхождения */
.test-hint { margin: 6px 0 0; font-size: 14px; color: var(--warn); }
.chip.warmup { font-size: 11px; vertical-align: middle; color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }

/* вкладки-ссылки (кабинет: «Обзор | Промокод») — тот же вид, что у кнопок-вкладок */
a.tab { display: inline-flex; align-items: center; text-decoration: none; }
.promo-form input { flex: 1 1 220px; min-width: 0; text-transform: uppercase; font-family: var(--mono, monospace); letter-spacing: .06em; }
.promo-uses { margin: 0; padding-inline-start: 20px; display: grid; gap: 6px; }
.promo-new { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; align-items: end; }
.promo-new label { display: grid; gap: 4px; font-size: 14px; }
.promo-new label.wide { grid-column: 1 / -1; }
.promo-new input, .promo-new select { width: 100%; min-width: 0; }
.promo-new label[hidden] { display: none; }
.table-wrap { overflow-x: auto; }
