@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap");

:root {
  --bg: #09090b;
  --surface: #111113;
  --surface-2: #18181b;
  --text: #ececee;
  --muted: #9f9fa8;
  --muted-2: #71717a;
  --accent: #c6a87c;
  --accent-hover: #d4ba94;
  --accent-soft: rgba(198, 168, 124, 0.1);
  --accent-border: rgba(198, 168, 124, 0.28);
  --edge: rgba(255, 255, 255, 0.08);
  --edge-strong: rgba(255, 255, 255, 0.14);
  --panel: #111113;
  --danger: #f0a0a0;
  --warn: #d9b86a;
  --font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --max: 680px;
  --radius: 8px;
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  font-size: 15px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: calc(var(--max) + 48px);
  margin: 0 auto;
  padding: 18px 24px;
  border-bottom: 1px solid var(--edge);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand em {
  font-style: normal;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.credits-pill {
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--edge);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.credits-pill:hover {
  border-color: var(--edge-strong);
  background: #1f1f23;
}

.credits-pill.is-busy {
  opacity: 0.6;
  cursor: wait;
  pointer-events: none;
}

.layout {
  max-width: calc(var(--max) + 48px);
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.steps-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.steps-bar li {
  position: relative;
  padding: 12px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-2);
  text-align: center;
  border-right: 1px solid var(--edge);
}

.steps-bar li:last-child { border-right: none; }

.steps-bar li.active {
  color: var(--text);
  background: var(--surface-2);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: calc(var(--radius) + 2px);
  padding: 28px;
}

.panel h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.hint {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
  max-width: 52ch;
}

.hidden { display: none !important; }

.drop {
  display: block;
  border: 1px dashed var(--edge-strong);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.drop:hover,
.drop.drop-active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--text);
}

.ref-thumb {
  display: block;
  max-width: 100%;
  max-height: 180px;
  margin: 0 auto 14px;
  border-radius: var(--radius);
  border: 1px solid var(--edge);
}

.ref-status {
  display: block;
  margin-top: 10px;
  font-size: 13px;
  color: var(--accent);
}

.ref-status.error { color: var(--danger); }

.consistency-row {
  display: grid;
  gap: 10px;
  margin: 16px 0 4px;
  font-size: 14px;
}

.consistency-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.consistency-head output {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
  font-family: var(--mono);
  font-size: 13px;
}

.consistency-row input[type="range"] { width: 100%; accent-color: var(--accent); }

.file-list {
  list-style: none;
  padding: 0;
  margin: 14px 0;
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}

.file-list li {
  padding: 10px 14px;
  border-bottom: 1px solid var(--edge);
}

.file-list li.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 14px;
}

.file-list .file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-remove {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.file-remove:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.file-remove:focus-visible {
  outline: 2px solid var(--accent-border);
  outline-offset: 1px;
}

.file-list li:last-child { border-bottom: none; }

.file-summary {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
  font-family: var(--mono);
}

.estimate-box {
  margin: 18px 0;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--edge);
  font-size: 14px;
}

.estimate-box .cost {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 6px 0;
  letter-spacing: -0.02em;
}

.estimate-box .warn { color: var(--warn); font-size: 13px; margin-top: 8px; }

.estimate-errors {
  margin-top: 10px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.export-file-list {
  margin: 0 0 12px;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.export-file-list .file-error { color: var(--danger); }

.export-summary { margin-top: 12px; font-size: 14px; }

.file-list.compact .file-error { color: var(--danger); }

.mono {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 12px 14px;
  white-space: pre-wrap;
  color: var(--muted);
}

.preview-shell { min-height: 240px; margin-top: 12px; position: relative; }

.preview-loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 240px;
  padding: 32px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--edge);
  background: var(--surface-2);
}

.preview-loading.is-active { display: flex; }

.preview-loading p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-family: var(--mono);
}

.preview-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--edge);
  border-top-color: var(--accent);
  animation: preview-spin 0.8s linear infinite;
}

.preview-error {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--danger);
  background: rgba(240, 160, 160, 0.06);
  border: 1px solid rgba(240, 160, 160, 0.2);
}

.preview-shell.is-busy .toggle-row,
.preview-shell.is-busy .select { opacity: 0.55; pointer-events: none; }

.preview-circles {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.preview-circle-wrap { margin: 0; text-align: center; }

.preview-circle-wrap figcaption {
  font-size: 11px;
  color: var(--muted-2);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.preview-circle {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--edge-strong);
  background: #000;
}

.preview-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-footnote {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted-2);
  text-align: center;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px 16px;
  margin: 8px 0 4px;
}

.preview-grid-item { margin: 0; text-align: center; }

.preview-grid-item > figcaption {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-grid-pair {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.preview-mini { margin: 0; text-align: center; }

.preview-mini figcaption {
  font-size: 10px;
  color: var(--muted-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.preview-circle.preview-circle-sm { width: 96px; height: 96px; }

.select.hidden { display: none; }

@keyframes preview-spin { to { transform: rotate(360deg); } }

.select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--edge);
  background: var(--surface-2);
  color: var(--text);
  margin-bottom: 14px;
  font-family: inherit;
  font-size: 14px;
}

.row { display: flex; gap: 10px; margin-top: 22px; }

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 11px 18px;
  font-weight: 500;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn.primary:hover:not(:disabled) { background: #fff; }

.btn.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--edge-strong);
}

.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn-block { width: 100%; margin-top: 18px; }

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 14px 0 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--edge);
  background: var(--surface-2);
  font-size: 14px;
  cursor: pointer;
}

.toggle-row input { width: 16px; height: 16px; accent-color: var(--accent); }

.toggle-hint {
  flex: 1 1 100%;
  font-size: 12px;
  color: var(--muted-2);
  margin-left: 28px;
  line-height: 1.45;
}

.file-list.compact li.file-row { padding: 8px 8px 8px 14px; }

.job-progress-wrap { margin-top: 16px; }

.job-progress-track {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--edge);
  overflow: hidden;
}

.job-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.35s ease;
}

.job-progress-label {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.btn-sm { padding: 7px 12px; font-size: 13px; }

#btn-sign-in.is-signed-in { color: var(--muted); }

.sign-in-dialog,
.plan-dialog {
  border: 1px solid var(--edge-strong);
  border-radius: calc(var(--radius) + 2px);
  padding: 0;
  background: var(--panel);
  color: var(--text);
}

.sign-in-dialog { max-width: 400px; }
.plan-dialog { max-width: min(920px, calc(100vw - 32px)); width: 100%; }

.sign-in-dialog::backdrop,
.plan-dialog::backdrop { background: rgba(0, 0, 0, 0.72); }

.sign-in-dialog form,
.plan-dialog-inner { padding: 24px; }

.sign-in-dialog h2,
.plan-dialog h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sign-in-actions { justify-content: flex-end; margin-top: 18px; }

.sign-in-status { margin-top: 12px; font-size: 13px; color: var(--muted); }
.sign-in-status.ok { color: #8fd4a8; }
.sign-in-status.error { color: var(--danger); }

.plan-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.plan-card {
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan-card.is-featured {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.plan-card h3 { margin: 0; font-size: 1rem; font-weight: 600; }

.plan-price { margin: 0; font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }

.plan-price span { font-size: 0.85rem; font-weight: 500; color: var(--muted); }

.plan-credits { margin: 0; font-size: 13px; color: var(--accent); font-family: var(--mono); }

.plan-card ul {
  margin: 0;
  padding-left: 16px;
  font-size: 13px;
  color: var(--muted);
  flex: 1;
}

.plan-card .btn { width: 100%; margin-top: 4px; }
.plan-card .btn:disabled { opacity: 0.45; cursor: not-allowed; }

.plan-dialog-note { margin-top: 4px; font-size: 12px; color: var(--muted-2); }
.plan-status { margin-top: 12px; font-size: 13px; color: var(--danger); }

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }

.field span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.field input {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--edge);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
}

.field input:focus {
  outline: none;
  border-color: var(--accent-border);
}

input[type="range"] { accent-color: var(--accent); }

@media (max-width: 640px) {
  .steps-bar { grid-template-columns: 1fr 1fr; }
  .steps-bar li:nth-child(2) { border-right: none; }
  .steps-bar li:nth-child(1),
  .steps-bar li:nth-child(2) { border-bottom: 1px solid var(--edge); }
  .plan-options { grid-template-columns: 1fr; }
  .panel { padding: 20px; }
}
