:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e8eaef;
  --muted: #8b93a3;
  --accent: #4f8cff;
  --accent-2: #3a6fd8;
  --danger: #ff6b6b;
  --danger-2: #e05252;
  --live: #3ddc84;
  --warn: #ffb84d;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
  height: 100%;
  padding: 16px;
}

/* ---------- Call area ---------- */

.call {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, #2b3242 0%, #161a22 70%);
  min-height: 420px;
}

.call__video { position: absolute; inset: 0; }

.call__top {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.call__badge, .call__state {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(6px);
  font-weight: 600;
}
.call__state { font-weight: 500; color: var(--muted); }
.call__state[data-state="listening"] { color: var(--live); }
.call__state[data-state="thinking"] { color: var(--warn); }
.call__state[data-state="speaking"] { color: var(--accent); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.is-live { background: var(--live); box-shadow: 0 0 0 4px rgba(61, 220, 132, .2); }

.call__subtitles {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  max-width: min(80%, 720px);
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .6);
  font-size: 17px;
  text-align: center;
  opacity: 0;
  transition: opacity .2s;
}
.call__subtitles.is-visible { opacity: 1; }

.call__loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 16px;
}

.call__controls {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn--call { flex: none; padding: 12px 20px; border-radius: 999px; }

.mic {
  width: 10px;
  height: 40px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .12);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}
.mic span { display: block; width: 100%; height: 0; background: var(--live); transition: height .08s; }

/* Phone mode: no video, a call card instead. */
.call__phone {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.call.is-phone .call__video { visibility: hidden; }
.call.is-phone .call__phone { display: flex; }
.phone__avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #3a4560, #252b3a);
  font-size: 48px;
  font-weight: 600;
}
.call.is-speaking .phone__avatar { box-shadow: 0 0 0 10px rgba(79, 140, 255, .25); }
.phone__name { font-size: 22px; font-weight: 600; }
.phone__timer { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Side panel ---------- */

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  overflow-y: auto;
  min-height: 0;
}

.panel__header h1 { margin: 0 0 10px; font-size: 20px; }
.panel__header small { color: var(--muted); font-weight: 400; font-size: 13px; }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: var(--panel-2); }
.tab {
  flex: 1;
  padding: 7px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tab.is-active { background: var(--border); color: var(--text); }

.tabpane { display: none; flex-direction: column; gap: 12px; }
.tabpane.is-active { display: flex; }

.section-title { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

.muted { color: var(--muted); }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
label.check { flex-direction: row; align-items: center; gap: 8px; }

select, textarea, input[type=text], input[type=range] { width: 100%; }

select, textarea, input[type=text] {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; font-size: 13px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-2); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger-2); }
.btn.is-off { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.notice {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 184, 77, .12);
  border: 1px solid rgba(255, 184, 77, .4);
  color: #ffd699;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* Transcript */
.transcript {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 200px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 2px;
}
.transcript .empty { margin: 8px 0; }
.bubble {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--panel-2);
  white-space: pre-wrap;
}
.bubble small { display: block; margin-bottom: 2px; color: var(--muted); font-size: 11px; }
.bubble--user { align-self: flex-end; background: #24375c; }
.bubble--pending { opacity: .6; font-style: italic; }
.bubble--cut::after { content: " …"; color: var(--muted); }

.typebox { display: flex; gap: 8px; }
.typebox .btn { flex: none; width: 48px; }

.metrics { border-top: 1px solid var(--border); padding-top: 12px; }
.metrics h2 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.metrics dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; }
.metrics dt { color: var(--muted); }
.metrics dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }

/* Report */
.report { display: flex; flex-direction: column; gap: 12px; }
.score { display: flex; align-items: baseline; gap: 10px; }
.score__value { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; }
.criterion { padding: 10px 12px; border-radius: 10px; background: var(--panel-2); }
.criterion__head { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.criterion__bar { height: 4px; margin: 6px 0; border-radius: 2px; background: var(--border); overflow: hidden; }
.criterion__bar span { display: block; height: 100%; background: var(--accent); }
.criterion q { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.report h3 { margin: 4px 0 0; font-size: 13px; }
.report ul { margin: 0; padding-left: 18px; }

.error { color: var(--danger); margin: 0; white-space: pre-wrap; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .call { height: 60vh; }
  .transcript { max-height: none; }
}

/* =========================================================
   App shell: login, editor admin, learner area
   ========================================================= */

a { color: var(--accent); }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn { white-space: nowrap; }
.btn--ghost-danger { background: transparent; border-color: rgba(255, 107, 107, .5); color: var(--danger); }
.btn--ghost-danger:hover { background: rgba(255, 107, 107, .1); }
.link { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; text-decoration: none; }
.small { font-size: 12px; }
.hint { color: var(--muted); font-size: 11px; }
.pre { white-space: pre-wrap; }
.neg { color: var(--danger); }
.pos { color: var(--live); }
input[type=email], input[type=password], input[type=number] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}
input:disabled { opacity: .6; }

/* Login */
body.auth { display: grid; place-items: center; min-height: 100%; padding: 16px; }
.auth__card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
}
.auth__card h1 { margin: 0; font-size: 24px; }
.auth__card h1 small { color: var(--muted); font-weight: 400; font-size: 14px; }

.form { display: flex; flex-direction: column; gap: 12px; }
.form--wide { gap: 16px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form-actions .btn { flex: none; }

/* Editor shell */
body.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); height: 100%; }
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 14px;
  border-right: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
}
.brand { font-size: 20px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand small { color: var(--muted); font-size: 12px; font-weight: 400; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav a:hover { background: var(--panel-2); }
.nav a.is-active { background: var(--border); font-weight: 600; }
.sidebar__footer { margin-top: auto; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.credits { display: flex; flex-direction: column; padding: 10px 12px; margin-bottom: 6px; border-radius: 10px; background: var(--panel-2); color: var(--text); text-decoration: none; align-self: stretch; }
.credits strong { font-size: 18px; }
.credits strong.is-low { color: var(--warn); }

.content { padding: 24px 28px 48px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.content--narrow { max-width: 980px; margin: 0 auto; width: 100%; }
.content h1 { margin: 0; font-size: 22px; }
.content h2 { margin: 0 0 4px; font-size: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head__actions { display: flex; gap: 8px; }
.page-head__actions .btn { flex: none; }

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
}
.card--accent { border-color: var(--accent); }
.card__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card__head label { min-width: 240px; }
.card__head > .btn { flex: none; } /* a header button keeps its size next to the title */
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }

.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
.checklist .check { color: var(--text); font-size: 13px; }
.creds { margin: 0; padding: 12px; border-radius: 8px; background: var(--panel-2); white-space: pre-wrap; font-size: 13px; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; background: var(--panel); }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { color: var(--muted); font-size: 12px; font-weight: 600; background: var(--panel-2); }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-link { cursor: pointer; }
.table tr.is-link:hover td { background: var(--panel-2); }
.table td .badge { margin-left: 6px; }

.badge {
  display: inline-block;
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}
.badge--good { background: rgba(61, 220, 132, .18); color: var(--live); }
.badge--ok { background: rgba(255, 184, 77, .18); color: var(--warn); }
.badge--bad { background: rgba(255, 107, 107, .18); color: var(--danger); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); }
.stat strong { font-size: 20px; font-variant-numeric: tabular-nums; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters select { width: auto; min-width: 200px; }
.filters .check { color: var(--text); }

.empty-state { padding: 32px; border-radius: var(--radius); border: 1px dashed var(--border); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }

.packages { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.package { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--border); }
.package strong { font-size: 18px; }
.package__price { font-size: 24px; font-weight: 700; }
.package .btn { margin-top: 6px; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.transcript--static { max-height: 70vh; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 10;
}
.toast.is-visible { opacity: 1; transform: none; }
.toast[data-kind="error"] { border-color: var(--danger); color: #ffc9c9; }

/* Learner area */
body.learner { display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--panel); }
.topbar__right { display: flex; gap: 14px; align-items: center; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.trainer-card { display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); }
.trainer-card h2 { margin: 0; font-size: 17px; }
.trainer-card p { margin: 0; color: var(--muted); }
.trainer-card__foot { margin-top: auto; padding-top: 8px; display: flex; align-items: center; gap: 8px; }
.trainer-card__foot .btn { margin-left: auto; flex: none; }

/* Call page extras */
.call__remaining { padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, .45); color: var(--muted); font-variant-numeric: tabular-nums; }
.call__remaining.is-low { color: var(--warn); }
.brief h3 { margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.brief p { margin: 0 0 6px; }
.panel__header .link { display: inline-block; margin-bottom: 6px; }

@media (max-width: 860px) {
  body.shell { grid-template-columns: 1fr; height: auto; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar__footer { margin-top: 0; }
  .content { padding: 16px; }
  .grid3, .two-col { grid-template-columns: 1fr; }
}

/* Inactive tab panes stay hidden whatever layout class they also carry (.form, .card…). */
.tabpane:not(.is-active) { display: none; }

/* Intro (title) page before the call — covers the call layout while the avatar loads underneath. */
.intro {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow-y: auto;
  padding: 32px 16px;
  background: var(--bg);
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.intro__card {
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
}
.intro__card h1 { margin: 0; font-size: 26px; }
.intro__card .brief h3 { font-size: 14px; color: var(--text); }
.intro__card .btn--call { align-self: flex-start; }

/* Interface language switch (RU / EN) */
.lang-switch { display: inline-flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); }
.lang-switch__btn { padding: 3px 8px; text-decoration: none; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.lang-switch__btn.is-active { background: var(--border); color: var(--text); }
.auth__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sidebar__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; align-self: stretch; margin-top: 6px; }

/* Action bar that stays at the bottom of the scrolling content area. */
.form-actions--sticky {
  position: sticky;
  bottom: -48px; /* compensates .content bottom padding so the bar sits on the viewport edge */
  z-index: 3;
  margin: 0 -28px -48px;
  padding: 14px 28px 20px;
  background: linear-gradient(to bottom, rgba(15, 17, 21, 0), var(--bg) 30%);
}
@media (max-width: 860px) {
  .form-actions--sticky { bottom: -16px; margin: 0 -16px -16px; padding: 14px 16px; }
}

/* Background layer behind the avatar (call page). */
.call__bg { position: absolute; inset: 0; }
.call.is-phone .call__bg { display: none; }

/* Trainer editor: character card with live preview */
.character { display: grid; grid-template-columns: minmax(280px, 420px) minmax(0, 1fr); gap: 18px; align-items: start; }
.character__fields { display: flex; flex-direction: column; gap: 12px; }
.preview__stage {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: #161a22;
  border: 1px solid var(--border);
}
.preview__bg, .preview__avatar { position: absolute; inset: 0; }
.preview__stage.is-phone .preview__avatar { opacity: .35; }
.preview__status {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .55);
  color: var(--text);
  font-size: 12px;
  text-align: center;
}
.voice-try { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip:disabled { opacity: .5; cursor: progress; }

.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin: 8px 0 4px; }
.bg-tile { display: flex; flex-direction: column; gap: 4px; padding: 4px; border: 2px solid transparent; border-radius: 10px; background: none; color: var(--muted); font: inherit; font-size: 11px; cursor: pointer; text-align: left; }
.bg-tile.is-active { border-color: var(--accent); color: var(--text); }
.bg-tile__swatch { display: grid; place-items: center; aspect-ratio: 16 / 10; border-radius: 6px; border: 1px solid var(--border); font-size: 22px; color: var(--muted); }
.bg-tile__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bg-tile--upload .bg-tile__swatch { border-style: dashed; }
.card h3 { margin: 0; font-size: 14px; }

@media (max-width: 1100px) {
  .character { grid-template-columns: 1fr; }
}

/* Landing demo inside an iframe: no navigation back to the cabinet. */
body.is-demo #back, body.is-demo #intro-back, body.is-demo #preview-notice { display: none; }
.demo-cta { margin-top: 16px; }
.demo-cta h3 { margin: 0; font-size: 16px; }
.demo-cta p { margin: 0; }
.demo-cta .btn { align-self: flex-start; }

/* ---------- Analytics ---------- */

.chart-box { display: flex; flex-direction: column; gap: 8px; }
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-hit { cursor: default; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chart-tip { position: fixed; z-index: 50; max-width: 280px; padding: 8px 10px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; pointer-events: none; box-shadow: 0 6px 20px rgba(0, 0, 0, .35); display: flex; flex-direction: column; gap: 2px; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bars__row { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr 36px; align-items: center; gap: 10px; }
.bars__label { font-size: 13px; }
.bars__track { height: 10px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.bars__fill { display: block; height: 100%; border-radius: 4px; }
.bars__value { text-align: right; font-variant-numeric: tabular-nums; }

.heat th.heat__col { white-space: normal; min-width: 90px; max-width: 160px; }
.heat td.heat__cell { text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; border-left: 2px solid var(--panel); }
.heat td.heat__cell--empty { color: var(--muted); font-weight: 400; }

.notes h3 { margin: 6px 0 4px; font-size: 14px; }
.notes ul, .improvements { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.notes q { display: block; margin-top: 2px; color: var(--muted); font-style: italic; }

.picker { position: relative; }
.picker > summary { list-style: none; cursor: pointer; }
.picker > summary::-webkit-details-marker { display: none; }
.picker__menu { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 260px; max-height: 340px; overflow: auto; padding: 12px;
  border-radius: 12px; background: var(--panel-2); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.picker__actions { display: flex; gap: 8px; margin-top: 6px; }

/* ---------- Printable report ---------- */

.print-doc { display: flex; flex-direction: column; gap: 16px; }
.print-doc__brand { color: var(--accent); font-weight: 700; letter-spacing: .02em; }
.print-doc h1 { margin: 4px 0; }
.print-doc__attempt { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); }
.print-doc__attempt h2 { margin: 0; font-size: 16px; }

@media print {
  @page { margin: 14mm; }
  :root { --bg: #fff; --panel: #fff; --panel-2: #f3f4f6; --border: #d6d9df; --text: #111; --muted: #555; --accent: #2a5bd7; color-scheme: light; }
  html, body { background: #fff; color: #111; height: auto; }
  body.shell { display: block; height: auto; }
  .sidebar, .page-head, .no-print, #toast { display: none !important; }
  .content { padding: 0; overflow: visible; }
  .print-doc__attempt { break-inside: avoid-page; border-color: #d6d9df; }
  .criterion__bar span { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ---------- Legal pages, registration consent, support ---------- */

body.legal { height: auto; }
.legal__doc { max-width: 820px; margin: 0 auto; padding: 32px 20px 64px; line-height: 1.6; }
.legal__doc h1 { font-size: 26px; line-height: 1.25; }
.legal__doc h2 { margin-top: 28px; font-size: 18px; }
.legal__doc ul { padding-left: 20px; }
.legal__doc a { color: var(--accent); }
label.check--terms { align-items: flex-start; font-size: 12px; line-height: 1.45; color: var(--muted); }
.check--terms input { margin-top: 2px; flex: none; }
.check--terms a { color: var(--accent); }
.login__support { text-align: center; }
.login__support a, #support { color: var(--muted); }
#support:hover { color: var(--text); }

/* ---------- Platform (owner) ---------- */

.subtabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.subtabs a { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtabs a:hover { color: var(--text); }
.subtabs a.is-active { color: var(--text); border-bottom-color: var(--accent); }

.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel__row { display: grid; grid-template-columns: minmax(130px, 1fr) 2fr 40px 40px; align-items: center; gap: 10px; font-size: 13px; }
.funnel__track { height: 10px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.funnel__fill { display: block; height: 100%; border-radius: 4px; background: #3987e5; }
.funnel__row strong { text-align: right; font-variant-numeric: tabular-nums; }

.impersonation { position: fixed; top: 0; left: 0; right: 0; z-index: 60; display: flex; align-items: center; justify-content: center; gap: 16px;
  min-height: 48px; padding: 8px 16px; background: #5a3d0a; color: #ffe3b0; font-weight: 600; border-bottom: 1px solid var(--warn); }
.impersonation .btn { padding: 6px 14px; }
body.shell.has-banner { padding-top: 48px; }

/* /join: trainers the invite link assigns */
.join-trainers { margin: 12px 0 0; padding-left: 18px; line-height: 1.6; }
.join-trainers:empty { display: none; }

/* Invite links on the learners page */
.invite-list { display: grid; gap: 10px; margin: 14px 0; }
.invite { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; }
.invite__main { flex: 1 1 260px; min-width: 0; }
.invite__main code { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.invite__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.invite.is-off { opacity: .6; }

/* Trainer editor: "Language practice" builder */
.card__head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.card__head-actions > .btn { flex: none; }
.card__head-actions label { min-width: 240px; }
.practice-builder { display: grid; gap: 12px; margin: 4px 0 18px; padding: 18px; border: 1px solid var(--accent); border-radius: 14px; background: rgba(79, 140, 255, .06); }
.practice-builder h3 { margin: 0; }
.practice-builder p { margin: 0; }
.practice-summary { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 0 16px; padding: 12px 14px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 12px; }
.practice-summary__actions { display: flex; gap: 8px; }
.practice-summary__actions .btn { flex: none; }
