/* ============================================================
   TravelBrain AI — design tokens
   ============================================================ */

:root {
  /* light theme (default) */
  --bg:            #f4f6fb;
  --bg-solid:      #eef1f8;
  --surface:       rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-2:     rgba(255, 255, 255, 0.55);
  --elevated:      rgba(255, 255, 255, 0.92);

  --text:          #131a2a;
  --text-soft:     #4a5568;
  --text-muted:    #7b869c;

  --border:        rgba(19, 26, 42, 0.10);
  --border-strong: rgba(19, 26, 42, 0.18);

  --accent:        #0d9488;
  --accent-2:      #0891b2;
  --accent-soft:   rgba(13, 148, 136, 0.12);
  --accent-text:   #0f766e;
  --amber:         #d97706;
  --violet:        #7c3aed;
  --rose:          #e11d48;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .07), 0 12px 28px rgba(16, 24, 40, .07);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .09), 0 24px 60px rgba(16, 24, 40, .12);

  --blob-1: #14b8a6;
  --blob-2: #6366f1;
  --blob-3: #f59e0b;
  --blob-opacity: .28;
  --grid-color: rgba(19, 26, 42, .045);

  --radius-sm: 10px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --font: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg:            #070b16;
  --bg-solid:      #050810;
  --surface:       rgba(20, 27, 45, 0.62);
  --surface-solid: #111827;
  --surface-2:     rgba(30, 41, 66, 0.45);
  --elevated:      rgba(24, 32, 52, 0.88);

  --text:          #e8edf7;
  --text-soft:     #a9b4c9;
  --text-muted:    #6f7c96;

  --border:        rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);

  --accent:        #2dd4bf;
  --accent-2:      #38bdf8;
  --accent-soft:   rgba(45, 212, 191, 0.14);
  --accent-text:   #5eead4;
  --amber:         #fbbf24;
  --violet:        #a78bfa;
  --rose:          #fb7185;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .38);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);

  --blob-1: #0d9488;
  --blob-2: #4338ca;
  --blob-3: #b45309;
  --blob-opacity: .40;
  --grid-color: rgba(255, 255, 255, .035);
}

/* ============================================================
   base
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

/* The `hidden` attribute must always win. Without this, any class that sets
   `display` (e.g. .modal { display: flex }) silently overrides it, because a
   class selector outranks the user-agent [hidden] rule. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.02em; line-height: 1.25; }
p { margin: 0; }
button { font: inherit; color: inherit; }
svg { width: 1em; height: 1em; display: block; }

::selection { background: var(--accent); color: #04121a; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: content-box; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ============================================================
   ambient background
   ============================================================ */

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: var(--blob-opacity);
  will-change: transform;
}
.blob-1 { width: 46vw; height: 46vw; background: var(--blob-1); top: -12vw; left: -8vw;  animation: drift1 26s ease-in-out infinite; }
.blob-2 { width: 40vw; height: 40vw; background: var(--blob-2); bottom: -14vw; right: -6vw; animation: drift2 32s ease-in-out infinite; }
.blob-3 { width: 30vw; height: 30vw; background: var(--blob-3); top: 40%; left: 55%;      animation: drift3 38s ease-in-out infinite; }

.grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 30%, transparent 78%);
}

@keyframes drift1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(6vw, 5vh) scale(1.14); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-7vw,-6vh) scale(1.1); } }
@keyframes drift3 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-5vw, 7vh) scale(.88); } }

/* ============================================================
   layout
   ============================================================ */

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* ---------------- brand ---------------- */

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: 1; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 11px;
  flex: none;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow-sm);
  font-size: 19px;
}
.brand-text { display: flex; align-items: baseline; gap: 4px; font-size: 17px; letter-spacing: -.03em; }
.brand-text strong { font-weight: 680; }
.brand-text em {
  font-style: normal;
  font-weight: 600;
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 6px;
  color: var(--accent-text);
  background: var(--accent-soft);
}


/* ---------------- api status chip ---------------- */

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 5px 12px 5px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .18s, background .18s;
}
.status:hover { border-color: var(--border-strong); background: var(--elevated); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.status[data-state="ok"]    .status-dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.status[data-state="down"]  .status-dot { background: var(--rose);  box-shadow: 0 0 0 3px rgba(225,29,72,.18); }
.status[data-state="setup"] .status-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(217,119,6,.20); }
.status[data-state="setup"] { color: var(--amber); border-color: rgba(217,119,6,.35); }
.status[data-state="down"]  { color: var(--rose);  border-color: rgba(225,29,72,.32); }
.status[data-state="checking"] .status-dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

/* ---------------- main ---------------- */

.main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, var(--surface), transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* ---------------- conversation ---------------- */

.conversation {
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 0 24px;
}

.messages {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---------------- hero ---------------- */

.hero {
  max-width: 880px;
  margin: 0 auto;
  padding: 8vh 0 24px;
  text-align: center;
  animation: rise .6s cubic-bezier(.22,1,.36,1) both;
}
.hero.is-hidden { display: none; }

.grad {
  background: linear-gradient(110deg, var(--accent), var(--accent-2) 55%, var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  max-width: 560px;
  margin: 16px auto 0;
  font-size: 15.5px;
  color: var(--text-soft);
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 34px;
  text-align: left;
}
.suggestion {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  text-align: left;
  transition: transform .18s cubic-bezier(.22,1,.36,1), border-color .18s, box-shadow .18s;
}
.suggestion:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.suggestion-emoji { font-size: 24px; flex: none; }
.suggestion-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.suggestion-body strong { font-size: 14px; font-weight: 600; }
.suggestion-body small { font-size: 12px; color: var(--text-muted); }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------------- messages ---------------- */

.msg { display: flex; flex-direction: column; animation: rise .45s cubic-bezier(.22,1,.36,1) both; }

.msg-user { align-items: flex-end; }
.bubble-user {
  max-width: min(600px, 88%);
  padding: 12px 17px;
  border-radius: var(--radius-lg) var(--radius-lg) 5px var(--radius-lg);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04121a;
  font-weight: 500;
  box-shadow: 0 8px 24px -12px var(--accent);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* result card */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.card-avatar {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  flex: none;
  border-radius: 9px;
  font-size: 16px;
  color: #04121a;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.card-title { flex: 1; min-width: 0; }
.card-title strong { display: block; font-size: 13.5px; font-weight: 600; }
.card-title small { font-size: 11.5px; color: var(--text-muted); }
.card-tools { display: flex; gap: 4px; flex: none; }

.card-body { padding: 20px 22px 22px; animation: fade .25s ease both; }

/* ---------------- progress bar ---------------- */

.progress-card { padding: 16px 20px 18px; }

.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.progress-label {
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex: none;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.progress-meta b { color: var(--accent-text); font-weight: 650; }
.progress-sep { opacity: .45; }

.progress-track {
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width .3s linear;
}

.error-card {
  border-color: rgba(225, 29, 72, .35);
  background: linear-gradient(var(--surface), var(--surface));
}
.error-body { display: flex; gap: 12px; padding: 16px 18px; }
.error-body .error-ico { color: var(--rose); font-size: 20px; flex: none; margin-top: 2px; }
.error-body strong { display: block; font-size: 13.5px; margin-bottom: 3px; }
.error-body p { font-size: 13px; color: var(--text-soft); overflow-wrap: anywhere; }
.error-body code {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12px;
  overflow-x: auto;
}

/* ---------------- composer ---------------- */

.composer-wrap {
  padding: 12px 24px 16px;
  border-top: 1px solid var(--border);
  background: linear-gradient(to top, var(--surface) 60%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.composer {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 880px;
  margin: 0 auto;
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--elevated);
  box-shadow: var(--shadow-md);
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-md), 0 0 0 4px var(--accent-soft);
}

.composer textarea {
  flex: 1;
  min-width: 0;
  max-height: 200px;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.55;
  resize: none;
  outline: none;
}
.composer textarea::placeholder { color: var(--text-muted); }

.composer-tool { flex: none; margin-bottom: 3px; }
.composer-tool.is-on { color: var(--accent-text); background: var(--accent-soft); }

.send-btn {
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
}
.send-btn .spinner { display: none; }
.send-btn.is-busy .ico-send { display: none; }
.send-btn.is-busy .spinner {
  display: block;
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,.28);
  border-top-color: currentColor;
  animation: spin .7s linear infinite;
}

/* ---------------- trip builder ---------------- */

.builder {
  max-width: 880px;
  margin: 0 auto 10px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--elevated);
  box-shadow: var(--shadow-md);
  animation: rise .28s cubic-bezier(.22,1,.36,1) both;
}
.builder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 11px;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-sm { max-width: 110px; }
.field > span, .field-span {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input::placeholder { color: var(--text-muted); }
[data-theme="dark"] .field input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.75); }

.builder-interests { margin-top: 14px; display: flex; flex-direction: column; gap: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-soft);
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 550;
}

.builder-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s, filter .15s, background .15s, border-color .15s;
}
.btn:active { transform: scale(.97); }
.btn svg { font-size: 15px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04121a;
  box-shadow: 0 6px 18px -8px var(--accent);
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-soft { background: var(--accent-soft); color: var(--accent-text); border-color: var(--border); }
.btn-soft:hover { border-color: var(--accent); }

.btn-ghost { background: transparent; color: var(--text-soft); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 8px; }

/* busy state for text buttons (the settings save button) */
.btn .spinner { display: none; }
.btn.is-busy .btn-label { opacity: .55; }
.btn.is-busy .spinner {
  display: block;
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,.28);
  border-top-color: currentColor;
  animation: spin .7s linear infinite;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  font-size: 17px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.icon-btn.sm { width: 28px; height: 28px; font-size: 14px; border-radius: 7px; }

[data-theme="dark"] .ico-sun  { display: block; }
[data-theme="dark"] .ico-moon { display: none; }
[data-theme="light"] .ico-sun  { display: none; }
[data-theme="light"] .ico-moon { display: block; }

/* ---------------- markdown output ---------------- */

.md { font-size: 14.5px; color: var(--text-soft); overflow-wrap: break-word; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }

.md h1, .md h2, .md h3, .md h4 {
  color: var(--text);
  margin: 26px 0 10px;
  letter-spacing: -.02em;
}
.md h1 { font-size: 21px; }
.md h2 {
  font-size: 18px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
}
.md h3 { font-size: 15.5px; }
.md h4 { font-size: 14px; color: var(--text-soft); }

.md p { margin: 0 0 12px; }
.md strong { color: var(--text); font-weight: 650; }
.md em { font-style: italic; }
.md del { opacity: .6; }

.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin-bottom: 5px; }
.md li::marker { color: var(--accent); }
.md ul ul, .md ol ol, .md ul ol, .md ol ul { margin: 5px 0 0; }

.md a { color: var(--accent-text); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
.md a:hover { border-bottom-color: currentColor; }

.md blockquote {
  margin: 0 0 12px;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}

.md hr { margin: 20px 0; border: 0; border-top: 1px solid var(--border); }

.md code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: .87em;
  color: var(--accent-text);
}
.md pre {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow-x: auto;
}
.md pre code { padding: 0; border: 0; background: none; color: var(--text-soft); font-size: 12.5px; line-height: 1.6; }

.md-table-wrap { overflow-x: auto; margin: 0 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.md table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.md th, .md td { padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--border); }
.md th { background: var(--surface-2); color: var(--text); font-weight: 600; white-space: nowrap; }
.md tr:last-child td { border-bottom: 0; }

.md-empty {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  transform: translate(-50%, 16px);
  padding: 10px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  background: var(--elevated);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 550;
  opacity: 0;
  transition: opacity .22s, transform .22s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   responsive
   ============================================================ */

@media (max-width: 900px) {
  .topbar { padding: 10px 14px; gap: 8px; }
  .conversation { padding: 0 16px; }
  .composer-wrap { padding: 10px 14px 14px; }
  .hero { padding-top: 5vh; }
  .card-body { padding: 16px 16px 18px; }
  .field-sm { max-width: none; }

  /* keep the topbar to one line on small screens */
  .topbar .btn-sm .btn-label { display: none; }
  .topbar .btn-sm { padding: 8px; }
  .status-text { display: none; }
  .status { padding: 7px; }
}

@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .suggestions { grid-template-columns: 1fr; }
  .bubble-user { max-width: 92%; }
  .brand-text em { display: none; }
}

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

@media print {
  .aurora, .topbar, .gate, .composer-wrap, .progress-card, .card-tools,
  .modal, .modal-scrim { display: none !important; }
  body { overflow: visible; background: #fff; }
  .layout, .main { display: block; height: auto; }
  .conversation { overflow: visible; }
  .card { border: 0; box-shadow: none; background: none; }
}


/* ============================================================
   settings modal
   ============================================================ */

.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade .18s ease both;
}

.modal {
  position: fixed;
  z-index: 61;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  animation: rise .28s cubic-bezier(.22,1,.36,1) both;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-heading { flex: 1; min-width: 0; }
.modal-head h2 { font-size: 16.5px; }
.modal-head p { margin-top: 4px; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.cred-loading { font-size: 13px; color: var(--text-muted); }

.cred { display: flex; flex-direction: column; gap: 7px; }

.cred-head { display: flex; align-items: center; gap: 10px; }
.cred-label { font-size: 13.5px; font-weight: 600; flex: 1; min-width: 0; }

.badge {
  flex: none;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  border: 1px solid transparent;
}
.badge-env     { color: #16a34a; background: rgba(34,197,94,.12);  border-color: rgba(34,197,94,.30); }
.badge-session { color: var(--accent-text); background: var(--accent-soft); border-color: rgba(13,148,136,.30); }
.badge-missing { color: var(--amber); background: rgba(217,119,6,.12); border-color: rgba(217,119,6,.32); }

.cred-hint { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }

.cred-field { display: flex; align-items: center; gap: 6px; }

.cred-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
}
.cred-input::placeholder { font-family: var(--font); color: var(--text-muted); }
.cred-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.cred-error {
  font-size: 12px;
  color: var(--rose);
  line-height: 1.5;
  word-break: break-word;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }


/* ============================================================
   setup gate - shown in place of the hero when no keys are live
   ============================================================ */

.gate {
  max-width: 520px;
  margin: 0 auto;
  padding: 8vh 0 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  animation: rise .5s cubic-bezier(.22,1,.36,1) both;
}

.gate-icon {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 16px;
  font-size: 26px;
  color: var(--amber);
  background: rgba(217, 119, 6, .12);
  border: 1px solid rgba(217, 119, 6, .30);
}

.gate h2 { font-size: clamp(24px, 4vw, 32px); letter-spacing: -.03em; }

.gate-sub {
  font-size: 14.5px;
  color: var(--text-soft);
  line-height: 1.65;
  max-width: 46ch;
}

.gate-creds {
  width: 100%;
  margin-top: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: left;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.gate-actions { display: flex; justify-content: center; width: 100%; }
.gate-actions .btn { min-width: 190px; justify-content: center; }

.gate-foot {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 44ch;
}
.gate-foot code {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* the composer is inert until at least one live API is configured */
.composer-wrap.is-locked { opacity: .5; pointer-events: none; }
