:root {
  --bg: #f0f2f5;
  --panel: #ffffff;
  --panel-strong: #fafafa;
  --ink: rgba(0, 0, 0, 0.88);
  --muted: rgba(0, 0, 0, 0.45);
  --line: rgba(5, 5, 5, 0.06);
  --accent: #1890ff;
  --accent-dark: #096dd9;
  --accent-light: #e6f4ff;
  --green: #52c41a;
  --green-dark: #389e0d;
  --green-light: #f6ffed;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 6px -1px rgba(0, 0, 0, 0.04);
  --shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
  --radius: 6px;
  --radius-lg: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.wizard-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 12px 16px;
  gap: 10px;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  box-shadow: var(--shadow-sm);
}

/* Hide redundant branding — we're already inside the Ouran UI */
.eyebrow {
  display: none;
}

.brand h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.brand p:last-child {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.step-counter {
  background: var(--accent-light);
  border: 1px solid rgba(24, 144, 255, 0.25);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Stepper ── */
.stepper {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 150ms ease, background 150ms ease;
  opacity: 0.65;
  cursor: default;
}

.wizard-step.active {
  background: var(--accent-light);
  border-color: var(--accent);
  opacity: 1;
}

.wizard-step.done {
  background: var(--green-light);
  border-color: rgba(82, 196, 26, 0.4);
  opacity: 1;
}

.wizard-step strong {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.wizard-step small {
  color: var(--muted);
  display: block;
  margin-top: 1px;
  font-size: 0.75rem;
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-strong);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.8rem;
  flex: 0 0 auto;
  border: 1px solid var(--line);
}

.wizard-step.active .step-number {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.wizard-step.done .step-number {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

/* ── Content grid ── */
.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  flex: 1;
}

.step-panel,
.workspace-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  min-height: 0;
}

.step-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-page {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.step-page.active {
  display: flex;
}

.page-header h2,
.workspace-copy h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-header p,
.workspace-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

/* ── Cards ── */
.card,
.status-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.card h3,
.status-card h3 {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Form elements ── */
label {
  display: block;
  margin-bottom: 10px;
}

label span {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 4px;
}

input,
select,
button {
  font: inherit;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafafa;
  color: var(--ink);
  font-size: 0.88rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.15);
  background: #fff;
}

input[type="file"] {
  width: 100%;
  font-size: 0.82rem;
}

/* ── Buttons ── */
button {
  border: 0;
  border-radius: var(--radius);
  padding: 8px 14px;
  background: var(--accent);
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
  box-shadow: 0 2px 6px rgba(24, 144, 255, 0.2);
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
  box-shadow: 0 4px 10px rgba(24, 144, 255, 0.28);
}

button:focus-visible {
  outline: 2px solid rgba(24, 144, 255, 0.45);
  outline-offset: 2px;
}

button:active:not(:disabled) {
  opacity: 0.88;
  box-shadow: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.button-muted {
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--line);
}

.button-muted:hover:not(:disabled) {
  background: #ebebeb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

button.active {
  background: var(--green);
  color: white;
  box-shadow: 0 2px 8px rgba(82, 196, 26, 0.25);
}

.row {
  display: flex;
  gap: 8px;
  align-items: end;
}

.row > * {
  flex: 1;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.checkbox span {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink);
}

/* ── Info / status boxes ── */
.info-box,
.page-status {
  min-height: 44px;
  font-size: 0.82rem;
  color: var(--muted);
  background: #fafafa;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  line-height: 1.6;
}

.page-status.ready {
  color: var(--green-dark);
  background: var(--green-light);
  border: 1px solid rgba(82, 196, 26, 0.35);
}

.page-status.blocked {
  color: #cf1322;
  background: #fff1f0;
  border: 1px solid rgba(255, 77, 79, 0.3);
}

.page-status.optional {
  color: var(--muted);
  background: #fafafa;
}

/* ── Upload gallery ── */
.upload-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.upload-empty {
  color: var(--muted);
  background: #fafafa;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  font-size: 0.82rem;
}

.upload-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 150ms ease;
}

.upload-card:hover {
  box-shadow: var(--shadow);
}

.upload-preview {
  aspect-ratio: 16 / 9;
  width: 100%;
  object-fit: cover;
  display: block;
  background: #1a1a2e;
}

.upload-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.upload-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.upload-title strong {
  font-size: 0.85rem;
  font-weight: 600;
}

.upload-chip {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent-dark);
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.upload-meta {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.upload-actions {
  display: flex;
  gap: 6px;
}

.upload-actions button {
  flex: 1;
  padding: 6px 10px;
  font-size: 0.78rem;
}

/* ── Diagnostics table ── */
.diagnostics-table {
  margin-top: 10px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.diagnostics-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.diagnostics-table th,
.diagnostics-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.diagnostics-table th {
  position: sticky;
  top: 0;
  background: #fafafa;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.diagnostics-table tr:last-child td {
  border-bottom: 0;
}

.diagnostics-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

/* ── Wizard nav ── */
.wizard-nav {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 110px;
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding-top: 4px;
}

/* ── Workspace ── */
.workspace-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.canvas-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(240px, 1fr);
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.canvas-grid.single-camera {
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
}

.panel.hidden {
  display: none;
}

.panel {
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 10px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 260px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.panel-header h3 {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.panel-header span {
  color: var(--muted);
  font-size: 0.75rem;
}

canvas {
  width: 100%;
  height: 100%;
  min-height: 380px;
  border-radius: var(--radius);
  background: #1a1a2e;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.hint-bar {
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.78rem;
}

/* ── Status log ── */
.status-log {
  background: #141414;
  color: #d9d9d9;
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 120px;
  max-height: 180px;
  overflow-y: auto;
  font-family: "IBM Plex Mono", "Consolas", monospace;
  font-size: 0.75rem;
  line-height: 1.6;
}

/* ── Responsive ── */
@media (max-width: 1380px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .canvas-grid {
    grid-template-columns: 1fr;
  }

  canvas {
    min-height: 300px;
  }
}

@media (max-width: 1100px) {
  .stepper {
    grid-template-columns: repeat(3, 1fr);
  }

  .wizard-nav {
    grid-template-columns: 1fr;
  }
}
