:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-deep: #040a13;
  --panel: rgba(12, 26, 45, 0.82);
  --panel-strong: rgba(15, 33, 56, 0.96);
  --line: rgba(163, 187, 217, 0.15);
  --line-strong: rgba(163, 187, 217, 0.28);
  --text: #f3f7fb;
  --muted: #91a2b7;
  --dim: #5f7087;
  --cyan: #45d7e8;
  --blue: #6689ff;
  --violet: #a77bff;
  --green: #6ee7b7;
  --danger: #ff7c91;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg-deep); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% -10%, rgba(72, 142, 255, 0.16), transparent 34rem),
    radial-gradient(circle at 95% 20%, rgba(146, 82, 255, 0.12), transparent 32rem),
    linear-gradient(135deg, #071321 0%, #06101d 48%, #081426 100%);
  overflow-x: hidden;
}

button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.62; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 22rem;
  height: 22rem;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.18;
  pointer-events: none;
}
.ambient-one { top: 26%; left: -11rem; background: var(--cyan); }
.ambient-two { right: -10rem; bottom: 6%; background: var(--violet); }

.app-shell { width: min(1480px, calc(100% - 56px)); margin: 0 auto; padding: 28px 0 22px; }

.topbar, .footer-bar, .topbar-actions, .brand-lockup, .field-label-row, .progress-header, .result-header, .result-actions, .preview-header {
  display: flex;
  align-items: center;
}

.topbar { justify-content: space-between; min-height: 62px; margin-bottom: 26px; }
.brand-lockup { gap: 14px; }
.brand-mark { position: relative; display: flex; align-items: end; gap: 3px; width: 38px; height: 38px; padding: 8px; border: 1px solid rgba(110, 231, 255, 0.44); border-radius: 13px; background: linear-gradient(145deg, rgba(69, 215, 232, 0.2), rgba(102, 137, 255, 0.18)); box-shadow: inset 0 0 18px rgba(69, 215, 232, 0.12), 0 0 26px rgba(69, 215, 232, 0.12); }
.brand-mark span { width: 4px; border-radius: 5px; background: linear-gradient(to top, var(--cyan), #c6fbff); }
.brand-mark span:nth-child(1) { height: 44%; opacity: 0.6; }
.brand-mark span:nth-child(2) { height: 76%; }
.brand-mark span:nth-child(3) { height: 100%; opacity: 0.8; }
.eyebrow, .section-kicker { color: var(--cyan); font-size: 10px; font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; }
.brand-lockup h1, .preview-header h2, .section-heading h2 { margin: 3px 0 0; letter-spacing: -0.04em; }
.brand-lockup h1 { font-size: 20px; font-weight: 700; }
.topbar-actions { gap: 12px; }
.status-badge, .job-badge, .template-type-pill { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; white-space: nowrap; }
.status-badge { padding: 8px 12px; border: 1px solid var(--line); color: var(--muted); background: rgba(11, 25, 42, 0.65); font-size: 12px; }
.status-badge.status-ok { border-color: rgba(110, 231, 183, 0.3); color: var(--green); background: rgba(40, 138, 106, 0.1); }
.status-badge.status-error { border-color: rgba(255, 124, 145, 0.32); color: var(--danger); background: rgba(160, 52, 75, 0.1); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); box-shadow: 0 0 0 4px rgba(95, 112, 135, 0.08); }
.status-ok .status-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(110, 231, 183, 0.1); }
.status-error .status-dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 124, 145, 0.1); }

.workspace { display: grid; grid-template-columns: minmax(460px, 0.82fr) minmax(540px, 1.18fr); gap: 26px; align-items: start; }
.panel-card { border: 1px solid var(--line); border-radius: 24px; background: linear-gradient(145deg, rgba(17, 36, 60, 0.88), rgba(8, 20, 36, 0.87)); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.control-panel { padding: 28px; }
.section-heading { display: flex; justify-content: space-between; min-height: 68px; margin-bottom: 28px; }
.section-heading h2, .preview-header h2 { font-size: 25px; }
.section-heading p { max-width: 360px; margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.heading-orbit { position: relative; width: 64px; height: 64px; margin-right: 5px; }
.heading-orbit::before, .heading-orbit::after { content: ""; position: absolute; inset: 5px; border: 1px solid rgba(69, 215, 232, 0.23); border-radius: 50%; transform: rotate(24deg) scaleX(0.55); }
.heading-orbit::after { inset: 10px -3px; border-color: rgba(167, 123, 255, 0.25); transform: rotate(-34deg) scaleX(0.63); }
.heading-orbit span { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.heading-orbit span:nth-child(1) { top: 2px; left: 29px; }
.heading-orbit span:nth-child(2) { right: 3px; bottom: 14px; background: var(--violet); box-shadow: 0 0 12px var(--violet); }
.heading-orbit span:nth-child(3) { bottom: 1px; left: 20px; width: 3px; height: 3px; }

.field-group { margin-top: 20px; }
.field-group:first-child { margin-top: 0; }
.field-label-row { justify-content: space-between; gap: 10px; margin-bottom: 9px; }
label, .field-label { display: block; color: #dce8f3; font-size: 12px; font-weight: 700; }
.field-state, .optional { color: var(--dim); font-size: 10px; font-weight: 600; }
.optional { font-weight: 500; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 11px; outline: none; color: var(--text); background: rgba(4, 13, 25, 0.62); transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease; }
input, select { height: 42px; padding: 0 12px; }
textarea { min-height: 120px; padding: 12px; resize: vertical; line-height: 1.65; }
input::placeholder, textarea::placeholder { color: #53677f; }
input:focus, textarea:focus, select:focus { border-color: rgba(69, 215, 232, 0.7); background: rgba(7, 20, 35, 0.84); box-shadow: 0 0 0 3px rgba(69, 215, 232, 0.1); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #7f94ad 50%), linear-gradient(135deg, #7f94ad 50%, transparent 50%); background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
option { color: #07111f; }
.input-with-icon { position: relative; }
.input-icon { position: absolute; top: 10px; left: 12px; color: var(--cyan); font-size: 17px; }
.input-with-icon input { padding-left: 34px; }
.helper-text { margin-top: 7px; color: var(--dim); font-size: 10px; line-height: 1.5; }

.free-mode-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; padding: 13px 14px; border: 1px solid rgba(110, 231, 183, 0.25); border-radius: 14px; background: linear-gradient(135deg, rgba(110, 231, 183, 0.1), rgba(69, 215, 232, 0.05)); }
.free-mode-copy { min-width: 0; }
.free-mode-kicker { display: block; color: var(--green); font-size: 9px; font-weight: 850; letter-spacing: 0.14em; }
.free-mode-copy strong { display: block; margin-top: 3px; color: #eafbf4; font-size: 12px; }
.free-mode-copy p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.free-mode-button { flex: 0 0 auto; min-height: 34px; padding: 0 12px; border: 1px solid rgba(110, 231, 183, 0.36); border-radius: 9px; color: var(--green); background: rgba(110, 231, 183, 0.08); font-size: 10px; font-weight: 800; transition: background 160ms ease, border-color 160ms ease, color 160ms ease; }
.free-mode-button:hover, .free-mode-button.active { border-color: rgba(110, 231, 183, 0.7); color: #032218; background: var(--green); }

.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-button, .ratio-card { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); color: var(--muted); background: rgba(7, 17, 31, 0.48); text-align: left; transition: border-color 160ms ease, transform 160ms ease, background 160ms ease; }
.mode-button { min-height: 62px; padding: 10px 11px; border-radius: 13px; }
.mode-button:hover, .ratio-card:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.mode-button.active { border-color: rgba(69, 215, 232, 0.68); background: linear-gradient(135deg, rgba(69, 215, 232, 0.14), rgba(102, 137, 255, 0.08)); color: var(--text); box-shadow: inset 0 0 22px rgba(69, 215, 232, 0.05); }
.mode-icon { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid var(--line); border-radius: 9px; color: var(--cyan); font-size: 15px; }
.mode-button strong, .mode-button small { display: block; }
.mode-button strong { font-size: 11px; }
.mode-button small { margin-top: 3px; color: var(--dim); font-size: 9px; }

.form-grid { display: grid; gap: 12px; }
.two-columns { grid-template-columns: 1fr 1fr; }
.compact-field { margin-top: 0; }
.range-wrap { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(4, 13, 25, 0.62); }
input[type="range"] { height: 4px; padding: 0; border: 0; border-radius: 99px; outline: none; accent-color: var(--cyan); background: rgba(143, 170, 200, 0.22); box-shadow: none; }
.range-wrap output { min-width: 23px; color: var(--cyan); font-size: 12px; font-weight: 800; text-align: right; }

.ratio-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ratio-card { min-height: 74px; padding: 10px; border-radius: 13px; }
.ratio-card.active { border-color: rgba(167, 123, 255, 0.68); background: linear-gradient(135deg, rgba(167, 123, 255, 0.14), rgba(102, 137, 255, 0.06)); }
.ratio-preview { flex: 0 0 auto; display: block; border: 1px solid rgba(177, 206, 235, 0.55); border-radius: 3px; background: linear-gradient(150deg, rgba(69, 215, 232, 0.22), rgba(167, 123, 255, 0.22)); box-shadow: inset 0 0 10px rgba(119, 200, 255, 0.1); }
.ratio-portrait { width: 22px; height: 38px; }
.ratio-landscape { width: 40px; height: 25px; }
.ratio-square { width: 31px; height: 31px; }
.ratio-card strong, .ratio-card small { display: block; }
.ratio-card strong { color: var(--text); font-size: 11px; }
.ratio-card small { margin-top: 4px; color: var(--dim); font-size: 9px; line-height: 1.2; }
.template-type-pill { padding: 4px 8px; color: var(--cyan); border: 1px solid rgba(69, 215, 232, 0.24); background: rgba(69, 215, 232, 0.08); font-size: 9px; font-weight: 800; }
.template-type-pill.type-static { color: #fcd38b; border-color: rgba(252, 211, 139, 0.24); background: rgba(252, 211, 139, 0.08); }
.template-type-pill.type-video { color: #c0a5ff; border-color: rgba(167, 123, 255, 0.28); background: rgba(167, 123, 255, 0.1); }

.advanced-panel { margin-top: 20px; border: 1px solid var(--line); border-radius: 13px; background: rgba(3, 12, 23, 0.26); }
.advanced-panel summary { display: flex; justify-content: space-between; align-items: center; min-height: 45px; padding: 0 13px; color: #dbe7f3; cursor: pointer; list-style: none; font-size: 11px; font-weight: 700; }
.advanced-panel summary::-webkit-details-marker { display: none; }
.summary-title { display: flex; align-items: center; gap: 8px; }
.summary-icon { color: var(--violet); }
.summary-note { color: var(--dim); font-size: 9px; font-weight: 500; }
.advanced-content { padding: 0 13px 14px; border-top: 1px solid var(--line); }
.advanced-content .field-group { margin-top: 14px; }
.advanced-content .form-grid { margin-top: 14px; }
.advanced-content .form-grid .field-group { margin-top: 0; }

.primary-button, .download-button { position: relative; display: flex; align-items: center; justify-content: center; gap: 14px; width: 100%; min-height: 50px; margin-top: 22px; overflow: hidden; border: 1px solid rgba(126, 244, 255, 0.52); border-radius: 13px; color: #02151e; background: linear-gradient(100deg, #55deed, #8e9bff 92%); box-shadow: 0 12px 30px rgba(69, 215, 232, 0.16); font-size: 13px; font-weight: 850; letter-spacing: 0.02em; transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease; }
.primary-button:hover, .download-button:hover { transform: translateY(-2px); box-shadow: 0 16px 38px rgba(69, 215, 232, 0.22); filter: brightness(1.04); }
.button-glow { position: absolute; inset: -80% 40% auto -20%; height: 200%; transform: rotate(24deg); background: rgba(255, 255, 255, 0.23); filter: blur(20px); pointer-events: none; }
.button-label, .button-arrow { position: relative; z-index: 1; }
.button-arrow { font-size: 18px; }
.security-note { display: flex; gap: 8px; align-items: center; margin-top: 14px; color: var(--dim); font-size: 9px; line-height: 1.4; }
.lock-icon { color: var(--green); font-size: 11px; }

.preview-panel { min-width: 0; }
.preview-header { justify-content: space-between; min-height: 68px; margin: 0 3px 18px; }
.job-badge { padding: 7px 10px; border: 1px solid var(--line); color: var(--dim); font-size: 9px; font-weight: 850; letter-spacing: 0.13em; }
.job-badge.job-running { border-color: rgba(69, 215, 232, 0.3); color: var(--cyan); background: rgba(69, 215, 232, 0.07); }
.job-badge.job-success { border-color: rgba(110, 231, 183, 0.32); color: var(--green); background: rgba(110, 231, 183, 0.08); }
.job-badge.job-error { border-color: rgba(255, 124, 145, 0.32); color: var(--danger); background: rgba(255, 124, 145, 0.08); }
.preview-stage { position: relative; display: grid; place-items: center; min-height: 430px; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: radial-gradient(circle at 48% 40%, rgba(62, 130, 201, 0.15), transparent 24rem), linear-gradient(145deg, #0d1e34, #081221); box-shadow: var(--shadow); }
.preview-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.15; background-image: linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px); background-size: 48px 48px; mask-image: linear-gradient(to bottom, transparent, black 25%, black 75%, transparent); }
.empty-state { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; padding: 30px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 74px; height: 74px; margin: 8px 0 18px; padding-left: 4px; border: 1px solid rgba(69, 215, 232, 0.35); border-radius: 24px; color: var(--cyan); background: linear-gradient(145deg, rgba(69, 215, 232, 0.15), rgba(167, 123, 255, 0.1)); box-shadow: 0 0 35px rgba(69, 215, 232, 0.13), inset 0 0 24px rgba(69, 215, 232, 0.05); font-size: 25px; }
.empty-sparkles { display: flex; gap: 15px; width: 160px; justify-content: space-between; color: var(--cyan); font-size: 12px; opacity: 0.8; }
.empty-sparkles span:nth-child(2) { margin-top: 13px; color: var(--violet); font-size: 19px; }
.empty-sparkles span:nth-child(3) { margin-top: 24px; color: #fcd38b; }
.empty-state h3 { margin: 0; color: #eaf3fb; font-size: 17px; letter-spacing: -0.02em; }
.empty-state p { max-width: 270px; margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.empty-line { display: flex; gap: 4px; margin-top: 20px; }
.empty-line span { width: 22px; height: 3px; border-radius: 4px; background: rgba(145, 162, 183, 0.3); }
.empty-line span:first-child { width: 7px; background: var(--cyan); }
.preview-stage video { position: relative; z-index: 2; display: block; width: 100%; height: 100%; max-height: 620px; object-fit: contain; background: #02070d; }
.preview-stage video[hidden] { display: none; }
.video-overlay { position: absolute; z-index: 3; inset: 0; display: grid; place-items: center; align-content: center; gap: 18px; color: var(--cyan); background: rgba(3, 11, 21, 0.62); backdrop-filter: blur(3px); }
.video-overlay[hidden] { display: none; }
.pulse-ring { display: block; width: 42px; height: 42px; border: 2px solid rgba(69, 215, 232, 0.82); border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; }
.overlay-label { font-size: 11px; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress-card, .result-card { margin-top: 16px; padding: 20px; }
.progress-header { justify-content: space-between; }
.progress-header h3, .result-header h3 { margin: 4px 0 0; font-size: 15px; letter-spacing: -0.02em; }
.progress-header > strong { color: var(--cyan); font-size: 19px; letter-spacing: -0.05em; }
.progress-track { height: 6px; margin-top: 17px; overflow: hidden; border-radius: 99px; background: rgba(145, 162, 183, 0.12); }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--violet)); box-shadow: 0 0 15px rgba(69, 215, 232, 0.62); transition: width 500ms ease; }
.progress-bar.indeterminate { width: 34%; animation: progress 1.35s ease-in-out infinite; }
@keyframes progress { 0% { transform: translateX(-120%); } 50% { transform: translateX(170%); } 100% { transform: translateX(310%); } }
.progress-detail { min-height: 17px; margin-top: 10px; color: var(--muted); font-size: 10px; }
.event-list { display: grid; gap: 8px; margin-top: 15px; }
.event-row { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 8px; color: #bdcad8; font-size: 10px; }
.event-row time { color: var(--dim); font-variant-numeric: tabular-nums; }
.event-marker { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px rgba(69, 215, 232, 0.65); }
.event-muted { color: var(--dim); }
.event-muted .event-marker { background: var(--dim); box-shadow: none; }
.event-error { color: var(--danger); }
.event-error .event-marker { background: var(--danger); box-shadow: 0 0 10px rgba(255, 124, 145, 0.45); }

.result-header { justify-content: space-between; }
.success-mark { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid rgba(110, 231, 183, 0.35); border-radius: 10px; color: var(--green); background: rgba(110, 231, 183, 0.1); }
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.meta-item { padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: rgba(4, 13, 25, 0.38); }
.meta-item span, .meta-item strong { display: block; }
.meta-item span { color: var(--dim); font-size: 9px; }
.meta-item strong { overflow: hidden; margin-top: 6px; color: #eaf3fb; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.result-actions { gap: 9px; margin-top: 15px; }
.download-button { min-height: 42px; margin-top: 0; text-decoration: none; font-size: 11px; }
.download-button span { font-size: 16px; }
.ghost-button { min-height: 38px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 10px; color: #c6d3e0; background: rgba(9, 21, 36, 0.56); font-size: 11px; transition: border-color 160ms ease, color 160ms ease, background 160ms ease; }
.ghost-button:hover { border-color: rgba(69, 215, 232, 0.55); color: var(--cyan); background: rgba(69, 215, 232, 0.07); }
.result-actions .ghost-button { flex: 0 0 auto; }

.footer-bar { justify-content: space-between; margin-top: 18px; padding: 0 3px; color: var(--dim); font-size: 9px; }

@media (max-width: 1050px) {
  .app-shell { width: min(760px, calc(100% - 32px)); }
  .workspace { grid-template-columns: 1fr; }
  .preview-stage { min-height: 360px; }
}

@media (max-width: 560px) {
  .app-shell { width: calc(100% - 20px); padding-top: 16px; }
  .topbar { align-items: flex-start; gap: 14px; }
  .topbar, .footer-bar { flex-wrap: wrap; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .control-panel { padding: 18px; border-radius: 18px; }
  .section-heading { margin-bottom: 20px; }
  .heading-orbit { transform: scale(0.76); transform-origin: top right; }
  .two-columns, .ratio-grid { grid-template-columns: 1fr; }
  .ratio-card { min-height: 60px; }
  .preview-stage { min-height: 300px; border-radius: 18px; }
  .progress-card, .result-card { padding: 16px; border-radius: 18px; }
  .meta-grid { grid-template-columns: 1fr 1fr; }
  .meta-item:last-child { grid-column: 1 / -1; }
  .result-actions { align-items: stretch; flex-direction: column; }
  .result-actions .ghost-button { width: 100%; }
}
