:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --panel: rgba(22, 22, 25, 0.88);
  --panel-solid: #161619;
  --panel-raised: #1d1d21;
  --line: rgba(255, 255, 255, 0.09);
  --line-bright: rgba(255, 255, 255, 0.16);
  --text: #f4f2ea;
  --muted: #99979d;
  --faint: #6e6c72;
  --accent: #f5ce58;
  --accent-strong: #ffb83e;
  --coral: #ff745d;
  --green: #71e6a3;
  --blue: #81b5ff;
  --danger: #ff7d86;
  --radius: 24px;
  --radius-small: 14px;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% -15%, rgba(245, 206, 88, 0.12), transparent 34%),
    radial-gradient(circle at -5% 34%, rgba(255, 116, 93, 0.09), transparent 28%),
    var(--bg);
  color: var(--text);
}

.gateway-admin-link {
  margin-left: auto;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: 160ms ease;
}

.gateway-admin-link:hover {
  color: var(--text);
  border-color: rgba(255, 213, 74, 0.48);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, select, summary, .dropzone { cursor: pointer; }
a { color: inherit; }
code {
  color: var(--accent);
  background: rgba(245, 206, 88, 0.08);
  border: 1px solid rgba(245, 206, 88, 0.14);
  padding: 0.08rem 0.35rem;
  border-radius: 6px;
  font-size: 0.88em;
}

.ambient {
  position: fixed;
  z-index: -1;
  filter: blur(100px);
  opacity: 0.18;
  pointer-events: none;
}
.ambient-one { width: 320px; height: 320px; background: var(--accent); top: 30%; right: -180px; }
.ambient-two { width: 260px; height: 260px; background: var(--coral); bottom: 8%; left: -170px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 74px;
  padding: 12px max(24px, calc((100vw - 1480px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(11, 11, 13, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(24px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  white-space: nowrap;
}
.brand strong { display: block; font-size: 15px; letter-spacing: 0.02em; }
.brand small { display: block; margin-top: 2px; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: 0.16em; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 12px;
  background: var(--accent);
  box-shadow: 0 8px 30px rgba(245, 206, 88, 0.18);
}
.brand-mark i { display: block; width: 4px; border-radius: 999px; background: #16130a; }
.brand-mark i:nth-child(1) { height: 10px; }
.brand-mark i:nth-child(2) { height: 20px; }
.brand-mark i:nth-child(3) { height: 14px; }

.key-console {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.key-console > label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 4px rgba(255,255,255,.03); }
.connection-dot.connected { background: var(--green); box-shadow: 0 0 0 4px rgba(113,230,163,.1); }
.connection-dot.error { background: var(--danger); box-shadow: 0 0 0 4px rgba(255,125,134,.1); }
.key-input-wrap { display: flex; align-items: center; width: min(290px, 26vw); }
.key-input-wrap input { width: 100%; padding: 7px 34px 7px 10px; border-radius: 9px; }
.icon-button {
  width: 30px; height: 30px; margin-left: -33px; border: 0; background: transparent; opacity: .55;
}
.key-status { min-width: 46px; color: var(--faint); font-size: 11px; }

.workspace { width: min(1480px, calc(100% - 48px)); margin: 0 auto; padding: 56px 0 90px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 40px; margin: 8px 0 40px; }
.hero > div:first-child { max-width: 800px; }
.eyebrow { margin: 0 0 14px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .22em; }
.hero h1 { margin: 0; font-size: clamp(42px, 6vw, 88px); line-height: .95; letter-spacing: -.065em; font-weight: 760; }
.hero h1 span { color: var(--accent); }
.hero p:not(.eyebrow) { max-width: 680px; margin: 22px 0 0; color: var(--muted); font-size: 15px; line-height: 1.8; }
.hero-stats { display: flex; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: rgba(255,255,255,.025); }
.hero-stats div { min-width: 94px; padding: 17px 20px; border-left: 1px solid var(--line); }
.hero-stats div:first-child { border-left: 0; }
.hero-stats strong { display: block; font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.hero-stats span { display: block; margin-top: 8px; color: var(--faint); font-size: 10px; }

.work-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(390px, .75fr); gap: 20px; }
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}
.composer-panel, .asset-panel { padding: 28px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 26px; }
.panel-heading > div:first-child { display: flex; align-items: center; gap: 12px; }
.panel-heading h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.step-number { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.soft-badge { padding: 6px 10px; color: var(--muted); background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 999px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field > span, .field > label, .field-label-row label { color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .02em; }
.field > span small { float: right; color: var(--faint); font-size: 9px; font-weight: 400; }
.field-label-row { display: flex; justify-content: space-between; margin-bottom: 8px; }
.field-label-row span { color: var(--faint); font-size: 10px; }
input, textarea, select {
  color: var(--text);
  background: #111114;
  border: 1px solid var(--line);
  outline: 0;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
input:focus, textarea:focus, select:focus { border-color: rgba(245,206,88,.52); box-shadow: 0 0 0 3px rgba(245,206,88,.07); background: #141416; }
input, select { height: 43px; padding: 0 12px; border-radius: 11px; }
textarea { width: 100%; min-height: 186px; padding: 17px; border-radius: 16px; resize: vertical; line-height: 1.7; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.prompt-shell { position: relative; }
.prompt-shell textarea { padding-bottom: 57px; }
.prompt-actions { position: absolute; left: 12px; right: 12px; bottom: 10px; display: flex; justify-content: space-between; align-items: center; padding-top: 9px; border-top: 1px solid var(--line); }
.ghost-button { min-height: 34px; padding: 0 11px; color: var(--muted); background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: 9px; font-size: 11px; }
.ghost-button:hover { color: var(--text); border-color: var(--line-bright); }
.switch-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; cursor: pointer; }
.switch-label input { display: none; }
.switch { position: relative; width: 31px; height: 18px; background: #303037; border-radius: 999px; transition: .2s; }
.switch::after { content: ""; position: absolute; width: 12px; height: 12px; top: 3px; left: 3px; background: #aaa8ae; border-radius: 50%; transition: .2s; }
.switch-label input:checked + .switch { background: var(--accent); }
.switch-label input:checked + .switch::after { left: 16px; background: #171309; }
.mention-strip { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; min-height: 30px; margin-top: 8px; }
.mention-strip > span { color: var(--faint); font-size: 10px; }
.mention-chip { padding: 5px 8px; color: var(--accent); background: rgba(245,206,88,.07); border: 1px solid rgba(245,206,88,.15); border-radius: 8px; font-size: 10px; }
.mention-menu { position: absolute; z-index: 20; left: 12px; bottom: 54px; width: min(340px, calc(100% - 24px)); max-height: 210px; overflow: auto; padding: 7px; background: #212126; border: 1px solid var(--line-bright); border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.5); }
.mention-menu.hidden { display: none; }
.mention-menu button { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 10px; background: transparent; border: 0; border-radius: 8px; text-align: left; }
.mention-menu button:hover { background: rgba(255,255,255,.06); }
.mention-menu small { color: var(--faint); }

.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; margin-top: 22px; }
.advanced-settings { margin-top: 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.advanced-settings summary { list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 15px 2px; font-size: 11px; font-weight: 650; }
.advanced-settings summary::-webkit-details-marker, .url-upload summary::-webkit-details-marker { display: none; }
.advanced-settings summary span { color: var(--faint); font-weight: 400; }
.toggle-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; padding: 0 0 16px; }
.option-card { display: flex; align-items: center; gap: 10px; padding: 11px; background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.option-card input { width: 16px; height: 16px; accent-color: var(--accent); }
.option-card span { display: flex; flex-direction: column; gap: 3px; }
.option-card strong { font-size: 11px; font-weight: 650; }
.option-card small { color: var(--faint); font-size: 9px; }
.submit-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-top: 22px; }
.submit-row > div { display: flex; flex-direction: column; gap: 4px; }
.submit-row strong { font-size: 12px; }
.submit-row span { color: var(--faint); font-size: 9px; }
.button { min-height: 43px; padding: 0 16px; border: 1px solid var(--line-bright); border-radius: 11px; background: #242429; font-size: 12px; font-weight: 700; transition: transform .2s, border-color .2s, background .2s; }
.button:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.28); }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.button-compact { min-height: 32px; padding: 0 12px; border-radius: 8px; font-size: 10px; }
.button-primary { min-width: 178px; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 18px; color: #171309; background: var(--accent); border-color: var(--accent); }
.button-primary:hover { background: #ffda64; border-color: #ffda64; }
.button-primary b { font-size: 18px; }

.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 190px; padding: 24px; text-align: center; border: 1px dashed rgba(245,206,88,.3); border-radius: 18px; background: linear-gradient(145deg, rgba(245,206,88,.06), rgba(255,255,255,.015)); transition: .2s; }
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: rgba(245,206,88,.09); transform: translateY(-2px); }
.drop-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 14px; color: #171309; background: var(--accent); border-radius: 15px; font-size: 25px; }
.dropzone strong { font-size: 13px; }
.dropzone span { margin-top: 7px; color: var(--muted); font-size: 10px; }
.dropzone small { margin-top: 18px; color: var(--faint); font-size: 9px; }
.url-upload { margin-top: 12px; padding: 0 2px; }
.url-upload summary { padding: 10px 0; color: var(--muted); font-size: 10px; }
.url-row { display: grid; grid-template-columns: 1fr 82px 58px; gap: 7px; }
.asset-list { display: flex; flex-direction: column; gap: 10px; max-height: 570px; margin-top: 18px; padding-right: 3px; overflow: auto; }
.empty-state { min-height: 185px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--faint); text-align: center; border: 1px solid var(--line); border-radius: 16px; }
.empty-state span { color: var(--accent); font-size: 24px; }
.empty-state strong { margin-top: 10px; color: var(--muted); font-size: 12px; }
.empty-state p { max-width: 300px; margin: 7px 20px; font-size: 10px; line-height: 1.6; }
.asset-card { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 11px; padding: 11px; background: rgba(255,255,255,.027); border: 1px solid var(--line); border-radius: 14px; }
.asset-kind { width: 42px; height: 42px; display: grid; place-items: center; background: #101012; border: 1px solid var(--line); border-radius: 11px; font-size: 17px; }
.asset-info { min-width: 0; }
.asset-info strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.asset-meta { display: flex; align-items: center; gap: 7px; margin-top: 5px; color: var(--faint); font-size: 9px; }
.asset-meta .ready { color: var(--green); }
.asset-meta .failed { color: var(--danger); }
.asset-actions { display: flex; gap: 5px; }
.mini-button { min-height: 30px; padding: 0 8px; background: transparent; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 9px; }
.mini-button:hover { color: var(--text); border-color: var(--line-bright); }
.asset-role { grid-column: 2 / -1; display: flex; align-items: center; justify-content: space-between; padding-top: 7px; border-top: 1px solid var(--line); }
.asset-role span { color: var(--faint); font-size: 9px; }
.asset-role select { width: 154px; height: 30px; font-size: 9px; background-position: calc(100% - 13px) 12px, calc(100% - 8px) 12px; }

.task-panel { margin-top: 20px; padding: 28px; }
.task-heading { margin-bottom: 20px; }
.task-tools { display: flex; align-items: center; gap: 10px; }
.segmented { display: flex; gap: 3px; padding: 3px; background: #101012; border: 1px solid var(--line); border-radius: 10px; }
.segmented button { min-height: 29px; padding: 0 10px; color: var(--faint); background: transparent; border: 0; border-radius: 7px; font-size: 9px; }
.segmented button.active { color: var(--text); background: #29292e; }
.task-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.empty-state.wide { grid-column: 1 / -1; min-height: 220px; }
.task-card { position: relative; overflow: hidden; background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: 17px; }
.task-progress-line { position: absolute; top: 0; left: 0; height: 2px; width: var(--progress, 0%); background: linear-gradient(90deg, var(--coral), var(--accent)); transition: width .5s; }
.task-body { padding: 16px; }
.task-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.task-id { min-width: 0; }
.task-id small { display: block; margin-bottom: 5px; color: var(--faint); font-size: 8px; text-transform: uppercase; letter-spacing: .12em; }
.task-id strong { display: block; overflow: hidden; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { flex: 0 0 auto; padding: 5px 8px; border-radius: 999px; font-size: 9px; }
.status-badge.running { color: var(--accent); background: rgba(245,206,88,.09); }
.status-badge.completed { color: var(--green); background: rgba(113,230,163,.09); }
.status-badge.failed { color: var(--danger); background: rgba(255,125,134,.09); }
.task-prompt { min-height: 42px; margin: 14px 0 12px; color: #cac7c0; font-size: 11px; line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-reference-row { display: flex; flex-wrap: wrap; gap: 5px; min-height: 22px; }
.task-reference-row span { padding: 4px 6px; color: var(--blue); background: rgba(129,181,255,.07); border-radius: 6px; font-size: 8px; }
.task-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.task-footer > span { color: var(--faint); font-size: 9px; }
.task-footer-actions { display: flex; gap: 6px; }
.task-error { margin-top: 10px; padding: 9px; color: #ffb0b6; background: rgba(255,125,134,.06); border-radius: 8px; font-size: 9px; line-height: 1.5; }
.video-result { position: relative; aspect-ratio: 16 / 7; background: #080809; border-bottom: 1px solid var(--line); }
.video-result video { width: 100%; height: 100%; object-fit: cover; }
.video-result a { position: absolute; right: 9px; bottom: 9px; padding: 6px 8px; color: #171309; background: var(--accent); border-radius: 7px; text-decoration: none; font-size: 9px; font-weight: 700; }

.toast-stack { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 44px)); }
.toast { padding: 13px 15px; background: #242428; border: 1px solid var(--line-bright); border-left: 3px solid var(--accent); border-radius: 11px; box-shadow: 0 18px 50px rgba(0,0,0,.5); font-size: 11px; animation: toast-in .24s ease-out; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1080px) {
  .key-status, .key-console > label { display: none; }
  .key-input-wrap { width: 240px; }
  .work-grid { grid-template-columns: 1fr; }
  .asset-list { max-height: none; }
}

@media (max-width: 760px) {
  .topbar { align-items: flex-start; padding: 12px 16px; }
  .brand small { display: none; }
  .key-console { flex: 1; }
  .key-input-wrap { width: 100%; }
  .workspace { width: min(100% - 24px, 1480px); padding-top: 34px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .hero h1 { font-size: 48px; }
  .hero-stats { width: 100%; }
  .hero-stats div { flex: 1; min-width: 0; }
  .composer-panel, .asset-panel, .task-panel { padding: 20px; }
  .settings-grid { grid-template-columns: repeat(2, 1fr); }
  .task-heading, .task-tools { align-items: flex-start; flex-direction: column; }
  .task-tools { width: 100%; }
  .task-list { grid-template-columns: 1fr; }
  .submit-row { align-items: stretch; flex-direction: column; }
  .button-primary { width: 100%; }
}

@media (max-width: 480px) {
  .brand strong { font-size: 12px; }
  .brand-mark { width: 34px; height: 34px; }
  .key-console { padding-left: 8px; }
  .hero h1 { font-size: 41px; }
  .hero-stats div { padding: 14px; }
  .settings-grid, .toggle-grid { grid-template-columns: 1fr; }
  .segmented { max-width: 100%; overflow-x: auto; }
  .url-row { grid-template-columns: 1fr 80px; }
  .url-row .button { grid-column: 1 / -1; }
}
