:root {
  color-scheme: dark;
  --bg: #090b0e;
  --ink: #f4f0e7;
  --muted: #a9a196;
  --quiet: #726d66;
  --panel: #11151a;
  --panel-strong: #171c22;
  --field: #0d1116;
  --line: rgba(226, 207, 170, .16);
  --line-strong: rgba(226, 207, 170, .32);
  --brass: #d7b56d;
  --brass-strong: #e4c987;
  --blue: #7fb5cb;
  --danger: #f09a93;
  --ok: #9ad7b0;
  --shadow: 0 28px 80px rgba(0, 0, 0, .42);
  --radius: 8px;
  --rail-h: 76px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background:
    linear-gradient(180deg, #101419 0%, var(--bg) 48%, #08090b 100%);
  color: var(--ink);
  overflow: hidden;
}
button, textarea, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }

.shell {
  width: min(1280px, 100%);
  height: 100svh;
  margin: 0 auto;
  padding: 18px 22px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
}

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.topbar > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}
.brand {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
  color: var(--ink);
  white-space: nowrap;
}
.brand::before {
  content: "5";
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-right: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--brass-strong);
  font: 700 16px/1 Inter, ui-sans-serif, system-ui;
  vertical-align: 5px;
}
.tagline {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}
.progress span {
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 11px 12px;
  background: rgba(15, 19, 24, .88);
  color: var(--quiet);
  font-size: 13px;
  white-space: nowrap;
}
.progress span.active {
  color: var(--ink);
  background: linear-gradient(180deg, rgba(29, 35, 41, .96), rgba(16, 21, 27, .96));
}

.workspace {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(255,255,255,.035), transparent 1px) 0 0 / 72px 72px,
    linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.012)),
    var(--panel);
  box-shadow: var(--shadow);
}
.stage {
  min-height: 100%;
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 38px;
  display: grid;
  align-content: center;
  gap: 18px;
}
.stage-wide { width: min(1160px, 100%); align-content: start; }
.stage-query { min-height: 100%; }
.stage-auth { width: min(560px, 100%); }

.eyebrow {
  color: var(--brass);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin: 0; letter-spacing: 0; }
h1 {
  max-width: 760px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 56px;
  line-height: 1.02;
  font-weight: 500;
}
h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 38px;
  line-height: 1.08;
  font-weight: 500;
}
h3 { font-size: 17px; line-height: 1.25; }
p { color: var(--muted); line-height: 1.55; font-size: 15px; }
.lead { max-width: 650px; font-size: 16px; color: #c5bdb1; }
.micro { color: var(--quiet); font-size: 12px; }

.field-shell {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(8, 11, 15, .76);
}
.field-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
textarea, input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--ink);
  padding: 15px;
  outline: none;
}
textarea {
  min-height: 240px;
  resize: vertical;
  line-height: 1.5;
}
.field-shell textarea {
  min-height: 260px;
  border: 0;
  padding: 4px 2px;
  background: transparent;
  font-size: 18px;
}
textarea::placeholder, input::placeholder { color: rgba(169, 161, 150, .58); }
textarea:focus, input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(127, 181, 203, .16);
}
.field-shell:focus-within {
  border-color: rgba(127, 181, 203, .54);
  box-shadow: 0 0 0 3px rgba(127, 181, 203, .1);
}

.action-rail {
  min-height: var(--rail-h);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  padding: 12px 0 0;
}
.primary, .secondary, .ghost, .icon {
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 11px 16px;
  color: var(--ink);
  background: rgba(18, 23, 28, .8);
}
.primary {
  min-width: 190px;
  border-color: var(--brass);
  background: linear-gradient(180deg, var(--brass-strong), var(--brass));
  color: #16120a;
  font-weight: 800;
}
.secondary { background: transparent; color: #cfc7bb; }
.ghost { background: rgba(255,255,255,.02); color: var(--muted); }
.primary:hover, .secondary:hover, .ghost:hover {
  transform: translateY(-1px);
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.secondary:hover, .ghost:hover { border-color: var(--line-strong); }
.icon {
  width: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
}

.stack { display: grid; gap: 14px; }
.question-list {
  display: grid;
  gap: 10px;
  counter-reset: question;
}
.question, .snapshot, .pro, .report-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 20, 25, .72);
}
.question {
  counter-increment: question;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px;
  color: #d8d0c5;
}
.question::before {
  content: counter(question);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(215,181,109,.12);
  color: var(--brass);
  font-size: 12px;
  font-weight: 900;
}

.pro-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.pro {
  min-width: 0;
  display: grid;
  gap: 9px;
  padding: 14px;
}
.pro strong {
  display: block;
  min-height: 42px;
  color: var(--ink);
  font-size: 15px;
}
.pro label {
  display: grid;
  gap: 6px;
  color: var(--quiet);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.pro input, .pro textarea {
  min-height: 0;
  padding: 9px;
  color: #d7d0c6;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
}
.pro textarea { min-height: 86px; }
.pro [data-field="title"] {
  order: -1;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

.snapshot {
  display: grid;
  gap: 14px;
  padding: 20px;
}
.snapshot-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.snapshot-row:first-child { border-top: 0; padding-top: 0; }
.snapshot strong { color: var(--brass-strong); }

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  margin: 2px 0 12px;
}
.tabs button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: rgba(255,255,255,.02);
  color: var(--muted);
}
.tabs button.active {
  color: #16120a;
  border-color: var(--brass);
  background: var(--brass);
  font-weight: 800;
}
.markdown {
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  background: rgba(8, 11, 15, .62);
  line-height: 1.68;
  white-space: pre-wrap;
  color: #ddd6cc;
}
.status-ready { color: var(--ok); }
.status-error { color: var(--danger); min-height: 20px; }

.profile {
  position: fixed;
  inset: 16px 16px 16px auto;
  width: min(390px, calc(100vw - 32px));
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(28, 33, 39, .98), rgba(12, 15, 19, .98));
  padding: 18px;
  box-shadow: var(--shadow);
  z-index: 20;
}
.profile-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.profile-head strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-weight: 500;
}
.history-item {
  border-top: 1px solid var(--line);
  padding: 12px 0;
  color: #d4cdc3;
}
.history-item small { color: var(--quiet); }

@media (max-width: 980px) {
  .pro-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { padding: 28px; }
}

@media (max-width: 760px) {
  body { overflow: hidden; }
  .shell {
    padding: 10px;
    gap: 9px;
  }
  .topbar {
    min-height: 48px;
    align-items: center;
  }
  .topbar > div:first-child {
    display: grid;
    gap: 3px;
  }
  .brand { font-size: 28px; }
  .brand::before {
    width: 26px;
    height: 26px;
    margin-right: 8px;
    vertical-align: 4px;
    font-size: 13px;
  }
  .tagline {
    max-width: none;
    white-space: nowrap;
    overflow: visible;
    line-height: 1;
    font-size: 10px;
  }
  .progress {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: hidden;
  }
  .progress span {
    justify-content: center;
    padding: 9px 3px;
    font-size: 11px;
  }
  .workspace { border-radius: var(--radius); }
  .stage {
    width: 100%;
    padding: 16px;
    align-content: start;
  }
  h1 {
    font-size: 30px;
    line-height: 1.04;
  }
  h2 { font-size: 28px; }
  .lead {
    font-size: 14px;
    line-height: 1.42;
  }
  .field-shell { padding: 13px; }
  .field-shell textarea {
    min-height: 150px;
    font-size: 16px;
  }
  textarea { min-height: 150px; }
  .pro-grid { grid-template-columns: 1fr; }
  .snapshot-row { grid-template-columns: 1fr; gap: 6px; }
  .markdown { min-height: 220px; padding: 16px; }
  .action-rail {
    min-height: 64px;
    padding-top: 6px;
    gap: 12px;
    display: grid;
    grid-auto-flow: row;
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .action-rail button { width: 100%; }
  .action-rail .secondary { order: 2; }
  .profile {
    inset: auto 10px 10px 10px;
    width: auto;
    max-height: calc(100svh - 20px);
  }
}
