/* =================================================================== UGclub
   Стиль в духе UG «Cosmos»: фиолетово-бирюзовый градиент, стеклянные карточки.
   Светлая тема — рассветное небо, тёмная — глубокий космос. */

:root {
  --violet: #7c5cff;
  --violet-d: #6a4bf5;
  --cyan: #22d3ee;
  --grad: linear-gradient(135deg, var(--violet), var(--cyan));
  --accent: var(--violet);
  --radius: 16px;
  --radius-sm: 10px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-head: Montserrat, Inter, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --side-w: 248px;
}

:root[data-theme="light"] {
  --bg: #f4f5ff;
  --card: rgba(255, 255, 255, 0.78);
  --card-solid: #ffffff;
  --surface-2: rgba(124, 92, 255, 0.07);
  --line: rgba(91, 80, 190, 0.16);
  --line-strong: rgba(91, 80, 190, 0.32);
  --text: #12163a;
  --muted: #5c6388;
  --on-accent: #ffffff;
  --accent-soft: rgba(124, 92, 255, 0.12);
  --focus: #6a4bf5;
  --correct: #16a34a;
  --correct-soft: rgba(22, 163, 74, 0.12);
  --wrong: #dc2626;
  --wrong-soft: rgba(220, 38, 38, 0.1);
  --skip: #c2780c;
  --skip-soft: rgba(217, 140, 18, 0.14);
  --flag: #ea580c;
  --code-bg: rgba(18, 22, 58, 0.05);
  --shadow: 0 1px 2px rgba(18, 22, 58, 0.05), 0 16px 40px -20px rgba(76, 60, 180, 0.3);
  --sky: radial-gradient(900px 600px at 10% -10%, rgba(244, 114, 182, 0.14), transparent 60%),
    radial-gradient(800px 600px at 100% 0%, rgba(34, 211, 238, 0.16), transparent 60%),
    radial-gradient(900px 700px at 60% 110%, rgba(124, 92, 255, 0.16), transparent 60%),
    linear-gradient(180deg, #f7f6ff, #eef1ff);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #070a1c;
  --card: rgba(22, 26, 62, 0.62);
  --card-solid: #141834;
  --surface-2: rgba(160, 170, 255, 0.08);
  --line: rgba(160, 170, 255, 0.15);
  --line-strong: rgba(160, 170, 255, 0.3);
  --text: #e9ecff;
  --muted: #9ca5cf;
  --on-accent: #ffffff;
  --accent: #9a84ff;
  --accent-soft: rgba(154, 132, 255, 0.16);
  --focus: #a99bff;
  --correct: #4ade80;
  --correct-soft: rgba(74, 222, 128, 0.13);
  --wrong: #f87171;
  --wrong-soft: rgba(248, 113, 113, 0.13);
  --skip: #fbbf24;
  --skip-soft: rgba(251, 191, 36, 0.13);
  --flag: #fb923c;
  --code-bg: rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 44px -18px rgba(0, 0, 0, 0.7);
  --sky: radial-gradient(900px 600px at 15% 10%, rgba(124, 92, 255, 0.22), transparent 60%),
    radial-gradient(800px 600px at 95% 30%, rgba(34, 211, 238, 0.11), transparent 60%),
    radial-gradient(900px 700px at 50% 120%, rgba(244, 114, 182, 0.12), transparent 60%), #070a1c;
  color-scheme: dark;
}

/* ------------------------------------------------------------------ база */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--sky);
  background-color: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; margin: 0.2rem 0 0.9rem; }
h2 { font-size: 1.2rem; margin: 0 0 0.8rem; }
h3 { font-size: 1.05rem; margin: 0 0 0.5rem; }
.h3 { font-size: 1.05rem; }
a { color: var(--accent); }
code, kbd, pre, .mono { font-family: var(--mono); }
kbd {
  display: inline-block; min-width: 1.5em; padding: 0 0.35em;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px;
  font-size: 0.78em; line-height: 1.5; text-align: center; color: var(--muted); background: var(--card-solid);
}
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.error { color: var(--wrong); }
.notice {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.7rem 1rem; border-radius: var(--radius-sm);
  background: var(--skip-soft); border: 1px solid color-mix(in srgb, var(--skip) 35%, transparent);
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.ic { flex: none; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.view:focus, h1:focus, .q-title:focus, .rv-item:focus { outline: none; }
.rv-item:focus-visible { outline: 3px solid var(--focus); }

/* ------------------------------------------------------------------ каркас */
.layout-app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1.25rem;
  padding: 1.25rem 0.9rem;
  background: linear-gradient(180deg, rgba(14, 12, 44, 0.92), rgba(28, 20, 78, 0.9));
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-right: 1px solid rgba(160, 170, 255, 0.14);
  color: #e9ecff;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: inherit; padding: 0 0.4rem; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--grad); color: #fff; font: 800 1.1rem/1 var(--font-head);
  box-shadow: 0 8px 20px -8px rgba(124, 92, 255, 0.9);
}
.brand-logo { width: 34px; height: 34px; border-radius: 50%; flex: none; }
.brand-name { font: 800 1.25rem/1 var(--font-head); letter-spacing: -0.02em; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 0.8rem; border-radius: 12px;
  color: rgba(233, 236, 255, 0.78); text-decoration: none; font-weight: 500;
}
.side-nav a:hover { background: rgba(160, 170, 255, 0.12); color: #fff; }
.side-nav a.on { background: var(--grad); color: #fff; box-shadow: 0 10px 24px -10px rgba(124, 92, 255, 0.9); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.9rem; }
.side-tools { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.side-user {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem;
  border-radius: 12px; background: rgba(160, 170, 255, 0.08);
}
.side-user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.side-user-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.92rem; }
.side-user-text small { color: rgba(233, 236, 255, 0.6); }
.side-auth { display: grid; gap: 0.5rem; }
.sidebar .btn-ghost { color: rgba(233, 236, 255, 0.85); }
.sidebar .icon-btn { color: rgba(233, 236, 255, 0.8); }
.sidebar .icon-btn:hover { background: rgba(160, 170, 255, 0.14); color: #fff; }
.sidebar .lang-switch { background: rgba(160, 170, 255, 0.1); }
.sidebar .lang-switch button { color: rgba(233, 236, 255, 0.7); }
.sidebar .lang-switch button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.16); color: #fff; }

.avatar {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--grad); color: #fff; font-weight: 700;
}
.avatar-lg { width: 64px; height: 64px; font-size: 1.6rem; }

.lang-switch { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); }
.lang-switch button {
  border: 0; background: none; padding: 0.3rem 0.5rem; border-radius: 7px; cursor: pointer;
  font: 600 0.72rem/1 var(--font); letter-spacing: 0.03em; color: var(--muted);
}
.lang-switch button[aria-pressed="true"] { background: var(--card-solid); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 10px;
  background: none; color: var(--muted); cursor: pointer; text-decoration: none; font-size: 1.1rem;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

.mtop, .tabbar { display: none; }
.view { min-width: 0; }
.page { max-width: 1120px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
.page.narrow { max-width: 860px; }

.layout-bare .bare-top {
  max-width: 1120px; margin: 0 auto; padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: space-between;
}
.mtop-tools { display: flex; align-items: center; gap: 0.4rem; }

/* ------------------------------------------------------------------ элементы */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 44px; padding: 0.5rem 1.05rem; border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--card-solid); color: var(--text); font: 600 0.95rem/1.2 var(--font);
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: transform 0.08s, box-shadow 0.15s, background 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--grad); border-color: transparent; color: var(--on-accent); box-shadow: 0 10px 24px -12px rgba(124, 92, 255, 0.9); }
.btn-primary:hover { background: var(--grad); filter: brightness(1.06); box-shadow: 0 12px 28px -10px rgba(124, 92, 255, 0.95); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: var(--wrong); border-color: var(--wrong); color: #fff; }
.btn-sm { min-height: 36px; padding: 0.3rem 0.75rem; font-size: 0.88rem; border-radius: 10px; }
.btn-lg { min-height: 52px; padding: 0.75rem 1.5rem; font-size: 1.02rem; }
.btn-block { width: 100%; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem 1.3rem; box-shadow: var(--shadow); margin-bottom: 1rem;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.12rem 0.6rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 0.8rem; font-weight: 500; white-space: nowrap;
}
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-lang { font-weight: 700; letter-spacing: 0.04em; }
.back-link { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.back-link:hover { color: var(--text); }

.field { display: flex; flex-direction: column; gap: 0.3rem; margin: 0 0 0.85rem; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: 0.88rem; font-weight: 600; color: var(--muted); padding: 0; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea {
  width: 100%; min-height: 44px; padding: 0.55rem 0.8rem; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--card-solid); color: var(--text); font: inherit;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px var(--accent-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.8rem; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 0.8rem; }
.check { display: flex; align-items: center; gap: 0.55rem; margin: 0 0 0.85rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--violet); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.section-head h1, .section-head h2 { margin: 0; }
.section-head > a { text-decoration: none; font-weight: 600; font-size: 0.92rem; }
section { margin-bottom: 1.5rem; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; align-items: start; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }

.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--grad); }
.mini-bar { display: inline-block; vertical-align: middle; width: 56px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-right: 0.35rem; }
.mini-bar span { display: block; height: 100%; background: var(--grad); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.table th, .table td { padding: 0.6rem 0.6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table select { min-height: 36px; padding: 0.25rem 0.5rem; width: auto; }
.row-actions { white-space: nowrap; text-align: right; }
span.row-actions { display: flex; gap: 0.25rem; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
td.row-actions > * { vertical-align: middle; }

.empty { text-align: center; padding: 2rem 1.25rem; }
.empty-ic { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); margin-bottom: 0.5rem; }

/* ------------------------------------------------------------------ карточки тестов */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.test-card { display: flex; flex-direction: column; gap: 0.4rem; margin: 0; color: inherit; text-decoration: none; transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s; }
.test-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.tc-top { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.3rem; }
.tc-title { margin: 0; font-size: 1.1rem; }
.tc-author { margin: 0; font-size: 0.88rem; }
.tc-meta { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; color: var(--muted); font-size: 0.86rem; margin-top: auto; padding-top: 0.4rem; }
.tc-meta span { display: inline-flex; align-items: center; gap: 0.3rem; }
.tc-best { display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 0.5rem; font-size: 0.86rem; color: var(--muted); padding-top: 0.5rem; border-top: 1px solid var(--line); margin-top: 0.3rem; }
.tc-best strong { color: var(--text); }
.tc-best .bar { grid-column: 1 / -1; height: 6px; }

.list-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.row-card { display: flex; align-items: center; gap: 0.85rem; margin: 0; padding: 0.8rem 1rem; color: inherit; text-decoration: none; }
a.row-card:hover { border-color: var(--line-strong); }
.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.row-main strong { overflow: hidden; text-overflow: ellipsis; }
.row-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); flex: none; }
.row-score { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.score-pill {
  flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  font: 700 0.8rem/1 var(--font); font-variant-numeric: tabular-nums;
  background: radial-gradient(closest-side, var(--card-solid) 76%, transparent 78% 100%), conic-gradient(var(--violet) calc(var(--p) * 1%), var(--surface-2) 0);
}
.note { display: block; margin-top: 0.3rem; font-size: 0.9rem; padding: 0.4rem 0.6rem; background: var(--surface-2); border-radius: 8px; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat-tile { display: flex; flex-direction: column; gap: 0.15rem; margin: 0; }
.stat-label { color: var(--muted); font-size: 0.85rem; font-weight: 500; }
.stat-value { font: 800 1.9rem/1.1 var(--font-head); font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.stat-tile .muted { font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ стартовая */
.landing .hero { text-align: center; padding: 2.5rem 0 2rem; }
.eyebrow { display: inline-block; margin: 0 0 1rem; padding: 0.3rem 0.85rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 0.88rem; }
.hero-title {
  font: 800 clamp(2rem, 5vw, 3.3rem)/1.1 var(--font-head); letter-spacing: -0.03em; margin: 0 auto 1rem; max-width: 820px;
  background: linear-gradient(120deg, var(--text) 30%, var(--violet) 70%, var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { max-width: 640px; margin: 0 auto 1.75rem; font-size: 1.12rem; color: var(--muted); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; }
.hero-stats { display: flex; justify-content: center; gap: 2.5rem; margin-top: 2.25rem; flex-wrap: wrap; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats strong { font: 800 1.9rem/1.1 var(--font-head); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-stats span { color: var(--muted); font-size: 0.9rem; }
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.feature { margin: 0; }
.feature p { margin: 0; font-size: 0.93rem; }
.feature-ic { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--grad); color: #fff; margin-bottom: 0.7rem; flex: none; }
.how { text-align: center; padding: 1rem 0; }
.steps { list-style: none; display: flex; justify-content: center; gap: 1rem; padding: 0; margin: 0; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 1.1rem; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-weight: 500; }
.steps span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 700; font-size: 0.9rem; }
.teach { display: flex; align-items: center; gap: 1.1rem; }
.teach h2 { margin-bottom: 0.3rem; }
.teach p { margin: 0; }
.teach .feature-ic { margin: 0; }
.teach > div { flex: 1; }

/* ------------------------------------------------------------------ вход */
.auth-wrap { display: grid; place-items: start center; padding: 1.5rem 1rem 4rem; }
.auth-card { width: min(520px, 100%); padding: 1.75rem; }
.auth-card h1 { margin-bottom: 1.1rem; }
.auth-switch { text-align: center; margin: 1rem 0 0; color: var(--muted); }

/* ------------------------------------------------------------------ каталог */
.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1.25rem; }
.filters select { width: auto; min-width: 170px; }
.search { position: relative; flex: 1 1 260px; display: flex; align-items: center; }
.search .ic { position: absolute; left: 0.8rem; color: var(--muted); pointer-events: none; }
.search input { padding-left: 2.4rem !important; }
.filters ~ * .search, #admin-body .search { margin-bottom: 0.8rem; }

/* ------------------------------------------------------------------ страница теста */
.desc { white-space: pre-wrap; }
.start-card { padding: 1.4rem 1.5rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.facts div { display: flex; flex-direction: column; }
.facts span { font-size: 0.85rem; }
.facts strong { font: 800 1.45rem/1.2 var(--font-head); }
.sections-list { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0; margin: 0 0 1rem; }
.sections-list li { padding: 0.35rem 0.8rem; border-radius: 10px; background: var(--surface-2); font-size: 0.92rem; }
.rules { margin: 0 0 0.8rem; padding-left: 1.2rem; }
.rules li { margin-bottom: 0.25rem; }
.keys-line { font-size: 0.88rem; margin: 0 0 1.1rem; }
.start-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.leaderboard { list-style: none; margin: 0; padding: 0; }
.leaderboard li { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.2rem; border-bottom: 1px solid var(--line); }
.leaderboard li:last-child { border-bottom: 0; }
.leaderboard .is-me { background: var(--accent-soft); border-radius: 10px; padding-inline: 0.5rem; }
.lb-place { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); font-weight: 700; font-size: 0.85rem; }
.leaderboard li:nth-child(-n + 3) .lb-place { background: var(--grad); color: #fff; }
.lb-name { flex: 1; min-width: 0; }
.lb-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-score small { color: var(--muted); font-weight: 500; }

/* ------------------------------------------------------------------ прохождение */
.layout-focus .view { min-height: 100vh; }
.quiz-bar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--card-solid) 82%, transparent);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.quiz-bar-inner { max-width: 1240px; margin: 0 auto; padding: 0.55rem 1.25rem; display: flex; align-items: center; gap: 0.9rem; }
.quiz-title { display: flex; flex-direction: column; min-width: 0; margin-right: auto; line-height: 1.3; }
.quiz-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quiz-title .muted { font-size: 0.85rem; }
.sync { font-size: 1.1rem; }
.sync.warn { color: var(--skip); }
.timer {
  font: 700 1.35rem/1 var(--mono); font-variant-numeric: tabular-nums;
  padding: 0.45rem 0.75rem; border-radius: 10px; background: var(--surface-2);
}
.timer.warn { color: var(--skip); background: var(--skip-soft); }
.timer.danger { color: var(--wrong); background: var(--wrong-soft); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }
.progress { height: 3px; background: var(--surface-2); }
.progress-fill { height: 100%; width: 0; background: var(--grad); transition: width 0.25s; }

.quiz-layout { max-width: 1240px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.q-pane { padding: 1.4rem 1.6rem; margin: 0; scroll-margin-top: 80px; }
.q-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.q-title { font-size: 1.15rem; margin: 0; }
.flag-btn { margin-left: auto; }
.flag-btn.is-on { color: var(--flag); background: color-mix(in srgb, var(--flag) 12%, transparent); }
.q-text { white-space: pre-wrap; font-size: 1.08rem; line-height: 1.65; margin-bottom: 1rem; overflow-wrap: anywhere; }

.code-wrap { position: relative; margin: 0 0 1.1rem; }
.code-lang { position: absolute; top: 0.45rem; right: 0.7rem; font-size: 0.74rem; color: var(--muted); font-weight: 600; }
.code {
  margin: 0; padding: 0.95rem 1.05rem; background: var(--code-bg); border: 1px solid var(--line); border-radius: 12px;
  overflow-x: auto; font-size: 0.95rem; line-height: 1.6; tab-size: 4; white-space: pre;
}
code.inline { padding: 0.05em 0.35em; border-radius: 5px; background: var(--code-bg); font-size: 0.92em; }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; font-size: 0.88em; line-height: 1.15; margin: 0 0.12em; }
.frac .num { border-bottom: 1.5px solid currentColor; padding: 0 0.2em; }
.frac .den { padding: 0 0.2em; }
sup, sub { line-height: 0; }

.options { display: grid; gap: 0.6rem; margin-bottom: 1.25rem; }
.opt {
  display: flex; align-items: center; gap: 0.9rem; width: 100%; min-height: 58px; padding: 0.6rem 0.95rem;
  border: 2px solid var(--line); border-radius: 14px; background: var(--card-solid); color: var(--text);
  font: inherit; font-size: 1.05rem; text-align: left; cursor: pointer; transition: border-color 0.12s, background 0.12s, transform 0.08s;
}
.opt:hover { border-color: var(--line-strong); background: var(--surface-2); }
.opt:active { transform: scale(0.995); }
.opt.is-selected { border-color: var(--violet); background: var(--accent-soft); }
.opt-letter {
  flex: none; display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%;
  border: 1.5px solid var(--line-strong); font-weight: 700; font-size: 0.95rem; color: var(--muted);
}
.opt.is-selected .opt-letter { background: var(--grad); border-color: transparent; color: #fff; }
.opt-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.q-actions { display: flex; gap: 0.6rem; }
.q-actions #next { margin-left: auto; }
.btn-skip.is-on { border-color: var(--skip); background: var(--skip-soft); }
.hint { margin: 1rem 0 0; font-size: 0.84rem; color: var(--muted); }

.palette { position: sticky; top: 76px; margin: 0; padding: 1rem; max-height: calc(100vh - 96px); overflow-y: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 0.35rem 0.85rem; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.6rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.sw { position: relative; display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--line-strong); background: var(--card-solid); }
.sw-answered { background: var(--violet); border-color: var(--violet); }
.sw-skip { background: var(--skip-soft); border-color: var(--skip); border-style: dashed; }
.sw-flag::after { content: ""; position: absolute; top: -4px; right: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--flag); }
.sw-correct { background: var(--correct); border-color: var(--correct); }
.sw-wrong { background: var(--wrong); border-color: var(--wrong); }
.pal-title { font: 600 0.82rem/1.3 var(--font); color: var(--muted); margin: 0.6rem 0 0.4rem; }
.pal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 6px; }
.pal {
  position: relative; height: 36px; min-width: 0; padding: 0; border: 1.5px solid var(--line-strong); border-radius: 9px;
  background: var(--card-solid); color: var(--text); font: 600 0.84rem/1 var(--font); font-variant-numeric: tabular-nums; cursor: pointer;
}
.pal:hover { background: var(--surface-2); }
.pal.is-answered { background: var(--violet); border-color: var(--violet); color: #fff; }
.pal.is-skip { background: var(--skip-soft); border-color: var(--skip); border-style: dashed; }
.pal.is-flagged::after { content: ""; position: absolute; top: -4px; right: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--flag); border: 2px solid var(--card-solid); }
.pal.is-current { box-shadow: 0 0 0 2px var(--card-solid), 0 0 0 4px var(--text); }
.pal-correct { background: var(--correct-soft); border-color: var(--correct); }
.pal-wrong { background: var(--wrong-soft); border-color: var(--wrong); }
.pal-skip { background: var(--skip-soft); border-color: var(--skip); border-style: dashed; }

.dialog {
  border: 1px solid var(--line); border-radius: 18px; background: var(--card-solid); color: var(--text);
  padding: 1.4rem 1.6rem; width: min(440px, calc(100vw - 2rem)); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.5);
}
.dialog::backdrop { background: rgba(7, 10, 28, 0.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dialog ul { padding-left: 1.2rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.1rem; flex-wrap: wrap; }

/* ------------------------------------------------------------------ результат */
.score-card { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: center; padding: 1.5rem; }
.ring { position: relative; width: 150px; height: 150px; }
.ring svg { width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 12; }
.ring-fg { fill: none; stroke-width: 12; stroke-linecap: round; transition: stroke-dasharray 0.8s ease; }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.ring-text strong { font: 800 2.4rem/1 var(--font-head); }
.ring-text span { color: var(--muted); font-weight: 600; }
.ring-text small { color: var(--accent); font-weight: 700; margin-top: 0.2rem; }
.sections { display: grid; gap: 0.85rem; }
.section-row .section-head { display: flex; justify-content: space-between; margin-bottom: 0.3rem; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.split-bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; margin-top: 0.25rem; }
.split-bar span { min-width: 0; }
.sb-correct { background: var(--correct); }
.sb-wrong { background: var(--wrong); }
.sb-skip { background: var(--skip); }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat { display: flex; flex-direction: column; padding: 0.9rem 1.1rem; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); border-top: 4px solid; }
.stat strong { font: 800 1.9rem/1.1 var(--font-head); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); }
.stat small { color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; }
.st-correct { border-top-color: var(--correct); }
.st-wrong { border-top-color: var(--wrong); }
.st-skip { border-top-color: var(--skip); }

/* ------------------------------------------------------------------ разбор */
.rv-map { margin-top: 0.25rem; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); margin-bottom: 1rem; }
.segmented button, .segmented a {
  min-height: 40px; display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.35rem 0.95rem; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted); font: 500 0.93rem/1.2 var(--font); cursor: pointer; text-decoration: none;
}
.segmented [aria-checked="true"], .segmented .on { background: var(--card-solid); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.segmented .count { font-size: 0.78rem; color: var(--muted); }
.rv-item { border-left: 4px solid; scroll-margin-top: 1rem; }
.rv-correct { border-left-color: var(--correct); }
.rv-wrong { border-left-color: var(--wrong); }
.rv-skip, .rv-empty { border-left-color: var(--skip); }
.rv-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.badge { margin-left: auto; padding: 0.15rem 0.65rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; }
.badge-correct { color: var(--correct); background: var(--correct-soft); }
.badge-wrong { color: var(--wrong); background: var(--wrong-soft); }
.badge-skip, .badge-empty { color: var(--skip); background: var(--skip-soft); }
.rv-options { list-style: none; padding: 0; margin: 0 0 0.75rem; display: grid; gap: 0.4rem; }
.rv-opt { display: flex; align-items: center; flex-wrap: wrap; gap: 0.7rem; padding: 0.45rem 0.75rem; border: 1.5px solid var(--line); border-radius: 10px; }
.rv-opt .opt-letter { width: 1.8rem; height: 1.8rem; font-size: 0.85rem; }
.rv-opt.is-correct { border-color: var(--correct); background: var(--correct-soft); }
.rv-opt.is-correct .opt-letter { background: var(--correct); border-color: var(--correct); color: #fff; }
.rv-opt.is-wrong { border-color: var(--wrong); background: var(--wrong-soft); }
.rv-opt.is-wrong .opt-letter { background: var(--wrong); border-color: var(--wrong); color: #fff; }
.tag { font-size: 0.74rem; font-weight: 600; padding: 0 0.5rem; border-radius: 999px; border: 1px solid currentColor; color: var(--muted); }
.rv-opt .tag:first-of-type { margin-left: auto; }
.tag-correct { color: var(--correct); }
.tag-wrong { color: var(--wrong); }
.rv-summary { margin: 0 0 0.6rem; font-size: 0.95rem; }
.explain { padding: 0.75rem 0.95rem; border-radius: 10px; background: var(--surface-2); white-space: pre-wrap; line-height: 1.6; }

/* ------------------------------------------------------------------ графики */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-box { position: relative; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 12px var(--font); }
.chart .line { fill: none; stroke: var(--violet); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--violet); stroke: var(--card-solid); stroke-width: 2; }
.chart .dot.active { r: 7; }
.tooltip {
  position: absolute; transform: translate(-50%, calc(-100% - 12px)); pointer-events: none; z-index: 5;
  background: var(--card-solid); border: 1px solid var(--line-strong); border-radius: 10px; padding: 0.45rem 0.7rem;
  font-size: 0.85rem; line-height: 1.4; white-space: nowrap; box-shadow: var(--shadow);
}
.qbars { display: flex; gap: 3px; align-items: flex-end; overflow-x: auto; padding-bottom: 0.25rem; }
.qbar { flex: 1 0 14px; display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.qbar-col { width: 100%; height: 140px; display: flex; align-items: flex-end; background: var(--surface-2); border-radius: 4px; }
.qbar-col span { display: block; width: 100%; border-radius: 4px; }
.qbar-col .low { background: var(--wrong); }
.qbar-col .mid { background: var(--skip); }
.qbar-col .high { background: var(--correct); }
.qbar small { font-size: 0.65rem; color: var(--muted); }
.hard-list { margin: 0; padding-left: 1.2rem; }
.hard-list li { margin-bottom: 0.75rem; }
.hard-top { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.hard-rate { margin-left: auto; font-weight: 700; color: var(--wrong); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0.2rem 0 0; white-space: pre-wrap; }

/* ------------------------------------------------------------------ профиль, мои тесты */
.profile-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.profile-head h1 { margin: 0; }
.profile-head p { margin: 0.15rem 0 0; }
.mt-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.mt-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 0; }
.mt-main { flex: 1 1 320px; min-width: 0; }
.mt-main h3 { margin: 0.25rem 0 0.2rem; }
.mt-main h3 a { color: inherit; text-decoration: none; }
.mt-main p { margin: 0; }
.mt-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.status { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.12rem 0.6rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-published { color: var(--correct); background: var(--correct-soft); }
.status-draft { color: var(--muted); background: var(--surface-2); }
.status-hidden { color: var(--wrong); background: var(--wrong-soft); }

/* ------------------------------------------------------------------ редактор */
.ed-bar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin: -0.5rem -0.5rem 0.75rem; padding: 0.6rem 0.5rem;
  background: color-mix(in srgb, var(--bg) 80%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.ed-bar-actions { margin-left: auto; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.ed-dirty { color: var(--skip); }
.file-btn { cursor: pointer; }
.ed-errors { padding: 0.8rem 1rem 0.8rem 0.4rem; border-radius: var(--radius-sm); background: var(--wrong-soft); border: 1px solid color-mix(in srgb, var(--wrong) 35%, transparent); margin-bottom: 1rem; }
.ed-errors ul { margin: 0; }
.ed-errors a { color: var(--wrong); }
.chip-checks { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span { display: inline-block; padding: 0.35rem 0.8rem; border-radius: 999px; border: 1.5px solid var(--line-strong); cursor: pointer; font-size: 0.88rem; user-select: none; }
.chip-check input:checked + span { background: var(--accent-soft); border-color: var(--violet); color: var(--accent); font-weight: 600; }
.chip-check input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.ed-sections { display: grid; gap: 0.5rem; margin-bottom: 0.5rem; }
.ed-section { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.ed-section > input { flex: 1 1 200px; }
.ed-section label { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); font-size: 0.9rem; }
.ed-section label input { width: 84px; }
.ed-jump { margin-bottom: 1rem; }
.ed-q { scroll-margin-top: 70px; }
.ed-q-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.ed-q-head h3 { margin: 0; }
.ed-q-tools { margin-left: auto; display: flex; gap: 2px; }
.ed-code { margin-bottom: 0.85rem; }
.ed-code summary { cursor: pointer; font-size: 0.88rem; font-weight: 600; color: var(--muted); padding: 0.25rem 0; }
.ed-code-body { display: grid; gap: 0.5rem; margin-top: 0.4rem; }
.ed-code-body select { width: 180px; }
textarea.mono { font-family: var(--mono); font-size: 0.92rem; tab-size: 4; white-space: pre; }
.ed-options { border: 0; padding: 0; margin: 0 0 0.85rem; display: grid; gap: 0.4rem; }
.ed-options legend { font-size: 0.88rem; font-weight: 600; color: var(--muted); margin-bottom: 0.3rem; padding: 0; }
.ed-opt { display: flex; align-items: center; gap: 0.5rem; }
.ed-radio { position: relative; cursor: pointer; }
.ed-radio input { position: absolute; opacity: 0; }
.ed-radio span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1.5px solid var(--line-strong); font-weight: 700; color: var(--muted); }
.ed-radio input:checked + span { background: var(--correct); border-color: var(--correct); color: #fff; }
.ed-radio input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.ed-opt.is-right > input { border-color: var(--correct); }
.ed-preview { border-top: 1px dashed var(--line-strong); padding-top: 1rem; margin-top: 0.5rem; }
.ed-preview .opt { cursor: default; min-height: 48px; }
.ed-add { display: flex; gap: 0.5rem; }

/* ------------------------------------------------------------------ уведомление */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 0.7rem 1.1rem; border-radius: 12px; background: #12163a; color: #fff; font-weight: 500; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.5);
  transition: opacity 0.2s, transform 0.2s; max-width: calc(100vw - 2rem);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: #7f1d1d; }

/* ------------------------------------------------------------------ планшет и телефон */
@media (max-width: 1100px) {
  .features { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 959px) {
  .layout-app { display: block; padding-bottom: 76px; }
  .sidebar { display: none; }
  .mtop {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20;
    padding: 0.55rem 1rem; padding-top: max(0.55rem, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--card-solid) 85%, transparent); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
  }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 0.35rem 0.25rem; padding-bottom: max(0.35rem, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--card-solid) 88%, transparent); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0.3rem 0.1rem;
    color: var(--muted); text-decoration: none; font-size: 0.68rem; font-weight: 600; border-radius: 10px; text-align: center; line-height: 1.15;
  }
  .tabbar a.on { color: var(--accent); }
  .layout-app .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .quiz-layout { grid-template-columns: 1fr; }
  .palette { position: static; max-height: none; }
  .pal-grid { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); }
  .pal { height: 40px; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  h1 { font-size: 1.45rem; }
  .page { padding: 1.1rem 1rem 3rem; }
  .layout-bare .bare-top { padding: 0.8rem 1rem; }
  .brand-name { font-size: 1.1rem; }
  .card { padding: 1rem; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .stat-tile { padding: 0.75rem; }
  .stat-value { font-size: 1.35rem; }
  .features { grid-template-columns: 1fr; }
  .teach { flex-direction: column; align-items: flex-start; }
  .quiz-bar-inner { padding: 0.45rem 0.75rem; gap: 0.5rem; }
  .quiz-exit { display: none; }
  .timer { font-size: 1.1rem; padding: 0.4rem 0.55rem; }
  .quiz-layout { padding: 0.75rem 0.75rem 2rem; }
  .q-pane { padding: 1rem; }
  .q-actions { flex-wrap: wrap; }
  .q-actions .btn { flex: 1 1 auto; }
  .q-actions #skip { order: 3; flex-basis: 100%; }
  .hint, .keys-line, .q-pane kbd { display: none; }
  .score-card { grid-template-columns: 1fr; justify-items: center; }
  .score-card .sections { width: 100%; }
  .stats3 { gap: 0.5rem; }
  .stat { padding: 0.7rem; }
  .stat strong { font-size: 1.45rem; }
  .filters select { flex: 1 1 140px; min-width: 0; }
  .hero-stats { gap: 1.5rem; }
  .ed-bar-actions .btn-ghost { padding-inline: 0.5rem; }
  .table { font-size: 0.86rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
