:root {
  --background: #060b1f;
  --surface: rgba(14, 23, 51, 0.72);
  --surface-strong: rgba(11, 19, 43, 0.92);
  --text: #e8eeff;
  --muted: #a8b5de;
  --accent: #68e7ff;
  --success: #44d79a;
  --warning: #f9b64d;
  --danger: #ff6b90;
  --border: rgba(255, 255, 255, 0.18);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 9%, rgba(104, 231, 255, 0.16), transparent 30%),
    radial-gradient(circle at 84% 16%, rgba(255, 107, 212, 0.11), transparent 34%),
    radial-gradient(circle at 76% 82%, rgba(104, 231, 255, 0.08), transparent 38%),
    linear-gradient(160deg, #040611, #0b1430 50%, #050816);
  font-family: Inter, system-ui, sans-serif;
  line-height: 1.45;
  padding: 1rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

.site-header,
.app-shell,
.site-footer {
  width: min(1100px, 100%);
  margin: 0 auto;
}

.site-header {
  margin-bottom: 1rem;
}

.brand-row {
  display: grid;
  gap: 0.5rem;
}

.logo { width: min(240px, 100%); max-width: 100%; min-width: 0; height: auto; }
.tagline { margin: 0; color: var(--muted); }

.panel,
.quiz-card,
.worker-card,
.taskboard-column,
.theatre-step,
.score-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.panel { padding: 1rem; margin-bottom: 1rem; background: rgba(14, 23, 51, 0.66); border-color: rgba(255, 255, 255, 0.14); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22); }
h1,
h2,
h3 {
  text-wrap: balance;
  overflow-wrap: anywhere;
}

h1 {
  letter-spacing: -0.06em;
  font-size: clamp(2.7rem, 8vw, 5.8rem);
  line-height: 0.98;
  margin: 0 0 0.65rem;
}
h2 {
  letter-spacing: -0.035em;
  font-size: clamp(1.55rem, 3.8vw, 2.35rem);
  line-height: 1.08;
}
h3 {
  letter-spacing: -0.02em;
  font-size: clamp(1.22rem, 2.8vw, 1.7rem);
  line-height: 1.14;
}
.hero {
  text-align: left;
  position: relative;
  overflow: hidden;
  padding: clamp(1.3rem, 4vw, 2.4rem);
  min-height: 430px;
}
.hero::after {
  content: "";
  position: absolute;
  width: clamp(340px, 52vw, 620px);
  height: clamp(340px, 52vw, 620px);
  right: -18%;
  top: -20%;
  background: radial-gradient(circle, rgba(104, 231, 255, 0.32) 0%, rgba(195, 96, 255, 0.2) 36%, rgba(104, 231, 255, 0.05) 58%, transparent 73%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.lead { font-size: clamp(1.1rem, 2vw, 1.35rem); max-width: min(62ch, 100%); }

.hero-proof-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1rem 0;
}

.hero-proof-strip span {
  border: 1px solid rgba(104, 231, 255, 0.28);
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  background: rgba(104, 231, 255, 0.08);
  color: #dff8ff;
  font-size: 0.86rem;
  font-weight: 700;
}

.landing-explainer {
  margin-top: 1.1rem;
  background: rgba(7, 14, 34, 0.52);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.landing-cards {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.9rem;
}

.landing-cards article {
  display: grid;
  gap: 0.25rem;
  padding: 0.8rem;
  border: 1px solid rgba(104, 231, 255, 0.18);
  border-radius: 14px;
  background: rgba(7, 14, 34, 0.5);
}

.landing-cards article span {
  color: var(--muted);
  font-size: 0.92rem;
}

.guide-inline-control {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

@media (min-width: 760px) {
  .landing-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badges { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.65rem 0; }
.badge { background: rgba(104, 231, 255, 0.12); border: 1px solid rgba(104, 231, 255, 0.35); border-radius: 999px; padding: 0.2rem 0.6rem; font-size: 0.82rem; }
.view-toggle { display: inline-flex; align-items: center; gap: 0.45rem; margin-top: 0.65rem; flex-wrap: wrap; }
.view-toggle button.active { background: rgba(104, 231, 255, 0.2); border-color: rgba(104, 231, 255, 0.65); }

button,
select,
textarea,
.option {
  min-height: 44px;
}

button {
  padding: 0.75rem 0.95rem;
  background: linear-gradient(135deg, #5ce7ff 0%, #b35cff 100%);
  border-radius: 12px;
  border: 1px solid rgba(186, 236, 255, 0.42);
  color: #102046;
  font-weight: 750;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease, opacity 140ms ease, box-shadow 160ms ease;
}
button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: saturate(1.08) brightness(1.03);
  box-shadow: 0 6px 14px rgba(92, 231, 255, 0.22);
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  filter: grayscale(0.28);
}

button:focus-visible,
.option:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.ghost { background: rgba(6, 12, 31, 0.44); color: #cfdbff; border-color: rgba(255, 255, 255, 0.18); }
.ghost:hover:not(:disabled) { background: rgba(8, 17, 41, 0.66); color: #e2ebff; box-shadow: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.pill { display: inline-block; border-radius: 999px; padding: 0.2rem 0.6rem; font-weight: 700; background: rgba(255, 255, 255, 0.12); }
.pill.complete, .pill.approved, .pill.ok { background: rgba(68, 215, 154, 0.18); color: #b8ffd9; }
.pill.blocked, .pill.err { background: rgba(255, 107, 144, 0.18); }
.pill.review { background: rgba(249, 182, 77, 0.2); }

.grid,
.choices,
.dashboard-grid,
.quiz-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

.option,
.score-card,
.quiz-card,
.worker-card,
.taskboard-column,
/* Workflow detail cards */
.theatre-step {
  padding: 0.75rem;
  text-align: left;
}

.option.active { border-color: var(--accent); background: rgba(50, 67, 153, 0.9); }
.level-card { min-height: 112px; display: flex; flex-direction: column; justify-content: center; gap: 0.25rem; }

.level-recommendation {
  flex-basis: 100%;
  margin: 0.15rem 0 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(104, 231, 255, 0.28);
  border-radius: 10px;
  background: rgba(8, 16, 39, 0.7);
  color: var(--muted);
  font-size: 0.92rem;
}


#buttons {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: stretch;
}

.level-group {
  display: grid;
  gap: 0.55rem;
}

.level-group h3 {
  margin: 0;
  color: #dbe5ff;
  font-size: 0.98rem;
}

.level-group-description {
  margin: 0;
  font-size: 0.87rem;
  line-height: 1.35;
}

.level-ladder {
  display: grid;
  gap: 0.6rem;
  margin: 0.9rem 0 1rem;
}

.level-ladder-step {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem;
  border: 1px solid rgba(104, 231, 255, 0.24);
  border-radius: 14px;
  background: rgba(7, 14, 34, 0.58);
}

.level-ladder-step strong {
  color: var(--text);
  font-size: 1rem;
}

.level-ladder-step span:last-child {
  color: var(--muted);
  font-size: 0.9rem;
}

.level-ladder-kicker {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.level-ladder-arrow {
  display: none;
  color: var(--accent);
  font-weight: 800;
  text-align: center;
  opacity: 0.75;
}


.level-group-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

.final-output-panel {
  margin-bottom: 1rem;
  background: linear-gradient(145deg, rgba(14, 23, 51, 0.98), rgba(7, 17, 42, 0.98));
  padding: 1.1rem;
  border: 1px solid rgba(104, 231, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(104, 231, 255, 0.2), 0 0 22px rgba(104, 231, 255, 0.1), var(--shadow);
}

.final-output-panel h3 {
  font-size: 1.35rem;
}

.final-output-body {
  margin-top: 0.35rem;
  font-size: 1.03rem;
  line-height: 1.62;
  color: #f2f6ff;
  white-space: pre-wrap;
}

.final-output-section { margin-top: 0.7rem; }
.final-output-section:first-child { margin-top: 0; }
.final-output-heading {
  margin: 0 0 0.2rem;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
}


.advanced-results-details {
  margin-top: 1rem;
  border: 1px solid rgba(104, 231, 255, 0.24);
  border-radius: 16px;
  background: rgba(7, 14, 34, 0.58);
  overflow: hidden;
}

.advanced-results-details > summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1rem;
  color: var(--text);
  list-style: none;
  flex-wrap: wrap;
}

.advanced-results-details > summary::-webkit-details-marker {
  display: none;
}

.advanced-results-details > summary::after {
  content: "+";
  color: var(--accent);
  font-weight: 800;
  font-size: 1.25rem;
}

.advanced-results-details[open] > summary::after {
  content: "–";
}

.advanced-results-body {
  display: grid;
  gap: 0.85rem;
  padding: 0 1rem 1rem;
}
.output-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.confirm-panel {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.55rem;
}
.setup-mode-tabs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.setup-mode-btn {
  width: 100%;
  text-align: center;
}
.setup-mode-btn.active {
  background: rgba(104, 231, 255, 0.2);
  border-color: rgba(104, 231, 255, 0.65);
}
.custom-use-case-form {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.surprise-card.active {
  border-color: var(--accent);
  background: rgba(50, 67, 153, 0.9);
}

textarea {
  width: 100%;
  background: rgba(5, 12, 29, 0.75);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem;
  resize: vertical;
}


.score-card,
.taskboard-column,
.worker-card,
.quiz-card,
.theatre-step {
  background: rgba(11, 19, 43, 0.55);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.raw-trace-details {
  margin-top: 0.5rem;
  opacity: 0.94;
}

.raw-trace-details summary {
  color: var(--muted);
}

.run-summary-panel {
  margin-bottom: 0.9rem;
  border-color: rgba(104, 231, 255, 0.45);
  background: linear-gradient(150deg, rgba(14, 23, 51, 0.9), rgba(10, 18, 42, 0.95));
}

.run-summary-panel.warning {
  border-color: rgba(249, 182, 77, 0.7);
  box-shadow: 0 0 0 1px rgba(249, 182, 77, 0.25), var(--shadow);
}

.run-summary-list {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.35rem;
}

.run-summary-list li {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.run-insight-panel,
.learning-takeaway-panel {
  margin-bottom: 0.8rem;
  border-color: rgba(104, 231, 255, 0.28);
  background: rgba(9, 18, 42, 0.84);
  box-shadow: none;
}

.next-step-panel {
  margin-bottom: 0.9rem;
  border-color: rgba(104, 231, 255, 0.5);
  background: rgba(9, 18, 42, 0.92);
  box-shadow: 0 0 0 1px rgba(104, 231, 255, 0.14);
}

.quick-compare-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
}

.quick-compare-actions button {
  min-height: 36px;
  padding: 0.42rem 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(104, 231, 255, 0.42);
  background: rgba(104, 231, 255, 0.08);
  font-size: 0.9rem;
}

.confirmed-context-details {
  margin-top: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: rgba(6, 13, 31, 0.7);
  padding: 0.45rem 0.65rem;
}

.confirmed-context-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}

.confirmed-context-details pre {
  margin: 0.5rem 0 0;
  padding: 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(4, 9, 24, 0.9);
  color: #dce6ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
}

.status {
  margin-bottom: 0.8rem;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
  display: grid;
  gap: 0.5rem;
}

#log {
  background: rgba(5, 12, 29, 0.75);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem;
  min-height: 220px;
  max-height: 42vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.msg { max-width: 100%; padding: 0.6rem 0.75rem; border-radius: 12px; white-space: pre-wrap; border: 1px solid rgba(255, 255, 255, 0.14); }
.msg.user { align-self: flex-end; background: #4e63d8; }
.msg.ai, .msg.agent { align-self: flex-start; background: #1b2a58; }
.msg.system { align-self: center; background: rgba(255, 255, 255, 0.1); }
.msg.trace { align-self: stretch; background: rgba(104, 231, 255, 0.08); border-left: 3px solid rgba(104, 231, 255, 0.6); }
.msg.tool { align-self: stretch; background: rgba(249, 182, 77, 0.12); border-left: 3px solid rgba(249, 182, 77, 0.8); }
.msg.verifier { align-self: stretch; background: rgba(68, 215, 154, 0.12); border-left: 3px solid rgba(68, 215, 154, 0.8); }

.theatre-flow { display: grid; gap: 0.6rem; }
.theatre-step { border-left: 4px solid var(--accent); }
.actor { font-weight: 700; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }

.taskboard-grid { display: grid; grid-template-columns: 1fr; gap: 0.6rem; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }

.skip-link { position: absolute; left: -999px; top: 0; background: #fff; color: #111; padding: 0.5rem; }
.skip-link:focus { left: 1rem; top: 1rem; z-index: 99; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { width: min(680px, 100%); background: var(--surface-strong); border: 1px solid var(--border); border-radius: 16px; padding: 1rem; }

.site-footer {
  margin-top: 1rem;
  text-align: center;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
}

.footer-disclaimer {
  margin: 0;
  max-width: 800px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  opacity: 0.9;
}

.site-footer a { color: var(--accent); }

@media (max-width: 759px) {
  #buttons {
    grid-template-columns: 1fr;
  }

  .guide-inline-control {
    justify-content: flex-start;
  }
  .run-summary-panel .section-header {
    align-items: flex-start;
  }
  .run-summary-panel .badge {
    width: fit-content;
  }
}

@media (min-width: 760px) {
  .level-ladder {
    grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
    align-items: stretch;
  }

  .level-ladder-arrow {
    display: grid;
    align-items: center;
  }
}

@media (min-width: 760px) {
  .logo { width: min(280px, 100%); }
  .setup-mode-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quiz-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status { grid-template-columns: auto 1fr; align-items: center; }
}

@media (min-width: 980px) {
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .taskboard-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}


body.force-mobile .site-header,
body.force-mobile .app-shell,
body.force-mobile .site-footer {
  width: min(420px, 100%) !important;
}

body.force-desktop .site-header,
body.force-desktop .app-shell,
body.force-desktop .site-footer {
  width: min(1100px, 100%) !important;
}

body.force-mobile .grid,
body.force-mobile .choices,
body.force-mobile .dashboard-grid,
body.force-mobile .quiz-grid,
body.force-mobile .taskboard-grid,
body.force-mobile .status,
body.force-mobile #buttons {
  grid-template-columns: 1fr !important;
}

body.force-desktop .choices {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}
body.force-desktop .grid {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}
body.force-desktop .dashboard-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}
body.force-desktop .quiz-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}
body.force-desktop .status {
  grid-template-columns: auto 1fr !important;
  align-items: center !important;
}
body.force-desktop .taskboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
}

.preview-tools { margin-top: 0.65rem; opacity: 0.85; }
.preview-tools summary { cursor: pointer; color: var(--muted); }
.segmented { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0.4rem; margin-top: 0.6rem; }
.seg-btn { width: 100%; background: rgba(255,255,255,0.06); }
.seg-btn.active { background: rgba(104, 231, 255, 0.2); border-color: rgba(104, 231, 255, 0.65); }
.pill.pending{background:rgba(130,140,170,.24);color:#eef2ff}
.pill.running{background:rgba(104,231,255,.22);color:#d9fbff}
.pill.complete,.pill.completed,.pill.approved,.pill.ok{background:rgba(68,215,154,.2);color:#b8ffd9}
.pill.blocked,.pill.failed,.pill.err{background:rgba(255,107,144,.26);color:#ffe3ec}
.pill.needs_review,.pill.needs_human_review{background:rgba(249,182,77,.24);color:#fff2d6}
.pill.merged{background:rgba(120,220,140,.24);color:#e8ffe8}
.worker-card.pending{border-left:4px solid #8fa0c8}
.worker-card.running{border-left:4px solid #68e7ff}
.worker-card.completed,.worker-card.merged{border-left:4px solid #44d79a}
.worker-card.needs_human_review{border-left:4px solid #f9b64d}
.worker-card.failed{border-left:4px solid #ff6b90}
.theatre-step.running{border-left-color:#68e7ff}
.theatre-step.needs_review,.theatre-step.needs_human_review{border-left-color:#f9b64d}
.theatre-step.failed{border-left-color:#ff6b90}
.theatre-step.merged{border-left-color:#44d79a}

.guide-card {
  margin-bottom: 1rem;
  padding: 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(223, 94, 255, 0.4);
  background: linear-gradient(145deg, rgba(14, 23, 51, 0.95), rgba(18, 15, 48, 0.94));
  box-shadow: 0 0 20px rgba(104, 231, 255, 0.16);
}
.guide-actions { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-top: 0.65rem; }
.guide-step { font-weight: 650; margin: 0; }
.guide-muted { color: var(--muted); margin: 0.45rem 0; }
.guide-dismiss { border-color: rgba(255, 107, 144, 0.5); }
.guide-highlight { outline: 2px solid rgba(104, 231, 255, 0.85); outline-offset: 4px; border-radius: 10px; }
.guide-recommendation { margin: 0.45rem 0; color: #d8edff; }
