* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #08080c;
  color: #c8c8d0;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Layout ── */
.app { max-width: 720px; margin: 0 auto; padding: 28px 20px 60px; }
.setup-container { max-width: 560px; margin: 0 auto; padding: 40px 20px 60px; }

/* ── Header ── */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 20px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }
.logo em { font-style: normal; color: #8b5cf6; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  background: #111118; border: 1px solid #1e1e2a;
  color: #707080; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; transition: all 0.15s;
}
.icon-btn:hover { background: #1a1a24; color: #a0a0b0; }

/* ── GPU Badge ── */
.gpu-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; padding: 5px 10px; border-radius: 20px; font-weight: 500;
}
.gpu-badge.online { background: #0a2e1a; color: #4ade80; }
.gpu-badge.offline { background: #2e0a0a; color: #f87171; }
.gpu-dot { width: 7px; height: 7px; border-radius: 50%; }
.gpu-dot.on { background: #4ade80; }
.gpu-dot.off { background: #f87171; }
.gpu-details { font-size: 10px; opacity: 0.8; }

/* ── Card ── */
.card {
  background: #111118; border: 1px solid #1e1e2a;
  border-radius: 16px; padding: 24px; margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; color: #fff; margin-bottom: 4px; }
.card-subtitle { font-size: 12px; color: #707080; margin-bottom: 18px; }

/* ── Banners ── */
.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 12px;
  font-size: 12px; font-weight: 500; margin-bottom: 16px;
}
.banner.warning { background: #1a1400; border: 1px solid #3a2a00; color: #fbbf24; }
.banner.error { background: #1a0808; border: 1px solid #3a1a1a; color: #f87171; }
.banner.info { background: #081018; border: 1px solid #1a2a3a; color: #60a5fa; }
.banner a { color: inherit; text-decoration: underline; margin-left: auto; white-space: nowrap; }

/* ── Buttons ── */
.btn-primary {
  padding: 12px 24px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.btn-primary:hover { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.btn-primary.full { width: 100%; padding: 14px; font-size: 15px; font-weight: 700; border-radius: 12px; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  padding: 10px 16px; background: #16161e; border: 1px solid #2a2a3a;
  color: #b0b0c0; border-radius: 10px; font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: center; text-decoration: none; transition: background 0.15s;
}
.btn-secondary:hover { background: #1e1e2a; }

.btn-test {
  padding: 8px 16px; background: #111118; border: 1px solid #2a2a3a;
  color: #a0a0b0; border-radius: 8px; font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.btn-test:hover { background: #1a1a24; }

.btn-ghost {
  background: none; border: none; color: #606070;
  font-size: 13px; cursor: pointer; padding: 8px 0;
}
.btn-ghost:hover { color: #a0a0b0; }

.btn-danger-link {
  background: none; border: none; color: #f87171;
  font-size: 12px; cursor: pointer; text-decoration: underline;
}

.divider { height: 1px; background: #1e1e2a; margin: 20px 0; }

/* ── Fields ── */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 500; color: #909098; }
.field .field-help { font-size: 10px; color: #505060; margin-top: 2px; }
.field select,
.field input[type="number"],
.field input[type="text"],
.field input[type="password"] {
  background: #0a0a10; border: 1px solid #1e1e2a; border-radius: 8px;
  padding: 10px 12px; color: #d0d0d8; font-size: 13px; font-family: inherit; width: 100%;
}
.field select:focus, .field input:focus { outline: none; border-color: #8b5cf6; }

.info-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  background: #1e1e2a; color: #606070;
  font-size: 9px; font-weight: 700; cursor: help; margin-left: 4px;
}

/* ── Test result ── */
.test-result {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 10px;
  font-size: 12px; font-weight: 500; margin-top: 12px;
}
.test-result.success { background: #0a2e1a; color: #4ade80; border: 1px solid #14442a; }
.test-result.fail { background: #2e0a0a; color: #f87171; border: 1px solid #44141a; }

/* ── Model picker ── */
.model-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 8px;
}
.model-card {
  background: #0c0c14; border: 2px solid #1e1e2a; border-radius: 12px;
  padding: 16px 12px; text-align: center; cursor: pointer; transition: all 0.15s;
}
.model-card:hover { border-color: #3a3a5a; }
.model-card.selected { border-color: #8b5cf6; background: #14101e; }
.model-card .model-icon { font-size: 24px; margin-bottom: 6px; }
.model-card .model-name { font-size: 13px; font-weight: 600; color: #e0e0e8; }
.model-card .model-tag { font-size: 10px; color: #707080; margin-top: 2px; }

/* ── Prompt ── */
.prompt-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.prompt-label span { font-size: 13px; font-weight: 600; color: #b0b0c0; }
.prompt-label .hint { font-size: 11px; color: #505060; font-weight: 400; }

textarea.prompt-input {
  width: 100%; background: #0a0a10;
  border: 2px solid #2a2a4a; border-radius: 12px;
  padding: 16px; color: #e0e0e8; font-size: 15px;
  font-family: inherit; resize: vertical;
  min-height: 110px; line-height: 1.6;
}
textarea.prompt-input:focus { outline: none; border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139,92,246,0.15); }
textarea.prompt-input::placeholder { color: #363646; }

/* ── Param row ── */
.param-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* ── Aspect ratio ── */
.aspect-grid { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.aspect-option {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 10px; border: 2px solid #1e1e2a; border-radius: 8px;
  cursor: pointer; background: #0c0c14; transition: all 0.15s;
}
.aspect-option:hover { border-color: #3a3a5a; }
.aspect-option.selected { border-color: #8b5cf6; background: #14101e; }
.aspect-box { border: 2px solid #505060; border-radius: 2px; }
.aspect-option.selected .aspect-box { border-color: #8b5cf6; }
.aspect-option .aspect-label { font-size: 10px; color: #808090; font-weight: 500; }
.aspect-option .aspect-res { font-size: 8px; color: #505060; }

/* ── Advanced (details/summary) ── */
details.advanced { margin-bottom: 16px; }
details.advanced summary {
  font-size: 12px; color: #606070; cursor: pointer; padding: 8px 0;
  list-style: none; display: flex; align-items: center; gap: 6px;
}
details.advanced summary::-webkit-details-marker { display: none; }
details.advanced summary::before { content: '▸'; transition: transform 0.15s; }
details.advanced[open] summary::before { transform: rotate(90deg); }
details.advanced summary:hover { color: #8b5cf6; }
details.advanced summary .hint { color: #404050; margin-left: 4px; }

.advanced-section {
  background: #0a0a10; border: 1px solid #1a1a24;
  border-radius: 12px; padding: 18px; margin-top: 8px;
}
.advanced-section .field-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px;
}
.advanced-section .field-row:last-child { margin-bottom: 0; }

textarea.neg-prompt {
  width: 100%; background: #111118; border: 1px solid #1e1e2a; border-radius: 8px;
  padding: 10px 12px; color: #d0d0d8; font-size: 12px; font-family: inherit;
  resize: none; min-height: 48px;
}

/* ── Progress ── */
.progress-card { text-align: center; padding: 36px 24px; }
.progress-ring-wrapper { position: relative; width: 130px; height: 130px; margin: 0 auto 20px; }
.progress-ring { transform: rotate(-90deg); }
.progress-ring circle { fill: none; stroke-width: 8; }
.progress-ring .bg { stroke: #1e1e2a; }
.progress-ring .fill { stroke: #8b5cf6; stroke-linecap: round; stroke-dasharray: 377; }
.progress-percent {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 28px; font-weight: 700; color: #fff;
}
.progress-step { font-size: 14px; color: #a0a0b0; margin-bottom: 4px; }
.progress-detail { font-size: 12px; color: #505060; }
.progress-meta {
  display: flex; justify-content: center; gap: 16px; margin-top: 16px; font-size: 11px; color: #505060;
}

/* ── Error state ── */
.error-card {
  background: #1a0a0a; border: 1px solid #3a1a1a; border-radius: 16px;
  padding: 32px 24px; text-align: center; margin-bottom: 16px;
}
.error-icon { font-size: 40px; margin-bottom: 12px; color: #f87171; }
.error-title { font-size: 16px; font-weight: 600; color: #f87171; margin-bottom: 6px; }
.error-msg { font-size: 13px; color: #a08080; margin-bottom: 6px; }
.error-detail {
  font-size: 11px; color: #604040; font-family: monospace;
  background: #140808; padding: 10px; border-radius: 8px;
  margin: 12px 0; text-align: left; word-break: break-all;
}
.error-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

/* ── Result ── */
.video-result {
  border-radius: 12px; overflow: hidden; background: #000;
  margin-bottom: 16px; aspect-ratio: 16/9;
  display: flex; align-items: center; justify-content: center;
  color: #404050; font-size: 14px; border: 1px solid #1e1e2a;
}
.video-result video { width: 100%; height: 100%; object-fit: contain; }
.result-actions { display: flex; gap: 10px; margin-bottom: 20px; }
.result-actions > * { flex: 1; }
.result-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 12px; }
.result-meta-item { background: #0c0c14; padding: 10px 12px; border-radius: 8px; }
.result-meta-item .meta-label { color: #505060; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.result-meta-item .meta-value { color: #d0d0d8; font-weight: 500; margin-top: 2px; }

/* ── History ── */
.history-section { margin-top: 24px; }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.history-header h2 { font-size: 16px; font-weight: 600; color: #fff; }

.video-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.video-card {
  background: #111118; border: 1px solid #1e1e2a;
  border-radius: 12px; overflow: hidden; transition: border-color 0.15s;
}
.video-card:hover { border-color: #2e2e4a; }
.video-thumb {
  width: 100%; aspect-ratio: 16/9; background: #0a0a10;
  display: flex; align-items: center; justify-content: center;
  color: #303040; font-size: 22px;
}
.video-thumb video { width: 100%; height: 100%; object-fit: cover; }
.video-info { padding: 10px 12px; }
.video-prompt { font-size: 12px; color: #b0b0c0; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-meta { font-size: 10px; color: #505060; margin-bottom: 6px; }
.video-actions { display: flex; gap: 6px; }
.video-actions button, .video-actions a {
  padding: 4px 8px; background: #0c0c14; border: 1px solid #1e1e2a;
  border-radius: 6px; color: #707080; font-size: 10px; cursor: pointer;
  text-decoration: none; font-family: inherit;
}
.video-actions button:hover, .video-actions a:hover { background: #1a1a24; color: #a0a0b0; }
.video-actions .delete-btn { color: #f87171; }
.video-actions .delete-btn:hover { background: #2e0a0a; }

.empty-state { text-align: center; padding: 48px 20px; color: #404050; }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 13px; margin-bottom: 16px; }

.error { color: #f87171; background: #2e0a0a; border: 1px solid #3a1a1a; border-radius: 8px; padding: 10px 14px; font-size: 12px; }

/* ── Setup wizard ── */
.setup-header { text-align: center; margin-bottom: 36px; }
.setup-header .logo { font-size: 28px; margin-bottom: 8px; }
.setup-header p { font-size: 13px; color: #707080; }

.wizard-steps { display: flex; align-items: center; justify-content: center; margin-bottom: 32px; }
.wiz-step { display: flex; align-items: center; gap: 8px; }
.wiz-num {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  border: 2px solid #1e1e2a; color: #505060; background: #0a0a10;
}
.wiz-num.active { border-color: #8b5cf6; color: #8b5cf6; background: #14101e; }
.wiz-num.done { border-color: #4ade80; color: #fff; background: #0a2e1a; }
.wiz-label { font-size: 11px; color: #505060; font-weight: 500; }
.wiz-label.active { color: #d0d0d8; }
.wiz-label.done { color: #4ade80; }
.wiz-line { width: 40px; height: 2px; background: #1e1e2a; margin: 0 12px; }
.wiz-line.done { background: #4ade80; }

.setup-step { display: none; }
.setup-step.active { display: block; }
.setup-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 28px; }

.location-btn {
  flex: 1; padding: 14px; background: #0c0c14; border: 2px solid #1e1e2a;
  border-radius: 10px; cursor: pointer; text-align: center; transition: all 0.15s;
}
.location-btn:hover { border-color: #3a3a5a; }
.location-btn.selected { border-color: #8b5cf6; background: #14101e; }

.input-with-btn { display: flex; gap: 8px; align-items: flex-start; }
.input-with-btn .field { flex: 1; }

/* ── Model detection ── */
.detected-models { display: flex; flex-direction: column; gap: 8px; }
.detected-model {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: #0c0c14; border: 1px solid #1e1e2a; border-radius: 12px;
}
.detected-model.available { border-color: #14442a; }
.detected-model.missing { opacity: 0.5; }
.dm-status { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.dm-status.found { background: #0a2e1a; color: #4ade80; }
.dm-status.not-found { background: #1a1018; color: #a78bfa; }
.dm-info { flex: 1; }
.dm-name { font-size: 13px; font-weight: 600; color: #e0e0e8; }
.dm-detail { font-size: 10px; color: #505060; margin-top: 1px; }

.toggle-label { cursor: pointer; display: flex; align-items: center; }
.toggle-input { display: none; }
.dm-toggle {
  width: 40px; height: 22px; border-radius: 11px;
  background: #1e1e2a; display: block; position: relative; transition: background 0.2s;
}
.dm-toggle.on, .toggle-input:checked + .dm-toggle { background: #6d28d9; }
.dm-toggle::after {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: left 0.2s;
}
.dm-toggle.on::after, .toggle-input:checked + .dm-toggle::after { left: 21px; }

/* ── Settings ── */
.settings-nav {
  display: flex; gap: 4px; background: #0a0a10; border: 1px solid #1e1e2a;
  border-radius: 12px; padding: 4px; margin-bottom: 20px;
}
.settings-nav button {
  flex: 1; padding: 8px 10px; background: transparent; border: none;
  color: #606070; font-size: 12px; font-weight: 600; border-radius: 8px;
  cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.settings-nav button:hover { color: #a0a0b0; }
.settings-nav button.active { background: #1e1e2a; color: #e0e0e8; }

.settings-tab { display: none; }
.settings-tab.active { display: block; }

.setting-group { margin-bottom: 20px; }
.setting-group-title { font-size: 13px; font-weight: 600; color: #fff; margin-bottom: 4px; }
.setting-group-desc { font-size: 11px; color: #505060; margin-bottom: 12px; }
.setting-row { display: flex; gap: 12px; margin-bottom: 12px; align-items: flex-end; }
.setting-row .field { flex: 1; }

.conn-status {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 12px;
}
.conn-status.connected { background: #0a2e1a; color: #4ade80; border: 1px solid #14442a; }
.conn-status.disconnected { background: #2e0a0a; color: #f87171; border: 1px solid #44141a; }
.conn-status .conn-details { margin-left: auto; font-size: 11px; opacity: 0.7; }

.storage-bar-outer { width: 100%; height: 6px; background: #1e1e2a; border-radius: 3px; overflow: hidden; margin: 6px 0; }
.storage-bar-inner { height: 100%; border-radius: 3px; background: #8b5cf6; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .app, .setup-container { padding: 16px 12px 40px; }
  .header .logo { font-size: 18px; }
  .model-grid { grid-template-columns: 1fr; }
  .param-row { grid-template-columns: 1fr; }
  .video-grid { grid-template-columns: 1fr; }
  .result-meta { grid-template-columns: 1fr; }
  .advanced-section .field-row { grid-template-columns: 1fr; }
}
