:root {
  --bg: #0f1220;
  --bg-2: #151a2e;
  --panel: #1a2038;
  --panel-2: #222a47;
  --line: #2a3252;
  --text: #e7ecff;
  --text-dim: #9aa3c7;
  --muted: #6d7499;
  --accent: #6d8cff;
  --accent-2: #8aa4ff;
  --success: #3ccf91;
  --warn: #ffb547;
  --danger: #ff6b6b;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  font-size: 15px;
  overflow: hidden;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  background: radial-gradient(1200px 600px at 0% 0%, #1a2348 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 100%, #1a1b3a 0%, transparent 60%),
    var(--bg);
}

/* ---------- Titlebar ---------- */
/* Left padding clears the macOS traffic-light buttons (titleBarStyle: hiddenInset). */
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px 14px 92px;
  -webkit-app-region: drag;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, #6d8cff, #c26dff);
  box-shadow: 0 4px 14px rgba(109, 140, 255, 0.5);
}

.brand-name {
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand-sub {
  color: var(--text-dim);
  font-weight: 500;
  margin-left: 4px;
}

.version-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12px;
  -webkit-app-region: no-drag;
}

.version-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(60, 207, 145, 0.2);
}

/* ---------- Layout ---------- */
.app-shell {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  padding: 0 22px 14px;
  min-height: 0;
}

.stepper {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stepper ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stepper li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  transition: background 0.2s ease, color 0.2s ease;
  position: relative;
}

.stepper li + li::before {
  content: "";
  position: absolute;
  left: 24px;
  top: -4px;
  height: 8px;
  width: 2px;
  background: var(--line);
  border-radius: 2px;
}

.stepper li .bullet {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--panel-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.stepper li .title {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.stepper li .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.stepper li.active {
  background: rgba(109, 140, 255, 0.12);
  color: var(--text);
}

.stepper li.active .bullet {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 4px 14px rgba(109, 140, 255, 0.45);
}

.stepper li.completed .bullet {
  background: var(--success);
  border-color: var(--success);
  color: #07251a;
}

.side-footer {
  padding-top: 14px;
  border-top: 1px solid var(--line);
  margin-top: 12px;
}

.link-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
}
.link-btn:hover {
  color: var(--text);
}

/* ---------- Stage ---------- */
.stage {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.step {
  flex: 1;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 0;
  min-height: 0;
  animation: fadeIn 280ms ease;
}

.step.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-art {
  background: linear-gradient(160deg, #1b2340 0%, #141a30 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--line);
}

.step-art svg {
  width: 100%;
  height: 100%;
  max-width: 420px;
  max-height: 420px;
}

.step-body {
  padding: 42px 44px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.step-body h1 {
  font-size: 26px;
  margin: 0;
  letter-spacing: -0.2px;
}

.lead {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.55;
  margin: 0;
}

.checklist,
.numbered {
  padding-left: 0;
  margin: 6px 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checklist li {
  position: relative;
  padding-left: 30px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.checklist li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(109, 140, 255, 0.15);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 700;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.numbered {
  counter-reset: num;
}
.numbered li {
  counter-increment: num;
  position: relative;
  padding-left: 36px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.numbered li::before {
  content: counter(num);
  position: absolute;
  left: 0;
  top: -1px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-2);
  font-weight: 600;
  font-size: 12px;
}

.callout {
  background: rgba(255, 181, 71, 0.08);
  border: 1px solid rgba(255, 181, 71, 0.35);
  color: #ffd58a;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
}

.callout-tip {
  background: rgba(109, 140, 255, 0.08);
  border-color: rgba(109, 140, 255, 0.4);
  color: #c3d0ff;
}

.callout strong {
  color: #fff;
}

.small {
  font-size: 12px;
}
.muted {
  color: var(--muted);
}

/* ---------- Detect card ---------- */
.detect-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.detect-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(109, 116, 153, 0.2);
  transition: all 0.2s ease;
}

.status-dot.idle {
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(109, 116, 153, 0.2);
}
.status-dot.searching {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(255, 181, 71, 0.25);
  animation: pulse 1.2s ease-in-out infinite;
}
.status-dot.ok {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(60, 207, 145, 0.25);
}
.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.25);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.7;
  }
}

/* ---------- Progress ---------- */
.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0 10px;
}

.progress {
  height: 10px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  transition: width 0.25s ease;
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(109, 140, 255, 0.5);
}

.progress-label {
  color: var(--text-dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.log-details {
  margin-top: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.log-details summary {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 13px;
  user-select: none;
  outline: none;
}

.log {
  margin: 10px 0 0;
  padding: 10px;
  background: #0b0e1c;
  border-radius: 6px;
  color: #9fb1d3;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}

/* ---------- Buttons ---------- */
.btn-primary,
.btn-ghost {
  font: inherit;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.05s ease, background 0.2s ease, border-color 0.2s ease;
  font-weight: 600;
  font-size: 14px;
}

.btn-primary {
  background: linear-gradient(180deg, #7a95ff 0%, #5d7bff 100%);
  color: white;
  border-color: #4a67e8;
  box-shadow: 0 6px 18px rgba(93, 123, 255, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #8aa3ff 0%, #6d8cff 100%);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-primary:disabled,
.btn-ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

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

.btn-ghost:hover {
  background: var(--panel-2);
  border-color: #3a4370;
}

.btn-lg {
  padding: 14px 22px;
  font-size: 15px;
}

/* ---------- Footer ---------- */
.footer {
  padding: 12px 22px 18px;
  flex-shrink: 0;
}

.nav-buttons {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.done-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #2b3358;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3a4370;
}
