/* ==========================================================================
   Screens. Layout families are deliberately different per screen so the app
   does not read as one repeated template: auth is a centred single column,
   the catalog is an asymmetric grid, the player is a two-pane reader,
   the admin editor is a work surface with a left rail.
   ========================================================================== */

/* ---------- auth ---------- */

.auth-wrap {
  min-height: calc(100dvh - 64px);
  display: grid; grid-template-columns: 1fr;
  align-items: center; justify-items: center;
  padding: 32px 0 64px;
}
.auth-card { width: min(420px, 100%); display: grid; gap: 18px; }
.auth-card .tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.auth-card .tabs button {
  appearance: none; cursor: pointer; font: inherit; font-weight: 550; font-size: .9375rem;
  height: 34px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.auth-card .tabs button[aria-selected="true"] { background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow-1); }
.auth-form { display: grid; gap: 14px; }

/* ---------- home ---------- */

.home-hero {
  display: grid; gap: 28px; align-items: center;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  padding: 44px 0 40px;
}
.home-hero h1 { max-width: 15ch; }
.home-hero .lede { color: var(--ink-2); font-size: 1.0625rem; max-width: 46ch; margin-top: 14px; }
.home-hero .cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.home-shot { border-radius: var(--r); border: 1px solid var(--line); overflow: hidden; box-shadow: var(--shadow-2); background: var(--surface-2); }
.home-shot img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; }

@media (max-width: 899px) {
  .home-hero { grid-template-columns: 1fr; padding: 28px 0 32px; }
  .home-hero h1 { max-width: none; }
}

.home-how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.home-how > div { background: var(--surface-raised); padding: 20px 18px; display: grid; gap: 7px; align-content: start; }
.home-how h3 { font-size: 1rem; }
.home-how p { color: var(--ink-2); font-size: .9375rem; }
@media (max-width: 767px) { .home-how { grid-template-columns: 1fr; } }

/* ---------- catalog ---------- */

.catalog { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.vcard {
  display: grid; grid-template-rows: auto 1fr;
  background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; text-decoration: none; color: inherit;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.vcard:hover { border-color: var(--accent-line); transform: translateY(-2px); box-shadow: var(--shadow-2); color: inherit; }
.vcard:active { transform: translateY(0); }
.vcard .thumb { position: relative; aspect-ratio: 16 / 9; background: var(--surface-3); }
.vcard .thumb img { width: 100%; height: 100%; object-fit: cover; }
.vcard .thumb .dur {
  position: absolute; right: 8px; bottom: 8px;
  background: color-mix(in srgb, #000 72%, transparent); color: #fff;
  font-family: var(--mono); font-size: .75rem; font-variant-numeric: tabular-nums;
  padding: 2px 6px; border-radius: 6px;
}
.vcard .meta { padding: 13px 14px 15px; display: grid; gap: 7px; align-content: start; }
.vcard .meta h3 { font-size: .9875rem; line-height: 1.35; }
.vcard .meta .ru { color: var(--ink-2); font-size: .875rem; }
.vcard .meta .foot { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 2px; }

/* ---------- watch ---------- */

.watch {
  display: grid; gap: 20px;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  align-items: start;
}
@media (max-width: 1099px) { .watch { grid-template-columns: 1fr; } }

.stage { display: grid; gap: 14px; position: sticky; top: 80px; }
@media (max-width: 1099px) { .stage { position: static; } }

.player-frame {
  aspect-ratio: 16 / 9; width: 100%;
  background: #000; border-radius: var(--r); overflow: hidden;
  border: 1px solid var(--line);
}
.player-frame iframe, .player-frame > div { width: 100%; height: 100%; border: 0; }

.page-head:has(.watch-title) { margin-bottom: 5px; }
.page:has(.watch-title) { padding-top: 9px; }
.watch-title { font-size: 1.5rem; line-height: 1.3; overflow-wrap: anywhere; }
.stage-bar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.now-line {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface-raised); padding: 16px 18px; display: grid; gap: 10px;
  min-height: 118px; align-content: start;
}
.now-en { font-size: 1.375rem; line-height: 1.45; font-weight: 500; color: var(--ink); }
.now-ru { font-size: 1rem; color: var(--ink-2); line-height: 1.5; }
@media (max-width: 767px) { .now-en { font-size: 1.125rem; } }

/* the reader */

.reader-panel { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-raised); display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; position: sticky; top: 80px; height: calc(100dvh - 96px); max-height: 760px; }
@media (max-width: 1099px) { .reader-panel { position: static; height: 70dvh; max-height: none; } }

.reader-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.reader-head .t { font-size: .875rem; font-weight: 600; color: var(--ink-2); }

.reader { overflow-y: auto; padding: 8px; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { .reader { scroll-behavior: auto; } }

.sent {
  display: grid; gap: 5px;
  padding: 11px 12px; border-radius: var(--r-sm);
  border-left: 3px solid transparent;
  cursor: default;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.sent + .sent { margin-top: 2px; }
.sent:hover { background: var(--surface-2); }
.sent.is-active { background: var(--accent-soft); border-left-color: var(--accent); }
.sent.is-done .sent-en { color: var(--ink-2); }

.sent-time {
  font-family: var(--mono); font-size: .6875rem; color: var(--ink-3);
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.sent-en { font-size: 1rem; line-height: 1.65; color: var(--ink); }
.sent-ru { font-size: .875rem; line-height: 1.5; color: var(--ink-2); }
.sent.is-active .sent-ru { color: var(--ink); }

/* words: the core interaction */

.w {
  appearance: none; border: 0; background: none; font: inherit; color: inherit;
  padding: 1px 1px; margin: 0 -1px; border-radius: 4px;
  cursor: pointer; line-height: inherit;
  transition: color .08s linear, background var(--dur) var(--ease);
}
.w:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.w.is-active { color: var(--accent); -webkit-text-stroke: .7px currentColor; text-shadow: .35px 0 0 currentColor; }
:root[data-theme="dark"] .w.is-active { color: var(--accent-hover); }
.w.is-saved { box-shadow: inset 0 -2px 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
.w.in-phrase { background: color-mix(in srgb, var(--warn) 16%, transparent); }
.w.in-phrase:hover { background: color-mix(in srgb, var(--warn) 30%, transparent); }
.w-punct { cursor: default; }
.w-punct:hover { background: none; }

.now-en .w { padding: 2px 2px; border-radius: 5px; }

/* word popup */

.pop {
  position: absolute; z-index: var(--z-pop);
  width: min(320px, calc(100vw - 24px));
  background: var(--surface-raised); border: 1px solid var(--line-strong);
  border-radius: var(--r); box-shadow: var(--shadow-2);
  padding: 14px; display: grid; gap: 10px;
  animation: pop-in .14s var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.pop .pop-head { display: flex; align-items: baseline; gap: 8px; }
.pop .pop-term { font-size: 1.125rem; font-weight: 640; letter-spacing: -.01em; }
.pop .pop-tr { font-size: 1rem; color: var(--ink); }
.pop .pop-note { font-size: .875rem; color: var(--ink-2); line-height: 1.5; }
.pop .pop-kind { margin-left: auto; }
.pop .pop-actions { display: flex; gap: 8px; }
.pop .pop-miss { font-size: .875rem; color: var(--ink-2); }

/* ---------- dictionary ---------- */

.dict-groups { display: grid; gap: 22px; }
.dict-group { display: grid; gap: 10px; }
.dict-group > header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dict-group > header h3 { font-size: 1rem; }

.dict-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.dict-item {
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-raised);
  padding: 12px 13px; display: grid; gap: 5px; align-content: start;
}
.dict-item .term { font-weight: 640; display: flex; align-items: center; gap: 7px; }
.dict-item .tr { color: var(--ink-2); font-size: .9375rem; }
.dict-item .note { color: var(--ink-3); font-size: .8125rem; line-height: 1.45; }
.dict-item .acts { display: flex; gap: 6px; margin-top: 4px; }

/* ---------- exercises ---------- */

.ex-wrap { max-width: 720px; margin-inline: auto; display: grid; gap: 18px; }

.ex-progress { height: 4px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.ex-progress > i { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); transition: width .3s var(--ease); }

.ex-card { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-raised); padding: 26px 22px; display: grid; gap: 18px; min-height: 260px; align-content: start; }
.ex-kind { font-size: .8125rem; font-weight: 600; color: var(--ink-2); }
.ex-prompt { font-size: 1.5rem; font-weight: 600; letter-spacing: -.015em; line-height: 1.3; }
.ex-sub { color: var(--ink-2); font-size: .9375rem; }

.ex-options { display: grid; gap: 9px; }
.ex-opt {
  appearance: none; cursor: pointer; font: inherit; text-align: left;
  padding: 13px 15px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface-raised); color: var(--ink);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.ex-opt:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink-3); }
.ex-opt:active:not(:disabled) { transform: scale(.99); }
.ex-opt:disabled { cursor: default; }
.ex-opt.is-right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.ex-opt.is-wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

.ex-verdict { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.ex-verdict.ok  { color: var(--ok); }
.ex-verdict.bad { color: var(--bad); }

.ex-clip { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; aspect-ratio: 16 / 9; background: #000; }

.ex-done { display: grid; gap: 16px; justify-items: center; text-align: center; padding: 34px 20px; }
.ex-score { font-size: 3rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.ex-score small { display: block; font-size: .875rem; font-weight: 500; color: var(--ink-2); letter-spacing: 0; margin-top: 8px; }

/* ---------- admin ---------- */

.admin-grid { display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 899px) { .admin-grid { grid-template-columns: 1fr; gap: 16px; } }

.admin-rail { display: grid; gap: 2px; position: sticky; top: 80px; }
@media (max-width: 899px) { .admin-rail { position: static; grid-auto-flow: column; justify-content: start; overflow-x: auto; } }
.admin-rail a {
  display: flex; align-items: center; gap: 9px; padding: 8px 11px; border-radius: var(--r-sm);
  color: var(--ink-2); text-decoration: none; font-size: .9375rem; font-weight: 500; white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.admin-rail a:hover { background: var(--surface-2); color: var(--ink); }
.admin-rail a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
:root[data-theme="dark"] .admin-rail a[aria-current="page"] { color: var(--accent-hover); }

/* video list as sortable rows, not a bordered spec table */
.vrows { display: grid; gap: 8px; }
.vrow {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-raised);
  padding: 10px 12px;
  transition: border-color var(--dur) var(--ease);
}
.vrow:hover { border-color: var(--line-strong); }
.vrow .vthumb { aspect-ratio: 16 / 9; border-radius: var(--r-sm); overflow: hidden; background: var(--surface-3); }
.vrow .vthumb img { width: 100%; height: 100%; object-fit: cover; }
.vrow .vmeta { display: grid; gap: 4px; min-width: 0; }
.vrow .vmeta .t { font-weight: 600; font-size: .9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vrow .vmeta .s { color: var(--ink-2); font-size: .8125rem; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.vrow .vacts { display: flex; gap: 6px; align-items: center; }
.vrow.is-draft .vthumb, .vrow.is-draft .vmeta .t { opacity: .55; }
@media (max-width: 719px) {
  .vrow { grid-template-columns: 76px minmax(0, 1fr); }
  .vrow .vacts { grid-column: 1 / -1; justify-content: flex-end; }
}

/* ---------- admin lesson editor ---------- */

.ed { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 400px); gap: 18px; align-items: start; }
@media (max-width: 1099px) { .ed { grid-template-columns: 1fr; } }

.ed-side { display: grid; gap: 14px; position: sticky; top: 80px; }
@media (max-width: 1099px) { .ed-side { position: static; } }

.ed-sents { display: grid; gap: 10px; }

.ed-sent {
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-raised);
  display: grid; gap: 10px; padding: 12px 13px;
}
.ed-sent.is-cur { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.ed-sent > header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ed-sent > header .n { font-family: var(--mono); font-size: .75rem; color: var(--ink-3); }

.ed-times { display: flex; align-items: center; gap: 6px; }
.ed-times .input { width: 92px; }

.ed-words { display: flex; flex-wrap: wrap; gap: 5px; }
.ed-word {
  display: inline-grid; gap: 1px; justify-items: center;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); padding: 4px 7px 5px;
  cursor: pointer; text-align: center;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.ed-word:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.ed-word.is-cur { border-color: var(--accent); background: var(--accent-soft); }
.ed-word.no-tr { border-style: dashed; }
.ed-word .wt { font-size: .875rem; font-weight: 600; }
.ed-word .wtr { font-size: .6875rem; color: var(--ink-2); max-width: 15ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-word .wtime { font-family: var(--mono); font-size: .625rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.ed-phrases { display: grid; gap: 6px; }
.ed-phrase {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 9px; border-radius: var(--r-sm);
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  font-size: .8125rem;
}
.ed-phrase .pt { font-weight: 650; }

/* timing studio */

.studio { display: grid; gap: 12px; }
.studio-frame { aspect-ratio: 16 / 9; border-radius: var(--r); overflow: hidden; background: #000; border: 1px solid var(--line); }
.studio-frame iframe, .studio-frame > div { width: 100%; height: 100%; border: 0; }
.studio-hint { font-size: .8125rem; color: var(--ink-2); line-height: 1.5; }
.studio-hint kbd {
  font-family: var(--mono); font-size: .75rem;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px;
  padding: 1px 5px; background: var(--surface-2); color: var(--ink);
}
.studio-target {
  border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: var(--r);
  padding: 12px 14px; display: grid; gap: 4px; min-height: 76px; align-content: center;
}
.studio-target .lbl { font-size: .75rem; font-weight: 600; color: var(--accent); }
:root[data-theme="dark"] .studio-target .lbl { color: var(--accent-hover); }
.studio-target .val { font-size: 1.25rem; font-weight: 650; }
.studio-target .ctx { font-size: .8125rem; color: var(--ink-2); }

/* ---------- stats ---------- */

/* Real gaps rather than a 1px-gap trick: an odd item count must not leave a
   filled-looking empty cell at the end of the row. */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.stat {
  background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; display: grid; gap: 4px; align-content: start;
}
.stat .k { font-size: .8125rem; color: var(--ink-2); font-weight: 500; }
.stat .v { font-family: var(--mono); font-size: 1.75rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .d { font-size: .75rem; color: var(--ink-3); }

.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.bar-row .bl { font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bv { font-family: var(--mono); font-size: .8125rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bar-row .bt { grid-column: 1 / -1; height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.bar-row .bt > i { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); }

.users-list { display: grid; gap: 8px; }
.user-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-raised);
}
.user-row .un { font-weight: 600; font-size: .9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .ue { font-size: .8125rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .ud { font-family: var(--mono); font-size: .75rem; color: var(--ink-3); text-align: right; }
