:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --border-strong: #3a4150;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --text-dim: #6b7280;
  --accent: #5b8cff;
  --accent-hover: #7aa0ff;
  --accent-muted: rgba(91, 140, 255, 0.15);
  --success: #3dd68c;
  --success-muted: rgba(61, 214, 140, 0.12);
  --warning: #f5a524;
  --warning-muted: rgba(245, 165, 36, 0.12);
  --error: #f07178;
  --error-muted: rgba(240, 113, 120, 0.12);
  --info: #7dcfff;
  --info-muted: rgba(125, 207, 255, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", "Consolas", "Liberation Mono", monospace;
  --max: 1120px;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px 20px 48px;
}

header.app-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand .domain {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.badge-p0 {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 999px;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--info-muted);
  border: 1px solid rgba(125, 207, 255, 0.25);
  color: var(--info);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 20px;
}

.input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.input-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.input-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.url-input {
  flex: 1 1 280px;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.url-input::placeholder {
  color: var(--text-dim);
}
.url-input:focus {
  border-color: var(--accent);
}
.url-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-secondary {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  min-height: 28px;
}
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}
.status-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.status-chip.idle {
  color: var(--text-muted);
}
.status-chip.queued {
  color: var(--warning);
  background: var(--warning-muted);
  border-color: rgba(245, 165, 36, 0.35);
}
.status-chip.analyzing,
.status-chip.generating {
  color: var(--info);
  background: var(--info-muted);
  border-color: rgba(125, 207, 255, 0.35);
}
.status-chip.done {
  color: var(--success);
  background: var(--success-muted);
  border-color: rgba(61, 214, 140, 0.35);
}
.status-chip.error {
  color: var(--error);
  background: var(--error-muted);
  border-color: rgba(240, 113, 120, 0.35);
}
.status-detail {
  font-size: 13px;
  color: var(--text-muted);
}

.error-box {
  background: var(--error-muted);
  border: 1px solid rgba(240, 113, 120, 0.35);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.error-box h3 {
  font-size: 15px;
  color: var(--error);
  margin-bottom: 6px;
}
.error-box p {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.error-box .error-code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 320px);
  gap: 16px;
  align-items: start;
}
@media (max-width: 820px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .preview-col {
    order: -1;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.panel-title {
  font-size: 14px;
  font-weight: 600;
}
.panel-body {
  padding: 16px;
}

.empty-state {
  color: var(--text-dim);
  font-size: 13.5px;
}
.empty-state strong {
  display: block;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.field {
  margin-bottom: 14px;
}
.field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.field-value {
  font-size: 14px;
  color: var(--text);
}
.field-value.mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}

.scene-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scene-item {
  display: flex;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text);
}
.scene-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  flex-shrink: 0;
  padding-top: 2px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-muted);
  color: var(--accent);
  border: 1px solid rgba(91, 140, 255, 0.25);
}

.skel {
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    #262b36 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: 4px;
  height: 14px;
  margin-bottom: 6px;
}
.skel.lg {
  width: 70%;
  height: 18px;
}
.skel.md {
  width: 90%;
}
.skel.sm {
  width: 45%;
}
.skel.block {
  width: 100%;
  height: 72px;
}
@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.preview-col .panel-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px;
  gap: 12px;
}
.phone-frame {
  width: 100%;
  max-width: 240px;
  aspect-ratio: 9 / 16;
  background: #0a0b0e;
  border: 2px solid var(--border-strong);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.phone-frame .placeholder-art {
  text-align: center;
  padding: 16px;
  color: var(--text-dim);
  font-size: 12px;
}
.phone-frame .placeholder-art .ratio {
  font-family: var(--mono);
  font-size: 11px;
  margin-top: 6px;
  opacity: 0.7;
}
.phone-frame img,
.phone-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: absolute;
  inset: 0;
}
.phone-frame .shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(91, 140, 255, 0.12) 50%,
    transparent 70%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.preview-meta {
  width: 100%;
  max-width: 240px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}
.preview-tabs {
  display: flex;
  gap: 4px;
  width: 100%;
  max-width: 240px;
}
.preview-tab {
  flex: 1;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
}
.preview-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-muted);
}
.preview-tab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

footer.app-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
}
footer a {
  color: var(--text-dim);
}
