:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --bg-soft: #12151a;
  --surface: #181c23;
  --surface-2: #1f2430;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --gold: #f5b942;
  --gold-soft: rgba(245, 185, 66, 0.14);
  --gold-strong: #ffcf5c;
  --green: #22c55e;
  --danger: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: "Manrope", system-ui, sans-serif;
  --control-h: 40px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: clip;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.page-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(245, 185, 66, 0.12), transparent 60%),
    radial-gradient(700px 360px at 100% 0%, rgba(34, 197, 94, 0.08), transparent 55%),
    linear-gradient(180deg, #0b0d10 0%, #101318 100%);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  background: rgba(24, 28, 35, 0.82);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header__logo {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, #1f2430, #141820);
  color: var(--gold-strong);
  border: 1px solid rgba(245, 185, 66, 0.35);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.header__logo svg {
  display: block;
}

.header__eyebrow {
  margin: 0 0 4px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

.header__title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.header__actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.header__action-item {
  display: grid;
  gap: 6px;
}

.control--toolbar,
.header__action-item {
  margin-bottom: 0 !important;
}

.control__label--spacer {
  visibility: hidden;
  user-select: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.workspace > * {
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.sidebar .card--fold {
  min-width: 0;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
  }

  .header__actions {
    justify-content: space-between;
  }
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(24, 28, 35, 0.92);
  box-shadow: var(--shadow);
}

.card--main {
  overflow: visible;
}

.card--fold {
  margin-bottom: 14px;
}

.card--fold:last-child {
  margin-bottom: 0;
}

.card__header,
.card__summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.card__summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-weight: 700;
}

.card__summary::-webkit-details-marker {
  display: none;
}

.card__summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--text-dim);
  transition: transform 0.2s ease;
}

details[open]>.card__summary::after {
  transform: rotate(180deg);
}

.card__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.card__subtitle {
  margin: 4px 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.card__body {
  padding: 18px;
}

.card__body--settings {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px 18px;
}

.card__body--settings .control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 0;
}

.card__body--settings .grid-2 {
  gap: 14px 10px;
  margin-bottom: 0;
}

.card__body--settings .grid-2 .control {
  gap: 8px;
  margin-bottom: 0;
}

.card__body--settings .control__label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 1.2rem;
}

.card__body--settings .control__label {
  line-height: 1.3;
}

.card__body--settings .ui-select {
  width: 100%;
}

.card--action {
  margin-top: 18px;
  overflow: visible;
}

.action-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.action-panel__head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid transparent;
}

.action-panel__intro {
  flex: 1;
  min-width: 0;
}

.action-panel__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.action-panel__subtitle {
  margin: 4px 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-dim);
}

.btn--generate {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 24px;
  border: 0;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 800;
  color: #171000;
  background: linear-gradient(180deg, var(--gold-strong), #e3a92d);
  box-shadow: 0 10px 28px rgba(245, 185, 66, 0.24);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.btn--generate::before {
  content: "▶";
  font-size: 0.72rem;
  line-height: 1;
}

.btn--generate:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(245, 185, 66, 0.32);
}

.btn--generate:disabled,
.btn--generate.is-loading {
  opacity: 0.72;
  cursor: wait;
  transform: none;
}

.action-progress {
  padding: 0 20px 18px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.action-progress__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.action-progress__text {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.action-progress__pct {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--gold-strong);
  font-variant-numeric: tabular-nums;
}

.action-progress__track {
  height: 8px;
  border-radius: 999px;
  background: #2a3140;
  overflow: hidden;
}

.action-progress__fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--green));
  transition: width 0.35s ease;
}

.action-result {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.action-result__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.action-result__badge {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 800;
  flex: 0 0 auto;
}

.action-result__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
}

.action-result__subtitle {
  margin: 4px 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-dim);
}

.action-result__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.action-result__item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(240px, 100%);
}

.action-result__video {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 320px;
  object-fit: cover;
  border-radius: 12px;
  background: #000;
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.action-result__caption {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.subtitle-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.subtitle-preview.is-off .subtitle-preview__frame {
  opacity: 0.55;
}

.subtitle-preview__label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.subtitle-preview__frame {
  position: relative;
  width: 100%;
  max-width: 140px;
  margin: 0;
  aspect-ratio: 9 / 16;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: #0a0c10;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 6px 18px rgba(0, 0, 0, 0.28);
}

.subtitle-preview__scene {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 35%),
    radial-gradient(circle at 30% 20%, rgba(245, 185, 66, 0.12), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(34, 197, 94, 0.08), transparent 40%),
    linear-gradient(160deg, #1a2030, #0d1016 55%, #151820);
}

.subtitle-preview__wrap {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding: 0 6px;
  z-index: 1;
  transition: top 0.15s ease, bottom 0.15s ease, transform 0.15s ease;
}

.subtitle-preview__wrap--bottom {
  bottom: 10%;
}

.subtitle-preview__wrap--top {
  top: 8%;
}

.subtitle-preview__wrap--center {
  top: 50%;
  transform: translateY(-50%);
}

.subtitle-preview__wrap--custom {
  transform: translateY(-50%);
}

.subtitle-preview__box {
  display: inline-block;
  max-width: 100%;
  transition: background 0.15s ease, border-radius 0.15s ease, padding 0.15s ease;
}

.subtitle-preview__text {
  word-break: break-word;
  transition: color 0.15s ease, font-size 0.15s ease;
}

.toast:not(.error) {
  color: var(--text);
}

@media (max-width: 720px) {
  .action-panel__head {
    flex-wrap: wrap;
  }

  .btn--generate {
    width: 100%;
  }
}

.step-badge {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--gold-soft);
  color: var(--gold-strong);
  font-size: 0.82rem;
  font-weight: 800;
  flex: 0 0 auto;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.stack {
  display: grid;
  gap: 12px;
}

.grid-2--pair {
  align-items: stretch;
  gap: 14px;
  margin-bottom: 14px;
}

.grid-2--pair .control {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.control__label-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  flex-wrap: wrap;
}

.api-key-status {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.35;
  flex: 0 0 auto;
}

.api-key-status--set {
  color: var(--green);
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.api-key-status--unset {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.modal__body .control__label-row {
  justify-content: space-between;
  width: 100%;
}

.control__label-row--title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control__label-row--title .card__title {
  margin: 0;
}

.control__head {
  display: contents;
}

.grid-2 .control {
  margin-bottom: 0;
}

/* Hint icon tooltip */
.hint-tip {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.hint-tip__btn {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  cursor: help;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.hint-tip__btn:hover,
.hint-tip__btn:focus-visible {
  outline: none;
  color: var(--gold-strong);
  border-color: rgba(245, 185, 66, 0.45);
  background: var(--gold-soft);
}

.hint-tip__text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.hint-tip-float {
  position: fixed;
  z-index: 2000;
  width: max-content;
  max-width: min(280px, calc(100vw - 16px));
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: #1a1f28;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text-muted);
  text-align: left;
  white-space: normal;
  pointer-events: none;
}

.hint-tip-float.hidden {
  display: none !important;
}

.card__body,
.card__header,
.sidebar,
.control,
details.card--fold {
  overflow: visible;
}

.stack .control:last-child {
  margin-bottom: 0;
}

.control {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.control--inline {
  min-width: 150px;
}

.control--toolbar {
  min-width: 150px;
}

.control__label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
}

.control__input:not(.ui-range__input):not(.control__input--area),
.ui-select__trigger,
.ui-file__btn {
  width: 100%;
  min-height: var(--control-h);
  height: var(--control-h);
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.2;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.ui-input.control__input:not(.control__input--area) {
  padding: 0 12px;
}

.control__input:not(.ui-range__input):not(.control__input--area):hover,
.ui-select__trigger:hover:not(:disabled),
.ui-file__btn:hover {
  border-color: rgba(255, 255, 255, 0.22);
}

.control__input:not(.ui-range__input):not(.control__input--area):focus,
.ui-input.control__input:not(.control__input--area):focus {
  outline: none;
  border-color: rgba(245, 185, 66, 0.55);
  box-shadow: 0 0 0 3px rgba(245, 185, 66, 0.12);
  background: #232936;
}

.control__input::placeholder {
  color: var(--text-dim);
}

/* Custom select */
.ui-select {
  position: relative;
  width: 100%;
}

.ui-select__native {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.ui-select__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
}

.ui-select__trigger::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg) translateY(-2px);
  flex: 0 0 auto;
  transition: transform 0.15s ease;
}

.ui-select.is-open .ui-select__trigger {
  border-color: rgba(245, 185, 66, 0.55);
  box-shadow: 0 0 0 3px rgba(245, 185, 66, 0.12);
  background: #232936;
}

.ui-select.is-open .ui-select__trigger::after {
  transform: rotate(-135deg) translateY(1px);
}

.ui-select.is-disabled .ui-select__trigger {
  opacity: 0.55;
  cursor: not-allowed;
}

.ui-select__menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow: auto;
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #1a1f28;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  display: none;
}

.ui-select__menu--float {
  position: fixed;
  z-index: 1500;
  top: 0;
  left: 0;
  right: auto;
  display: block;
}

.ui-select__search-wrap {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 6px;
  border-bottom: 1px solid var(--border);
  background: #1a1f28;
}

.ui-select__search {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.86rem;
}

.ui-select__search:focus {
  outline: none;
  border-color: rgba(245, 185, 66, 0.55);
  box-shadow: 0 0 0 3px rgba(245, 185, 66, 0.12);
}

.ui-select__empty {
  padding: 10px 12px;
  color: var(--text-dim);
  font-size: 0.82rem;
}

dialog .ui-select__menu--float {
  z-index: 3000;
}

.ui-select.is-open .ui-select__menu:not(.ui-select__menu--float) {
  display: block;
}

.ui-select__option {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.ui-select__option:hover,
.ui-select__option:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.06);
}

.ui-select__option.is-active {
  background: var(--gold-soft);
  color: var(--gold-strong);
}

textarea.control__input,
textarea.ui-input.control__input {
  display: block;
  width: 100%;
  min-height: 120px;
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.55;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
}

textarea.control__input--sm,
textarea.ui-input.control__input--sm {
  min-height: 72px;
}

textarea.control__input:focus,
textarea.ui-input.control__input:focus {
  outline: none;
  border-color: rgba(245, 185, 66, 0.55);
  box-shadow: 0 0 0 3px rgba(245, 185, 66, 0.12);
  background: #232936;
}

/* Custom range */
.ui-range {
  --range-inset: 8px;
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: var(--control-h);
  min-height: var(--control-h);
  max-height: var(--control-h);
  padding-inline: var(--range-inset);
  overflow: hidden;
}

.ui-range::before {
  content: "";
  position: absolute;
  left: var(--range-inset);
  right: var(--range-inset);
  top: 50%;
  height: 6px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: #2a3140;
  pointer-events: none;
}

.ui-range::after {
  content: "";
  position: absolute;
  left: var(--range-inset);
  width: calc((100% - (2 * var(--range-inset))) * var(--pct-num, 0) / 100);
  top: 50%;
  height: 6px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--gold-strong));
  pointer-events: none;
}

.ui-range__input {
  position: relative;
  z-index: 1;
  width: 100%;
  height: var(--control-h);
  min-height: var(--control-h);
  max-height: var(--control-h);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
  appearance: none;
  cursor: pointer;
  transition: none;
}

.ui-range__input:focus,
.ui-range__input:focus-visible,
.ui-range__input:active {
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
}

.ui-range__input::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #171000;
  background: var(--gold-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.ui-range__input::-webkit-slider-thumb:hover,
.ui-range__input::-webkit-slider-thumb:active {
  width: 16px;
  height: 16px;
}

.ui-range__input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #171000;
  background: var(--gold-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.ui-range__input::-moz-range-thumb:active {
  width: 16px;
  height: 16px;
}

.ui-range__input::-webkit-slider-runnable-track,
.ui-range__input::-moz-range-track {
  height: 6px;
  background: transparent;
  border: 0;
}

/* Custom color */
.ui-color {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--control-h);
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
}

.ui-color__native {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.ui-color__swatch {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  flex: 0 0 auto;
}

.ui-color__value {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* Custom file */
.ui-file {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--control-h);
}

.ui-file__native {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.ui-file__btn {
  width: auto;
  flex: 0 0 auto;
  padding: 0 14px;
  background: #2a3140;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.ui-file__name {
  font-size: 0.82rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Custom checkbox */
.check {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.92rem;
  cursor: pointer;
  user-select: none;
}

.ui-check__native {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ui-check__box {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.check.is-checked .ui-check__box {
  background: linear-gradient(180deg, var(--gold-strong), #e3a92d);
  border-color: rgba(245, 185, 66, 0.6);
}

.check.is-checked .ui-check__box::after {
  content: "";
  width: 5px;
  height: 9px;
  border-right: 2px solid #171000;
  border-bottom: 2px solid #171000;
  transform: rotate(45deg) translate(-1px, -1px);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.btn-group--compact {
  gap: 8px;
  margin-bottom: 14px;
}

.btn-group--after-field {
  margin-top: -6px;
  margin-bottom: 12px;
}

.btn--sm {
  min-height: 34px;
  padding: 7px 13px;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
}

.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  color: #171000;
  background: linear-gradient(180deg, var(--gold-strong), #e3a92d);
  box-shadow: 0 10px 24px rgba(245, 185, 66, 0.22);
}

.btn--secondary {
  color: var(--text);
  background: #2a3140;
  border: 1px solid var(--border-strong);
}

.btn--ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border-strong);
}

.btn.btn--toolbar,
#settings-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: var(--control-h);
  height: var(--control-h);
  padding: 0 14px;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.btn--xl {
  width: 100%;
  min-height: 54px;
  font-size: 1rem;
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  background: #2a3140;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}

.tags li,
.tags__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  border: 1px solid rgba(245, 185, 66, 0.22);
  color: #fde68a;
  font-size: 0.78rem;
}

.tags__label {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tags__remove {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 4px;
  opacity: 0.75;
}

.tags__remove:hover {
  opacity: 1;
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  max-width: calc(100vw - 24px);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
}

.modal__panel {
  width: min(760px, 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  margin: 0;
}

.modal__head,
.modal__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal__foot {
  border-bottom: 0;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.modal__head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.modal__body {
  padding: 18px;
}

.modal--video {
  padding: 24px 12px;
  width: max-content;
  max-width: calc(100vw - 24px);
}

.modal__panel--video {
  width: auto;
  max-width: calc(100vw - 24px);
}

.modal__body--video {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 20px 20px;
}

.video-preview__frame {
  margin: 0 auto;
  width: 100%;
  max-height: min(78vh, 820px);
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.video-preview__frame--portrait {
  width: min(360px, calc(100vw - 72px), calc(78vh * 9 / 16));
  aspect-ratio: 9 / 16;
}

.video-preview__frame--landscape {
  width: min(720px, calc(100vw - 72px), calc(78vh * 16 / 9));
  aspect-ratio: 16 / 9;
}

.video-preview__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.video-preview__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.video-preview__index {
  font-size: 0.82rem;
  color: var(--text-dim);
  min-width: 4.5rem;
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  border-radius: 12px;
  background: #1f2430;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.workflow-notice {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.workflow-notice--warn {
  border-color: rgba(245, 185, 66, 0.28);
  background: rgba(245, 185, 66, 0.08);
  color: #f3e4bd;
}

.control__hint--inline {
  display: block;
  margin-top: 4px;
}

.custom-audio-indicator {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(34, 197, 94, 0.28);
  background: rgba(34, 197, 94, 0.08);
}

.custom-audio-indicator__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.custom-audio-indicator__badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--green);
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(34, 197, 94, 0.28);
}

.custom-audio-indicator__name {
  margin: 0 0 4px;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.custom-audio-indicator__hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

#fetch-source-block {
  gap: 10px;
}

#fetch-source-block .fetch-preview {
  margin-top: 0;
}

.fetch-preview {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.fetch-preview__meta {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
  min-width: 0;
}

.fetch-preview__text {
  min-width: 0;
  flex: 1;
}

.fetch-preview__thumb {
  width: 96px;
  height: 54px;
  max-width: 40%;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: #000;
}

.fetch-preview__title {
  margin: 0 0 4px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.fetch-preview__duration,
.fetch-preview__status {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.fetch-preview__badge {
  display: inline-flex;
  margin: 6px 0 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold-strong);
  background: var(--gold-soft);
  border: 1px solid rgba(245, 185, 66, 0.28);
}

.fetch-preview__media {
  width: 100%;
  max-width: 100%;
  margin-bottom: 10px;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.fetch-preview__player {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: min(42vw, 220px);
  margin: 0;
  border-radius: 8px;
  background: #000;
  object-fit: contain;
}

video.fetch-preview__player {
  aspect-ratio: 16 / 9;
}

.fetch-preview .btn-group {
  margin-bottom: 0;
}

.fetch-preview .btn-group .btn {
  flex: 1 1 calc(50% - 4px);
  min-width: 0;
}

.hidden {
  display: none !important;
}