/* Mobile-first UI shared by the website and Telegram Mini App. */
@font-face {
  font-family: "Manrope";
  src: url("/static/fonts/Manrope-Variable.ttf") format("truetype");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Unbounded";
  src: url("/static/fonts/Unbounded-Variable.ttf") format("truetype");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

:root {
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --font-display: "Unbounded", "Arial Black", sans-serif;
  --lime-400: oklch(0.91 0.22 124);
  --aqua-400: oklch(0.82 0.13 180);
  --header-height: 68px;
  --radius-lg: 20px;
  --radius-md: 15px;
  --radius-sm: 11px;
  --shadow: 0 18px 50px rgb(0 0 0 / 20%);
}

/* Primitive palette → semantic tokens → component tokens. */
html[data-design="studio"] {
  color-scheme: dark;
  --bg: oklch(0.155 0.018 155);
  --bg-elevated: oklch(0.185 0.020 155);
  --surface: oklch(0.215 0.022 155);
  --surface-hover: oklch(0.265 0.028 155);
  --surface-soft: oklch(0.255 0.025 155);
  --input: oklch(0.180 0.018 155);
  --text: oklch(0.955 0.018 120);
  --text-soft: oklch(0.780 0.030 145);
  --muted: oklch(0.670 0.028 150);
  --border: oklch(0.315 0.032 155);
  --border-strong: oklch(0.440 0.050 150);
  --accent: var(--lime-400);
  --accent-strong: oklch(0.82 0.20 124);
  --accent-text: oklch(0.215 0.040 130);
  --accent-soft: oklch(0.91 0.22 124 / 12%);
  --header: oklch(0.155 0.018 155 / 84%);
  --success: oklch(0.82 0.17 155);
  --success-soft: oklch(0.82 0.17 155 / 12%);
  --danger: oklch(0.74 0.17 25);
  --danger-soft: oklch(0.74 0.17 25 / 12%);
  --warning: oklch(0.84 0.15 85);
  --info: var(--aqua-400);
  --gradient: linear-gradient(120deg, var(--lime-400), oklch(0.84 0.18 145));
}

html[data-design="light"] {
  color-scheme: light;
  --bg: oklch(0.955 0.018 130);
  --bg-elevated: oklch(0.980 0.012 130);
  --surface: oklch(0.985 0.010 130);
  --surface-hover: oklch(0.935 0.025 130);
  --surface-soft: oklch(0.925 0.028 130);
  --input: oklch(0.970 0.015 130);
  --text: oklch(0.240 0.035 155);
  --text-soft: oklch(0.420 0.035 155);
  --muted: oklch(0.500 0.030 155);
  --border: oklch(0.850 0.035 140);
  --border-strong: oklch(0.710 0.055 140);
  --accent: oklch(0.490 0.145 130);
  --accent-strong: oklch(0.430 0.130 135);
  --accent-text: oklch(0.980 0.012 120);
  --accent-soft: oklch(0.490 0.145 130 / 11%);
  --header: oklch(0.955 0.018 130 / 88%);
  --success: oklch(0.490 0.130 155);
  --success-soft: oklch(0.490 0.130 155 / 10%);
  --danger: oklch(0.520 0.180 25);
  --danger-soft: oklch(0.520 0.180 25 / 10%);
  --warning: oklch(0.520 0.130 75);
  --info: oklch(0.500 0.110 200);
  --gradient: linear-gradient(120deg, oklch(0.46 0.13 145), oklch(0.56 0.17 124));
  --shadow: 0 18px 50px oklch(0.30 0.05 155 / 10%);
}

html[data-design="telegram"] {
  color-scheme: light;
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-elevated: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --surface: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --surface-hover: var(--tg-theme-secondary-bg-color, #ededf0);
  --surface-soft: var(--tg-theme-bg-color, #ffffff);
  --input: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #17212b);
  --text-soft: var(--tg-theme-hint-color, #667781);
  --muted: var(--tg-theme-hint-color, #8796a0);
  --border: color-mix(in srgb, var(--tg-theme-hint-color, #8796a0) 23%, transparent);
  --border-strong: color-mix(in srgb, var(--tg-theme-hint-color, #8796a0) 42%, transparent);
  --accent: var(--tg-theme-button-color, #3390ec);
  --accent-strong: var(--tg-theme-button-color, #2481da);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --accent-soft: color-mix(in srgb, var(--tg-theme-button-color, #3390ec) 12%, transparent);
  --header: var(--tg-theme-bg-color, #ffffff);
  --success: #239b5b;
  --success-soft: rgba(35, 155, 91, .11);
  --danger: var(--tg-theme-destructive-text-color, #d33b45);
  --danger-soft: rgba(211, 59, 69, .1);
  --warning: #a86e13;
  --info: #288ac1;
  --gradient: linear-gradient(135deg, var(--tg-theme-button-color, #3390ec), var(--tg-theme-button-color, #287dcc));
  --radius-lg: 18px;
  --radius-md: 13px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(23, 33, 43, .06);
}

html[data-design="telegram"][data-tg-scheme="dark"] {
  color-scheme: dark;
  --bg: var(--tg-theme-bg-color, #17212b);
  --bg-elevated: var(--tg-theme-secondary-bg-color, #232e3c);
  --surface: var(--tg-theme-secondary-bg-color, #232e3c);
  --surface-hover: var(--tg-theme-secondary-bg-color, #2b3948);
  --surface-soft: var(--tg-theme-bg-color, #17212b);
  --input: var(--tg-theme-bg-color, #17212b);
  --text: var(--tg-theme-text-color, #f5f5f5);
  --text-soft: var(--tg-theme-hint-color, #9babb8);
  --muted: var(--tg-theme-hint-color, #708394);
  --header: var(--tg-theme-bg-color, #17212b);
  --success: #62d895;
  --danger: var(--tg-theme-destructive-text-color, #ff8585);
  --warning: #f0c167;
  --info: #7cc8ff;
  --shadow: 0 8px 24px rgba(0, 0, 0, .16);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
html[data-design="studio"] body {
  background:
    radial-gradient(circle at 15% -10%, rgba(128, 90, 242, .14), transparent 32rem),
    var(--bg);
}
button, input, select, textarea { font: inherit; }
button, summary, label, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }
button, summary { touch-action: manipulation; }
[hidden], .hidden { display: none !important; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: 3px;
}
.skip-link {
  position: fixed;
  z-index: 100;
  left: 12px;
  top: -80px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
}
.skip-link:focus { top: 12px; }

.app-header {
  position: sticky;
  z-index: 30;
  top: 0;
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 1px solid var(--border);
  background: var(--header);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.header-inner {
  width: min(100%, 1080px);
  min-height: var(--header-height);
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 13px;
  background: var(--gradient);
  box-shadow: 0 7px 18px color-mix(in srgb, var(--accent) 25%, transparent);
}
.brand-mark span {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid var(--accent-text);
}
.brand-copy { display: grid; gap: 1px; min-width: 0; }
.brand-copy strong { font-size: 16px; line-height: 1.2; letter-spacing: -.025em; }
.brand-copy small { color: var(--muted); font-size: 11px; white-space: nowrap; }

.design-picker { position: relative; flex: 0 0 auto; }
.design-picker summary {
  min-height: 42px;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.design-picker summary::-webkit-details-marker { display: none; }
.design-swatch {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0 50%, var(--surface-soft) 50% 100%);
}
.design-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}
.design-menu button {
  width: 100%;
  min-height: 54px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.design-menu button:hover { background: var(--surface); }
.design-menu button[aria-pressed="true"] { background: var(--accent-soft); }
.design-menu button > span:last-child { display: grid; gap: 2px; }
.design-menu strong { font-size: 13px; font-weight: 650; }
.design-menu small { color: var(--muted); font-size: 11px; }
.design-dot { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto; }
.design-dot-telegram { background: linear-gradient(135deg, #fff 50%, #3390ec 50%); border: 1px solid #d9e2e9; }

.app-main {
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 25px 16px calc(42px + env(safe-area-inset-bottom, 0px));
}
.page-heading { margin-bottom: 22px; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(27px, 7vw, 40px); line-height: 1.08; letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: 18px; line-height: 1.3; letter-spacing: -.025em; }
h3 { font-size: 15px; }
.page-description { max-width: 620px; margin-bottom: 0; color: var(--text-soft); font-size: 14px; line-height: 1.55; }
.muted { color: var(--muted); }
.text-soft { color: var(--text-soft); }
.tabular-nums { font-variant-numeric: tabular-nums; }

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
html[data-design="telegram"] .card { box-shadow: none; }
.card-body { padding: 18px; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-heading-title { display: flex; align-items: center; gap: 10px; }
.step-number {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}
html[data-design="telegram"] .step-number { color: var(--accent); }
.section-caption { margin: -8px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.form-stack { display: grid; gap: 14px; }

.button {
  min-height: 44px;
  padding: 11px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  transition: transform .15s, background .15s, border-color .15s;
}
.button:active { transform: scale(.98); }
.button-primary { background: var(--gradient); color: var(--accent-text); box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 22%, transparent); }
.button-primary:hover { filter: brightness(1.06); }
.button-secondary { border-color: var(--border); background: var(--surface-soft); color: var(--text); }
.button-secondary:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.button-danger { border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-soft); color: var(--danger); }
.button-block { width: 100%; }
.button-large { min-height: 52px; font-size: 15px; }
.button-icon { width: 44px; padding: 0; flex: 0 0 auto; }
.source-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.helper-text { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.helper-text code { color: var(--text-soft); }

.source-list { display: grid; gap: 9px; }
.source-list:empty { display: none; }
.source-list:empty + .source-empty { display: block; }
.source-empty { display: none; padding: 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); color: var(--muted); font-size: 13px; text-align: center; }
.source-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.source-kind {
  width: 24px;
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}
.text-input, .number-input, .source-display {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input);
  color: var(--text);
  font-size: 16px;
  line-height: 1.35;
}
.text-input::placeholder { color: var(--muted); opacity: 1; }
.text-input:focus, .number-input:focus { border-color: var(--accent); outline: 3px solid var(--accent-soft); }
.source-display { display: flex; align-items: center; overflow: hidden; color: var(--text-soft); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.source-display > span { overflow: hidden; text-overflow: ellipsis; }
.source-remove { color: var(--muted); }
.source-remove:hover { color: var(--danger); }
.source-count { color: var(--muted); font-size: 12px; white-space: nowrap; }

.settings-grid { display: grid; gap: 20px; }
.setting { min-width: 0; }
.setting-label { display: block; margin-bottom: 9px; color: var(--text-soft); font-size: 12px; font-weight: 650; }
.chip-group { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { position: relative; cursor: pointer; user-select: none; }
.chip input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.chip span {
  min-height: 40px;
  padding: 9px 12px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.25;
  transition: background .15s, border-color .15s;
}
.chip:hover span { border-color: var(--border-strong); color: var(--text); }
.chip input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.chip input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.number-setting { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.number-input { width: 88px; }
.num-quick-group { display: flex; flex-wrap: wrap; gap: 6px; }
.num-quick {
  min-width: 38px;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
}
.num-quick.active { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.num-quick-auto.active { border-color: var(--success); background: var(--success-soft); color: var(--success); }
.warning-text { margin: 9px 0 0; color: var(--warning); font-size: 12px; line-height: 1.5; }

.subtitle-preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.subtitle-preset { position: relative; min-width: 0; cursor: pointer; user-select: none; }
.subtitle-preset input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.subtitle-preview {
  min-height: 92px;
  padding: 16px 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  background: linear-gradient(145deg, #323544, #14151c);
  color: white;
  font-family: "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 1px 2px #000;
  transition: border-color .15s, background .15s;
}
.subtitle-preset-name {
  min-height: 38px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
}
.subtitle-preset:hover .subtitle-preview,
.subtitle-preset:hover .subtitle-preset-name { border-color: var(--border-strong); }
.subtitle-preset input:checked ~ .subtitle-preview,
.subtitle-preset input:checked ~ .subtitle-preset-name { border-color: var(--accent); }
.subtitle-preset input:checked ~ .subtitle-preset-name { background: var(--accent-soft); color: var(--text); }
.subtitle-preset input:focus-visible ~ .subtitle-preview { outline: 3px solid var(--accent); outline-offset: 2px; }
.subtitle-preview--minimal { font-size: 13px; font-weight: 400; }
.subtitle-preview--standard { font-weight: 700; -webkit-text-stroke: .5px #000; }
.subtitle-preview--bold { font-family: "Arial Black", sans-serif; font-size: 17px; font-weight: 900; -webkit-text-stroke: 1px #000; }
.subtitle-preview--karaoke { font-size: 17px; font-weight: 700; }
.subtitle-preview--karaoke .subtitle-preview-phrase { color: #ffe600; }
.subtitle-preview--clean { font-weight: 400; text-shadow: 0 2px 5px #000; }
.subtitle-preview--boxed .subtitle-preview-phrase { padding: 5px 8px; background: rgb(0 0 0 / 65%); font-weight: 700; }
.subtitle-preview--word_pop, .subtitle-preview--phrase_pop { font-family: "Arial Black", sans-serif; font-weight: 900; -webkit-text-stroke: .7px #000; }
.subtitle-preview--word_slide, .subtitle-preview--phrase_slide { font-weight: 700; -webkit-text-stroke: .5px #000; }
.subtitle-preview--word_pop .subtitle-preview-word { animation: subtitle-word-pop 2.4s infinite; }
.subtitle-preview--word_pop .subtitle-preview-word:nth-child(2) { animation-delay: .35s; }
.subtitle-preview--word_pop .subtitle-preview-word:nth-child(3) { animation-delay: .7s; }
.subtitle-preview--word_slide .subtitle-preview-word { animation: subtitle-word-slide 2.4s infinite; }
.subtitle-preview--word_slide .subtitle-preview-word:nth-child(2) { animation-delay: .35s; }
.subtitle-preview--word_slide .subtitle-preview-word:nth-child(3) { animation-delay: .7s; }
.subtitle-preview--phrase_pop .subtitle-preview-phrase { animation: subtitle-phrase-pop 2.8s infinite; }
.subtitle-preview--phrase_slide .subtitle-preview-phrase { animation: subtitle-phrase-slide 2.8s infinite; }
.subtitle-off { margin-top: 10px; display: inline-block; }
@keyframes subtitle-word-pop { 0%, 8% { opacity: 0; transform: scale(.55); } 14%, 80% { opacity: 1; transform: scale(1); } 90%, 100% { opacity: 0; } }
@keyframes subtitle-word-slide { 0%, 8% { opacity: 0; transform: translateY(18px); } 16%, 80% { opacity: 1; transform: translateY(0); } 90%, 100% { opacity: 0; } }
@keyframes subtitle-phrase-pop { 0%, 10% { opacity: 0; transform: scale(.55); } 20%, 82% { opacity: 1; transform: scale(1); } 92%, 100% { opacity: 0; } }
@keyframes subtitle-phrase-slide { 0%, 10% { opacity: 0; transform: translateY(22px); } 22%, 82% { opacity: 1; transform: translateY(0); } 92%, 100% { opacity: 0; } }
@media (min-width: 760px) { .subtitle-preset-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (prefers-reduced-motion: reduce) { .subtitle-preview-word, .subtitle-preview-phrase { animation: none !important; } }

.advanced-settings { margin-top: 18px; border-top: 1px solid var(--border); }
.advanced-settings summary {
  min-height: 48px;
  padding: 16px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}
.advanced-settings summary::-webkit-details-marker { display: none; }
.advanced-settings summary::after { content: "+"; color: var(--muted); font-size: 20px; font-weight: 400; line-height: 1; }
.advanced-settings[open] summary::after { content: "−"; }
.advanced-content { padding-top: 20px; }
.submit-dock {
  position: sticky;
  z-index: 20;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  box-shadow: 0 10px 32px rgba(0, 0, 0, .18);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.submit-dock .button { border-radius: 11px; }

.jobs-section { margin-top: 30px; }
.section-header { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.section-header .count { color: var(--muted); font-size: 12px; }
.jobs-list { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.job-card {
  min-height: 78px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: background .15s, border-color .15s;
}
.job-card:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.job-card-icon { display: grid; place-items: center; width: 39px; height: 39px; flex: 0 0 auto; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 17px; }
.job-card-main { flex: 1; min-width: 0; }
.job-card-title { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.job-card-meta { margin-top: 5px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.job-card-arrow { color: var(--muted); font-size: 20px; }
.empty-jobs { padding: 25px 18px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--muted); font-size: 13px; line-height: 1.5; text-align: center; }

.status-pill {
  min-height: 23px;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .025em;
  line-height: 1;
  white-space: nowrap;
}
.status-queued, .status-pending, .status-cancelled { background: var(--surface-soft); color: var(--text-soft); border-color: var(--border); }
.status-running { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); animation: pulse 1.8s ease-in-out infinite; }
html[data-design="telegram"] .status-running { color: var(--accent); }
.status-done { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 28%, transparent); }
.status-failed { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.status-partial { background: color-mix(in srgb, var(--warning) 12%, transparent); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 28%, transparent); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .62; } }

.back-link { min-height: 40px; margin: -8px 0 10px -10px; padding: 8px 10px; display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); font-size: 13px; }
.back-link:hover { color: var(--text); }
.job-heading { margin-bottom: 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.job-heading h1 { margin: 0; font-size: 25px; }
.job-heading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.job-heading-actions .button { min-height: 38px; padding: 8px 12px; font-size: 12px; }
.job-timestamp { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.progress-card { margin-bottom: 14px; }
.progress-card .card-body { padding: 18px; }
.progress-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.progress-heading h2 { font-size: 16px; }
.progress-info { color: var(--muted); font-size: 11px; }
.time-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; }
.time-stat { padding: 11px 12px; border-radius: var(--radius-sm); background: var(--surface-soft); }
.time-stat-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.time-stat-value { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.time-stat-value.accent { color: var(--accent); }
html[data-design="telegram"] .time-stat-value.accent { color: var(--accent); }
.progress-track { height: 8px; overflow: hidden; border-radius: 99px; background: var(--surface-soft); }
.progress-bar { height: 100%; border-radius: inherit; background: var(--gradient); transition: width .5s ease; }
.progress-caption { min-height: 17px; margin: 9px 0 0; color: var(--muted); font-size: 11px; }

.job-details { margin-bottom: 14px; }
.job-details summary, .log-details summary {
  min-height: 48px;
  padding: 14px 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.job-details summary::-webkit-details-marker, .log-details summary::-webkit-details-marker { display: none; }
.job-details summary::after, .log-details summary::after { content: "+"; color: var(--muted); font-size: 18px; }
.job-details[open] summary::after, .log-details[open] summary::after { content: "−"; }
.settings-summary { padding: 0 17px 17px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 10px; }
.setting-summary-item { min-width: 0; }
.setting-summary-label { margin-bottom: 3px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.setting-summary-value { overflow-wrap: anywhere; font-size: 12px; }
.n-best-note { grid-column: 1 / -1; padding: 10px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); font-size: 11px; line-height: 1.5; }
html[data-design="telegram"] .n-best-note { color: var(--accent); }

.sources-section { display: grid; gap: 12px; }
.source-card { min-width: 0; overflow: hidden; }
.source-card .card-body { padding: 16px; }
.source-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.source-title-group { min-width: 0; }
.source-index { display: block; margin-bottom: 4px; color: var(--accent); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.source-title { overflow: hidden; font-size: 14px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.source-raw { margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.source-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.source-meta-item { min-width: 0; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-soft); }
.source-meta-label { margin-bottom: 4px; color: var(--muted); font-size: 10px; }
.source-meta-value { overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.source-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.source-badges:empty { display: none; }
.source-badge { padding: 5px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 10px; }
.source-badge.info { background: color-mix(in srgb, var(--info) 12%, transparent); color: var(--info); }
.source-badge.success { background: var(--success-soft); color: var(--success); }
.clip-plan { margin: 0 0 12px; }
.clip-plan[hidden] { display: none; }
.clip-plan-heading { margin-bottom: 8px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.clip-plan-total { color: var(--text-soft); font-size: 10px; font-variant-numeric: tabular-nums; text-transform: none; }
.clip-plan-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.clip-plan-item { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 7px 9px; border-radius: var(--radius-sm); background: var(--surface-soft); }
.clip-plan-item .phase-dot { width: 16px; height: 16px; border-width: 2px; }
.clip-plan-title { overflow: hidden; color: var(--text-soft); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.clip-plan-item.done .phase-dot { border-color: var(--success); background: var(--success); }
.clip-plan-item.done .phase-dot::after { content: "✓"; color: var(--bg-elevated); font-size: 9px; font-weight: 800; line-height: 1; }
.clip-plan-item.done .clip-plan-title { color: var(--muted); }
.clip-plan-item.current .phase-dot { border-color: var(--accent); background: var(--accent-soft); animation: pulse 1.8s ease-in-out infinite; }
.clip-plan-item.current .clip-plan-title { color: var(--accent); }
.error-message { margin: 12px 0 0; padding: 11px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.log-details { margin: 0 -16px -16px; border-top: 1px solid var(--border); }
.log-details pre {
  max-height: 230px;
  margin: 0 16px 16px;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input);
  color: var(--text-soft);
  font: 10px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.clips-section { margin-top: 16px; }
.clips-heading { margin-bottom: 10px; font-size: 13px; font-weight: 650; }
.clip-grid { display: grid; gap: 12px; }
.clip-card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--input); }
.clip-card video { width: 100%; max-height: 72vh; aspect-ratio: 9 / 16; background: #000; object-fit: contain; }
.clip-footer { padding: 11px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.clip-name { overflow: hidden; color: var(--text-soft); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.download-link { min-height: 38px; padding: 8px 10px; display: inline-flex; align-items: center; flex: 0 0 auto; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 650; }
html[data-design="telegram"] .download-link { color: var(--accent); }
.artifact-links { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.artifact-links a { min-height: 40px; padding: 9px 12px; display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-soft); font-size: 12px; }

@media (min-width: 600px) {
  .app-main { padding-inline: 24px; }
  .header-inner { padding-inline: 24px; }
  .card-body { padding: 22px; }
  .source-card .card-body { padding: 20px; }
  .log-details { margin: 0 -20px -20px; }
  .settings-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .source-meta { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .clip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-actions { display: flex; }
  .source-actions .button { min-width: 150px; }
}

@media (min-width: 800px) {
  :root { --header-height: 74px; }
  .app-main { padding-top: 36px; padding-bottom: 60px; }
  .page-heading { margin-bottom: 28px; }
  .form-stack { gap: 18px; }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 28px; }
  .setting-full { grid-column: 1 / -1; }
  .jobs-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jobs-section { margin-top: 38px; }
  .progress-card .card-body { padding: 24px; }
  .time-stats { max-width: 420px; }
  .settings-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .clip-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 390px) {
  .brand-copy small { display: none; }
  .design-current { display: none; }
  .design-picker summary { padding-inline: 10px; }
  .job-heading { flex-direction: column; }
  .job-heading-actions { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ============================================================
   App shell: sidebar (desktop) + bottom tab bar (mobile)
   ============================================================ */

.icon { width: 20px; height: 20px; flex: 0 0 auto; }

.app-shell { display: block; }
.side-nav { display: none; }
.mobile-brand { display: inline-flex; }

.tab-bar {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
  border-top: 1px solid var(--border);
  background: var(--header);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.tab-bar .nav-link {
  min-width: 56px;
  padding: 7px 4px;
  display: grid;
  justify-items: center;
  gap: 3px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}
.tab-bar .nav-link .icon { width: 22px; height: 22px; }
body[data-user] .app-main { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 600;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); }

/* Active nav item per page (body[data-page] vs data-nav). */
body[data-page="dashboard"] .nav-link[data-nav="dashboard"],
body[data-page="new_job"] .nav-link[data-nav="new_job"],
body[data-page="jobs"] .nav-link[data-nav="jobs"],
body[data-page="balance"] .nav-link[data-nav="balance"],
body[data-page="account"] .nav-link[data-nav="account"],
body[data-page="settings"] .nav-link[data-nav="settings"],
body[data-page="admin"] .nav-link[data-nav="admin"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

@media (min-width: 1024px) {
  .app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
  .side-nav {
    position: sticky;
    top: 0;
    display: flex;
    width: 236px;
    height: 100vh;
    height: 100dvh;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 8px;
    padding: 18px 14px;
    border-right: 1px solid var(--border);
    background: var(--bg-elevated);
  }
  .side-nav .brand { padding: 4px 8px 14px; }
  .side-nav-links { display: grid; gap: 4px; align-content: start; }
  .side-user {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
  }
  .side-user:hover { border-color: var(--border-strong); }
  .side-user-copy { display: grid; min-width: 0; }
  .side-user-copy strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
  .side-user-copy small { color: var(--muted); font-size: 10.5px; }
  .app-column { flex: 1; min-width: 0; }
  .mobile-brand { display: none; }
  .tab-bar { display: none; }
  body[data-user] .app-main { padding-bottom: 60px; }
}

  .avatar {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--gradient);
    color: var(--accent-text);
    font-size: 14px;
    font-weight: 750;
  }
  /* Telegram Mini App: password change/logout make no sense inside the client. */
  html[data-tg] [data-security-card] { display: none; }
  /* Photo avatars (Telegram Mini App) cover the letter initials. */
  .avatar-img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }
.avatar-sm { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 8px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 750; vertical-align: middle; }

.balance-chip {
  min-height: 38px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.balance-chip .icon { width: 16px; height: 16px; }
.balance-chip:hover { border-color: var(--accent); }

/* ============================================================
   Page scaffolding
   ============================================================ */

.page-head {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.page-head h1 { margin: 0; font-size: 24px; }
.page-sub { margin: 5px 0 0; color: var(--text-soft); font-size: 13px; }
.page-head .button { flex: 0 0 auto; }
.section-head {
  margin: 22px 0 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.section-head h2 { font-size: 16px; }
.section-link { color: var(--accent); font-size: 12.5px; font-weight: 650; }
.card-title-sm { margin-bottom: 14px; font-size: 15px; }

.empty-state {
  padding: 28px 18px;
  display: grid;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.empty-state p { margin: 0; }

/* ============================================================
   Dashboard
   ============================================================ */

.dash-hero {
  position: relative;
  overflow: hidden;
  min-height: 252px;
  margin-bottom: 14px;
  isolation: isolate;
}
.dash-hero-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dash-hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(95deg, rgba(9, 7, 14, .9) 0%, rgba(9, 7, 14, .66) 46%, rgba(9, 7, 14, .22) 100%);
}
.dash-hero-content {
  position: relative;
  min-height: 252px;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 7px;
  color: #fff;
}
.dash-hero-content h1 { margin: 0; font-size: 22px; opacity: .92; }
.dash-hero-title {
  margin: 0;
  font-size: clamp(21px, 4.5vw, 30px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -.04em;
  text-wrap: balance;
}
.dash-hero-text {
  margin: 0;
  max-width: 52ch;
  font-size: 13.5px;
  line-height: 1.55;
  color: rgba(255, 255, 255, .9);
  text-shadow: 0 1px 8px rgba(0, 0, 0, .35);
}
.dash-hero-cta { margin-top: 12px; }
@media (min-width: 700px) {
  .dash-hero, .dash-hero-content { min-height: 284px; }
  .dash-hero-content { padding: 34px; }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.stat-card { padding: 15px 16px; display: grid; gap: 3px; align-content: start; }
.stat-value { font-size: 26px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.stat-label { color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.stat-accent { border-color: color-mix(in srgb, var(--accent) 32%, transparent); background: linear-gradient(150deg, var(--accent-soft), var(--surface) 65%); }
.stat-accent .stat-value { color: var(--accent); }

.dash-columns { display: grid; gap: 14px; }
.dash-side { display: grid; gap: 10px; align-content: start; }
.balance-card { padding: 18px; display: grid; gap: 10px; border-color: color-mix(in srgb, var(--accent) 30%, transparent); background: linear-gradient(155deg, var(--accent-soft), var(--surface) 70%); }
.balance-big { font-size: 34px; font-weight: 800; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.balance-big small { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.mini-stat { padding: 16px; display: grid; gap: 8px; }

.active-jobs { display: grid; gap: 9px; }
.active-job { display: grid; gap: 10px; }
.job-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.job-title { overflow: hidden; font-size: 14px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.job-title small { color: var(--muted); font-weight: 500; }
.job-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.job-owner { color: var(--accent); font-weight: 650; }
.recent-jobs { display: grid; gap: 9px; }
.recent-jobs .job-card, .active-job { display: grid; gap: 8px; padding: 14px; }
.recent-jobs .job-card { display: block; }
.recent-jobs .job-card .job-card-top { margin-bottom: 6px; }

@media (min-width: 900px) {
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-columns { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); align-items: start; }
}

/* ============================================================
   Jobs list
   ============================================================ */

.jobs-toolbar { margin-bottom: 14px; display: grid; gap: 10px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.filter-chip:hover { border-color: var(--border-strong); color: var(--text); }
.filter-chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.search-input {
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input);
  color: var(--text);
  font-size: 14px;
}
.search-input:focus { border-color: var(--accent); outline: 3px solid var(--accent-soft); }
.jobs-grid { display: grid; gap: 9px; }
@media (min-width: 800px) { .jobs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ============================================================
   Phase stepper (job detail — one step per pipeline process)
   ============================================================ */

.phase-stepper {
  margin: 0 0 14px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 8px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  list-style: none;
}
.phase-step { display: flex; align-items: center; gap: 8px; min-width: 0; }
.phase-dot {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  color: transparent;
  font-size: 11px;
  transition: border-color .2s, background .2s;
}
.phase-copy { display: grid; min-width: 0; }
.phase-name { overflow: hidden; color: var(--muted); font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.phase-time { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }

.phase-step.done .phase-dot { border-color: var(--success); background: var(--success); color: var(--bg-elevated); }
.phase-step.done .phase-dot::after { content: "✓"; font-size: 11px; font-weight: 800; line-height: 1; }
.phase-step.done .phase-name { color: var(--text-soft); }
.phase-step.current .phase-dot { border-color: var(--accent); background: var(--accent-soft); animation: pulse 1.8s ease-in-out infinite; }
.phase-step.current .phase-name { color: var(--accent); }
.phase-step.current .phase-time { color: var(--accent); }
.phase-step.failed .phase-dot { border-color: var(--danger); background: var(--danger-soft); }
.phase-step.failed .phase-dot::after { content: "×"; color: var(--danger); font-size: 13px; font-weight: 800; line-height: 1; }
.phase-step.failed .phase-name { color: var(--danger); }

@media (min-width: 700px) {
  .phase-stepper { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .phase-step { flex-direction: column; align-items: center; gap: 6px; text-align: center; }
}

/* ============================================================
   Balance
   ============================================================ */

.balance-columns { display: grid; gap: 14px; }
.balance-left { display: grid; gap: 14px; }
.balance-hero { padding: 22px; display: grid; gap: 8px; border-color: color-mix(in srgb, var(--accent) 30%, transparent); background: linear-gradient(155deg, var(--accent-soft), var(--surface) 72%); }
.balance-hero-meta { color: var(--text-soft); font-size: 12.5px; }
.how-list { margin: 0; padding-left: 18px; display: grid; gap: 8px; color: var(--text-soft); font-size: 13px; line-height: 1.55; }
.topup-note { margin-top: 14px; padding: 12px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); font-size: 12.5px; line-height: 1.5; }
.topup-note strong { color: var(--accent); }

.ledger-list { display: grid; }
.ledger-row {
  padding: 12px 2px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  border-bottom: 1px solid var(--border);
}
.ledger-row:last-child { border-bottom: 0; }
.ledger-kind { color: var(--text); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.ledger-kind a { color: var(--accent); }
.ledger-date { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.ledger-amount { font-size: 14px; font-weight: 750; font-variant-numeric: tabular-nums; }
.ledger-amount.credit { color: var(--success); }
.ledger-amount.debit { color: var(--text-soft); }

@media (min-width: 900px) {
  .balance-columns { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr); align-items: start; }
}

/* ============================================================
   Account / settings
   ============================================================ */

.account-columns { display: grid; gap: 14px; }
.account-main { display: grid; gap: 14px; }
.account-side { display: grid; gap: 10px; align-content: start; }
.profile-body { display: flex; align-items: center; gap: 16px; }
.profile-copy h2 { margin: 0 0 6px; font-size: 19px; }
.profile-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.profile-links { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.role-pill { text-transform: none; letter-spacing: 0; }
.role-pill.role-admin { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.role-pill.role-user { background: var(--surface-soft); color: var(--text-soft); border-color: var(--border); }
.form-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.form-status { color: var(--muted); font-size: 12px; }

@media (min-width: 900px) {
  .account-columns { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); align-items: start; }
}

/* ============================================================
   Auth screens
   ============================================================ */

.auth-main {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding-top: 24px;
  padding-bottom: 40px;
}
.auth-layout {
  width: min(100%, 980px);
  display: grid;
  gap: 18px;
  justify-items: center;
  align-items: stretch;
}
.auth-hero {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 236px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  isolation: isolate;
}
.auth-hero-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.auth-hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 8, 16, .18) 0%, rgba(10, 8, 16, .5) 52%, rgba(10, 8, 16, .88) 100%);
}
.auth-hero-content {
  position: relative;
  min-height: 236px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 9px;
  color: #fff;
}
.auth-hero-brand {
  position: absolute;
  top: 18px;
  left: 20px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 15px;
  letter-spacing: -.02em;
}
.auth-hero-brand .brand-mark { width: 32px; height: 32px; border-radius: 11px; }
.auth-hero-content h2 {
  margin: 0;
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1.12;
  letter-spacing: -.035em;
  text-wrap: balance;
}
.auth-hero-content > p { margin: 0; max-width: 48ch; font-size: 13.5px; line-height: 1.55; color: rgba(255, 255, 255, .84); }
.auth-hero-features { display: none; margin: 8px 0 0; padding: 0; list-style: none; }
.auth-hero-features li {
  position: relative;
  padding: 3px 0 3px 30px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, .92);
}
.auth-hero-features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 4px;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  font-size: 11px;
  font-weight: 800;
}
.auth-card {
  width: min(100%, 400px);
  padding: 30px 26px;
  text-align: center;
}
.auth-logo { margin: 0 auto 16px; width: 52px; height: 52px; border-radius: 17px; }
.auth-card h1 { margin-bottom: 6px; font-size: 26px; }
.auth-subtitle { margin: 0 0 18px; color: var(--text-soft); font-size: 13px; line-height: 1.5; }
.auth-form { display: grid; gap: 13px; text-align: left; }
.field { display: grid; gap: 6px; }
.field > span { color: var(--text-soft); font-size: 12px; font-weight: 650; }
.auth-alt { margin: 16px 0 0; color: var(--text-soft); font-size: 13px; }
.auth-alt a { color: var(--accent); font-weight: 650; }
.auth-hint { margin: 14px 0 0; color: var(--muted); font-size: 11.5px; }
.auth-card .error-message { text-align: left; }

@media (min-width: 860px) {
  .auth-layout { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 22px; }
  .auth-hero, .auth-hero-content { min-height: 532px; }
  .auth-hero-content { padding: 30px; }
  .auth-hero-brand { top: 24px; left: 26px; }
  .auth-hero-features { display: block; }
}

/* ============================================================
   Admin table
   ============================================================ */

.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  padding: 12px 14px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-hover); }
.table .num { text-align: right; }
.table-user { font-weight: 650; }
.table-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.grant-form { display: flex; align-items: center; gap: 6px; }
.grant-input {
  width: 110px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input);
  color: var(--text);
  font-size: 13px;
}
.button-sm { min-height: 38px; padding: 8px 11px; font-size: 12px; }
.button-ghost { border-color: transparent; background: transparent; color: var(--text-soft); }
.button-ghost:hover { background: var(--surface-hover); color: var(--text); }

/* ============================================================
   Promo codes (balance redeem + admin management)
   ============================================================ */

.redeem-form { display: flex; gap: 8px; margin-top: 12px; }
.redeem-input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.promo-create-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.promo-field { display: grid; gap: 5px; font-size: 12px; color: var(--text-soft); font-weight: 650; }
.promo-field input {
  width: 110px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input);
  color: var(--text);
  font-size: 13px;
}
.promo-field-code input { width: 180px; letter-spacing: .05em; text-transform: uppercase; }
.promo-create-card .page-sub { margin: 10px 0 0; font-size: 11.5px; }
.promo-code { font-size: 13px; font-weight: 700; letter-spacing: .05em; }
.promo-redeemers { margin-top: 4px; color: var(--muted); font-size: 11px; }
.promo-status-active { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 28%, transparent); }
.promo-status-disabled { background: var(--surface-soft); color: var(--text-soft); border-color: var(--border); }
.promo-status-expired, .promo-status-exhausted { background: color-mix(in srgb, var(--warning) 12%, transparent); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 28%, transparent); }

/* ============================================================
   Toasts
   ============================================================ */

.toast-host {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  width: min(92vw, 380px);
  pointer-events: none;
}
@media (min-width: 1024px) { .toast-host { bottom: 26px; } }
.toast {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toast-in .25s ease;
}
.toast-success { border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.toast-error { border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.toast-out { opacity: 0; transform: translateY(8px); transition: opacity .4s, transform .4s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Cost estimate under the submit button */
.cost-estimate { margin: 0 0 4px; color: var(--text-soft); font-size: 12.5px; font-weight: 600; text-align: center; }
.cost-estimate.cost-shortage { color: var(--danger); }

/* ============================================================
   Gentle entrance for page sections
   ============================================================ */

@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.app-main > * { animation: rise-in .4s ease backwards; }
.app-main > *:nth-child(2) { animation-delay: .06s; }
.app-main > *:nth-child(3) { animation-delay: .12s; }
.app-main > *:nth-child(4) { animation-delay: .18s; }
.auth-layout > * { animation: rise-in .45s ease backwards; }
.auth-layout > *:last-child { animation-delay: .08s; }

/* ============================================================
   Kinetic identity: local Blender motion + editorial typography
   ============================================================ */

html[data-design="studio"] body {
  background:
    radial-gradient(ellipse at 88% -12%, oklch(0.82 0.13 180 / 8%), transparent 34rem),
    radial-gradient(ellipse at 8% 20%, oklch(0.91 0.22 124 / 5%), transparent 28rem),
    var(--bg);
}
html[data-design="light"] body {
  background:
    radial-gradient(ellipse at 90% -10%, oklch(0.82 0.13 180 / 13%), transparent 32rem),
    var(--bg);
}
body::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  opacity: .12;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

h1, h2, h3, .dash-hero-title, .balance-big, .stat-value {
  font-family: var(--font-display);
}
h1, h2, h3 { font-weight: 650; }
p, .page-description, .page-sub { line-height: 1.6; }
.card {
  border-color: color-mix(in srgb, var(--border) 82%, transparent);
  box-shadow: var(--shadow);
}
html[data-design="studio"] .card {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}
.button { font-weight: 700; letter-spacing: -.01em; }
.button-primary { color: var(--accent-text); }
.button-primary:hover { filter: brightness(1.04) saturate(1.08); transform: translateY(-1px); }
.button-primary:active { transform: scale(.98); }

.brand-mark {
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  box-shadow: none;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-copy strong {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -.055em;
}
.brand-copy small { font-size: 10px; letter-spacing: .01em; }
.side-nav { background: color-mix(in srgb, var(--bg-elevated) 92%, transparent); }
.nav-link { border: 1px solid transparent; }
.nav-link:hover { border-color: var(--border); }
body[data-page="dashboard"] .nav-link[data-nav="dashboard"],
body[data-page="new_job"] .nav-link[data-nav="new_job"],
body[data-page="jobs"] .nav-link[data-nav="jobs"],
body[data-page="balance"] .nav-link[data-nav="balance"],
body[data-page="account"] .nav-link[data-nav="account"],
body[data-page="settings"] .nav-link[data-nav="settings"],
body[data-page="admin"] .nav-link[data-nav="admin"] {
  border-color: color-mix(in srgb, var(--accent) 24%, transparent);
}
.design-dot-studio { background: linear-gradient(135deg, #17201b 50%, #c8ff4d 50%); border-color: #435048; }
.design-dot-light { background: linear-gradient(135deg, #f0f4ed 50%, #558700 50%); border-color: #c2cbbd; }

.dash-hero {
  min-height: 330px;
  border-color: color-mix(in srgb, var(--aqua-400) 18%, var(--border));
  border-radius: 26px 26px 26px 8px;
  background: #0b100e;
}
.dash-hero-photo, .dash-hero-motion, .auth-hero-photo, .auth-hero-motion {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.dash-hero-photo, .auth-hero-photo { z-index: -3; }
.dash-hero-motion, .auth-hero-motion { z-index: -2; }
.dash-hero-motion { object-position: 58% center; }
.dash-hero-scrim {
  z-index: -1;
  background:
    linear-gradient(90deg, rgb(5 12 9 / 97%) 0%, rgb(5 12 9 / 88%) 34%, rgb(5 12 9 / 38%) 63%, rgb(5 12 9 / 10%) 100%),
    linear-gradient(0deg, rgb(5 12 9 / 40%), transparent 55%);
}
.dash-hero-content {
  min-height: 330px;
  max-width: 650px;
  padding: 38px 34px;
  justify-content: center;
  gap: 10px;
}
.dash-hero-content h1 {
  font-family: "Manrope", sans-serif;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0;
  opacity: .78;
}
.dash-hero-title {
  max-width: 15ch;
  font-size: clamp(25px, 3.3vw, 37px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.045em;
}
.dash-hero-text { max-width: 39ch; font-size: 14px; }
.dash-hero-cta { margin-top: 14px; }
.dash-hero-code {
  position: absolute;
  top: 20px;
  right: 22px;
  color: #c8ff4d;
  font: 600 10px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .10em;
  opacity: .82;
}

.stat-card { position: relative; overflow: hidden; min-height: 96px; }
.stat-card::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 8px;
  height: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  transform: rotate(45deg);
}
.stat-accent::after { border-color: var(--accent); background: var(--accent-soft); }
.stat-value { font-size: 24px; font-weight: 650; }
.stat-label { letter-spacing: .065em; }
.balance-card, .balance-hero {
  background: linear-gradient(145deg, var(--accent-soft), var(--surface) 64%);
}
.page-head h1 { font-size: clamp(23px, 3vw, 30px); }
.section-head h2 { font-family: "Manrope", sans-serif; font-weight: 750; letter-spacing: -.025em; }
.empty-state { min-height: 130px; align-content: center; }

.auth-layout { width: min(100%, 1080px); gap: 0; }
.auth-hero {
  border: 1px solid color-mix(in srgb, var(--aqua-400) 18%, var(--border));
  border-radius: 26px 26px 26px 8px;
  background: #0b100e;
}
.auth-hero-motion { object-position: center 38%; }
.auth-hero-scrim {
  z-index: -1;
  background: linear-gradient(180deg, rgb(5 12 9 / 10%) 0%, rgb(5 12 9 / 12%) 35%, rgb(5 12 9 / 94%) 100%);
}
.auth-hero-content { gap: 11px; }
.auth-hero-brand { z-index: 1; font-family: var(--font-display); font-size: 13px; }
.auth-hero-brand .brand-mark { width: 34px; height: 34px; }
.auth-hero-content h2 { max-width: 17ch; font-size: clamp(22px, 3vw, 30px); }
.auth-hero-content > p { max-width: 45ch; }
.auth-hero-features li::before {
  content: "";
  left: 4px;
  top: 9px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: #c8ff4d;
  transform: rotate(45deg);
}
.auth-card {
  position: relative;
  z-index: 2;
  padding: 34px 30px;
  text-align: left;
  border-radius: 8px 24px 24px 8px;
}
.auth-card h1 { font-size: 24px; line-height: 1.2; }
.auth-form .button { margin-top: 4px; }
.auth-alt, .auth-hint { line-height: 1.55; }

@media (max-width: 699px) {
  .dash-hero, .dash-hero-content { min-height: 340px; }
  .dash-hero-content { padding: 28px 22px; justify-content: flex-end; }
  .dash-hero-title { font-size: clamp(23px, 7vw, 30px); }
  .dash-hero-motion { object-position: 64% center; opacity: .74; }
  .dash-hero-scrim {
    background: linear-gradient(0deg, rgb(5 12 9 / 97%) 0%, rgb(5 12 9 / 70%) 64%, rgb(5 12 9 / 30%) 100%);
  }
  .dash-hero-code { top: 16px; right: 16px; font-size: 8px; }
  .auth-card { border-radius: 20px; }
}

@media (min-width: 860px) {
  .auth-layout { grid-template-columns: minmax(0, 1.35fr) minmax(0, .9fr); align-items: center; }
  .auth-hero, .auth-hero-content { min-height: 570px; }
  .auth-hero { border-radius: 26px 6 6 26px; }
  .auth-hero-content { padding: 34px 58px 34px 34px; }
  .auth-card { margin-left: -30px; }
}

@media (prefers-reduced-motion: reduce) {
  [data-brand-motion] { display: none; }
  body::before { opacity: .08; }
}
