:root {
  color-scheme: light;

  /* Brand palette — source of truth (#000 #fff #cbe500 #43729a #94ffef + purple accent) */
  --brand-black: #000000;
  --brand-white: #ffffff;
  --brand-lime: #cbe500;
  --brand-blue: #43729a;
  --brand-aqua: #94ffef;
  --brand-purple: rgb(155, 136, 255);

  /* Neutrals (greyscale chrome) */
  --bg: #ececec;
  --panel: var(--brand-white);
  --surface: #f5f5f5;
  --border: #d6d6d6;
  --border-strong: #a8a8a8;
  --text: var(--brand-black);
  --muted: #5a5a5a;
  --muted-2: #858585;

  /* Accents: purple = primary UI accent; blue = links / secondary emphasis */
  --accent: var(--brand-purple);
  --accent-soft: rgba(155, 136, 255, 0.12);
  --accent-border: rgba(155, 136, 255, 0.38);
  --link: var(--brand-blue);

  /* Success → lime; Error / warn → readable neutrals + brand tints */
  --ok: var(--brand-black);
  --ok-soft: rgba(203, 229, 0, 0.22);
  --ok-border: rgba(180, 198, 0, 0.55);
  --err: var(--brand-black);
  --err-soft: rgba(155, 136, 255, 0.09);
  --err-border: rgba(155, 136, 255, 0.4);
  --warn: var(--brand-blue);
  --warn-soft: rgba(67, 114, 154, 0.11);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 56px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100%;
}

.app--narrow {
  max-width: 440px;
}

/* ---------- Top bar ---------- */

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.appbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

.appbar__email {
  font-size: 12px;
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.appbar__mark {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  line-height: 0;
  color: var(--text);
  transform: rotate(-4deg);
  transform-origin: center center;
}

.appbar__logo-svg {
  display: block;
  height: 28px;
  width: auto;
}

.appbar__title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.appbar__sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.ghost-btn:hover {
  color: var(--text);
  border-color: var(--text);
}

.ghost-btn[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ghost-btn--sm {
  font-size: 11px;
  padding: 4px 10px;
}

/* ---------- Layout / cards ---------- */

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.card__title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---------- Form ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.field__hint {
  font-size: 11px;
  color: var(--muted);
}

.field__input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.field__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field__input--compact {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

textarea.field__input--compact {
  min-height: 72px;
}

/* Single-line variant: normal (non-monospace) font, no min-height so the
   control stays one line tall even with the compact spacing utilities. */
.field__input--line {
  font-size: 13px;
  padding: 8px 10px;
}

textarea.field__input {
  min-height: 88px;
}

/* ---------- Choice row ---------- */

.choice-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 640px) {
  .choice-row {
    grid-template-columns: 1fr;
  }
}

.choice {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.choice__label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.choice__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.choice__label-row .choice__label {
  flex: 1;
  min-width: 0;
}

.choice__info {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted-2, var(--muted));
  cursor: help;
  transition: color 0.15s, background 0.15s;
}

.choice__info:hover {
  color: var(--text);
  background: var(--surface-2, rgba(15, 23, 42, 0.06));
}

.choice__info:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.choice__select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

select.choice__select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

.choice__select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

@media (hover: hover) and (pointer: fine) {
  .choice__info[data-tooltip] {
    position: relative;
    z-index: 0;
  }

  .choice__info[data-tooltip]:hover,
  .choice__info[data-tooltip]:focus-visible {
    z-index: 3;
  }

  .choice__info[data-tooltip]:hover::after,
  .choice__info[data-tooltip]:focus-visible::after {
    content: attr(data-tooltip);
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    left: auto;
    width: max-content;
    max-width: min(18rem, calc(100vw - 2rem));
    padding: 7px 9px;
    border-radius: var(--radius-sm);
    background: var(--panel);
    border: 1px solid var(--border-strong);
    color: var(--text);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: 0.01em;
    text-transform: none;
    text-align: left;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
    pointer-events: none;
    white-space: normal;
  }
}

/* ---------- Advanced disclosure ---------- */

.advanced {
  border-top: 1px dashed var(--border);
  padding-top: 14px;
}

.advanced__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.advanced__toggle::-webkit-details-marker {
  display: none;
}

.advanced__toggle:hover {
  color: var(--text);
}

.advanced__caret {
  transition: transform 0.15s ease;
  font-size: 10px;
  color: var(--muted-2);
}

details[open] > summary .advanced__caret {
  transform: rotate(180deg);
}

.advanced__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

@media (max-width: 640px) {
  .advanced__grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Primary button ---------- */

.form__footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: var(--text);
  color: var(--brand-white);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

.primary-btn:hover {
  background: var(--brand-black);
}

.primary-btn:active {
  transform: translateY(1px);
}

.primary-btn__arrow {
  transition: transform 0.15s ease;
}

.primary-btn:hover .primary-btn__arrow {
  transform: translateX(2px);
}

/* ---------- Progress card (status + site rows) ---------- */

.card--progress {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress__status {
  font-size: 13px;
  color: var(--text);
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress__status::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--accent-border);
  border-top-color: var(--accent);
  animation: spin 0.85s linear infinite;
  flex-shrink: 0;
}

.progress__status[data-final="done"]::before {
  border: 2px solid var(--brand-lime);
  border-top-color: var(--brand-lime);
  animation: none;
}

.progress__status[data-final="error"]::before {
  border: 2px solid var(--accent);
  border-top-color: var(--accent);
  animation: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Per-URL site chips ---------- */

.sites {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.site {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  font-size: 12px;
  min-width: 0;
}

.site__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted-2);
  font-size: 11px;
}

.site[data-state="working"] .site__icon {
  color: var(--accent);
  background: var(--accent-soft);
  position: relative;
}

.site[data-state="working"] .site__icon::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-border);
  border-top-color: var(--accent);
  animation: spin 0.85s linear infinite;
}

.site[data-state="ok"] .site__icon {
  background: var(--ok-soft);
  color: var(--brand-black);
}

.site[data-state="error"] .site__icon {
  background: var(--err-soft);
  color: var(--err);
}

.site[data-state="warn"] .site__icon {
  background: var(--warn-soft);
  color: var(--warn);
}

.site__url {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.site__detail {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.site__error {
  flex-basis: 100%;
  color: var(--err);
  font-size: 11px;
  padding-left: 28px;
  margin-top: 2px;
}

/* ---------- Answer card ---------- */

.card--answer {
  box-shadow: var(--shadow-lg);
}

.answer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.answer-head__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.answer {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.answer.answer--rich h1,
.answer.answer--rich h2,
.answer.answer--rich h3,
.answer.answer--rich h4 {
  margin: 1.1em 0 0.4em;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.answer.answer--rich h1 {
  font-size: 1.3em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

.answer.answer--rich h2 {
  font-size: 1.15em;
}

.answer.answer--rich h3 {
  font-size: 1.02em;
  color: var(--link);
}

.answer.answer--rich p {
  margin: 0.6em 0;
}

.answer.answer--rich p:first-child {
  margin-top: 0;
}

.answer.answer--rich ul,
.answer.answer--rich ol {
  margin: 0.5em 0 0.7em;
  padding-left: 1.35em;
}

.answer.answer--rich li {
  margin: 0.25em 0;
}

.answer.answer--rich strong {
  font-weight: 700;
}

.answer.answer--rich blockquote {
  margin: 0.7em 0;
  padding: 0.35em 0 0.35em 0.9em;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--muted);
  border-radius: 0 6px 6px 0;
}

.answer.answer--rich code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.answer.answer--rich pre {
  margin: 0.7em 0;
  padding: 0.8em 1em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: auto;
  font-size: 0.88em;
  line-height: 1.5;
}

.answer.answer--rich pre code {
  background: none;
  border: none;
  padding: 0;
}

.answer.answer--rich a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.answer.answer--rich table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.7em 0;
  font-size: 0.94em;
}

.answer.answer--rich th,
.answer.answer--rich td {
  border: 1px solid var(--border);
  padding: 0.45em 0.6em;
  text-align: left;
  vertical-align: top;
}

.answer.answer--rich th {
  background: var(--surface);
  font-weight: 600;
}

.answer pre.answer-json {
  margin: 0;
  padding: 0.85em 1em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre;
}

/* ---------- Run details disclosure ---------- */

.run-details {
  margin-top: 18px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}

.run-details__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.run-details__toggle::-webkit-details-marker {
  display: none;
}

.run-details__toggle:hover {
  color: var(--text);
}

.run-details__body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}

.run-details__section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.run-details__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.strategy {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 11px;
}

.strategy__kv {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.strategy__notes {
  flex-basis: 100%;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  color: var(--muted);
  font-size: 11px;
  white-space: pre-wrap;
}

/* ---------- Login ---------- */

.card--login {
  padding: 22px 24px;
}

.login-lead {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.login-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--err-border);
  background: var(--err-soft);
  color: var(--err);
  font-size: 13px;
}

.login-actions {
  display: flex;
  justify-content: stretch;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.google-btn:hover {
  border-color: var(--text);
  background: var(--surface);
}

.google-btn__icon {
  display: inline-flex;
  flex-shrink: 0;
}

.debug {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  max-height: 340px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ===================================================================== */
/*  Chat-shell layout (three-column: history | chat | advisory)          */
/* ===================================================================== */

body.chat-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.chat-topbar__left,
.chat-topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-topbar__title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.chat-topbar__sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.chat-topbar__email {
  font-size: 12px;
  color: var(--muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--text);
}

.icon-btn--ghost {
  border-color: transparent;
  background: transparent;
}

.icon-btn--ghost:hover {
  background: var(--surface);
}

.icon-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.icon-btn__chevron {
  display: inline-block;
  font-size: 20px;
  line-height: 1;
  font-weight: 600;
  transform: translateY(-1px);
}

/* Three-column grid ----------------------------------------------------- */

.chat-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 340px;
  min-height: 0;
}

/* Pin columns so hidden sidebars (display:none) do not re-flow main into a 0px track. */
.chat-layout > .chat-sidebar--left {
  grid-column: 1;
  grid-row: 1;
}

.chat-layout > .chat-main {
  grid-column: 2;
  grid-row: 1;
}

.chat-layout > .chat-sidebar--right {
  grid-column: 3;
  grid-row: 1;
}

.chat-layout[data-left-collapsed="true"] {
  grid-template-columns: 0 minmax(0, 1fr) 340px;
}

.chat-layout[data-right-collapsed="true"] {
  grid-template-columns: 280px minmax(0, 1fr) 0;
}

.chat-layout[data-left-collapsed="true"][data-right-collapsed="true"] {
  grid-template-columns: 0 minmax(0, 1fr) 0;
}

@media (max-width: 1100px) {
  .chat-layout {
    grid-template-columns: 240px minmax(0, 1fr) 300px;
  }
  .chat-layout[data-left-collapsed="true"] {
    grid-template-columns: 0 minmax(0, 1fr) 300px;
  }
  .chat-layout[data-right-collapsed="true"] {
    grid-template-columns: 240px minmax(0, 1fr) 0;
  }
}

@media (max-width: 820px) {
  .chat-layout,
  .chat-layout[data-left-collapsed="true"],
  .chat-layout[data-right-collapsed="true"] {
    grid-template-columns: minmax(0, 1fr);
  }
  .chat-layout > .chat-sidebar--left,
  .chat-layout > .chat-main,
  .chat-layout > .chat-sidebar--right {
    grid-column: 1;
    grid-row: auto;
  }
  .chat-sidebar {
    position: fixed;
    top: 56px;
    bottom: 0;
    width: min(320px, 90vw);
    z-index: 20;
    transform: translateX(-105%);
  }
  .chat-sidebar--right {
    right: 0;
    transform: translateX(105%);
  }
  .chat-layout[data-left-open="true"] .chat-sidebar--left {
    transform: translateX(0);
  }
  .chat-layout[data-right-open="true"] .chat-sidebar--right {
    transform: translateX(0);
  }
}

/* Sidebars -------------------------------------------------------------- */

.chat-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px 14px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  transition: transform 0.2s ease;
  min-height: 0;
}

.chat-sidebar--right {
  border-right: none;
  border-left: 1px solid var(--border);
}

.chat-layout[data-left-collapsed="true"] .chat-sidebar--left,
.chat-layout[data-right-collapsed="true"] .chat-sidebar--right {
  display: none;
}

.chat-sidebar__section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-sidebar__section--profile {
  border-top: 1px dashed var(--border);
  padding-top: 14px;
}

.chat-sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-sidebar__label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chat-sidebar__label--sub {
  letter-spacing: 0.04em;
}

.chat-sidebar__sub {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-sidebar__sub[hidden] {
  display: none;
}

/* History list ---------------------------------------------------------- */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 40vh;
  overflow-y: auto;
}

.history-item {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 6px 6px 10px;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 6px;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
  position: relative;
}

.history-item:hover {
  background: var(--surface);
}

.history-item[aria-current="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.history-item__title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}

.history-item__meta {
  font-size: 11px;
  color: var(--muted-2);
}

.history-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 10px;
}

/* Personas -------------------------------------------------------------- */

.chat-sidebar__count {
  font-weight: 500;
  color: var(--muted-2);
  font-size: 11px;
  margin-left: 6px;
}

.chat-sidebar__help {
  font-size: 11px;
  color: var(--muted-2);
  margin: 2px 0 8px;
  line-height: 1.4;
}

.persona-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}

.persona-list__empty {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 10px;
  line-height: 1.4;
}

.persona-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.persona-item:hover {
  border-color: var(--accent);
}

.persona-item[aria-selected="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.persona-item__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

.persona-item__desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.persona-item__edit {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--muted-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 2px 6px;
  cursor: pointer;
}

.persona-item__edit:hover {
  color: var(--text);
  border-color: var(--border);
}

.persona-form[hidden] {
  display: none;
}

.persona-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-2, transparent);
}

.persona-form__actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ghost-btn--danger {
  color: #b14a55;
  border-color: #e2b5bb;
  margin-left: auto;
}

.ghost-btn--danger:hover {
  color: #fff;
  background: #b14a55;
  border-color: #b14a55;
}

.primary-btn--sm {
  font-size: 12px;
  padding: 6px 12px;
}

/* Advisory meta --------------------------------------------------------- */

.advisory-meta {
  font-size: 12px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.advisory-meta__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.advisory-meta__row {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 8px;
  align-items: baseline;
  margin: 0;
}

.advisory-meta__label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.5;
  margin: 0;
}

.advisory-meta__value {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.4;
  margin: 0;
  word-break: break-word;
}

.advisory-meta__quote {
  display: block;
  font-style: italic;
  color: var(--muted-2, var(--muted));
  padding-left: 8px;
  border-left: 2px solid var(--border-strong);
  line-height: 1.45;
}

.advisory-meta__links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.advisory-meta__link {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.advisory-meta__link:hover {
  text-decoration: underline;
}

.advisory-meta__divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0 2px;
}

.advisory-meta__actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-start;
}

/* Legacy class — kept for any in-flight markup; the new layout replaces it. */
.advisory-meta__urls {
  color: var(--text);
  word-break: break-all;
}

.choice-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

@media (max-width: 640px) {
  .choice-stack {
    grid-template-columns: 1fr;
  }
}

/* Center chat main ------------------------------------------------------ */

.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  position: relative;
  /* Let body.chat-shell carry the page tint so the scroll column can fill
     edge-to-edge; the composer is overlaid (absolute) instead of a second row. */
  background: transparent;
}

.chat-timeline {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* Room for the floating composer so the last messages scroll above it. */
  padding: 28px 32px
    max(9rem, calc(5.75rem + env(safe-area-inset-bottom, 0px)));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.chat-empty {
  max-width: 560px;
  margin: 10vh auto 0;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.chat-empty__title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.chat-empty__body {
  font-size: 14px;
  margin: 0 0 12px;
  line-height: 1.55;
}

.chat-empty__hint {
  font-size: 12px;
  margin: 0;
  color: var(--muted-2);
}

/* Chat turns ------------------------------------------------------------ */

.chat-turn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 820px;
  align-self: stretch;
}

.chat-turn--user {
  align-self: flex-end;
  max-width: 640px;
}

.chat-turn__role {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chat-turn--user .chat-turn__role {
  text-align: right;
}

.chat-bubble {
  border-radius: 16px;
  padding: 14px 16px;
  line-height: 1.55;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  overflow-wrap: anywhere;
}

.chat-turn--user .chat-bubble {
  background: var(--accent);
  color: var(--brand-white);
  border-bottom-right-radius: 6px;
}

.chat-turn--assistant .chat-bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 6px;
}

.chat-bubble .answer--rich :first-child { margin-top: 0; }
.chat-bubble .answer--rich :last-child { margin-bottom: 0; }

.chat-turn__actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.chat-turn--user .chat-turn__actions {
  justify-content: flex-end;
}

/* Composer -------------------------------------------------------------- */

.chat-composer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  padding: 6px 24px max(10px, env(safe-area-inset-bottom, 0px));
  background: transparent;
}

.chat-composer__form {
  max-width: 860px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 6px 8px;
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.04),
    0 18px 44px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-composer__row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-composer__input {
  flex: 1;
  min-height: 32px;
  max-height: 200px;
  border: none;
  resize: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  padding: 6px 4px;
  overflow-y: auto;
}

.chat-composer__urls {
  border-bottom: 1px dashed var(--border);
  padding-bottom: 8px;
}

.chat-composer__status {
  font-size: 11px;
  color: var(--muted);
  min-height: 14px;
  padding: 0 4px;
}

.chat-composer__status[data-state="error"] {
  color: #b14a55;
}

/* Progress / run details in the new shell ------------------------------- */

.chat-timeline .card--progress {
  margin: 0;
  max-width: 820px;
  align-self: stretch;
}

/* Centered advisory creation form --------------------------------------- */

.advisory-create {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 24px 48px;
  overflow-y: auto;
}

.advisory-create[hidden] {
  display: none;
}

.advisory-create__inner {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.advisory-create__header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
}

.advisory-create__title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.advisory-create__subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* Right-sidebar empty state (shown before any advisory is created). */
.chat-sidebar__empty {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  padding: 8px 2px 0;
}

.advisory-technical {
  font-size: 11px;
  color: var(--text);
  line-height: 1.45;
  padding: 0 2px 10px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 10px;
}

.advisory-technical[hidden] {
  display: none !important;
}

.advisory-technical .advisory-meta__list {
  gap: 6px;
}

.advisory-technical .advisory-meta__label {
  font-size: 10px;
}

.advisory-technical .advisory-meta__value {
  font-size: 11px;
}

.advisory-technical__notes {
  margin: 8px 0 0;
  padding: 8px 0 0;
  border-top: 1px dashed var(--border);
  font-size: 10px;
  color: var(--muted-2);
  white-space: pre-wrap;
}

.advisory-meta__muted {
  color: var(--muted);
  font-style: normal;
}

.advisory-meta__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
  margin-bottom: 8px;
}

/* History item with kebab menu ------------------------------------------ */

.history-item__body {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
}

.history-item__kebab {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.history-item__kebab:hover,
.history-item__kebab[aria-expanded="true"] {
  background: var(--panel-alt, rgba(0, 0, 0, 0.05));
  color: var(--text);
}

/* Rendered as a portal on <body> so the sidebar's overflow never clips it. */
.history-menu {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9999;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  padding: 4px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.history-menu[hidden] {
  display: none;
}

.history-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
}

.history-menu__item:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.history-menu__item--danger {
  color: #b14a55;
}

.history-menu__item--danger:hover {
  background: rgba(177, 74, 85, 0.08);
}

