:root {
  /* Accent: teal. Reads as water / utility, calmer than the previous gold,
     reserves color for primary actions and state communication. */
  --accent:      #0F766E;   /* teal-700 - primary actions, focus rings */
  --accent-soft: #14B8A6;   /* teal-500 - busy / animated states */
  --accent-bg:   #CCFBF1;   /* teal-100 - approval pill, subtle hovers */
  --accent-fg:   #115E59;   /* teal-800 - text on accent-bg */

  /* Slate-based neutrals. Slightly cooler than the prior #0F1115 family;
     plays better next to teal accents. */
  --ink:    #0F172A;        /* slate-900 - primary text */
  --ink-2:  #334155;        /* slate-700 - secondary text */
  --muted:  #64748B;        /* slate-500 - tertiary */
  --muted-2:#94A3B8;        /* slate-400 - faintest, captions */
  --line:   #E2E8F0;        /* slate-200 - default borders */
  --line-2: #F1F5F9;        /* slate-100 - subtle borders / hover bg */
  --surface:#FFFFFF;        /* cards, sidebar */
  --bg:     #F8FAFC;        /* slate-50 - page background */

  --user-bg: #0F172A;
  --user-fg: #FFFFFF;

  /* State communication */
  --danger:  #DC2626;       /* red-600 */
  --success: #16A34A;       /* green-600 */
  --warning: #D97706;       /* amber-600 */

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  /* Inter for Latin; Noto Sans Devanagari/Bengali for Hindi/Assamese fallbacks
     so script-mismatched glyphs don't drop to the system default. */
  font-family: "Inter", "Noto Sans Devanagari", "Noto Sans Bengali",
    -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
html[lang="hi"] body, html[lang="as"] body {
  /* Indic scripts read better with slightly more line-height. */
  line-height: 1.55;
}

/* ---------- Layout ---------- */
body {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-areas: "sidebar main";
  height: 100vh;
}
/* Three top-level views swap into the "main" cell:
   - hub: equipment-first landing (default)
   - chat: LLM diagnose / propose / advise flow
   - proposal: final priced proposal
   Visibility is driven entirely by body[data-view]. */
#hub-view, #main-chat, #proposal-full { display: none; }
body[data-view="hub"] #hub-view { display: flex; }
body[data-view="chat"] #main-chat { display: flex; }
body[data-view="proposal"] #proposal-full { display: flex; }
body[data-view="proposal"] { grid-template-areas: "sidebar proposal"; }
body[data-view="hub"] { grid-template-areas: "sidebar hub"; }
.hidden { display: none !important; }
/* `.mobile-only` must use !important because some elements that carry it
   also have .btn-icon / .btn-ghost rules that set display later in the
   cascade and would otherwise win on desktop. The 900px media query
   re-overrides with `display: inline-flex !important` at the same
   importance but later source order, so the mobile state still works. */
.mobile-only { display: none !important; }

/* ---------- Sidebar ---------- */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 24px;
}
.logo-block { display: flex; flex-direction: column; gap: 1px; }
.logo-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.logo-sub { font-size: 11px; color: var(--muted-2); font-weight: 500; }

.section { display: flex; flex-direction: column; gap: 8px; }
.section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted-2);
}

.input-group { display: flex; flex-direction: column; gap: 4px; }
.input-group label { font-size: 11px; color: var(--muted); }
.input-group input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13px; color: var(--ink); font-family: inherit;
}
.input-group input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

/* Status-row / status-dot rules removed - the sidebar status pill they
   targeted was dropped in the resume-cleanup commit. The keyframes pulse
   is kept because other components (notably busy buttons) re-use it. */
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.4;} }

.mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; font-size: 10px; color: var(--ink-2); }

/* History panel: live mirror of the current session's user / assistant turns,
   so the SO can see what they answered while reviewing the proposal. */
.history-section {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
}
.history-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.sidebar-history {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  padding-right: 4px;
}
.history-empty {
  color: var(--muted-2); font-size: 11px;
  font-style: italic; line-height: 1.5;
  padding: 8px 0;
}
.history-row {
  display: block; width: 100%;
  text-align: left; cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit; font-size: 12px; line-height: 1.4;
  color: var(--ink-2);
  transition: border-color 0.12s, background 0.12s;
}
.history-row:hover { border-color: var(--accent); background: var(--accent-bg); }
.history-row.history-active {
  border-color: var(--accent); background: var(--accent-bg);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.history-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10px; color: var(--muted-2);
  margin-bottom: 3px;
}
.history-time { font-family: "JetBrains Mono", monospace; letter-spacing: 0.02em; }
.history-total { font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.history-summary {
  color: var(--ink); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* ---------- Main / chat ---------- */
.main {
  grid-area: main;
  display: flex; flex-direction: column;
  min-width: 0; background: var(--bg);
}
.main-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.head-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }

/* Mode chip in the chat header: shows the active flow (Diagnose / Advise /
   Propose) so the SO sees which tool the system routed them to. */
.mode-chip {
  display: inline-flex; align-items: center;
  margin-left: 12px;
  padding: 3px 10px;
  background: var(--accent-bg);
  color: var(--accent-fg);
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em;
  border: 1px solid var(--accent);
}
.mode-chip.hidden { display: none; }
.mode-chip[data-mode="advise"] { background: #FEF3C7; color: #92400E; border-color: #FBBF24; }
.mode-chip[data-mode="propose"] { background: #DBEAFE; color: #1E40AF; border-color: #60A5FA; }

/* Auto-speak toggle: small inline checkbox in the sidebar so the SO can
   silence audio for an entire shift if they don't want to be the source of
   noise in a meeting / quiet area. */
.tts-toggle {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-2);
  padding: 4px 0;
  cursor: pointer; user-select: none;
}
.tts-toggle input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.head-tools { display: flex; gap: 8px; }
.tool-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--line-2);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px; font-weight: 500; color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.pill-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

.chat-area {
  flex: 1; overflow-y: auto;
  padding: 24px 0;
  display: flex; flex-direction: column; align-items: center;
}
.chat-inner {
  width: 100%;
  max-width: 760px;
  padding: 0 28px;
  display: flex; flex-direction: column; gap: 12px;
}

.bubble {
  padding: 12px 14px;
  border-radius: 12px;
  line-height: 1.55;
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.bubble.user {
  background: var(--user-bg); color: var(--user-fg);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  max-width: 75%;
  padding: 10px 14px;
}
.bubble.assistant {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
  max-width: 92%;
  position: relative;
  padding-right: 38px;  /* room for speaker icon */
}
.bubble.heard {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 12px; font-style: italic;
  padding: 5px 11px;
  align-self: flex-end;
  max-width: 75%;
}
.bubble.system-hint {
  background: transparent; color: var(--muted-2);
  font-size: 12px;
  align-self: center;
  padding: 4px 8px;
  text-align: center;
  max-width: 90%;
}

/* First-run examples row: tappable starter prompts under the greeting. */
.examples-wrap {
  align-self: center;
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 6px;
  padding: 4px 8px 12px;
  max-width: 720px;
}
.examples-intro {
  font-size: 11.5px; color: var(--muted-2);
  font-style: italic;
  margin-right: 4px;
}
.example-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  padding: 6px 11px;
  border-radius: 999px;
  font-family: inherit; font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
  min-height: 32px;
}
.example-chip:hover, .example-chip:focus-visible {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent-fg);
  outline: none;
}

.speaker-btn {
  position: absolute; top: 6px; right: 6px;
  width: 36px; height: 36px;  /* bumped from 24x24 to meet field-usable target */
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  display: grid; place-items: center;
  cursor: pointer; color: var(--muted-2);
  padding: 0; opacity: 0.7;
  transition: opacity 0.12s, color 0.12s, border-color 0.12s, background 0.12s;
}
.speaker-btn:hover, .speaker-btn:focus-visible {
  opacity: 1; color: var(--accent); border-color: var(--accent);
  background: var(--accent-bg); outline: none;
}

/* Pulsing dot near the speaker icon while TTS audio is being fetched */
.bubble.tts-loading .speaker-btn::after {
  content: '';
  position: absolute;
  top: -3px; right: -3px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: tts-pulse 1s ease-in-out infinite;
}
@keyframes tts-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

.typing {
  display: inline-flex; gap: 3px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: var(--shadow-sm);
}
.typing span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--muted-2);
  animation: typingDot 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingDot {
  0%,60%,100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* Recording bar: appears above the composer while recording. Shows a level
   meter (so the SO knows the mic is picking them up), an elapsed timer (so
   they know they actually held long enough), and a Stop button (so they
   don't have to find the same mic button to release). */
.recording-bar {
  display: flex; align-items: center; gap: 10px;
  margin: 0 28px 8px;
  padding: 8px 12px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 10px;
}
.recording-bar.hidden { display: none; }
.recording-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger);
  animation: pulseRedDot 1s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulseRedDot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.recording-meter {
  flex: 1; height: 6px;
  background: rgba(220, 38, 38, 0.15);
  border-radius: 3px;
  overflow: hidden;
}
.recording-meter-fill {
  height: 100%;
  background: var(--danger);
  width: 0%;
  transition: width 0.08s linear;
  border-radius: 3px;
}
.recording-time {
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px; color: var(--danger);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 38px; text-align: right;
}
.recording-stop-btn {
  padding: 5px 12px; font-size: 12px;
  border-color: var(--danger);
  color: var(--danger);
  background: var(--surface);
  min-height: 32px;
}
.recording-stop-btn:hover { background: var(--danger); color: white; }

/* ---------- Composer ---------- */
.composer-wrap {
  border-top: 1px solid var(--line);
  background: var(--surface);
  display: flex; justify-content: center;
  padding: 12px 28px 18px;
}
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  width: 100%; max-width: 760px;
}
.composer textarea {
  flex: 1; resize: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: inherit; font-size: 14px;
  max-height: 120px; line-height: 1.5; color: var(--ink);
}
.composer textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}
.mic-btn, .send-btn, .image-btn {
  width: 40px; height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  display: grid; place-items: center;
  cursor: pointer; color: var(--ink-2);
  transition: all 0.12s; padding: 0; flex-shrink: 0;
}
.mic-btn:hover, .send-btn:hover, .image-btn:hover { border-color: var(--accent); color: var(--accent); }
.image-btn.has-image { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

.image-preview {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  position: relative;
}
.image-preview img {
  max-width: 80px; max-height: 80px;
  border-radius: 6px;
  object-fit: cover;
}
.image-clear-btn {
  position: absolute; top: 4px; right: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 50%; width: 32px; height: 32px;  /* up from 22 */
  cursor: pointer; color: var(--muted);
  font-size: 18px; line-height: 1;
  padding: 0;
}
.image-clear-btn:hover, .image-clear-btn:focus-visible {
  color: var(--danger); border-color: var(--danger); outline: none;
}

/* Full-page drop overlay for drag-and-drop image attach */
.drop-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  pointer-events: none;  /* let drag events bubble to window */
  animation: dropFadeIn 0.12s ease-out;
}
.drop-overlay.hidden { display: none; animation: none; }
.drop-overlay-inner {
  background: var(--surface);
  border: 2px dashed var(--accent);
  border-radius: 16px;
  padding: 36px 56px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  font-size: 16px; font-weight: 600; color: var(--ink);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
}
.drop-overlay-inner .drop-icon { font-size: 40px; }
@keyframes dropFadeIn { from { opacity: 0; } to { opacity: 1; } }

.mic-btn.listening {
  background: var(--danger); color: white; border-color: var(--danger);
  animation: pulseRed 1.2s infinite;
}
@keyframes pulseRed {
  0%,100% { box-shadow: 0 0 0 0 rgba(179,38,30,.4); }
  50% { box-shadow: 0 0 0 6px rgba(179,38,30,0); }
}
.send-btn { background: var(--ink); color: white; border-color: var(--ink); }
.send-btn:hover { background: var(--ink-2); color: white; border-color: var(--ink-2); }
.send-btn:disabled { background: var(--line); color: var(--muted-2); border-color: var(--line); cursor: not-allowed; }

/* ---------- Question card ---------- */
.q-text { font-size: 14.5px; line-height: 1.5; color: var(--ink); font-weight: 500; }
.q-hint { margin-top: 4px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.q-hint .ref-link { display: inline; }

/* Advise mode: chat-style answer with markdown structure (headers, lists,
   bold). Visual hierarchy is the whole point of advise; tighten spacing. */
.advise-bubble { max-width: 640px; }
.advise-bubble > *:first-child { margin-top: 0; }
.advise-bubble > *:last-child { margin-bottom: 0; }
.advise-bubble p { margin: 0 0 10px; line-height: 1.55; font-size: 14px; color: var(--ink); }
.advise-bubble h3 { margin: 14px 0 6px; font-size: 14px; font-weight: 700; color: var(--ink); letter-spacing: -0.005em; }
.advise-bubble h4 { margin: 12px 0 4px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.advise-bubble h5 { margin: 10px 0 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.advise-bubble strong { font-weight: 600; color: var(--ink); }
.advise-bubble em { font-style: italic; color: var(--ink-2); }
.advise-bubble ol,
.advise-bubble ul {
  margin: 4px 0 12px;
  padding-left: 22px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}
.advise-bubble li { margin-bottom: 4px; }
.advise-bubble li::marker { color: var(--accent); font-weight: 600; }
.advise-bubble .ref-link { display: inline; }

.options-group {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 12px;
}
.option-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  padding: 9px 14px;
  border-radius: 999px;
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: all 0.12s;
  text-align: left;
  min-height: 40px;  /* field-thumb tap target */
}
.option-chip:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--ink);
}
.option-chip:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.22);
}
.option-chip:disabled { opacity: 0.4; cursor: not-allowed; }
.option-chip.chosen {
  background: var(--ink); color: white;
  border-color: var(--ink); opacity: 1;
}

/* Ready-made-template suggestion bubble on the chat (propose) path. */
.bubble.tpl-suggest {
  padding-right: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.tpl-suggest-lead {
  font-size: 13px;
  color: var(--muted);
}
.tpl-suggest-btn {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--ink);
  font-weight: 600;
}
.q-skip {
  margin-top: 8px;
  font-size: 11px; color: var(--muted-2);
  font-style: italic;
}

/* ---------- Subtle clickable manual refs ---------- */
.ref-link {
  font-size: 0.82em;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  padding: 4px 6px;  /* invisible padding gives a 24-32px tap target */
  margin: 0 1px;
  border-bottom: 1px dotted var(--accent);
  cursor: pointer;
  vertical-align: baseline;
  white-space: nowrap;
  border-radius: 4px;
}
.ref-link:hover, .ref-link:focus-visible {
  color: var(--ink); border-bottom-color: var(--ink);
  background: var(--accent-bg); outline: none;
}

/* ---------- Diagnosis card ---------- */
.diagnosis-card {
  max-width: 100%;
  /* Teal-tinted gradient to match the accent palette (was a cream gold-era leftover). */
  background: linear-gradient(180deg, var(--accent-bg) 0%, var(--surface) 70%);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 16px 18px;
  padding-right: 50px;
  position: relative;
}
.diag-label {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em;
  color: var(--accent-fg); text-transform: uppercase; margin-bottom: 6px;
}
.diag-root {
  font-size: 18px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.01em; line-height: 1.35;
  margin-bottom: 10px;
}
.diag-section { margin-top: 10px; }
.diag-section-label {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--ink-2); text-transform: uppercase; margin-bottom: 4px;
}
.diag-section-body { font-size: 14px; color: var(--ink-2); line-height: 1.55; }
.diag-section ul { margin: 4px 0 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); line-height: 1.7; }
.diag-section ul li { padding: 1px 0; }
.diag-action-row { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Template-suggestion row appended to a diagnosis card once the server has
   matched the diagnosed failure to a ready-made template. */
.diag-suggest {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.diag-suggest-lead { font-size: 13px; color: var(--muted); }

/* "+ Add another issue at this scheme" - secondary action next to the
   primary "Generate / View draft" button. Stays unobtrusive but tappable. */
.btn-add-issue {
  background: transparent;
  color: var(--accent-fg);
  border: 1px dashed var(--accent);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, border-style 0.12s;
  min-height: 40px;
}
.btn-add-issue:hover, .btn-add-issue:focus-visible {
  background: var(--accent-bg);
  border-style: solid;
  outline: none;
}

/* Visual separator between issues in a multi-scope session. */
.issue-separator {
  align-self: stretch;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-style: italic;
  padding: 6px 14px;
  margin: 6px 0;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
  text-align: center;
  background: var(--line-2);
}

.btn-generate {
  background: var(--ink); color: white; border: none;
  padding: 11px 18px; border-radius: 8px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.12s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-generate:hover { background: var(--ink-2); }
.btn-generate:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-generate .spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Proposal full view ---------- */
.proposal-full {
  grid-area: proposal;
  background: var(--bg);
  display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
}
.proposal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.head-left { display: flex; align-items: center; gap: 10px; }
.head-left h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.head-actions { display: flex; gap: 8px; }
.btn-icon {
  width: 32px; height: 32px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 7px;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary {
  background: var(--accent); color: white; border: none;
  border-radius: 8px; padding: 9px 16px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background 0.12s, box-shadow 0.12s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-fg); }
.btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.25); }
.btn-primary:disabled { background: var(--line); color: var(--muted-2); cursor: not-allowed; }
.btn-ghost {
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 8px;
  font-size: 12.5px; font-weight: 500; cursor: pointer; font-family: inherit;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.btn-ghost:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18); }

.proposal-body {
  flex: 1; overflow-y: auto;
  padding: 22px 28px 32px;
  max-width: 1300px; margin: 0 auto; width: 100%;
}
.proposal-meta { margin-bottom: 16px; }
.meta-scheme { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.meta-diag {
  background: var(--accent-bg);
  padding: 12px 14px;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  font-size: 13.5px; color: var(--ink-2); line-height: 1.55;
}

/* Top summary - total + approval at a glance */
.prop-summary {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.prop-summary-top {
  display: flex; align-items: stretch; gap: 14px;
}
.prop-total-block { flex: 1; min-width: 0; }
.prop-total-label {
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.prop-total-value {
  font-size: 32px; font-weight: 800; color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.1; margin-top: 4px;
}
.prop-slab-pill {
  background: var(--accent-bg); border: 1px solid var(--accent);
  border-radius: 10px; padding: 8px 12px;
  min-width: 130px; max-width: 180px;
  display: flex; flex-direction: column; justify-content: center;
}
.prop-slab-label {
  font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); font-weight: 700;
}
.prop-slab-value {
  font-size: 14px; font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.prop-slab-chain {
  font-size: 12px; color: var(--ink-2); margin-top: 6px;
  line-height: 1.35; font-weight: 500;
}
.prop-summary-meta {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px; color: var(--ink-2);
  line-height: 1.5;
}
.meta-scheme { color: var(--muted); font-size: 11.5px; margin-bottom: 4px; }
.meta-scheme:empty { display: none; }
.approval-caveat {
  color: var(--muted); font-style: italic;
  margin-top: 10px; font-size: 11.5px; line-height: 1.4;
}
.approval-caveat:empty { display: none; }
.approval-caveat.caveat-warn {
  background: #FEF3C7;
  border-left: 3px solid var(--warning);
  padding: 8px 10px;
  border-radius: 6px;
  font-style: normal; color: var(--ink-2);
}

/* Items list header */
.prop-items-header {
  display: flex; justify-content: space-between; align-items: center;
  margin: 4px 2px 8px;
}
.prop-items-title {
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}

/* Rate-card search panel: appears between the Line items header and the
   items list when "+ Add line" is tapped. Tappable result cards pre-fill
   the line item with the matched rate-card row. */
.rate-search-panel {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-md);
  animation: panelSlideIn 0.16s ease-out;
}
.rate-search-panel.hidden { display: none; animation: none; }
@keyframes panelSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.rate-search-input-row {
  display: flex; align-items: center; gap: 8px;
}
.rate-search-input {
  flex: 1; min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit; font-size: 14.5px;
  color: var(--ink);
  min-height: 40px;
}
.rate-search-input:focus {
  outline: none; border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}
.rate-search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

.rate-search-status {
  margin-top: 10px;
  font-size: 12.5px; color: var(--muted);
  font-style: italic;
  min-height: 18px;
  display: flex; align-items: center; gap: 6px;
}
.rate-search-status .spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.rate-search-results {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 8px;
}
.rate-search-results:empty { display: none; }

.rate-search-item {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s, background 0.12s;
  min-height: 56px;
  width: 100%;
}
.rate-search-item:hover, .rate-search-item:focus-visible {
  border-color: var(--accent);
  background: var(--accent-bg);
  outline: none;
}
.rate-search-item-desc {
  font-size: 13.5px; font-weight: 500; color: var(--ink);
  line-height: 1.4;
  margin-bottom: 6px;
  word-break: break-word;
}
.rate-search-item-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}
.rate-search-item-rate {
  font-weight: 700; color: var(--accent-fg);
  font-size: 13px;
  margin-left: auto;
}
.rate-search-item-unit { font-style: italic; }
.rate-search-item-band {
  background: var(--accent-bg);
  color: var(--accent-fg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px; font-weight: 600;
}

.rate-search-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  display: flex; justify-content: flex-end;
}
.rate-search-custom-btn {
  font-size: 12px;
}

@media (max-width: 900px) {
  .rate-search-panel { padding: 10px 12px; }
  .rate-search-input { font-size: 16px; }  /* avoids iOS zoom on focus */
}

/* Per-item card */
.prop-items {
  display: flex; flex-direction: column; gap: 8px;
}

/* Group heading: separates line items per diagnosed issue in a multi-scope
   proposal. Plain header text, no decoration; the visual hierarchy comes
   from the slight uppercase + accent color. */
.prop-group-head {
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--accent-fg);
  padding: 8px 4px 2px;
  margin-top: 6px;
}
.prop-group-head:first-child { margin-top: 0; padding-top: 4px; }
.prop-item {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}
.prop-row-1 { display: flex; align-items: flex-start; gap: 6px; }
.prop-row-1 .desc {
  flex: 1; min-width: 0; background: transparent;
  border: 1px solid transparent; border-radius: 6px;
  padding: 6px 8px; font-family: inherit;
  font-size: 14px; color: var(--ink); font-weight: 500;
  line-height: 1.4;
  resize: none; overflow: hidden;
  word-wrap: break-word; overflow-wrap: anywhere;
  white-space: pre-wrap;
  width: 100%;
}
.prop-row-1 .desc:hover { background: var(--line-2); }
.prop-row-1 .desc:focus {
  outline: none; background: var(--bg);
  border-color: var(--accent); box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.15);
}
.del-row {
  background: transparent; border: 1px solid transparent;
  color: var(--muted-2); cursor: pointer;
  font-size: 22px; line-height: 1;
  width: 36px; height: 36px;  /* solid tap target */
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.del-row:hover, .del-row:focus-visible {
  color: var(--danger);
  background: #FEF2F2;
  border-color: #FECACA;
  outline: none;
}

.row-note {
  font-size: 11px; color: var(--muted); margin: 4px 8px;
  font-style: italic; line-height: 1.4;
}

.prop-row-2 {
  display: flex; align-items: center; gap: 4px;
  margin-top: 6px; padding-left: 8px;
  font-size: 13.5px; font-variant-numeric: tabular-nums;
}
.prop-row-2 .qty, .prop-row-2 .rate {
  background: transparent; border: 1px solid transparent;
  border-radius: 5px; padding: 4px 6px;
  font-family: inherit; font-variant-numeric: tabular-nums;
  font-size: 13.5px; color: var(--ink); text-align: right;
  width: 64px;
}
.prop-row-2 .rate { width: 84px; }
.prop-row-2 .qty:hover, .prop-row-2 .rate:hover {
  background: var(--line-2); border-color: var(--line);
}
.prop-row-2 .qty:focus, .prop-row-2 .rate:focus {
  outline: none; background: var(--bg);
  border-color: var(--accent); box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.15);
}
.prop-row-2 .prop-times,
.prop-row-2 .prop-eq,
.prop-row-2 .prop-rupee {
  color: var(--muted-2); font-size: 13px; padding: 0 2px;
}
.prop-row-2 .amount {
  margin-left: auto; font-weight: 700; color: var(--ink);
  font-size: 14.5px; padding: 0 4px;
}

.prop-row-3 {
  margin-top: 6px; padding-left: 8px;
}
.src-pill {
  display: inline-block;
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px; color: var(--muted);
  background: var(--line-2); border: 1px solid var(--line);
  padding: 2px 6px; border-radius: 4px;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.src-pill-link { cursor: pointer; }
.src-pill-link:hover {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
}

/* Conditional items section */
.conditional-block {
  margin-top: 18px;
  padding: 14px 16px;
  background: var(--line-2);
  border-radius: 8px;
  border-left: 3px solid var(--muted-2);
}
.conditional-block h3 {
  margin: 0; padding: 0;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
}
.conditional-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.cond-rollup {
  font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-style: italic;
}
.cond-rollup:empty { display: none; }
.conditional-block .cond-note {
  font-size: 12px; color: var(--muted); margin-bottom: 10px;
  line-height: 1.5;
}
.cond-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px; margin-bottom: 8px;
  font-size: 12.5px;
}
.cond-item .cond-cond { font-size: 11px; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.cond-item .cond-desc { color: var(--ink-2); line-height: 1.5; }
.cond-item .cond-actions {
  margin-top: 10px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}
.cond-add-btn {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.cond-add-btn:hover {
  background: var(--accent);
  color: white;
}
.cond-item .cond-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; gap: 8px; flex-wrap: wrap;
  font-size: 11px; color: var(--muted);
  font-family: "JetBrains Mono", monospace;
}

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "sidebar" "main";
  }
  body[data-view="proposal"] { grid-template-areas: "sidebar" "proposal"; }
  body[data-view="hub"] { grid-template-areas: "sidebar" "hub"; }
  .sidebar {
    flex-direction: row; flex-wrap: wrap;
    gap: 10px; padding: 12px;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .sidebar .section { flex: 1 1 160px; }
  .logo-block { flex: 1 1 100%; }
  .mobile-only { display: inline-flex !important; align-items: center; justify-content: center; gap: 6px; }

  /* History on phone: hidden by default, opens as a full-height drawer when
     the header History button is tapped. The toggle adds .open to the section. */
  .history-section {
    position: fixed; inset: 0;
    z-index: 1000;
    background: var(--surface);
    padding: 16px;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    animation: drawerSlideIn 0.18s ease-out;
  }
  .history-section.open { display: flex; }
  .history-head {
    margin-bottom: 12px; padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
  }
  .history-head .section-label { font-size: 13px; color: var(--ink); }
  @keyframes drawerSlideIn {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
  }
  .chat-inner, .composer { padding: 0 16px; }
  .composer-wrap { padding: 10px 16px 14px; }
  .proposal-body { padding: 14px; }

  /* Phone tightening for proposal cards */
  .prop-summary { padding: 14px; }
  .prop-summary-top { flex-direction: column; gap: 10px; }
  .prop-slab-pill { max-width: none; }
  .prop-total-value { font-size: 30px; }

  .prop-item { padding: 10px; }
  .prop-row-1 .desc { font-size: 13.5px; }
  .prop-row-2 .qty { width: 56px; }
  .prop-row-2 .rate { width: 76px; }
  .prop-row-2 .amount { font-size: 13.5px; }
}

/* ---------- Quick-estimate template picker modal ---------- */
.btn-templates {
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.btn-templates:hover, .btn-templates:focus-visible {
  background: var(--accent-bg);
  outline: none;
}

.modal {
  position: fixed; inset: 0;
  z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  margin: 0; font-size: 17px; font-weight: 600;
  color: var(--ink);
}
.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}
.templates-intro {
  font-size: 13.5px; color: var(--ink-2);
  margin-bottom: 14px; line-height: 1.5;
}
.templates-list {
  display: flex; flex-direction: column; gap: 8px;
}
.template-row {
  text-align: left; cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: inherit;
  transition: border-color 0.12s, background 0.12s;
  min-height: 56px;
  width: 100%;
}
.template-row:hover, .template-row:focus-visible {
  border-color: var(--accent);
  background: var(--accent-bg);
  outline: none;
}
.template-row-label {
  font-size: 14.5px; font-weight: 600; color: var(--ink);
  margin-bottom: 4px;
}
.template-row-desc {
  font-size: 12.5px; color: var(--muted);
  line-height: 1.45;
}
.template-row-loc {
  display: inline-block;
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--accent-fg);
  background: var(--accent-bg);
  padding: 2px 7px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.templates-back {
  font-size: 12px; padding: 6px 10px;
  margin-bottom: 12px;
}
.templates-form-title {
  margin: 4px 0 6px; font-size: 15.5px; font-weight: 600;
}
.templates-form-desc {
  font-size: 12.5px; color: var(--muted);
  margin-bottom: 16px; line-height: 1.45;
}
.templates-form {
  display: flex; flex-direction: column; gap: 14px;
}
.templates-input-row {
  display: flex; flex-direction: column; gap: 4px;
}
.templates-input-row label {
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.templates-input-row select,
.templates-input-row input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--ink);
  min-height: 42px;
}
.templates-input-row select:focus,
.templates-input-row input[type="number"]:focus {
  outline: none; border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.templates-actions {
  margin-top: 18px;
  display: flex; justify-content: flex-end;
}

@media (max-width: 600px) {
  .modal { padding: 0; align-items: stretch; }
  .modal-card { max-height: 100vh; border-radius: 0; max-width: none; }
}

/* ============================================================================
   Hub view: equipment-first landing. The 80% path. Templates absorb the
   bulk of jobs; the small "describe in your own words" composer routes the
   long tail into the chat flow. Tile -> sub-templates (if >1) -> form.
   ============================================================================ */
.hub-view {
  grid-area: hub;
  background: var(--bg);
  flex-direction: column;
  min-width: 0; overflow-y: auto;
  padding: 32px 32px 0;
}
.hub-head { margin-bottom: 24px; max-width: 980px; }
.hub-title {
  font-size: 26px; font-weight: 700; letter-spacing: -0.015em;
  color: var(--ink); margin: 0 0 6px;
}
.hub-subtitle {
  font-size: 14px; color: var(--muted);
}

.hub-step { max-width: 980px; }
.hub-step-title {
  font-size: 19px; font-weight: 600; margin: 0 0 16px;
  color: var(--ink);
}

.hub-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: none;
  color: var(--muted); font-size: 13px; font-weight: 500;
  cursor: pointer; padding: 4px 0; margin-bottom: 12px;
  font-family: inherit;
}
.hub-back:hover { color: var(--accent); }

/* Equipment tile grid: 2-col on phone, auto-fit on desktop */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.hub-grid-sub {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.hub-tile {
  display: flex; flex-direction: column;
  gap: 10px; padding: 20px;
  min-height: 132px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color .12s ease, box-shadow .12s ease, transform .08s ease;
  text-align: left;
  font-family: inherit;
}
.hub-tile:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.hub-tile:active { transform: scale(0.99); }
.hub-tile-icon {
  width: 36px; height: 36px;
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-bg);
  border-radius: 10px;
  flex-shrink: 0;
}
.hub-tile-icon svg { width: 20px; height: 20px; }
.hub-tile-label {
  font-size: 16px; font-weight: 600; color: var(--ink);
  line-height: 1.3;
}
.hub-tile-hint {
  font-size: 12.5px; color: var(--muted);
  line-height: 1.4;
}
.hub-tile-count {
  font-size: 11px; color: var(--muted-2);
  margin-top: auto;
}

/* Form: option grids (segmented buttons) + toggle chips + live total */
.hub-form {
  display: flex; flex-direction: column; gap: 22px;
  margin-top: 8px;
}
.hub-form-desc {
  font-size: 13.5px; color: var(--muted);
  margin-bottom: 16px; line-height: 1.45;
}
.hub-input-row {
  display: flex; flex-direction: column; gap: 8px;
}
.hub-input-label {
  font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  display: flex; align-items: center; gap: 4px;
}
.hub-input-label .req { color: var(--accent); }

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.option-btn {
  min-height: 52px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.option-btn:hover { border-color: var(--accent); }
.option-btn.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-fg);
  font-weight: 600;
}

.hub-number-row {
  display: flex; align-items: stretch; gap: 0;
  max-width: 240px;
}
.hub-number-input {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  min-height: 52px;
  width: 100%;
}
.hub-number-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}
.hub-number-suffix {
  display: inline-flex; align-items: center;
  padding: 0 14px;
  color: var(--muted);
  font-size: 13px;
  background: var(--line-2);
  border: 1.5px solid var(--line);
  border-left: none;
  border-radius: 0 10px 10px 0;
  margin-left: -10px;
}

/* Conditional items: toggle chips with inline price-delta hint */
.hub-conditional {
  margin-top: 6px;
  display: flex; flex-direction: column; gap: 10px;
}
.hub-conditional-head {
  font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted-2);
  margin-bottom: 2px;
}
.toggle-chip {
  display: flex; align-items: flex-start;
  gap: 12px; padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.toggle-chip:hover { border-color: var(--accent); }
.toggle-chip.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.toggle-chip-check {
  width: 20px; height: 20px;
  border: 1.5px solid var(--muted-2);
  border-radius: 5px;
  flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  transition: all .12s ease;
}
.toggle-chip.selected .toggle-chip-check {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}
.toggle-chip-check svg { width: 12px; height: 12px; opacity: 0; }
.toggle-chip.selected .toggle-chip-check svg { opacity: 1; }
.toggle-chip-body { flex: 1; }
.toggle-chip-text {
  font-size: 13.5px; color: var(--ink); line-height: 1.4;
}
.toggle-chip-delta {
  display: inline-block;
  margin-left: 6px;
  font-size: 12.5px; font-weight: 600;
  color: var(--accent);
}

/* Sticky action bar: live total + submit */
.hub-actions {
  position: sticky; bottom: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  z-index: 10;
}
.hub-live-total { display: flex; flex-direction: column; gap: 1px; }
.hub-live-total-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted);
}
.hub-live-total-value {
  font-size: 22px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.hub-live-total-value.loading { color: var(--muted-2); }
.hub-submit {
  min-height: 48px; padding: 12px 24px;
  font-size: 14.5px; font-weight: 600;
}
.hub-submit:disabled {
  opacity: 0.5; cursor: not-allowed;
}

/* Fallback composer: persistent, pinned to the bottom of the hub.
   `margin-top: auto` (instead of a fixed gap) pushes the composer to the
   bottom of the flex column when the hub content is shorter than the
   viewport - without it, the composer would sit immediately under the
   tiles with a tall band of whitespace beneath it.
   `position: sticky; bottom: 0` keeps it visible when the content is
   tall enough to require scrolling. */
.hub-fallback {
  position: sticky; bottom: 0;
  margin-top: auto;
  margin-left: -32px; margin-right: -32px;
  padding: 14px 32px 18px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 5;
}
.hub-fallback-label {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 8px;
}
.hub-fallback-row {
  display: flex; align-items: center; gap: 8px;
}
.hub-describe-input {
  flex: 1;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--ink);
  min-height: 46px;
}
.hub-describe-input:focus {
  outline: none; border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}
.hub-mic-btn, .hub-describe-send {
  flex-shrink: 0;
}

/* Chat-back button in main-chat header */
.chat-back-btn { margin-right: 8px; }

@media (max-width: 600px) {
  .hub-view { padding: 20px 16px 0; }
  .hub-title { font-size: 22px; }
  .hub-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .hub-grid-sub { grid-template-columns: 1fr; }
  .hub-tile { min-height: 110px; padding: 14px; }
  .hub-tile-label { font-size: 14px; }
  .hub-tile-hint { font-size: 11.5px; }
  .hub-tile-icon { width: 30px; height: 30px; }
  .hub-tile-icon svg { width: 16px; height: 16px; }

  .option-grid { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 6px; }
  .option-btn { font-size: 13px; min-height: 48px; padding: 8px 10px; }

  .hub-fallback {
    margin-left: -16px; margin-right: -16px;
    padding: 12px 16px 16px;
  }

  .hub-actions { padding: 14px; }
  .hub-live-total-value { font-size: 19px; }
  .hub-submit { min-height: 46px; padding: 10px 16px; font-size: 13.5px; }
}

/* ============================================================================
   Multi-template merge banner. Shown on the hub when the SO is adding a
   second/third issue on top of an existing proposal.
   ============================================================================ */
.hub-merge-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 16px;
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: 12px;
  max-width: 980px;
}
.hub-merge-text {
  display: flex; flex-direction: column; gap: 2px;
}
.hub-merge-label {
  font-size: 13px; font-weight: 600;
  color: var(--accent-fg);
}
.hub-merge-total {
  font-size: 11px; font-weight: 500;
  color: var(--accent-fg);
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

/* Language picker - 3 tiny segmented buttons in the sidebar. Persists to
   localStorage on click. Active button highlighted. */
.lang-picker {
  display: flex; gap: 3px;
  background: var(--line-2);
  padding: 3px;
  border-radius: 8px;
  margin-top: 4px;
}
.lang-btn {
  flex: 1; padding: 6px 0;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  transition: background .12s, color .12s, box-shadow .12s;
}
.lang-btn:hover { color: var(--ink-2); }
.lang-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Promoted "+ Add line" button on the proposal view. Was a subdued
   .btn-ghost that read like a secondary action; the SO actually uses
   this to add items the model missed, so it deserves more visibility. */
.btn-add-line {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-bg);
  color: var(--accent-fg);
  border: 1px solid var(--accent);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn-add-line:hover {
  background: var(--accent);
  color: white;
}
.btn-add-line:active { transform: scale(0.97); }
.btn-add-line svg { flex-shrink: 0; }

/* History row badge for template-built sessions. The opening_message is
   "[Template] <label>" - the badge surfaces "Template" inline so the
   row label stays readable. */
.history-badge {
  display: inline-block;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 5px; margin-right: 4px;
  background: var(--accent-bg);
  color: var(--accent-fg);
  border-radius: 4px;
  vertical-align: 1px;
}

/* Small filled dot in the history row indicating the session has a
   server-persisted proposal (so the SO knows clicking lands on the
   proposal view, not a blank chat). Matches the accent palette. */
.history-draft-dot {
  display: inline-block;
  color: var(--accent);
  font-size: 9px;
  vertical-align: 2px;
  margin-right: 5px;
  line-height: 1;
}

/* Resume-with-proposal panel: shown inside the chat panel when the SO
   re-opens a session that already has a saved proposal. Replaces the
   noisy transcript with a single clean "Proposal saved" card and a big
   "View proposal" button. */
.resume-proposal-panel {
  display: flex; gap: 16px;
  margin: 32px auto;
  max-width: 520px;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  align-items: flex-start;
}
.resume-proposal-icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--accent-bg);
  color: var(--accent-fg);
  border-radius: 10px;
  flex-shrink: 0;
}
.resume-proposal-body { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.resume-proposal-title {
  font-size: 15px; font-weight: 600; color: var(--ink);
}
.resume-proposal-meta {
  font-size: 13px; color: var(--muted);
  display: flex; gap: 6px; align-items: baseline;
  flex-wrap: wrap;
}
.resume-proposal-amount {
  font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.resume-proposal-label {
  color: var(--muted-2);
}
.resume-proposal-btn {
  margin-top: 10px;
  align-self: flex-start;
  padding: 10px 18px;
  font-size: 13.5px;
}
