@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f7f7fa;
  --surface: #fff;
  --surface2: #f0f0f5;
  --border: #e4e4ec;
  --border-hover: #d0d0da;
  --text: #6b6b7a;
  --text-dim: #9a9aae;
  --text-bright: #1a1a2e;
  --accent: #e94560;
  --accent-glow: rgba(233,69,96,.15);
  --accent2: #6c5ce7;
  --green: #27ae60;
  --yellow: #e67e22;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 40px 16px 80px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app { width: 100%; max-width: 880px; }

/* ── Header ── */
.header {
  text-align: center;
  margin-bottom: 32px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.logo-mark {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff; font-weight: 800;
  box-shadow: 0 0 24px var(--accent-glow);
}
h1 {
  font-size: 1.6rem; font-weight: 800; color: var(--text-bright);
  letter-spacing: -.03em;
}
.subtitle {
  font-size: .82rem; color: var(--text-dim);
  font-weight: 500;
}

/* ── Nav tabs ── */
.nav-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  background: var(--surface); border-radius: var(--radius);
  padding: 4px;
}
.nav-tab {
  flex: 1; padding: 10px 16px; border: none; border-radius: 9px;
  font-size: .82rem; font-weight: 600; cursor: pointer;
  font-family: inherit; color: var(--text-dim);
  background: transparent; transition: all .2s;
}
.nav-tab.active { background: var(--surface2); color: var(--text-bright); }
.nav-tab:hover:not(.active) { color: var(--text); }

/* ── Tab panels ── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Status bar ── */
.status-bar {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 24px; font-size: .78rem; font-weight: 600;
  margin-bottom: 20px; transition: all .3s;
}
.status-bar.ok { background: rgba(39,174,96,.08); color: var(--green); }
.status-bar.warn { background: rgba(230,126,34,.08); color: var(--yellow); }
.status-bar.err { background: rgba(233,69,96,.08); color: var(--accent); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; }
.status-bar.ok .status-dot { background: var(--green); }
.status-bar.warn .status-dot { background: var(--yellow); animation: pulse 1.5s infinite; }
.status-bar.err .status-dot { background: var(--accent); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; margin-bottom: 14px;
}

/* ── Upload ── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: all .25s; background: var(--surface);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent); background: rgba(233,69,96,.04);
  box-shadow: 0 0 32px rgba(233,69,96,.06);
}
.upload-zone.loaded { padding: 18px 24px; border-style: solid; border-color: var(--border); }
.upload-zone input { display: none; }
.upload-icon {
  width: 56px; height: 56px; margin: 0 auto 14px;
  background: var(--surface2); border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.upload-zone.loaded .upload-icon { display: none; }
.upload-title { font-size: .92rem; color: var(--text-dim); }
.upload-title strong { color: var(--accent); font-weight: 700; }
.upload-hint { font-size: .72rem; color: var(--text-dim); margin-top: 6px; opacity: .7; }
.upload-progress { width: 100%; height: 8px; background: #e0e0e6; border-radius: 4px; margin-top: 10px; overflow: hidden; display: none; }
.upload-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 4px; width: 0%; transition: width .3s ease; }
#uploadPct { display: inline-block; min-width: 52px; color: var(--accent); font-weight: 700; }

/* ── Preview ── */
.preview-grid {
  display: none; gap: 14px; grid-template-columns: 1fr 1fr;
}
.preview-grid.show { display: grid; }
@media (max-width: 700px) { .preview-grid { grid-template-columns: 1fr; } }
.preview-cell {
  background: #000; border-radius: var(--radius); overflow: hidden;
  position: relative; aspect-ratio: 16/10;
  border: 1px solid var(--border);
}
.preview-cell video, .preview-cell img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.preview-badge {
  position: absolute; top: 10px; left: 12px; z-index: 2;
  font-size: .68rem; font-weight: 700; color: #fff;
  background: rgba(0,0,0,.55); backdrop-filter: blur(8px);
  padding: 4px 12px; border-radius: 20px;
}
.preview-badge.live { background: var(--accent); }

.meta-row {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px;
  font-size: .72rem; color: var(--text-dim); font-weight: 500;
}
.meta-row span {
  background: var(--surface2); padding: 4px 12px;
  border-radius: 8px; border: 1px solid var(--border);
}

/* ── Section titles ── */
.section-title {
  font-size: .68rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .12em; margin-bottom: 14px;
}

/* ── Controls ── */
.ctrl { margin-bottom: 18px; }
.ctrl:last-child { margin-bottom: 0; }
.ctrl-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.ctrl-label { font-size: .84rem; color: var(--text-bright); font-weight: 600; }
.ctrl-value { font-size: .78rem; font-weight: 700; color: var(--accent); min-width: 32px; text-align: right; }
.ctrl-hint { font-size: .68rem; color: var(--text-dim); opacity: .7; margin-top: 2px; }

input[type=range] {
  -webkit-appearance: none; width: 100%; height: 5px;
  background: var(--border); border-radius: 3px; outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px;
  background: var(--surface); border: 2px solid var(--accent);
  border-radius: 50%; cursor: pointer; box-shadow: 0 0 12px var(--accent-glow);
  transition: all .2s;
}
input[type=range]::-webkit-slider-thumb:hover {
  background: var(--accent); border-color: var(--accent);
}

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Param groups ── */
.param-group { margin-bottom: 4px; }

/* ── Toggle switch ── */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border); border-radius: 24px; transition: .25s;
}
.toggle-track::before {
  content: ''; position: absolute; height: 18px; width: 18px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .25s;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.toggle-switch input:checked + .toggle-track { background: var(--accent2); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(20px); }

/* ── Buttons ── */
.btn-row { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.btn {
  padding: 13px 18px; border: none; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 700; cursor: pointer;
  font-family: inherit; transition: all .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  flex: 1; min-width: 120px;
  background: linear-gradient(135deg, var(--accent), #e0485f);
  color: #fff; box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 6px 28px rgba(233,69,96,.25); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-cancel {
  flex: 1; min-width: 100px; background: var(--surface2);
  color: var(--text-dim); display: none;
}
.btn-cancel:hover { background: var(--border); color: var(--text); }

.btn-sm {
  padding: 8px 16px; font-size: .76rem; border-radius: 8px;
  background: var(--surface2); color: var(--text-dim);
  border: 1px solid var(--border); cursor: pointer;
  font-family: inherit; font-weight: 600; transition: all .2s;
}
.btn-sm:hover { background: var(--border); color: var(--text); border-color: var(--border-hover); }
.btn-sm.active {
  background: rgba(233,69,96,.1); color: var(--accent);
  border-color: rgba(233,69,96,.25);
}

.preset-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }

.trim-row {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 14px; font-size: .8rem; color: var(--text);
}
.trim-row input[type=text] {
  width: 72px; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-family: inherit; font-size: .8rem;
  text-align: center; background: var(--surface2); color: var(--text-bright);
}
.trim-row input:focus { outline: none; border-color: var(--accent); }

/* ── Progress ── */
.progress-card { display: none; }
.progress-card.show { display: block; }
.progress-track {
  width: 100%; height: 6px; background: var(--surface2);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .3s;
}
.progress-info {
  display: flex; justify-content: space-between;
  margin-top: 8px; font-size: .75rem; color: var(--text-dim);
  font-weight: 500;
}

/* ── Result ── */
.result-card { display: none; }
.result-card.show { display: block; }
.result-video {
  width: 100%; max-height: 400px; border-radius: var(--radius);
  background: #000; border: 1px solid var(--border);
}
.result-actions { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.btn-dl {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px 22px; background: var(--green); color: #000;
  border-radius: var(--radius-sm); text-decoration: none;
  font-weight: 700; font-size: .88rem;
  box-shadow: 0 4px 20px rgba(45,212,160,.2);
  transition: all .2s;
}
.btn-dl:hover { box-shadow: 0 6px 28px rgba(45,212,160,.3); transform: translateY(-1px); }

/* ── Messages ── */
.msg {
  text-align: center; font-size: .76rem; margin-top: 10px;
  min-height: 20px; font-weight: 500;
}
.msg.err { color: var(--accent); } .msg.ok { color: var(--text-dim); }

/* ── Shortcuts ── */
.kbd {
  display: inline-block; padding: 2px 7px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 5px; font-size: .7rem; font-family: monospace;
  color: var(--text-dim);
}
.shortcuts-hint { font-size: .68rem; color: var(--text-dim); opacity: .5; text-align: center; margin-top: 6px; }

/* ── History ── */
.history-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

/* ── Seedance Tutorial ── */
.tutorial-card {}
.tut-hero {
  background: linear-gradient(135deg, rgba(124,92,252,.08), rgba(255,94,122,.06));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px;
}
.tut-hero h3 { font-size: 1.15rem; color: var(--text-bright); font-weight: 700; margin-bottom: 6px; }
.tut-hero p { font-size: .82rem; color: var(--text-dim); line-height: 1.6; }

.tut-steps { display: flex; flex-direction: column; gap: 20px; }
.tut-step { display: flex; gap: 16px; }
.tut-step-num {
  flex-shrink: 0; width: 36px; height: 36px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: .9rem; font-weight: 800;
  color: var(--accent);
}
.tut-step-body { flex: 1; }
.tut-step-body h4 { font-size: .9rem; color: var(--text-bright); font-weight: 700; margin-bottom: 4px; }
.tut-step-body p { font-size: .78rem; color: var(--text-dim); line-height: 1.65; }
.tut-step-body code {
  display: inline-block; padding: 2px 8px; margin: 2px 0;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 5px; font-size: .76rem; font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  color: var(--accent2);
}

.tut-prompt-block {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 18px 20px;
  margin: 10px 0; position: relative;
}
.tut-prompt-block .tag {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  font-size: .7rem; font-weight: 700; margin-right: 4px;
}
.tag-img { background: rgba(124,92,252,.2); color: var(--accent2); }
.tag-vid { background: rgba(255,94,122,.15); color: var(--accent); }
.tag-action { background: rgba(45,212,160,.15); color: var(--green); }
.tut-prompt-block pre {
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: .78rem; color: var(--text-bright); white-space: pre-wrap;
  line-height: 1.7; margin: 0;
}
.tut-copy-btn {
  position: absolute; top: 12px; right: 14px;
  padding: 5px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-dim); font-size: .7rem;
  cursor: pointer; font-family: inherit; font-weight: 600; transition: all .2s;
}
.tut-copy-btn:hover { background: var(--border); color: var(--text); }
.tut-copy-btn.copied { background: rgba(45,212,160,.15); border-color: var(--green); color: var(--green); }

.tut-tips {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.tut-tips h4 { font-size: .88rem; color: var(--yellow); font-weight: 700; margin-bottom: 10px; }
.tut-tips li {
  font-size: .78rem; color: var(--text-dim); line-height: 1.8;
  list-style: inside; margin-bottom: 4px;
}
.tut-tips li::marker { color: var(--yellow); }

/* ── Accordion ── */
.accordion { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.accordion-trigger {
  width: 100%; padding: 16px 20px; background: var(--surface2);
  border: none; border-bottom: 1px solid var(--border); color: var(--text-bright);
  font-family: inherit; font-size: .86rem; font-weight: 600;
  cursor: pointer; text-align: left; display: flex; justify-content: space-between;
  align-items: center; transition: background .2s;
}
.accordion-trigger:last-child { border-bottom: none; }
.accordion-trigger:hover { background: var(--border); }
.accordion-trigger::after { content: '+'; font-size: 1.1rem; color: var(--text-dim); font-weight: 400; }
.accordion-trigger.open::after { content: '−'; color: var(--accent); }
.accordion-body {
  display: none; padding: 18px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.accordion-body.open { display: block; }
.accordion-body:last-child { border-bottom: none; }

/* ── Footer ── */
.footer {
  text-align: center; font-size: .7rem; color: var(--text-dim);
  opacity: .5; margin-top: 32px; line-height: 1.8;
}
