:root {
  color-scheme: light;

  /* Brand palette — MTP Intelligence Platform */
  --brand-black: #000000;
  --brand-white: #ffffff;
  --brand-lime: #cbe500;
  --brand-lime-dark: #7ba100;
  --brand-blue: #43729a;
  --brand-aqua: #94ffef;
  --brand-purple: #a593ff;
  --brand-purple-dark: #514399;

  /* Neutrals — warm off-white chrome */
  --bg: #f4f2ef;
  --panel: var(--brand-white);
  --surface: #faf8f5;
  --border: #e4e0d8;
  --border-strong: #b8b2a8;
  --text: var(--brand-black);
  --muted: #5c574e;
  --muted-2: #8a8478;

  /* Accents: purple for focus/selection; lime for progress/success */
  --accent: var(--brand-purple);
  --accent-soft: rgba(165, 147, 255, 0.14);
  --accent-border: rgba(165, 147, 255, 0.42);
  --link: var(--brand-blue);

  /* Success → lime; Error / warn → brand tints */
  --ok: var(--brand-black);
  --ok-soft: rgba(203, 229, 0, 0.28);
  --ok-border: rgba(123, 161, 0, 0.55);
  --err: var(--brand-black);
  --err-soft: rgba(165, 147, 255, 0.1);
  --err-border: rgba(81, 67, 153, 0.45);
  --warn: var(--brand-blue);
  --warn-soft: rgba(67, 114, 154, 0.11);

  --radius: 16px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.08);

  /* Typography scale */
  --font-display: 1.75rem;
  --font-header: 1.25rem;
  --font-body: 0.9375rem;
  --font-caption: 0.8125rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--font-body);
  line-height: 1.45;
  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;
}

/* Explicit display on .primary-btn overrides the UA [hidden] rule. */
.primary-btn[hidden],
.ghost-btn[hidden],
.sidebar-new-btn[hidden],
.sidebar-text-btn[hidden] {
  display: none !important;
}

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

.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 ---------- */

.login-page {
  min-height: 100%;
  background:
    radial-gradient(
      1200px 600px at 12% -10%,
      rgba(203, 229, 0, 0.18),
      transparent 55%
    ),
    radial-gradient(
      900px 500px at 95% 0%,
      rgba(148, 255, 239, 0.22),
      transparent 50%
    ),
    linear-gradient(180deg, #f7f5f1 0%, var(--bg) 45%, #ebe8e2 100%);
}

.login-shell {
  width: min(440px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 100%;
  padding: 56px 0 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.login-brand__name {
  font-size: clamp(1.85rem, 4.5vw, 2.35rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}

.login-brand__tagline {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.4;
  color: var(--muted);
}

.login-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 22px 20px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

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

.login-contact {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

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

.login-contact a:hover {
  color: var(--brand-purple-dark);
}

.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;
  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 {
  color: var(--brand-purple-dark);
  font-size: 18px;
  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;
  --left-sidebar-width: 280px;
  grid-template-columns: var(--left-sidebar-width) 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: var(--left-sidebar-width) 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: var(--left-sidebar-width) 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: var(--left-sidebar-width) 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%);
  }
  /* On mobile, overlays use transform — don't hard-hide via collapsed. */
  .chat-layout[data-left-collapsed="true"] .chat-sidebar--left,
  .chat-layout[data-right-collapsed="true"] .chat-sidebar--right {
    display: flex;
  }
  .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: 18px;
  padding: 12px 10px 20px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: transform 0.2s ease;
  min-height: 0;
}

.chat-sidebar--left {
  /* Single scroll container — lists inside must not nest overflow. */
  position: relative;
  gap: 16px;
  background: color-mix(in srgb, var(--bg) 55%, var(--panel));
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.chat-sidebar__resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  z-index: 5;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
}

.chat-sidebar__resize::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 2px;
  border-radius: 1px;
  background: transparent;
  transition: background 120ms ease;
}

.chat-sidebar__resize:hover::after,
.chat-sidebar__resize:focus-visible::after,
.chat-layout[data-left-resizing="true"] .chat-sidebar__resize::after {
  background: var(--accent, #a593ff);
}

.chat-sidebar__resize:focus-visible {
  outline: none;
}

.chat-layout[data-left-resizing="true"] {
  cursor: col-resize;
  user-select: none;
}

.chat-layout[data-left-resizing="true"] .chat-main,
.chat-layout[data-left-resizing="true"] .chat-sidebar--right {
  pointer-events: none;
}

@media (max-width: 820px) {
  .chat-sidebar__resize {
    display: none;
  }
}

.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__top {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 2px 0 2px;
  background: color-mix(in srgb, var(--bg) 55%, var(--panel));
}

.sidebar-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: var(--brand-black);
  color: var(--brand-white);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease;
}

.sidebar-new-btn:hover {
  background: var(--brand-purple-dark);
}

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

.sidebar-new-btn__icon {
  font-size: 16px;
  line-height: 1;
  font-weight: 500;
}

.sidebar-text-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 4px;
  border-radius: 6px;
  cursor: pointer;
}

.sidebar-text-btn:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.chat-sidebar__section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.chat-sidebar__section--personas {
  padding-top: 6px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

.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;
  padding: 0 6px 2px;
}

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

.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 — dense, no nested scroll -------------------------- */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.history-item {
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 7px 6px 7px 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  color: var(--text);
  transition: background 0.12s;
  position: relative;
  min-width: 0;
}

.history-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

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

.history-item__title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item__meta {
  font-size: 11px;
  color: var(--muted-2);
  flex-shrink: 0;
  white-space: nowrap;
}

.history-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 8px;
  line-height: 1.4;
}

.history-show-all {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted-2);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  padding: 6px 8px;
  margin-top: 2px;
  border-radius: 6px;
  cursor: pointer;
}

.history-show-all:hover {
  color: var(--muted);
  background: rgba(0, 0, 0, 0.03);
}

/* Personas — list rows, not cards -------------------------------- */

.chat-sidebar__count {
  font-weight: 500;
  color: var(--muted-2);
  font-size: 11px;
  margin-left: 4px;
  text-transform: none;
  letter-spacing: 0;
}

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

.persona-list,
.client-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

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

.persona-item,
.client-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 7px 6px 7px 8px;
  background: transparent;
  cursor: pointer;
  transition: background 120ms ease;
  min-width: 0;
}

.persona-item:hover,
.client-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.persona-item[aria-selected="true"] {
  background: var(--accent-soft);
}

.persona-item__body,
.client-item__body {
  min-width: 0;
  flex: 1 1 auto;
}

.persona-item__title,
.client-item__title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.persona-item__desc,
.client-item__desc {
  font-size: 11px;
  color: var(--muted-2);
  margin-top: 1px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.persona-item__edit,
.client-item__edit {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--muted-2);
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 2px 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s, background 0.12s;
}

.persona-item:hover .persona-item__edit,
.persona-item:focus-within .persona-item__edit,
.client-item:hover .client-item__edit,
.client-item:focus-within .client-item__edit {
  opacity: 1;
}

.persona-item__edit:hover,
.client-item__edit:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.06);
}


.wizard-client-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.wizard-client-picker__empty {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  width: 100%;
}

.wizard-client-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
  user-select: none;
}

.wizard-client-chip:hover {
  background: rgba(0, 0, 0, 0.03);
}

.wizard-client-chip[aria-pressed="true"] {
  border-color: var(--accent, #514399);
  background: var(--accent-soft);
}

.wizard-client-chip__name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wizard-client-chip__host {
  color: var(--muted-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.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;
  padding: 28px 32px 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/*
 * Flex scroll containers often ignore padding-bottom when computing
 * scrollHeight. A trailing spacer keeps the last turn (and Copy) above
 * the floating composer.
 */
.chat-timeline::after {
  content: "";
  flex: 0 0 auto;
  height: max(10rem, calc(8.5rem + env(safe-area-inset-bottom, 0px)));
  pointer-events: none;
}

.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: row;
  align-items: baseline;
  gap: 8px;
  min-height: 0;
}

.history-item__kebab {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: none;
  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;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}

.history-item:hover .history-item__kebab,
.history-item__kebab[aria-expanded="true"],
.history-item:focus-within .history-item__kebab {
  opacity: 1;
}

.history-item__kebab:hover,
.history-item__kebab[aria-expanded="true"] {
  background: rgba(0, 0, 0, 0.06);
  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);
}

/* ---------- Home empty state ------------------------------------------- */

.home-empty {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 28px;
  overflow-y: auto;
}

.home-empty[hidden] {
  display: none;
}

.home-empty__inner {
  max-width: 420px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.home-empty__title {
  margin: 0;
  font-size: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
}

.home-empty__subtitle {
  margin: 0;
  font-size: var(--font-body);
  color: var(--muted);
  line-height: 1.55;
}

.home-empty__hint {
  margin: 4px 0 0;
  font-size: var(--font-caption);
  color: var(--muted-2);
  line-height: 1.45;
}

/* ---------- Advisory wizard overlay ------------------------------------ */

.wizard-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(2px);
}

.wizard-backdrop[hidden] {
  display: none;
}

.advisory-wizard {
  width: min(560px, 100%);
  max-height: min(90vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  /* Allow flex children to shrink so the body can scroll. */
  min-height: 0;
}

.advisory-wizard__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.advisory-wizard__titles {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.advisory-wizard__eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-lime-dark);
}

.advisory-wizard__title {
  margin: 0;
  font-size: var(--font-header);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.advisory-wizard__close {
  flex-shrink: 0;
}

.wizard-progress {
  padding: 12px 22px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

/* Form spans remaining height: scrollable body + sticky footer. */
.advisory-wizard__form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 0;
  overflow: hidden;
}

.wizard-progress__track {
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.wizard-progress__fill {
  height: 100%;
  width: 33.333%;
  border-radius: 999px;
  background: var(--brand-lime);
  transition: width 0.2s ease;
}

.wizard-progress__steps {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted-2);
}

.wizard-progress__step {
  font-weight: 500;
}

.wizard-progress__step[data-active="true"] {
  color: var(--brand-lime-dark);
  font-weight: 700;
}

.wizard-progress__step[data-done="true"] {
  color: var(--muted);
}

.advisory-wizard__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 22px 16px;
  -webkit-overflow-scrolling: touch;
}

.wizard-step[hidden] {
  display: none;
}

.wizard-step__intro {
  margin: 0 0 14px;
  font-size: var(--font-caption);
  color: var(--muted);
  line-height: 1.5;
}

.wizard-step__error {
  margin: 8px 0 0;
  font-size: 12px;
  color: #b14a55;
}

.wizard-step__error[hidden] {
  display: none;
}

.url-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.url-list__row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.url-list__row .field__input {
  flex: 1 1 auto;
  min-width: 0;
}

.url-list__remove {
  flex-shrink: 0;
}

.url-list__add {
  align-self: flex-start;
  margin-top: 4px;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.prompt-chip {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  line-height: 1.35;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.prompt-chip:hover {
  border-color: var(--brand-purple);
  background: var(--accent-soft);
  color: var(--text);
}

.type-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

@media (max-width: 520px) {
  .type-cards {
    grid-template-columns: 1fr;
  }
}

.type-card {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.type-card:hover {
  border-color: var(--accent-border);
}

.type-card[aria-pressed="true"] {
  border-color: var(--brand-purple);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.type-card__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.type-card__hint {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted-2);
  line-height: 1.35;
}

.choice__hint {
  font-size: 11px;
  color: var(--muted-2);
  line-height: 1.4;
  margin-top: 2px;
}

.debug-toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0 4px;
  grid-column: 1 / -1;
}

.debug-toggle-row input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--brand-purple);
}

.debug-toggle-row__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.debug-toggle-row__label {
  font-size: 12px;
  font-weight: 600;
}

.debug-toggle-row__hint {
  font-size: 11px;
  color: var(--muted-2);
  line-height: 1.4;
}

.advisory-wizard__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.advisory-wizard__foot-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Pulse on right toggle after create */
.icon-btn--pulse {
  animation: icon-pulse 1.4s ease 2;
}

@keyframes icon-pulse {
  0%,
  100% {
    box-shadow: none;
  }
  50% {
    box-shadow: 0 0 0 4px var(--ok-soft);
  }
}

/* Composer persona chip */
.composer-persona {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 2px 8px;
  font-size: 12px;
  color: var(--muted);
}

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

.composer-persona__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-aqua) 35%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--brand-aqua) 55%, var(--border));
  color: var(--text);
  font-weight: 600;
  font-size: 11px;
}

.composer-persona__change {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 11px;
  color: var(--link);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.composer-persona__change:hover {
  color: var(--brand-purple-dark);
}

/* Centered modal overlays (rename, client, persona) */
.entity-dialog {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.32);
}

.entity-dialog[hidden] {
  display: none;
}

.entity-dialog__panel {
  width: min(360px, 100%);
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.entity-dialog__panel--form {
  width: min(440px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
}

.entity-dialog__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.entity-dialog__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.entity-dialog__actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.entity-dialog__actions .ghost-btn--danger {
  margin-right: auto;
  margin-left: 0;
}

.entity-dialog__error {
  font-size: 12px;
  color: #b14a55;
}

.entity-dialog__error[hidden] {
  display: none;
}

.field--toggle {
  margin-top: 2px;
}

.toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__ui {
  flex: 0 0 auto;
  width: 36px;
  height: 20px;
  margin-top: 2px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid var(--border);
  position: relative;
  transition: background 140ms ease, border-color 140ms ease;
}

.toggle__ui::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 140ms ease;
}

.toggle input:checked + .toggle__ui {
  background: var(--brand-purple, #514399);
  border-color: var(--brand-purple, #514399);
}

.toggle input:checked + .toggle__ui::after {
  transform: translateX(16px);
}

.toggle input:focus-visible + .toggle__ui {
  outline: 2px solid var(--accent, #a593ff);
  outline-offset: 2px;
}

.toggle__copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.toggle__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.toggle__hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.client-docs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.client-docs[hidden] {
  display: none;
}

.client-docs__hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.client-docs__dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.02);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.client-docs__dropzone:hover,
.client-docs__dropzone:focus-visible,
.client-docs__dropzone.is-dragover {
  border-color: var(--accent, #a593ff);
  background: rgba(81, 67, 153, 0.06);
  outline: none;
}

.client-docs__dropzone[hidden] {
  display: none;
}

.client-docs__dropzone-label {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.client-docs__browse {
  color: var(--brand-purple, #514399);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.client-docs__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow: auto;
}

.client-docs__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.03);
  font-size: 12px;
}

.client-docs__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
  color: var(--text);
}

.client-docs__meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  text-transform: capitalize;
}

.client-docs__meta[data-status="failed"] {
  color: #b14a55;
}

.client-docs__meta[data-status="ready"] {
  color: #2f6b4f;
}

.client-docs__remove {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
}

.client-docs__remove:hover {
  color: #b14a55;
}

.client-docs__status {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.client-docs__status[data-tone="error"] {
  color: #b14a55;
}

.client-docs__status[hidden] {
  display: none;
}

.client-social {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.client-social[hidden] {
  display: none;
}

.client-social__hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.client-social__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.client-social__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
  text-decoration: none;
  max-width: 100%;
}

.client-social__chip:hover {
  border-color: var(--accent, #a593ff);
}

.client-social__chip-name {
  font-weight: 600;
  text-transform: capitalize;
}

.client-social__chip-meta {
  color: var(--muted);
  font-size: 11px;
  text-transform: capitalize;
}

.client-social__chip-meta[data-status="ready"] {
  color: #2f6b4f;
}

.client-social__chip-meta[data-status="blocked"],
.client-social__chip-meta[data-status="error"] {
  color: #b14a55;
}

.client-social__chip-meta[data-status="pending"],
.client-social__chip-meta[data-status="empty"] {
  color: var(--muted);
}

.client-social__empty {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.client-social__empty[hidden] {
  display: none;
}

.client-item__title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.client-badge {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--brand-purple-dark, #514399);
  background: var(--accent-soft, rgba(165, 147, 255, 0.18));
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.4;
}

.client-badge--shared {
  color: var(--muted-2);
  background: rgba(0, 0, 0, 0.05);
}

.client-item--shared {
  cursor: default;
}

.wizard-client-chip__badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted-2);
  text-transform: uppercase;
}

body.wizard-open {
  overflow: hidden;
}

