/* Video studio. Tokens follow the docs site (src/css/custom.css). */

@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --brand-500: #1a7ae0;
  --brand-600: #0b6bcb;
  --brand-700: #0a5aac;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #64748b;
  --surface: #ffffff;
  --sunken: #f8fafc;
  --line: #e2e8f0;
  --line-soft: #eef2f7;
  --ok: #0f8f6a;
  --ok-bg: #e9f8f2;
  --info: #0b6bcb;
  --info-bg: #eaf3fd;
  --warn: #b45309;
  --warn-bg: #fdf4e7;
  --danger: #be123c;
  --danger-bg: #fdf0f3;
  --record: #e11d48;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 6%);
  --shadow-md: 0 8px 28px -8px rgb(15 23 42 / 18%);
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand-50: #12243a;
    --brand-100: #16314f;
    --brand-500: #74b3f5;
    --brand-600: #74b3f5;
    --brand-700: #a8d2f9;
    --ink: #e6edf5;
    --ink-soft: #a5b3c4;
    --ink-faint: #8494a6;
    --surface: #0d131b;
    --sunken: #121a24;
    --line: #23303f;
    --line-soft: #1b2632;
    --ok: #4fd1a5;
    --ok-bg: #0e2019;
    --info: #74b3f5;
    --info-bg: #101f30;
    --warn: #f0b04a;
    --warn-bg: #241c0e;
    --danger: #f87f9c;
    --danger-bg: #261219;
    --record: #fb7185;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-md: 0 8px 28px -8px rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  background: var(--sunken);
  color: var(--ink);
  font: 15px/1.75 Vazirmatn, system-ui, sans-serif;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.4;
  font-weight: 700;
}

h1 {
  font-size: 1.6rem;
}

h2 {
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0;
}

a {
  color: var(--brand-600);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
.ltr {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.86em;
}

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

.small {
  font-size: 0.85rem;
}

.warn-text {
  color: var(--warn);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

/* Icons ------------------------------------------------------------------ */

.icon {
  display: inline-flex;
  width: 1.1em;
  height: 1.1em;
  flex: none;
  vertical-align: -0.15em;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.icon.big {
  width: 2.2rem;
  height: 2.2rem;
  color: var(--brand-600);
}

/* Controls --------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.4rem;
  padding: 0.35rem 1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none !important;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  min-height: 2rem;
  padding: 0.2rem 0.7rem;
  font-size: 0.85rem;
}

.btn-wide {
  width: 100%;
}

.btn-primary {
  background: var(--brand-600);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-700);
}

@media (prefers-color-scheme: dark) {
  .btn-primary {
    color: #08111c;
  }
}

.btn-primary.record .icon {
  color: #fecdd3;
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--brand-500);
  color: var(--brand-600);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--line-soft);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
}

.btn-danger-ghost:hover {
  background: var(--danger-bg);
}

.icon-only {
  padding: 0.2rem;
  width: 2rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: 2.4rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
  line-height: 1.7;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgb(26 122 224 / 15%);
}

input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  min-height: 0;
  margin: 0;
  accent-color: var(--brand-600);
}

input[type="date"],
input[type="datetime-local"] {
  direction: ltr;
  text-align: right;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field > span,
.field > .label {
  font-weight: 600;
  font-size: 0.9rem;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.inline > select {
  width: auto;
  flex: 1;
}

.form-actions,
.card-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.form-error {
  color: var(--danger);
  font-size: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.05rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-muted {
  background: var(--line-soft);
  color: var(--ink-soft);
}

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex: none;
}

.dot-ok {
  background: var(--ok);
}

.dot-info {
  background: var(--info);
}

.dot-warn {
  background: var(--warn);
}

.dot-danger {
  background: var(--danger);
}

.dot-muted {
  background: var(--ink-faint);
}

.alert {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.alert-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.meter {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.meter.big {
  height: 10px;
  width: 100%;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--brand-600);
  border-radius: inherit;
  transition: width 0.3s;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 0.9rem;
  align-content: start;
}

.empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--ink-faint);
}

/* Login ------------------------------------------------------------------ */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: 1rem;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  height: 40px;
  width: auto;
  justify-self: start;
}

/* Shell ------------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 3.6rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none !important;
}

.brand img {
  height: 26px;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  height: 100%;
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.8rem;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.92rem;
  border-bottom: 2px solid transparent;
  text-decoration: none !important;
}

.tab:hover {
  color: var(--ink);
}

.tab.active {
  color: var(--brand-600);
  border-bottom-color: var(--brand-600);
}

.topbar-end {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.user {
  padding: 0 0.5rem;
  color: var(--ink-soft);
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
  display: grid;
  gap: 1.25rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.page-head p {
  margin-top: 0.25rem;
  max-width: 70ch;
}

/* Features --------------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: 2fr repeat(4, 1fr);
  gap: 0.75rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: grid;
  gap: 0.1rem;
  align-content: start;
}

.stat strong {
  font-size: 1.5rem;
  line-height: 1.3;
}

.stat span {
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.stat-progress .meter {
  margin-top: 0.5rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.toolbar select {
  width: auto;
  min-width: 11rem;
}

.search {
  position: relative;
  flex: 1;
  min-width: 15rem;
}

.search .icon {
  position: absolute;
  inset-inline-start: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
}

.search input {
  padding-inline-start: 2.2rem;
}

.segments {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.segment {
  border: 0;
  background: transparent;
  padding: 0.25rem 0.8rem;
  border-radius: 6px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.segment.active {
  background: var(--brand-50);
  color: var(--brand-600);
  font-weight: 600;
}

.groups {
  display: grid;
  gap: 1.5rem;
}

.group h2 {
  margin-bottom: 0.5rem;
}

.count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-faint);
  background: var(--line-soft);
  border-radius: 999px;
  padding: 0 0.5rem;
}

.feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.feature-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1rem;
}

.feature-row + .feature-row {
  border-top: 1px solid var(--line-soft);
}

.feature-row:hover {
  background: var(--sunken);
}

.feature-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.6rem;
}

.feature-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.7rem;
  margin-top: 0.15rem;
}

.feature-meta .icon {
  margin-inline-end: 0.25rem;
}

.kind {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0 0.45rem;
  border-radius: 5px;
  background: var(--line-soft);
  color: var(--ink-soft);
}

.kind-upcoming {
  background: var(--warn-bg);
  color: var(--warn);
}

.kind-guide {
  background: var(--ok-bg);
  color: var(--ok);
}

.path {
  color: var(--ink-faint);
}

.feature-videos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.video-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
  padding: 0.1rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.83rem;
  text-decoration: none !important;
  background: var(--surface);
}

.video-chip:hover {
  border-color: var(--brand-500);
}

.chip-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
}

.chip-lang {
  font-size: 0.72rem;
  color: var(--ink-faint);
  text-transform: uppercase;
}

.feature-actions {
  display: flex;
  gap: 0.35rem;
}

/* Videos ----------------------------------------------------------------- */

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.video-card {
  display: grid;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--ink);
  text-decoration: none !important;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.video-card:hover {
  border-color: var(--brand-500);
  box-shadow: var(--shadow-md);
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--line-soft);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--ink-faint);
}

.thumb-empty .icon {
  width: 2rem;
  height: 2rem;
}

.duration {
  position: absolute;
  bottom: 0.45rem;
  left: 0.45rem;
  padding: 0 0.4rem;
  border-radius: 5px;
  background: rgb(0 0 0 / 75%);
  color: #fff;
  font-size: 0.78rem;
  direction: ltr;
}

.on-thumb {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  box-shadow: var(--shadow-sm);
}

.card-body {
  padding: 0.7rem 0.85rem 0.85rem;
  display: grid;
  gap: 0.15rem;
}

.card-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-foot {
  display: flex;
  justify-content: space-between;
}

/* Upcoming --------------------------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem 1rem;
  margin-bottom: 0.9rem;
}

.span-2 {
  grid-column: span 2;
}

.upcoming-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

.upcoming-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: grid;
  gap: 0.7rem;
  align-content: start;
}

.upcoming-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}

.upcoming-head > div {
  display: grid;
}

/* Editor ----------------------------------------------------------------- */

.editor-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.editor-title {
  display: grid;
  gap: 0.25rem;
}

.title-input {
  font-size: 1.35rem;
  font-weight: 700;
  border-color: transparent;
  background: transparent;
  padding-inline: 0.4rem;
}

.title-input:hover {
  border-color: var(--line);
}

.status-slot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding-inline: 0.4rem;
}

.status-slot a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.editor-actions {
  display: flex;
  gap: 0.5rem;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.editor-main {
  display: grid;
  gap: 1.25rem;
}

.details {
  gap: 1.3rem;
  position: sticky;
  top: 4.6rem;
}

.preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  display: block;
}

.preview.live {
  outline: 3px solid var(--record);
}

.media-info {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.media-info .icon {
  margin-inline-end: 0.25rem;
}

.ready,
.uploading,
.processing,
.source-chooser,
.recorder {
  display: grid;
  gap: 0.8rem;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.source-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.source-card {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.4rem;
  min-height: 220px;
  padding: 1.5rem;
  text-align: center;
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: var(--sunken);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.source-card strong {
  font-size: 1.05rem;
}

.source-card span:not(.icon) {
  color: var(--ink-faint);
  font-size: 0.88rem;
  max-width: 28ch;
}

.source-card:hover,
.source-card.over,
.source-card.active {
  border-color: var(--brand-500);
  background: var(--brand-50);
}

.processing {
  justify-items: center;
  text-align: center;
  padding: 2.5rem 1rem;
}

.processing .percent {
  font-size: 1.3rem;
  font-weight: 700;
}

.processing .meter {
  max-width: 420px;
}

.spinner {
  width: 2.2rem;
  height: 2.2rem;
  border: 3px solid var(--line);
  border-top-color: var(--brand-600);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.trim-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.time-input {
  width: 6.5rem;
  flex: none;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.chapters,
.captions {
  display: grid;
  gap: 0.45rem;
  justify-items: start;
}

.chapter-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  width: 100%;
}

.caption-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.picker {
  display: grid;
  gap: 0.5rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.1rem 0.25rem 0.1rem 0.4rem;
  padding-inline-start: 0.7rem;
  background: var(--brand-50);
  color: var(--brand-700);
  border-radius: 999px;
  font-size: 0.86rem;
}

.chip-upcoming {
  background: var(--warn-bg);
  color: var(--warn);
}

.chip button {
  display: inline-flex;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0.15rem;
  border-radius: 50%;
  cursor: pointer;
}

.chip button:hover {
  background: rgb(0 0 0 / 8%);
}

.picker-box {
  position: relative;
}

.picker-results {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 4px);
  z-index: 5;
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  max-height: 300px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

.picker-results button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  text-align: start;
  cursor: pointer;
}

.picker-results button:hover {
  background: var(--sunken);
}

.meta {
  border-top: 1px solid var(--line-soft);
  padding-top: 0.9rem;
}

.danger-zone {
  display: flex;
  justify-content: flex-end;
}

/* Recorder --------------------------------------------------------------- */

.rec-settings {
  display: grid;
  gap: 0.6rem;
}

.rec-settings .inline select {
  max-width: 320px;
}

.tips {
  padding: 0.8rem 1rem;
  border-radius: 8px;
  background: var(--info-bg);
  font-size: 0.88rem;
}

.tips ul {
  margin: 0.3rem 0 0;
  padding-inline-start: 1.2rem;
}

.countdown {
  display: grid;
  justify-items: center;
  padding: 3rem 1rem;
  text-align: center;
}

.countdown span {
  font-size: 5rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--record);
}

.rec-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.rec-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  color: var(--record);
}

.rec-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--record);
  animation: blink 1.2s ease-in-out infinite;
}

.rec-indicator.paused {
  color: var(--ink-faint);
}

.rec-indicator.paused .rec-dot {
  animation: none;
  background: var(--ink-faint);
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

.rec-time {
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.level {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-inline-start: auto;
  color: var(--ink-faint);
}

.level-bar {
  width: 120px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  direction: ltr;
}

.level-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ok);
}

/* Dialogs and toasts ----------------------------------------------------- */

.dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.4rem;
  width: min(420px, calc(100vw - 2rem));
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 1rem;
}

.dialog:not([open]) {
  display: none;
}

.dialog::backdrop {
  background: rgb(15 23 42 / 45%);
}

.dialog-wide {
  width: min(640px, calc(100vw - 2rem));
}

.dialog-close {
  position: absolute;
  top: 0.8rem;
  left: 0.8rem;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
}

.steps {
  margin: 0;
  padding-inline-start: 1.3rem;
  display: grid;
  gap: 0.8rem;
}

.steps p {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

#toasts {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: grid;
  gap: 0.5rem;
  justify-items: center;
  pointer-events: none;
}

.toast {
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.92rem;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.4s;
  max-width: min(560px, calc(100vw - 2rem));
}

.toast-danger {
  background: var(--danger);
  color: #fff;
}

.toast-warn {
  background: var(--warn);
  color: #fff;
}

.toast.leaving {
  opacity: 0;
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

/* Narrow screens --------------------------------------------------------- */

@media (max-width: 1100px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-progress {
    grid-column: span 2;
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  .details {
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar-inner {
    gap: 0.75rem;
    padding: 0 0.75rem;
  }

  .brand span,
  .tab .icon,
  .topbar-end .btn-ghost:not(:last-child),
  .user {
    display: none;
  }

  .feature-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .source-cards,
  .form-grid,
  .trim-row {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .editor-head {
    grid-template-columns: 1fr;
  }

  .page-head {
    flex-direction: column;
  }
}
