:root {
  color-scheme: light;
  --bg: #e0e5ec;
  --panel: #e4e9f0;
  --card: #e6ebf2;
  --text: #39465b;
  --muted: #5e6d80;
  --accent: #0fb891;
  --teal: #006e5c;
  --on: #05372b;
  --blue: #2563eb;
  --warn: #d97706;
  --danger: #aa3143;
  --line: #cbd3df;
  --overlay: rgba(38, 50, 69, 0.47);
  --shadow: 6px 6px 15px #bec5cf, -6px -6px 15px #f9fbff;
  --raised: 3px 4px 8px #c3cad4, -3px -3px 8px #f7faff;
  --inset: inset 3px 3px 8px #c0c8d5, inset -3px -3px 8px #f8fbff;
  --r-panel: 22px;
  --r-stage: 18px;
  --r-seg: 15px;
  --r-btn: 13px;
  --r-chip: 11px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #252b2e;
  --panel: #2b3236;
  --card: #2d3437;
  --text: #e2ded5;
  --muted: #a1adb4;
  --accent: #10b894;
  --teal: #40e0b7;
  --on: #042b22;
  --blue: #83aaff;
  --warn: #f9b861;
  --danger: #ff93a1;
  --line: #434b50;
  --overlay: rgba(15, 19, 22, 0.65);
  --shadow: 5px 6px 13px #171c1e, -4px -4px 11px #414b52;
  --raised: 3px 4px 7px #171c1e, -2px -2px 6px #434a51;
  --inset: inset 3px 3px 8px #161b20, inset -3px -3px 7px #41474d;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.43;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  transition: background-color 0.2s ease, color 0.2s ease;
}

button,
input,
textarea,
select {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* App Shell */
.app-shell {
  width: 100%;
  max-width: 1440px;
  min-width: 0;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header (.top) */
.top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand seg tools";
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  border-radius: var(--r-panel);
  background: var(--panel);
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  box-shadow: var(--raised);
  flex-shrink: 0;
  display: block;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-size: 18.5px;
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 7px;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: var(--inset);
  color: var(--teal);
  flex-shrink: 0;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Segmented Mode Switcher */
.seg {
  grid-area: seg;
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 6px;
  padding: 5px;
  border-radius: var(--r-seg);
  background: var(--bg);
  box-shadow: var(--inset);
  max-width: 100%;
  min-width: 0;
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  min-width: 0;
  padding: 0 14px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--muted);
  transition: all 0.16s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn[aria-selected="true"],
.seg-btn.on {
  background: var(--panel);
  color: var(--teal);
  box-shadow: var(--raised);
  font-weight: 750;
}

.seg-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Header Tools */
.top-tools {
  grid-area: tools;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--raised);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  position: relative;
  flex-shrink: 0;
  transition: box-shadow 0.14s ease, color 0.14s ease, transform 0.12s ease;
}

.icon-btn:hover {
  color: var(--teal);
}

.icon-btn:active,
.icon-btn.on {
  box-shadow: var(--inset);
  color: var(--teal);
}

.icon-btn svg {
  width: 19px;
  height: 19px;
}

.engine-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--bg);
  box-shadow: var(--inset);
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.engine-pill:hover {
  color: var(--text);
}

.engine-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  flex-shrink: 0;
}

.engine-led.online {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Main 2-Column Workspace */
.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 445px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  min-width: 0;
  max-width: 100%;
}

.panel {
  background: var(--panel);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
  max-width: 100%;
}

.controls-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  max-width: 100%;
}

.stage-col {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  max-width: 100%;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-bottom: 14px;
  min-width: 0;
}

.section-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 770;
  letter-spacing: -0.023em;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.section-head h2 svg {
  width: 19px;
  height: 19px;
  color: var(--teal);
  flex-shrink: 0;
}

.label-uc {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 10px;
}

/* Recessed Input Well */
.input-well {
  background: var(--bg);
  border-radius: 15px;
  box-shadow: var(--inset);
  padding: 6px 8px 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.input-well input[type="url"],
.input-well input[type="text"] {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 15px;
  font-weight: 500;
  padding: 9px 0;
  color: var(--text);
}

.input-well input::placeholder,
.textarea-well textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.mini-btn {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--raised);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
  transition: box-shadow 0.14s ease, color 0.14s ease;
}

.mini-btn:hover {
  color: var(--teal);
}

.mini-btn:active {
  box-shadow: var(--inset);
}

.mini-btn svg {
  width: 14px;
  height: 14px;
}

.textarea-well {
  background: var(--bg);
  border-radius: 16px;
  box-shadow: var(--inset);
  padding: 12px 14px;
  min-width: 0;
  max-width: 100%;
}

.textarea-well textarea {
  width: 100%;
  min-height: 146px;
  border: 0;
  background: transparent;
  outline: none;
  resize: vertical;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

/* Live Detected Platform Strip */
.detect-strip {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 13px;
  background: var(--card);
  box-shadow: var(--raised);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  min-width: 0;
  max-width: 100%;
}

.detect-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.plat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.detect-name {
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtype-chip {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: var(--inset);
  color: var(--teal);
  flex-shrink: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Platform Grid (6 Supported Apps) */
.plat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  min-width: 0;
}

.plat-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: var(--r-chip);
  background: var(--panel);
  box-shadow: var(--raised);
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s ease;
}

.plat-pill.active {
  box-shadow: var(--inset);
  color: var(--teal);
  font-weight: 750;
}

.plat-pill .dot-color {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* 4-Tier Quality Grid (720 / 1080 / 2K / 4K) */
.quality-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  min-width: 0;
}

.q-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 54px;
  min-width: 0;
  padding: 8px 4px;
  border-radius: 13px;
  background: var(--panel);
  box-shadow: var(--raised);
  transition: all 0.15s ease;
}

.q-btn:hover {
  color: var(--teal);
}

.q-btn[aria-pressed="true"],
.q-btn.on {
  box-shadow: var(--inset);
  color: var(--teal);
}

.q-main {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 800;
}

.q-sub {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 600;
}

.q-btn.on .q-sub {
  color: var(--teal);
}

/* Option Toggle Row */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  border-radius: 13px;
  background: var(--bg);
  box-shadow: var(--inset);
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
}

.toggle-row > span {
  min-width: 0;
  flex: 1;
}

.switch {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--raised);
  position: relative;
  transition: background-color 0.16s ease;
  flex-shrink: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.16s ease, background-color 0.16s ease;
}

.switch[aria-checked="true"] {
  background: var(--accent);
}

.switch[aria-checked="true"]::after {
  transform: translateX(20px);
  background: #ffffff;
}

/* Primary & Secondary CTA Buttons */
.btn-primary {
  width: 100%;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: var(--r-btn);
  background: linear-gradient(135deg, #16cfa6 0%, var(--accent) 55%, #0a9a7a 100%);
  color: var(--on);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  box-shadow: var(--raised);
  transition: filter 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: var(--inset);
}

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

.btn-primary svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-soft {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--r-btn);
  background: var(--panel);
  box-shadow: var(--raised);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-align: center;
  transition: box-shadow 0.14s ease, color 0.14s ease;
}

.btn-soft:hover:not(:disabled) {
  color: var(--teal);
}

.btn-soft:active:not(:disabled) {
  box-shadow: var(--inset);
}

.btn-soft.danger:hover:not(:disabled) {
  color: var(--danger);
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-row > * {
  flex: 1 1 120px;
}

/* Private Steps Guide */
.steps-guide {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 14px;
  border-radius: 15px;
  background: var(--bg);
  box-shadow: var(--inset);
  font-size: 13px;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--raised);
  color: var(--teal);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Stage & Preview Panel */
.stage-well {
  border-radius: var(--r-stage);
  background: var(--bg);
  box-shadow: var(--inset);
  padding: 22px;
  min-height: 280px;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.empty-stage {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 8px;
  min-width: 0;
}

.empty-hero-icon {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--raised);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
}

.empty-hero-icon svg {
  width: 32px;
  height: 32px;
}

.empty-stage h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2.2vw, 1.85rem);
  font-weight: 810;
  letter-spacing: -0.04em;
  line-height: 1.18;
  max-width: 100%;
  word-wrap: break-word;
}

.empty-stage p {
  margin: 0;
  max-width: 520px;
  color: var(--muted);
  font-size: 13.8px;
}

.sample-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  max-width: 100%;
}

.sample-chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--raised);
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
  transition: color 0.14s ease, box-shadow 0.14s ease;
}

.sample-chip:hover {
  color: var(--teal);
}

.sample-chip:active {
  box-shadow: var(--inset);
}

/* Resolved Media Card */
.media-card {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.thumb-box {
  position: relative;
  border-radius: 15px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--raised);
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

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

.thumb-fallback {
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}

.duration-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: 7px;
  background: rgba(15, 19, 22, 0.78);
  color: #ffffff;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.media-meta {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}

.meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.meta-chip {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--raised);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--teal);
}

.meta-chip.muted {
  color: var(--muted);
}

.media-title {
  margin: 0;
  font-size: 16px;
  font-weight: 760;
  line-height: 1.3;
  letter-spacing: -0.02em;
  word-break: break-word;
}

.media-author {
  font-size: 12.5px;
  color: var(--muted);
}

/* Stream Variants Grid (720 / 1080 / 2K / 4K) */
.variants-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  min-width: 0;
}

.variant-card {
  padding: 13px 14px;
  border-radius: 15px;
  background: var(--panel);
  box-shadow: var(--raised);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  transition: box-shadow 0.15s ease;
}

.variant-card.preferred {
  outline: 2px solid var(--accent);
}

.variant-card.unavailable {
  opacity: 0.56;
  box-shadow: var(--inset);
}

.variant-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.variant-res {
  font-family: var(--mono);
  font-size: 14.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.variant-tag {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: var(--inset);
  color: var(--teal);
}

.variant-tag.mux {
  color: var(--blue);
}

.variant-spec {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.variant-dl {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--on);
  font-size: 12.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
  box-shadow: var(--raised);
}

.variant-dl:hover:not(:disabled) {
  filter: brightness(1.06);
}

.variant-dl:disabled {
  background: var(--bg);
  color: var(--muted);
  box-shadow: var(--inset);
  cursor: not-allowed;
}

/* Render / Muxing Pipeline Card */
.pipeline-card {
  padding: 16px 18px;
  border-radius: 17px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.pipeline-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pipeline-title {
  font-size: 14px;
  font-weight: 760;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.pipeline-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.pipe-step {
  padding: 8px 6px;
  border-radius: 11px;
  background: var(--bg);
  box-shadow: var(--inset);
  text-align: center;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pipe-step.active {
  background: var(--panel);
  box-shadow: var(--raised);
  color: var(--blue);
  font-weight: 750;
}

.pipe-step.done {
  background: var(--panel);
  box-shadow: var(--raised);
  color: var(--teal);
  font-weight: 750;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: var(--inset);
  overflow: hidden;
  padding: 2px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  transition: width 0.2s ease;
}

.pipeline-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* Guidance Notice Banner */
.notice-card {
  margin-top: 14px;
  padding: 13px 15px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--raised);
  border-left: 4px solid var(--warn);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  min-width: 0;
}

.notice-card.info {
  border-left-color: var(--blue);
}

.notice-card strong {
  color: var(--text);
}

/* Batch Queue List */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 460px;
  overflow-y: auto;
  padding-right: 2px;
}

.queue-item {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--raised);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.queue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.queue-url {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.status-badge {
  font-size: 11px;
  font-weight: 750;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: var(--inset);
  color: var(--muted);
  flex-shrink: 0;
}

.status-badge.working {
  color: var(--blue);
}

.status-badge.done {
  color: var(--teal);
}

.status-badge.error {
  color: var(--danger);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-card {
  width: min(100%, 580px);
  max-height: 86dvh;
  overflow-y: auto;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
}

.history-item {
  padding: 11px 13px;
  border-radius: 13px;
  background: var(--bg);
  box-shadow: var(--inset);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.history-copy {
  min-width: 0;
  flex: 1;
}

.history-title {
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.code-block {
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--bg);
  box-shadow: var(--inset);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  font-size: 13.5px;
  font-weight: 650;
  z-index: 2000;
  max-width: calc(100vw - 32px);
  text-align: center;
}

/* =========================================================
   iPad Landscape (861px - 1200px, e.g., 1024x768, 1180x820)
   ========================================================= */
@media (min-width: 861px) and (max-width: 1200px) {
  .app-shell {
    padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    gap: 16px;
  }

  .top {
    gap: 12px;
    padding: 9px 12px;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .brand-title {
    font-size: 17px;
  }

  .brand-sub {
    max-width: 168px;
  }

  .seg {
    grid-template-columns: repeat(3, minmax(84px, 1fr));
    gap: 4px;
    padding: 4px;
  }

  .seg-btn {
    padding: 0 10px;
    font-size: 13px;
    gap: 5px;
  }

  .top-tools {
    gap: 8px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .engine-pill {
    padding: 0 10px;
    height: 36px;
  }

  .workspace {
    grid-template-columns: minmax(320px, 376px) minmax(0, 1fr);
    gap: 16px;
  }

  .panel {
    padding: 17px;
  }

  .stage-col {
    top: 12px;
  }

  .stage-well {
    padding: 18px;
    min-height: 250px;
  }

  .media-card {
    grid-template-columns: 165px minmax(0, 1fr);
    gap: 14px;
  }

  .variants-grid {
    gap: 10px;
  }

  .variant-card {
    padding: 11px 12px;
  }

  .pipeline-steps {
    gap: 6px;
  }

  .pipe-step {
    font-size: 11px;
    padding: 7px 4px;
  }
}

/* =========================================================
   iPad Portrait & Mobile (<= 860px)
   ========================================================= */
@media (max-width: 860px) {
  .app-shell {
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    gap: 14px;
  }

  .top {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand tools"
      "seg seg";
    gap: 10px;
    padding: 10px 12px;
    border-radius: 18px;
  }

  .brand {
    gap: 10px;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .brand-title {
    font-size: 17px;
    gap: 6px;
  }

  .top-tools {
    gap: 7px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .engine-pill {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 12px;
  }

  .engine-pill span.engine-label {
    display: none;
  }

  .seg {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border-radius: 14px;
  }

  .seg-btn {
    min-height: 38px;
    padding: 0 8px;
    font-size: 13px;
    gap: 5px;
    border-radius: 10px;
  }

  .seg-btn svg {
    width: 14px;
    height: 14px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .stage-col {
    position: static;
  }

  .panel {
    padding: 16px 14px;
    border-radius: 18px;
  }

  .stage-well {
    padding: 16px 14px;
    min-height: 220px;
    border-radius: 15px;
  }

  .media-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .variants-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .pipeline-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .input-well input[type="url"],
  .input-well input[type="text"],
  .textarea-well textarea {
    font-size: 16px;
  }
}

/* =========================================================
   Mobile Portrait Compact (<= 480px - iPhone SE / 14 / 15 / 16)
   ========================================================= */
@media (max-width: 480px) {
  .brand-sub {
    display: none;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .brand-title {
    font-size: 16px;
  }

  .top-tools {
    gap: 6px;
  }

  .icon-btn,
  .engine-pill {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }

  .icon-btn svg {
    width: 17px;
    height: 17px;
  }

  /* Clean icon-free segmented pills on narrow mobile so Vietnamese labels never collide */
  .seg-btn svg {
    display: none;
  }

  .seg-btn {
    font-size: 12.5px;
    padding: 0 4px;
    min-height: 36px;
  }

  .input-well {
    padding: 5px 6px 5px 12px;
    gap: 6px;
  }

  .detect-strip {
    padding: 9px 10px;
    gap: 8px;
    font-size: 12.5px;
  }

  .detect-strip .subtype-chip {
    max-width: 40%;
    font-size: 11px;
    padding: 3px 8px;
  }

  .plat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .plat-pill {
    padding: 6px 4px;
    font-size: 11.5px;
    gap: 4px;
    min-height: 36px;
  }

  .plat-pill .dot-color {
    width: 7px;
    height: 7px;
  }

  .quality-grid {
    gap: 7px;
  }

  .q-btn {
    min-height: 50px;
    padding: 6px 3px;
    border-radius: 12px;
  }

  .q-main {
    font-size: 13px;
  }

  .q-sub {
    font-size: 9.5px;
  }

  .toggle-row {
    padding: 10px 11px;
    font-size: 12.5px;
  }

  .btn-primary {
    min-height: 44px;
    font-size: 14px;
    padding: 10px 12px;
  }

  .section-head h2 {
    font-size: 0.98rem;
  }

  .empty-hero-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
  }

  .empty-stage {
    gap: 11px;
    padding: 8px 2px;
  }

  .empty-stage h1 {
    font-size: 1.2rem;
  }

  .empty-stage p {
    font-size: 13px;
  }
}

@media (pointer: coarse) {
  .q-btn,
  .variant-dl,
  .sample-chip {
    min-height: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
