:root {
  color-scheme: dark;
  --bg: #0c0d0e;
  --panel: #171a1d;
  --panel-2: #202426;
  --line: #343a3f;
  --line-soft: #262b2f;
  --text: #f3f6f4;
  --muted: #a9b4ae;
  --teal: #2dd4bf;
  --teal-dark: #0f766e;
  --amber: #f59e0b;
  --red: #ef4444;
  --green: #22c55e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(45, 212, 191, .05), transparent 240px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.018) 0, rgba(255,255,255,.018) 1px, transparent 1px, transparent 48px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--text);
}

button, input, select { font: inherit; }

#boot-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: #0c0d0e;
  transition: opacity .28s ease, visibility .28s ease;
}

.boot-complete #boot-screen { opacity: 0; visibility: hidden; }

.boot-orb {
  width: 96px;
  height: 68px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(180deg, #171a1d, #0f1113);
  position: relative;
  overflow: hidden;
}

.boot-orb::before {
  content: "";
  position: absolute;
  inset: 0;
  height: 2px;
  background: var(--teal);
  box-shadow: 0 0 18px rgba(45, 212, 191, .65);
  animation: scanline 1s ease-in-out infinite;
}

@keyframes scanline {
  0%, 100% { transform: translateY(8px); opacity: .65; }
  50% { transform: translateY(56px); opacity: 1; }
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 800;
  font-size: 12px;
}

.assistant-shell {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.guide-rail,
.workspace,
.panel,
.status-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 26, 29, .95);
}

.guide-rail {
  padding: 10px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.step {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 12px;
  color: var(--muted);
  background: transparent;
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.step span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #101214;
  color: var(--muted);
  font-weight: 800;
}

.step strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.step.active {
  border-color: rgba(45, 212, 191, .45);
  background: rgba(45, 212, 191, .08);
  color: var(--text);
}

.step.active span {
  border-color: var(--teal);
  color: var(--teal);
}

.workspace {
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
  gap: 18px;
}

.assistant-copy {
  grid-column: 1 / -1;
  max-width: 760px;
}

h2 {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.assistant-copy p:last-child { margin-bottom: 0; }

.upload-panel,
.settings-panel {
  min-width: 0;
}

.drop-zone {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 210px;
  padding: 24px;
  border: 1px dashed rgba(45, 212, 191, .55);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(45, 212, 191, .08), transparent),
    #111416;
  color: var(--text);
  text-align: center;
  cursor: pointer;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(45, 212, 191, .55);
  border-radius: 999px;
  color: var(--teal);
  font-size: 28px;
  line-height: 1;
}

.drop-zone small,
.upload-status {
  color: var(--muted);
}

.upload-status {
  min-height: 24px;
  margin: 10px 0;
  font-size: 14px;
}

label {
  display: block;
  margin-top: 0;
  color: var(--muted);
  font-weight: 760;
}

label + label { margin-top: 14px; }

input,
select {
  width: 100%;
  margin-top: 8px;
  background: #0f1113;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 13px 12px;
}

input:focus,
select:focus,
button:focus-visible,
.drop-zone:focus-within {
  outline: 2px solid rgba(45, 212, 191, .55);
  outline-offset: 2px;
}

.action,
.copy {
  min-height: 46px;
  border-radius: 6px;
  padding: 12px 15px;
  font-weight: 850;
  cursor: pointer;
  background: #242a2d;
  color: var(--text);
  border: 1px solid var(--line);
}

.action:hover:not(:disabled),
.copy:hover {
  border-color: var(--teal);
  transform: translateY(-1px);
}

.action:disabled {
  cursor: not-allowed;
  opacity: .44;
}

.primary {
  background: linear-gradient(135deg, var(--teal-dark), #17443f);
  border-color: rgba(45, 212, 191, .55);
}

.danger {
  background: linear-gradient(135deg, #5b1e25, #2a1719);
  border-color: rgba(239, 68, 68, .42);
}

.gold {
  background: linear-gradient(135deg, #6a4308, #2d2211);
  border-color: rgba(245, 158, 11, .45);
}

.ghost,
.secondary {
  background: #161a1c;
}

.status-strip {
  margin-top: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.verdict {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.verdict p {
  margin: 0;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 12px;
}

.idle {
  background: #23282b;
  color: var(--muted);
}

.blocked {
  background: rgba(239, 68, 68, .12);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, .38);
}

.allowed {
  background: rgba(34, 197, 94, .12);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, .32);
}

.review {
  background: rgba(245, 158, 11, .12);
  color: #facc15;
  border: 1px solid rgba(245, 158, 11, .32);
}

.results-layout {
  margin-top: 14px;
  display: none;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
}

body[data-stage="scan"] .results-layout,
body[data-stage="repair"] .results-layout,
body[data-stage="verify"] .results-layout {
  display: grid;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.summary-panel pre {
  max-height: 360px;
}

.next-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.action-stack,
.secondary-actions {
  display: grid;
  gap: 10px;
}

.secondary-actions {
  grid-template-columns: 1fr 1fr;
}

.secondary-actions .action:last-child {
  grid-column: 1 / -1;
}

.repair-panel {
  margin-top: 14px;
  display: none;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

body[data-stage="repair"] .repair-panel,
body[data-stage="verify"] .repair-panel {
  display: grid;
}

.prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.repair-panel pre {
  grid-column: 1 / -1;
  max-height: 520px;
}

.evidence-panel {
  margin-top: 14px;
  display: none;
}

body[data-stage="scan"] .evidence-panel,
body[data-stage="repair"] .evidence-panel,
body[data-stage="verify"] .evidence-panel {
  display: block;
}

summary {
  cursor: pointer;
  font-weight: 850;
}

.evidence-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.raw-output {
  margin-top: 14px;
}

pre,
code {
  display: block;
  width: 100%;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 420px;
  margin: 0;
  background: #0b0d0e;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 14px;
  color: #dbe7e1;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

code { color: var(--teal); }

@media (max-width: 920px) {
  .shell { width: min(100% - 24px, 1120px); padding-top: 18px; }
  .topbar,
  .status-strip,
  .verdict {
    align-items: stretch;
    flex-direction: column;
  }
  .topbar-actions { justify-content: stretch; }
  .topbar-actions .action,
  .status-strip .action { width: 100%; }
  .assistant-shell,
  .workspace,
  .results-layout,
  .evidence-grid {
    grid-template-columns: 1fr;
  }
  .guide-rail {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .step {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 6px;
    padding: 10px 6px;
  }
  .step span {
    width: 26px;
    height: 26px;
  }
  .secondary-actions,
  .repair-panel {
    grid-template-columns: 1fr;
  }
  .prompt-actions {
    justify-content: stretch;
  }
  .prompt-actions .copy {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .guide-rail {
    grid-template-columns: 1fr 1fr;
  }
  .topbar h1 {
    font-size: 32px;
  }
}
