:root {
  color-scheme: dark;
  --bg: oklch(0.155 0.014 262);
  --bg-soft: oklch(0.19 0.018 262);
  --surface: oklch(0.225 0.02 262 / 0.88);
  --surface-solid: oklch(0.225 0.02 262);
  --surface-raised: oklch(0.265 0.025 262);
  --surface-hover: oklch(0.29 0.028 262);
  --line: oklch(0.39 0.025 262 / 0.6);
  --line-strong: oklch(0.49 0.04 262 / 0.72);
  --text: oklch(0.965 0.008 255);
  --text-soft: oklch(0.83 0.025 255);
  --muted: oklch(0.68 0.035 255);
  --accent: oklch(0.7 0.16 252);
  --accent-hover: oklch(0.75 0.145 252);
  --accent-soft: oklch(0.7 0.16 252 / 0.14);
  --accent-line: oklch(0.7 0.16 252 / 0.42);
  --live: oklch(0.68 0.205 27);
  --live-soft: oklch(0.68 0.205 27 / 0.14);
  --ok: oklch(0.75 0.16 151);
  --ok-soft: oklch(0.75 0.16 151 / 0.13);
  --danger: oklch(0.72 0.17 24);
  --danger-soft: oklch(0.72 0.17 24 / 0.12);
  --radius-sm: 0.75rem;
  --radius-md: 1rem;
  --radius-lg: 1.5rem;
  --shadow: 0 1px 2px oklch(0 0 0 / 0.2), 0 20px 60px oklch(0 0 0 / 0.22);
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 20rem; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -10%, oklch(0.48 0.13 259 / 0.2), transparent 35rem),
    radial-gradient(circle at 100% 40%, oklch(0.42 0.1 215 / 0.09), transparent 28rem),
    var(--bg);
  font: 400 0.9375rem/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font: inherit; }
button, select, label[for], input[type="checkbox"] { cursor: pointer; }

a {
  color: var(--accent);
  text-decoration-thickness: from-font;
  text-underline-offset: 0.2em;
}
a:hover { color: var(--accent-hover); }

::selection { color: var(--text); background: oklch(0.7 0.16 252 / 0.38); }

.skip-link {
  position: fixed;
  inset-block-start: 0.75rem;
  inset-inline-start: 0.75rem;
  z-index: 100;
  transform: translateY(-200%);
  padding: 0.65rem 0.9rem;
  border-radius: 0.6rem;
  color: var(--bg);
  background: var(--text);
  font-weight: 700;
}
.skip-link:focus { transform: translateY(0); }

.wrap {
  width: min(100%, 78rem);
  margin-inline: auto;
  padding: clamp(1rem, 2.5vw, 2.25rem);
}

main.wrap { padding-block-end: 4rem; }
.narrow { width: min(100%, 70rem); }

header.top {
  position: sticky;
  inset-block-start: 0;
  z-index: 20;
  display: flex;
  min-height: 4.5rem;
  align-items: center;
  gap: 0.75rem;
  padding-inline: max(1rem, calc((100vw - 78rem) / 2 + 2.25rem));
  border-block-end: 1px solid var(--line);
  background: oklch(0.165 0.014 262 / 0.84);
  box-shadow: 0 1px 0 oklch(1 0 0 / 0.015);
  backdrop-filter: blur(18px) saturate(130%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 720;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand::before {
  content: "";
  width: 2rem;
  height: 2rem;
  margin-inline-end: 0.7rem;
  border-radius: 0.7rem;
  background:
    linear-gradient(90deg, transparent 22%, oklch(0.98 0 0 / 0.95) 22% 31%, transparent 31% 44%, oklch(0.98 0 0 / 0.95) 44% 56%, transparent 56% 69%, oklch(0.98 0 0 / 0.95) 69% 78%, transparent 78%),
    linear-gradient(135deg, oklch(0.73 0.18 249), oklch(0.61 0.2 277));
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.25), 0 8px 24px oklch(0.6 0.18 260 / 0.23);
}

.brand span { color: var(--accent); }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 0.8125rem; }

.top-status {
  display: inline-flex;
  min-height: 2.25rem;
  align-items: center;
  gap: 0.55rem;
  padding-inline: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.card-pad { padding: clamp(1.2rem, 3vw, 2rem); }
.card + .card { margin-block-start: 1rem; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0.25rem var(--accent-soft);
}

h1, h2, h3, p { overflow-wrap: break-word; }
h1, h2, h3 { color: var(--text); text-wrap: balance; }
h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.65rem);
  font-weight: 730;
  line-height: 1.08;
  letter-spacing: -0.045em;
}
h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 680;
  line-height: 1.25;
  letter-spacing: -0.015em;
}
h3 { margin: 0; font-size: 0.95rem; }
.sub {
  max-width: 65ch;
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
  text-wrap: pretty;
}

label {
  display: block;
  margin-block: 1rem 0.45rem;
  color: var(--text-soft);
  font-size: 0.8rem;
  font-weight: 620;
}

input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text);
  background: oklch(0.18 0.016 262 / 0.78);
  box-shadow: inset 0 1px 1px oklch(0 0 0 / 0.12);
  transition-property: border-color, background-color, box-shadow;
  transition-duration: 140ms;
}

input::placeholder, textarea::placeholder { color: oklch(0.58 0.028 255); }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--bg-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 5rem; resize: vertical; }

select {
  padding-inline-end: 2.5rem;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 1.05rem) 50%, calc(100% - 0.75rem) 50%;
  background-size: 0.3rem 0.3rem, 0.3rem 0.3rem;
  background-repeat: no-repeat;
}

button {
  display: inline-flex;
  min-height: 2.65rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: oklch(0.985 0 0);
  background: var(--accent);
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.22), 0 8px 22px oklch(0.46 0.13 257 / 0.2);
  font-weight: 680;
  line-height: 1.1;
  cursor: pointer;
  transition-property: transform, background-color, border-color, color, box-shadow, opacity;
  transition-duration: 140ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}
button:hover { background: var(--accent-hover); }
button:active { transform: scale(0.96); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}
button:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
button:disabled:active { transform: none; }
button.ghost {
  color: var(--text-soft);
  border-color: var(--line);
  background: oklch(1 0 0 / 0.035);
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.035);
}
button.ghost:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface-hover); }
button.danger { color: var(--danger); border-color: transparent; background: transparent; box-shadow: none; }
button.danger:hover { border-color: oklch(0.72 0.17 24 / 0.24); background: var(--danger-soft); }
button.big { min-height: 3.2rem; padding-inline: 1.4rem; }
button.icon-only { width: 2.65rem; padding-inline: 0; }

.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.grow { flex: 1 1 12rem; min-width: 0; }
.mt { margin-block-start: 1.25rem; }

.msg {
  display: none;
  margin-block-start: 1rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}
.msg.err { display: block; color: oklch(0.87 0.09 25); border-color: oklch(0.72 0.17 24 / 0.28); background: var(--danger-soft); }
.msg.ok { display: block; color: oklch(0.88 0.1 151); border-color: oklch(0.75 0.16 151 / 0.25); background: var(--ok-soft); }

/* Authentication */
.auth-shell {
  display: grid;
  min-height: calc(100vh - 4.5rem);
  grid-template-columns: minmax(0, 1.12fr) minmax(22rem, 0.88fr);
  gap: clamp(2rem, 7vw, 7rem);
  align-items: center;
  padding-block: clamp(2rem, 6vw, 5rem);
}
.auth-story { align-self: center; }
.auth-story h1 { max-width: 13ch; font-size: clamp(2.7rem, 6vw, 5.4rem); }
.auth-story .sub { max-width: 34rem; font-size: clamp(1rem, 1.8vw, 1.18rem); }
.feature-list {
  display: grid;
  max-width: 38rem;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-block-start: 2rem;
}
.feature {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  background: oklch(1 0 0 / 0.025);
  font-size: 0.78rem;
  line-height: 1.45;
}
.feature strong { display: block; margin-block-end: 0.2rem; color: var(--text); font-size: 0.86rem; }
.auth-card { width: 100%; max-width: 29rem; justify-self: end; padding: clamp(1.4rem, 4vw, 2.1rem); }
.auth-card h2 { font-size: 1.35rem; }
.auth-card button[type="submit"] { width: 100%; margin-block-start: 0.25rem; }
.auth-card .sub { margin-block-end: 1.5rem; }
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-block: 1.35rem 0.25rem;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius-sm) + 0.3rem);
  background: oklch(0.16 0.014 262 / 0.7);
}
.tabs button {
  min-height: 2.5rem;
  padding: 0.55rem 0.8rem;
  color: var(--muted);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  box-shadow: none;
}
.tabs button.active { color: var(--text); background: var(--surface-raised); box-shadow: 0 1px 2px oklch(0 0 0 / 0.2); }

/* Dashboard */
.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-block: 0.8rem 1.5rem;
}
.page-head h1 { font-size: clamp(2rem, 4vw, 3.2rem); }
.create-card { padding: clamp(1.2rem, 3vw, 2rem); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-block-end: 1rem; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(14rem, 0.4fr); gap: 1rem; align-items: end; }
.form-grid label { margin-block-start: 0; }
.option-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.check {
  display: inline-flex;
  min-height: 2.65rem;
  align-items: center;
  gap: 0.65rem;
  margin: 0;
  padding-inline: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  background: oklch(1 0 0 / 0.025);
}
.check:has(input:checked) { color: var(--text); border-color: var(--accent-line); background: var(--accent-soft); }
.check input { width: 1rem; height: 1rem; accent-color: var(--accent); }
.events-card { margin-block-start: 1rem; padding: clamp(1.2rem, 3vw, 2rem); }
.events-list { display: grid; gap: 0.65rem; }
.event {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: oklch(1 0 0 / 0.027);
  transition-property: background-color, border-color, transform;
  transition-duration: 140ms;
}
.event:hover { border-color: var(--line); background: oklch(1 0 0 / 0.045); }
.event-main { min-width: 0; }
.event .title { color: var(--text); font-weight: 670; }
.event .meta { margin-block-start: 0.25rem; color: var(--muted); font-size: 0.77rem; font-variant-numeric: tabular-nums; }
.event-actions { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; justify-content: end; }
.event-actions button { min-height: 2.4rem; padding: 0.55rem 0.75rem; font-size: 0.78rem; }
.badge {
  display: inline-flex;
  min-height: 1.6rem;
  align-items: center;
  gap: 0.38rem;
  padding-inline: 0.58rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: oklch(1 0 0 / 0.025);
  font-size: 0.65rem;
  font-weight: 740;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge::before { content: ""; width: 0.34rem; height: 0.34rem; border-radius: 50%; background: currentColor; }
.badge.live { color: oklch(0.88 0.1 27); border-color: oklch(0.68 0.205 27 / 0.3); background: var(--live-soft); }
.badge.ended { color: oklch(0.84 0.1 151); border-color: oklch(0.75 0.16 151 / 0.24); background: var(--ok-soft); }
.empty-state { padding: 3rem 1.25rem; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-block-end: 0.25rem; color: var(--text); font-size: 1rem; }

/* Live workspaces */
.studio-head { padding: clamp(1.2rem, 3vw, 1.75rem); }
.studio-title { display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; }
.studio-title h1 { font-size: clamp(1.55rem, 3vw, 2.25rem); }
.studio-actions { display: flex; align-items: center; gap: 0.8rem; }
.start-button { min-width: 9rem; }
.start-button.is-live { color: oklch(0.94 0.045 24); border-color: oklch(0.72 0.17 24 / 0.3); background: var(--danger-soft); box-shadow: none; }
.stream-meta { display: flex; gap: 0.45rem; flex-wrap: wrap; margin-block-start: 0.8rem; }
.meta-pill { padding: 0.3rem 0.58rem; border-radius: 999px; color: var(--muted); background: oklch(1 0 0 / 0.04); font-size: 0.72rem; }
.share-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.65rem; margin-block-start: 1.35rem; }
.linkbox {
  display: flex;
  min-height: 2.9rem;
  align-items: center;
  gap: 0.6rem;
  padding-inline: 0.85rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  background: oklch(0.16 0.014 262 / 0.58);
  font: 0.77rem/1.35 var(--mono);
}
.linkbox .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: all; }
.hint { margin-block-start: 0.55rem; color: var(--muted); font-size: 0.76rem; }
.live-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.58fr) minmax(19rem, 0.72fr);
  gap: 1rem;
  align-items: stretch;
  margin-block-start: 1rem;
}
.workspace-card { min-height: min(42rem, calc(100vh - 18rem)); padding: 1.1rem; overflow: hidden; }
.workspace-head { display: flex; min-height: 2.25rem; align-items: center; justify-content: space-between; gap: 1rem; margin-block-end: 0.8rem; }
.workspace-label { display: flex; align-items: center; gap: 0.55rem; }
.count { color: var(--muted); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.transcript, .notes {
  height: min(35rem, calc(100vh - 23rem));
  min-height: 20rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--line-strong) transparent;
}
.transcript { display: flex; flex-direction: column; gap: 0.3rem; padding-inline-end: 0.35rem; }
.seg {
  position: relative;
  display: grid;
  grid-template-columns: 3.7rem minmax(0, 1fr);
  gap: 0.8rem;
  padding: 0.9rem;
  border-radius: var(--radius-sm);
  transition-property: background-color;
  transition-duration: 140ms;
}
.seg:hover { background: oklch(1 0 0 / 0.035); }
.seg .t { padding-block-start: 0.13rem; color: var(--muted); font: 0.7rem/1.5 var(--mono); font-variant-numeric: tabular-nums; }
.seg .orig { color: var(--text); font-size: 0.98rem; line-height: 1.6; }
.seg .tr { grid-column: 2; margin-block-start: 0.35rem; color: oklch(0.84 0.07 251); font-size: 0.9rem; line-height: 1.55; }
.seg.dim .orig { color: var(--muted); font-size: 0.82rem; }
.partial { min-height: 3rem; margin-block-start: 0.35rem; padding: 0.8rem 0.9rem 0.8rem 5.4rem; border-block-start: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; font-style: italic; }
.partial:empty::before { content: "Ожидаем следующую фразу…"; opacity: 0.55; }
.notes { padding: 0.25rem 0.35rem 1rem; color: var(--text-soft); font-size: 0.88rem; }
.notes h2 { margin: 1.5rem 0 0.55rem; color: var(--text); font-size: 0.88rem; }
.notes h2:first-child { margin-block-start: 0; }
.notes ul { margin: 0.4rem 0; padding-inline-start: 1.2rem; }
.notes li { margin-block: 0.42rem; }
.notes li::marker { color: var(--accent); }
.notes p { margin: 0.5rem 0; }
.notes code { padding: 0.12rem 0.32rem; border-radius: 0.3rem; background: var(--surface-raised); font-family: var(--mono); font-size: 0.82em; }
.notes .empty { display: grid; min-height: 14rem; place-items: center; margin: 0; color: var(--muted); text-align: center; font-style: normal; }
.meter { width: 7.5rem; height: 0.35rem; overflow: hidden; border-radius: 999px; background: var(--surface-raised); }
.meter i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--ok); transition: width 80ms linear; }
.dot { width: 0.48rem; height: 0.48rem; flex: 0 0 auto; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--live); box-shadow: 0 0 0 0.28rem var(--live-soft); }
.listener-head { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; }
.language-control { width: min(100%, 17rem); }
.language-control label { margin-block-start: 0; }
.top-language { display: none; width: auto; max-width: 12rem; }

@media (max-width: 58rem) {
  .auth-shell { grid-template-columns: 1fr; gap: 2.5rem; }
  .auth-story { padding-block-start: 1.5rem; }
  .auth-story h1 { max-width: 16ch; font-size: clamp(2.5rem, 9vw, 4.5rem); }
  .auth-card { max-width: 34rem; justify-self: start; }
  .live-grid { grid-template-columns: 1fr; }
  .workspace-card { min-height: auto; }
  .transcript, .notes { height: auto; max-height: 34rem; min-height: 18rem; }
}

@media (max-width: 42rem) {
  header.top { min-height: 4rem; padding-inline: 1rem; }
  .brand { font-size: 0.88rem; }
  .brand::before { width: 1.8rem; height: 1.8rem; }
  header.top .who { display: none; }
  header.top button { min-height: 2.4rem; padding-inline: 0.75rem; }
  .wrap { padding: 1rem; }
  .feature-list { display: none; }
  .auth-story { padding-block-start: 0; }
  .auth-story h1 { font-size: clamp(2.35rem, 13vw, 3.6rem); }
  .form-grid { grid-template-columns: 1fr; }
  .option-row { align-items: stretch; }
  .option-row .check { flex: 1 1 auto; }
  .option-row button { width: 100%; }
  .page-head, .listener-head, .studio-title { align-items: stretch; flex-direction: column; }
  .event { grid-template-columns: 1fr; }
  .event-actions { justify-content: start; }
  .event-actions button:not(.danger) { flex: 1; }
  .share-row { grid-template-columns: 1fr; }
  .share-row button { width: 100%; }
  .studio-actions { justify-content: space-between; }
  .start-button { flex: 1; }
  .meter { flex: 1; }
  .seg { grid-template-columns: 2.9rem minmax(0, 1fr); padding-inline: 0.45rem; }
  .seg .tr { grid-column: 2; }
  .partial { padding-inline-start: 4.15rem; }
  .language-control { display: none; }
  .top-language { display: block; max-width: 9.5rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .card { animation: rise 420ms cubic-bezier(0.2, 0, 0, 1) both; }
  .live-grid .card:nth-child(2), .events-card { animation-delay: 80ms; }
  .dot.on { animation: pulse 1.8s ease-out infinite; }
  @keyframes rise { from { opacity: 0; transform: translateY(0.5rem); } to { opacity: 1; transform: translateY(0); } }
  @keyframes pulse { 50% { box-shadow: 0 0 0 0.45rem oklch(0.68 0.205 27 / 0.02); } }
}

@media (forced-colors: active) {
  button, .card, .event, .check, .tabs, .top-status { border: 1px solid CanvasText; }
  button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline-color: Highlight; }
}
