/* KEDVI Academy. Палитра и шрифт — как в KEDVI-студии: #261A66 основа, #EF5F18 главные действия, белый текст.
   Roboto лежит в сборке (SIL OFL 1.1, roboto-LICENSE.txt). */
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("roboto-cyrillic-wght-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("roboto-latin-ext-wght-normal.woff2") format("woff2"); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("roboto-latin-wght-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: dark;
  --violet: #261A66;
  --orange: #EF5F18;
  --white: #FFFFFF;
  --deep: #150D40;
  --muted: rgba(255,255,255,.68);
  --lilac: #C9BEFF;
  --line: rgba(255,255,255,.11);
  --line-strong: rgba(255,255,255,.20);
  --surface: rgba(255,255,255,.05);
  --surface-2: rgba(255,255,255,.10);
  --field: rgba(255,255,255,.045);
  --panel: linear-gradient(165deg, rgba(255,255,255,.085), rgba(255,255,255,.035));
  --ok: #7BE0A6;
  --warn: #FFB48C;
  --radius: 18px;
  --control: 44px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--deep); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden;
  color: var(--white); font: 15px/1.5 "Roboto", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1000px 640px at 50% 18%, rgba(74,54,176,.40), transparent 72%),
    radial-gradient(760px 520px at -8% 104%, rgba(239,95,24,.08), transparent 70%),
    linear-gradient(170deg, #190F49 0%, var(--violet) 48%, #1A1050 100%) fixed;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 20px; line-height: 1.25; }
h3 { font-size: 17px; line-height: 1.3; }
p, li, td { overflow-wrap: anywhere; }
a { color: var(--white); }
small, .small { font-size: 13px; }
.muted { color: var(--lilac); opacity: .85; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 13px; }

/* Поля и кнопки */
button, input, select, textarea { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button { border: 0; background: none; padding: 0; border-radius: 12px; }
input:not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; min-height: var(--control); padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--field);
}
input[type=file] { width: 100%; max-width: 100%; font-size: 14px; color: var(--muted); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--orange); }
input::placeholder, textarea::placeholder { color: rgba(255,255,255,.42); }
textarea { min-height: 140px; resize: vertical; display: block; line-height: 1.5; }
textarea.code { font-family: Consolas, "Courier New", monospace; font-size: 13px; min-height: 420px; }
select option { background: var(--violet); color: var(--white); }
label { display: grid; gap: 6px; }
label.check { display: flex; align-items: center; gap: 10px; }
:is(button, a, input, textarea, select, summary):focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }
.primary, .outline, .ghost, .danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  min-height: var(--control); padding: 0 20px; border-radius: 12px; font-weight: 600; white-space: nowrap;
}
.primary { background: linear-gradient(180deg, #FF7A38, var(--orange)); color: var(--violet); font-weight: 700; box-shadow: 0 10px 30px -14px rgba(239,95,24,.9); }
.primary:hover { background: linear-gradient(180deg, #FF8A4E, #F56B25); }
.primary:disabled, .primary[aria-disabled=true] { opacity: .55; cursor: default; }
.outline { border: 1px solid var(--line-strong); background: var(--surface); }
.outline:hover, .ghost:hover { border-color: rgba(255,255,255,.42); background: var(--surface-2); }
.ghost { border: 1px solid var(--line-strong); min-height: 36px; padding: 0 12px; font-size: 14px; }
.danger { border: 1px solid var(--line-strong); background: rgba(255,255,255,.08); min-height: 36px; padding: 0 12px; font-size: 14px; }
.danger:hover { background: #C6381A; border-color: #C6381A; }
.wide { width: 100%; }
.inline { display: inline; }
.badge { display: inline-block; font-size: 12px; color: var(--lilac); border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 10px; white-space: nowrap; vertical-align: middle; }
.badge.ok { color: var(--ok); border-color: rgba(123,224,166,.4); }
.badge.warn { color: var(--warn); border-color: rgba(255,180,140,.45); }
.badge.test { color: var(--violet); background: var(--warn); border-color: var(--warn); font-weight: 700; }

/* Шапка */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px;
  padding: 12px clamp(16px, 2.6vw, 40px); min-height: 68px;
  background: rgba(24,15,72,.88); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.brand-group { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand { font-size: 24px; font-weight: 600; letter-spacing: .02em; line-height: 1; }
.tagline { color: var(--muted); font-size: 15px; padding-left: 12px; border-left: 1px solid var(--line-strong); white-space: nowrap; }
.topnav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; min-width: 0; }
.nav-link { display: inline-flex; align-items: center; padding: 0 14px; height: 38px; border-radius: 999px; font-size: 15px; text-decoration: none; white-space: nowrap; }
.nav-link:hover { background: var(--surface); }
.nav-link[aria-current=page] { background: linear-gradient(180deg, rgba(255,255,255,.26), rgba(255,255,255,.13)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
.account { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: linear-gradient(140deg, #FF8A4C, var(--orange)); color: var(--violet); font-weight: 800; }

/* Страница */
main.page { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 16px 48px; display: grid; gap: 22px; align-content: start; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px 16px; }
.page-head > div:not(.row) { min-width: 0; display: grid; gap: 6px; }
form.row > input:not([type=checkbox]) { flex: 1 1 220px; width: auto; }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 14px; min-width: 0; }
.card.narrow { max-width: 440px; width: 100%; margin: 6vh auto 0; }
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.row.between { justify-content: space-between; }
.grid-cards { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); align-items: end; }
.flash { border: 1px solid rgba(123,224,166,.4); background: rgba(123,224,166,.08); border-radius: 12px; padding: 10px 14px; }
.alert { border: 1px solid rgba(255,180,140,.45); background: rgba(239,95,24,.10); border-radius: 12px; padding: 10px 14px; }
.note { border-left: 3px solid var(--orange); padding: 8px 12px; background: var(--surface); border-radius: 0 10px 10px 0; color: var(--muted); font-size: 14px; }
.secret { font-family: Consolas, monospace; font-size: 18px; background: var(--surface-2); padding: 8px 12px; border-radius: 10px; user-select: all; }
progress { width: 100%; height: 8px; appearance: none; border: 0; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 99px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, #FF8A4E, var(--orange)); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--orange); border-radius: 99px; }

/* Таблицы: прокрутка внутри обёртки, не у страницы */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--lilac); font-weight: 500; background: var(--surface); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; background: var(--surface); }

/* Курс: блоки и элементы */
.blocks { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.block { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--surface); display: grid; gap: 8px; }
.block-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.state { font-size: 12px; border-radius: 999px; padding: 2px 9px; white-space: nowrap; border: 1px solid var(--line-strong); }
.state-done .state { color: var(--ok); border-color: rgba(123,224,166,.45); }
.state-available .state { color: var(--violet); background: var(--orange); border-color: var(--orange); font-weight: 600; }
.state-locked { opacity: .72; }
.state-locked .state { color: var(--muted); }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.items li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 9px; font-size: 14px; }
.items li a { text-decoration: none; flex: 1; min-width: 0; }
.items li .small, .items li .badge { flex: none; white-space: nowrap; }
.items li:hover { background: var(--surface); }
.items li.current { background: var(--surface-2); font-weight: 600; }
.items .mark { width: 18px; flex: none; text-align: center; color: var(--muted); }
.items li.complete .mark { color: var(--ok); }
.items li.locked { color: var(--muted); }
.req { font-size: 13px; color: var(--warn); }
.req ul { margin: 4px 0 0; padding-left: 18px; }

/* Урок */
.lesson-layout { display: grid; gap: 22px; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); align-items: start; }
.course-outline { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; position: sticky; top: 92px; max-height: calc(100vh - 110px); overflow: auto; }
.course-outline > summary { font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 10px; padding: 4px 4px 10px; }
.course-outline > summary::-webkit-details-marker { display: none; }
.course-outline > summary::after { content: "▾"; color: var(--muted); }
.course-outline:not([open]) > summary { padding-bottom: 4px; }
.course-outline:not([open]) > summary::after { content: "▸"; }
.lesson-body { display: grid; gap: 18px; min-width: 0; }
.prose { font-size: 16px; line-height: 1.65; display: grid; gap: 12px; }
.prose h3 { margin-top: 6px; }
.prose ul { margin: 0; padding-left: 22px; }
video { display: block; width: 100%; max-height: 70vh; border-radius: 14px; background: #0E0930; border: 1px solid var(--line-strong); }
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.files li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tokens { display: grid; gap: 4px; }
.uploader { display: grid; gap: 8px; }
.uploader output { font-size: 14px; color: var(--warn); }
.submission { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 6px; }
.submission pre { white-space: pre-wrap; margin: 0; font: inherit; overflow-wrap: anywhere; }

/* Админка */
.admin-item { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.admin-item:last-child { border-bottom: 0; }
.admin-item .title { flex: 1; min-width: 160px; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }

footer { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 16px 26px; border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  .lesson-layout { grid-template-columns: minmax(0, 1fr); }
  .course-outline { position: static; max-height: none; }
  h1 { font-size: 23px; }
  .tagline { display: none; }
  .card { padding: 16px; }
  .topnav { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .account .small { display: none; }
}
@media (max-width: 520px) {
  .topbar { padding: 10px 16px; }
  .nav-link { padding: 0 10px; font-size: 14px; }
  .primary, .outline { padding: 0 14px; }
}
