/* ════════════════════════════════════════════════════════════
   SCOTTY OS — the public guide

   Same ground as the constellation: one near-black, one near-white,
   greys in between. No hue, no glow, no blur stack, no terminal
   pastiche. Hierarchy is carried by type size, weight and space —
   which is the only thing that still reads at 390px.
   ════════════════════════════════════════════════════════════ */

:root {
  color-scheme: dark;
  --bg:      #030303;
  --panel:   #070707;
  --raised:  #0c0c0c;
  --line:    #212121;
  --line-hi: #333;
  --ink:     #f4f4f4;
  --dim:     #9a9a9a;
  --faint:   #6d6d6d;
  --mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans:    'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
body { overflow-x: hidden; }

:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 10px;
  z-index: 10;
  background: #fff;
  color: #000;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
}
.skip:focus { left: 14px; }

#space {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: .6;
}

.topbar, main { position: relative; z-index: 1; }

/* ── topbar ──────────────────────────────────────────────── */

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(18px, 5vw, 68px);
  border-bottom: 1px solid #161616;
  background: rgba(3, 3, 3, .86);
  backdrop-filter: blur(14px);
}
.brand {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #fff;
  text-decoration: none;
}
.brand strong { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }

.brand span,
.eyebrow,
.msg-who,
.knowledge h2,
.sources-label,
.card-label,
form label,
.composer-foot {
  font: 500 10px/1.4 var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
}

.topbar nav { display: flex; gap: clamp(14px, 3vw, 26px); }
.topbar nav a {
  color: var(--dim);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}
.topbar nav a:hover { color: #fff; }

/* ── intro ───────────────────────────────────────────────── */

main {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(40px, 7vw, 74px) 0 clamp(48px, 8vw, 90px);
}

.intro { max-width: 760px; margin-bottom: clamp(28px, 4vw, 42px); }
.intro h1 {
  font-size: clamp(34px, 6vw, 66px);
  line-height: 1;
  letter-spacing: -.045em;
  font-weight: 600;
  margin: 14px 0 18px;
}
.standfirst {
  margin: 0;
  max-width: 640px;
  color: var(--dim);
  font-size: clamp(15px, 1.6vw, 17px);
  line-height: 1.65;
}

/* ── workspace shell ─────────────────────────────────────── */

.workspace {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--panel);
}

.knowledge {
  padding: 26px 22px;
  border-right: 1px solid var(--line);
  background: #050505;
}
.knowledge h2 { margin: 0 0 16px; }
.knowledge ul { list-style: none; margin: 0; padding: 0; }
.knowledge li { border-top: 1px solid #171717; }
.knowledge li:last-child { border-bottom: 1px solid #171717; }
.knowledge a {
  display: block;
  padding: 11px 0;
  font-size: 13px;
  color: #cfcfcf;
  text-decoration: none;
}
.knowledge a:hover { color: #fff; }
.knowledge-foot {
  margin: 20px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--faint);
}

/* ── conversation ────────────────────────────────────────── */

.chat {
  display: flex;
  flex-direction: column;
  min-height: 640px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  max-height: 62vh;
  min-height: 340px;
  padding: clamp(20px, 3vw, 32px);
  display: flex;
  flex-direction: column;
  gap: 26px;
  scroll-behavior: smooth;
}

.msg { max-width: 700px; }
.msg-who { display: block; margin-bottom: 9px; }

.msg.user {
  align-self: flex-end;
  max-width: 560px;
  background: #f2f2f2;
  color: #070707;
  border-radius: 14px 14px 3px 14px;
  padding: 14px 18px;
}
.msg.user .msg-who { color: #6a6a6a; }
.msg.user p { margin: 0; line-height: 1.55; font-size: 15px; }

.msg.assistant { align-self: flex-start; }
.msg.assistant p {
  margin: 0 0 12px;
  line-height: 1.7;
  font-size: 15px;
  color: #e6e6e6;
}
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
  margin: 22px 0 10px;
  color: #fff;
}
.msg.assistant h3:first-child { margin-top: 0; }
.msg.assistant ul, .msg.assistant ol {
  margin: 0 0 12px;
  padding-left: 20px;
  line-height: 1.7;
  font-size: 15px;
  color: #dcdcdc;
}
.msg.assistant li { margin-bottom: 6px; }
.msg.assistant li:last-child { margin-bottom: 0; }
.msg.assistant a { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.msg.assistant a:hover { text-decoration-thickness: 2px; }
.msg.assistant strong { color: #fff; font-weight: 600; }

/* the one line of understated emphasis — a question being asked back */
.ask-back {
  border-left: 2px solid #454545;
  padding-left: 16px;
  margin: 4px 0 0;
}
.ask-back p { color: #fff !important; font-size: 16px !important; }
.ask-back .step {
  display: block;
  font: 500 10px/1.4 var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 8px;
}

/* ── result cards: diagnosis and plans ───────────────────── */

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--raised);
  padding: 20px;
  margin: 0 0 12px;
}
.card-label { display: block; margin-bottom: 8px; }
.card h4 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: #fff;
}
.card p { margin: 0 0 10px; font-size: 14px; line-height: 1.65; color: #cfcfcf; }
.card p:last-child, .card ol:last-child, .card ul:last-child { margin-bottom: 0; }
.card.primary { border-color: #4a4a4a; background: #101010; }
.card.warn { border-style: dashed; }

.quote {
  font-style: italic;
  color: #fff !important;
  border-left: 2px solid #3a3a3a;
  padding-left: 12px;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}
.plan {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--raised);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
}
.plan.pick { border-color: #fff; background: #131313; }
.plan-name { font-size: 15px; font-weight: 600; color: #fff; margin: 0 0 2px; }
.plan-price { font: 500 12px/1.4 var(--mono); color: var(--dim); margin: 0 0 14px; }
.plan-inherits {
  font-size: 12px;
  line-height: 1.5;
  color: #fff;
  background: #1c1c1c;
  border-radius: 6px;
  padding: 7px 9px;
  margin: 0 0 12px;
}
.plan ul { list-style: none; margin: 0 0 12px; padding: 0; }
.plan li {
  font-size: 13px;
  line-height: 1.5;
  color: #cfcfcf;
  padding: 6px 0;
  border-top: 1px solid #1a1a1a;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.plan li b { color: #fff; font-weight: 600; white-space: nowrap; }
.plan-for {
  margin: auto 0 0;
  padding-top: 12px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--faint);
}
.plan-badge {
  display: inline-block;
  font: 500 9px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  background: #fff;
  color: #000;
  padding: 4px 7px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.note-line {
  font-size: 13px !important;
  color: var(--faint) !important;
  line-height: 1.6 !important;
}

/* ── sources ─────────────────────────────────────────────── */

.sources {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #1e1e1e;
}
.sources-label { display: block; margin-bottom: 8px; }
.sources ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.sources li { margin: 0; }
.sources a {
  display: inline-block;
  font: 400 12px/1 var(--sans);
  color: var(--dim);
  text-decoration: none;
  border: 1px solid #242424;
  border-radius: 999px;
  padding: 6px 11px;
}
.sources a:hover { color: #fff; border-color: var(--line-hi); }

/* ── suggestions and composer ────────────────────────────── */

.composer { border-top: 1px solid var(--line); background: #040404; }

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px clamp(20px, 3vw, 32px) 0;
}
.suggestions:empty { display: none; }
.suggestions button {
  font: 400 13px/1 var(--sans);
  color: #d2d2d2;
  background: #0d0d0d;
  border: 1px solid #262626;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.suggestions button:hover { color: #fff; border-color: #565656; background: #151515; }

form { padding: 18px clamp(20px, 3vw, 32px) 22px; }
form label { display: block; margin-bottom: 9px; }

.ask-row { display: flex; gap: 10px; align-items: flex-end; }
textarea {
  flex: 1;
  min-height: 52px;
  max-height: 190px;
  resize: none;
  background: #0a0a0a;
  color: #fff;
  border: 1px solid #2c2c2c;
  border-radius: 11px;
  padding: 15px 16px;
  font: 400 15px/1.5 var(--sans);
  outline: none;
}
textarea::placeholder { color: #5a5a5a; }
textarea:focus { border-color: #7a7a7a; }

.ask-row button {
  flex: none;
  height: 52px;
  border: 0;
  border-radius: 11px;
  background: #fff;
  color: #060606;
  padding: 0 26px;
  font: 600 15px/1 var(--sans);
  cursor: pointer;
}
.ask-row button:hover { background: #d9d9d9; }

.composer-foot { margin: 10px 0 0; text-transform: none; letter-spacing: .04em; }

/* ── responsive ──────────────────────────────────────────── */

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .knowledge {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 20px;
  }
  .knowledge ul { display: flex; flex-wrap: wrap; gap: 6px; }
  .knowledge li { border: 1px solid #1e1e1e; border-radius: 999px; }
  .knowledge li:last-child { border-bottom: 1px solid #1e1e1e; }
  .knowledge a { padding: 7px 12px; font-size: 12px; }
  .knowledge-foot { margin-top: 14px; }
  .plan-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar { height: 64px; }
  .topbar nav a:not(:last-child) { display: none; }
  main { width: calc(100% - 24px); }
  .workspace { border-radius: 14px; }
  .chat { min-height: 0; }
  .messages {
    max-height: none;
    min-height: 300px;
    gap: 22px;
    padding: 18px;
  }
  .msg.user { max-width: 90%; }
  .msg.assistant p, .msg.assistant ul, .msg.assistant ol { font-size: 15px; }
  .suggestions { padding: 14px 18px 0; }
  .suggestions button { font-size: 12px; padding: 9px 12px; }
  form { padding: 14px 18px 18px; }
  .ask-row { flex-direction: column; align-items: stretch; }
  .ask-row button { width: 100%; height: 48px; }
  .card { padding: 16px; }
  .plan { padding: 16px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .messages { scroll-behavior: auto; }
  /* the star field stops repainting entirely — see scotty-os.js */
}
