:root {
  color-scheme: light;
  --ink: #17231f;
  --ink-soft: #4f5d57;
  --paper: #f4f2eb;
  --paper-deep: #e9e5da;
  --panel: #fffefa;
  --line: #d9d4c8;
  --line-dark: #bdb8ad;
  --green: #174f3b;
  --green-bright: #2e7d5b;
  --green-pale: #dce9df;
  --amber: #c8762b;
  --amber-pale: #f4e5d4;
  --red: #963e34;
  --shadow: 0 22px 60px rgba(32, 46, 39, 0.09);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

button, textarea { font: inherit; }
button { color: inherit; }
button:disabled { cursor: wait; opacity: .62; }

.app-shell {
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 304px;
  display: flex;
  flex-direction: column;
  padding: 34px 28px 28px;
  overflow-y: auto;
  background: var(--ink);
  color: #f3f0e7;
}

.brand { display: flex; gap: 15px; align-items: flex-start; }

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 50%;
}

.brand-mark span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: #d9a05e;
}
.brand-mark span:nth-child(1) { height: 9px; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 12px; }

.eyebrow, .side-label, .welcome-kicker, .starter-label, .result-label {
  margin: 0;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.eyebrow { color: #9cb5a9; }
.brand h1 {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -.02em;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 34px 0 31px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 3px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease;
}
.new-chat:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.42); }
.new-chat span { color: #d9a05e; font-size: 18px; line-height: 1; }

.side-section {
  padding: 20px 0;
  border-top: 1px solid rgba(255,255,255,.13);
}
.side-label { color: #91a59b; }
.scope-title { margin: 10px 0 5px; font-weight: 670; }
.scope-copy { margin: 0; color: #b8c2bd; font-size: 12px; line-height: 1.55; }
.scope-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.scope-tags span {
  padding: 4px 7px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 2px;
  color: #cbd3cf;
  font-size: 10px;
}

.service-card { margin-top: 2px; }
.status-line { display: flex; align-items: center; gap: 9px; color: #dbe3df; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #5eb988; box-shadow: 0 0 0 4px rgba(94,185,136,.1); }
.status-dot.checking { background: #d9a05e; }
.status-dot.error { background: #d96c61; }
.index-stats { margin: 15px 0 0; }
.index-stats div { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; }
.index-stats dt { color: #91a198; font-size: 11px; }
.index-stats dd { margin: 0; color: #fff; font-size: 11px; font-variant-numeric: tabular-nums; }
.side-note { margin: auto 0 0; padding-top: 24px; color: #89968f; font-size: 10px; line-height: 1.55; }

.workspace {
  grid-column: 2;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(rgba(23,35,31,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23,35,31,.025) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  padding: 0 38px;
  border-bottom: 1px solid var(--line);
  background: rgba(244,242,235,.92);
  backdrop-filter: blur(14px);
}
.mode-line { display: flex; align-items: center; gap: 9px; color: var(--ink-soft); font-size: 12px; font-weight: 620; }
.mode-mark { width: 16px; height: 2px; background: var(--amber); }
.mobile-brand { display: none; }
.top-actions { display: flex; align-items: center; gap: 13px; }
.backend-control { display: flex; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 10px; }
.backend-control span { white-space: nowrap; }
.backend-control select {
  max-width: 190px;
  padding: 6px 26px 6px 9px;
  border: 1px solid #aeb8b1;
  border-radius: 2px;
  outline: 0;
  background: var(--panel);
  color: var(--green);
  font-size: 11px;
  font-weight: 650;
}
.backend-control select:focus { border-color: var(--green-bright); box-shadow: 0 0 0 2px rgba(46,125,91,.1); }
.local-badge {
  padding: 5px 8px;
  border: 1px solid #9bb7a8;
  border-radius: 2px;
  color: var(--green);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .13em;
}
.clear-button { border: 0; background: transparent; color: var(--ink-soft); font-size: 12px; cursor: pointer; }
.clear-button:hover { color: var(--ink); }

.conversation { width: min(960px, calc(100% - 56px)); margin: 0 auto; flex: 1; }
.welcome { padding: 74px 0 50px; }
.welcome-kicker { color: var(--amber); }
.welcome h2 {
  max-width: 750px;
  margin: 17px 0 20px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 6vw, 68px);
  font-weight: 400;
  line-height: .98;
  letter-spacing: -.045em;
}
.welcome-copy { max-width: 650px; margin: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.65; }

.starter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 42px; }
.starter-card {
  min-height: 187px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto 1fr;
  gap: 4px 12px;
  padding: 18px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(255,254,250,.72);
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(32,46,39,.025);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.starter-card:hover { transform: translateY(-3px); border-color: #9aaa9f; box-shadow: var(--shadow); }
.starter-number { color: #99a29e; font-family: Georgia, serif; font-size: 13px; }
.starter-label { grid-column: 1 / -1; margin-top: 16px; color: var(--green-bright); }
.starter-card strong { align-self: end; font-family: Georgia, serif; font-size: 17px; font-weight: 500; line-height: 1.25; }
.starter-arrow { grid-column: 2; grid-row: 1; color: var(--amber); font-size: 18px; }

.message-list { padding: 34px 0 46px; }
.message { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 24px; padding: 27px 0; border-bottom: 1px solid var(--line); }
.message-role { padding-top: 3px; color: #7a8580; font-size: 9px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.message.user .message-body { max-width: 760px; font-family: Georgia, serif; font-size: 21px; line-height: 1.4; }
.message p { margin-top: 0; }
.answer-summary { max-width: 760px; margin: 13px 0 0; font-size: 16px; line-height: 1.65; }
.model-answer { padding: 17px 19px; border-left: 3px solid var(--green-bright); background: var(--green-pale); }
.model-answer .answer-summary { margin-top: 0; }
.generation-note { margin: 10px 0 0; color: #7a5a3d; font-size: 11px; }
.point-list { margin: 0; padding-left: 19px; color: var(--ink-soft); font-size: 13px; }
.point-list li + li { margin-top: 7px; }
.evidence-ref-list { display: flex; flex-wrap: wrap; gap: 6px; }
.evidence-ref { padding: 4px 7px; border: 1px solid #a8bbb0; border-radius: 2px; color: var(--green); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }

.result-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.route-pill, .status-pill {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 2px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.route-pill { background: var(--green); color: #fff; }
.status-pill { border: 1px solid var(--line-dark); color: var(--ink-soft); }
.status-pill.abstained, .status-pill.no_match, .status-pill.outside_current_index { border-color: #d1a183; color: #8b4e29; background: var(--amber-pale); }
.context-note { width: 100%; margin: 5px 0 0; color: var(--green-bright); font-size: 11px; }

.result-section { margin-top: 25px; }
.result-label { margin-bottom: 10px; color: #6c7872; }
.recommendation-list, .evidence-list { display: grid; gap: 10px; }
.recommendation-card, .evidence-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel);
}
.recommendation-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.rank { display: inline-flex; min-width: 22px; color: var(--amber); font-family: Georgia, serif; font-size: 18px; }
.grade-title { margin: 0; font-family: Georgia, serif; font-size: 21px; font-weight: 500; line-height: 1.15; }
.grade-company { margin: 4px 0 0; color: var(--ink-soft); font-size: 11px; }
.confidence { padding: 4px 7px; background: var(--green-pale); color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.confidence.low { background: var(--amber-pale); color: #8b4e29; }

.property-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; margin: 16px 0 0; background: var(--line); border: 1px solid var(--line); }
.property { min-width: 0; padding: 10px 11px; background: #faf9f4; }
.property-name { display: block; color: #748079; font-size: 9px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.property-value { display: block; margin-top: 3px; font-variant-numeric: tabular-nums; font-weight: 670; overflow-wrap: anywhere; }
.qualification-list, .limitation-list { margin: 12px 0 0; padding-left: 18px; color: var(--ink-soft); font-size: 12px; }
.qualification-list li + li, .limitation-list li + li { margin-top: 5px; }

details.citations { margin-top: 13px; border-top: 1px solid var(--line); padding-top: 11px; }
details.citations summary { color: var(--green); font-size: 11px; font-weight: 700; cursor: pointer; }
.citation { padding: 12px 0 2px; font-size: 11px; color: var(--ink-soft); overflow-wrap: anywhere; }
.citation + .citation { border-top: 1px dotted var(--line-dark); margin-top: 10px; }
.citation a { color: var(--green-bright); text-underline-offset: 2px; }
.quote { margin: 7px 0; padding-left: 10px; border-left: 2px solid #d9a05e; color: var(--ink); }
.citation-meta { margin: 3px 0 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }

.evidence-head { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 10px; }
.evidence-kind { color: var(--green-bright); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.evidence-text { margin: 0; font-family: Georgia, serif; font-size: 16px; line-height: 1.55; }
.source-link { display: inline-block; margin-top: 11px; color: var(--green-bright); font-size: 11px; text-underline-offset: 2px; }
.source-meta { margin: 8px 0 0; color: #79837e; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; overflow-wrap: anywhere; }

.limitation-box { padding: 14px 16px; border-left: 3px solid var(--amber); background: var(--amber-pale); }
.limitation-box .result-label { color: #7c4d28; }
.limitation-box .limitation-list { margin-top: 0; color: #5b4d42; }
.suggestions { display: flex; flex-wrap: wrap; gap: 7px; }
.suggestion {
  padding: 7px 10px;
  border: 1px solid #b9c8c0;
  border-radius: 20px;
  background: transparent;
  color: var(--green);
  font-size: 11px;
  cursor: pointer;
}
.suggestion:hover { background: var(--green-pale); border-color: #8aaa99; }

.typing { display: inline-flex; gap: 4px; padding-top: 7px; }
.typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--green-bright); animation: pulse 1s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .13s; }
.typing span:nth-child(3) { animation-delay: .26s; }
@keyframes pulse { 0%, 70%, 100% { opacity: .28; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }

.error-card { padding: 13px 15px; border-left: 3px solid var(--red); background: #f2dfdc; color: #642d27; }

.composer-wrap {
  position: sticky;
  z-index: 9;
  bottom: 0;
  padding: 15px 28px 17px;
  border-top: 1px solid var(--line);
  background: linear-gradient(to top, var(--paper) 78%, rgba(244,242,235,.88));
}
.composer { width: min(960px, 100%); min-height: 56px; margin: 0 auto; display: flex; align-items: flex-end; padding: 7px 7px 7px 18px; border: 1px solid #aaa99f; border-radius: 3px; background: var(--panel); box-shadow: 0 8px 30px rgba(32,46,39,.06); }
.composer:focus-within { border-color: var(--green-bright); box-shadow: 0 0 0 3px rgba(46,125,91,.1); }
.composer textarea { width: 100%; max-height: 150px; resize: none; border: 0; outline: 0; padding: 9px 8px 7px 0; background: transparent; color: var(--ink); line-height: 1.45; }
.composer textarea::placeholder { color: #8a918c; }
.send-button { width: 41px; height: 41px; flex: 0 0 auto; border: 0; border-radius: 2px; background: var(--green); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; transition: background .18s ease; }
.send-button:hover { background: var(--green-bright); }
.send-button:disabled { background: #9ca49f; }
.composer-note { width: min(960px, 100%); margin: 7px auto 0; color: #7b8580; font-size: 9px; }
.composer-note span { float: right; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 860px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .workspace { min-height: 100vh; }
  .topbar { height: 64px; padding: 0 20px; }
  .mobile-brand { display: block; margin: 0 0 2px; font-family: Georgia, serif; font-size: 14px; }
  .mode-line { font-size: 10px; }
  .conversation { width: min(100% - 32px, 760px); }
  .welcome { padding-top: 52px; }
  .starter-grid { grid-template-columns: 1fr; }
  .starter-card { min-height: 126px; }
  .composer-wrap { padding-inline: 16px; }
}

@media (max-width: 560px) {
  .local-badge, .backend-control span, .composer-note span { display: none; }
  .backend-control select { max-width: 118px; }
  .welcome h2 { font-size: 39px; }
  .welcome-copy { font-size: 14px; }
  .message { grid-template-columns: 1fr; gap: 8px; padding: 22px 0; }
  .message.user .message-body { font-size: 19px; }
  .property-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .composer-note { line-height: 1.4; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
