/* ═══════════════════════════════════════════════════
   Noushen v11.1
   The awareness is felt, not displayed.
   Warm peach & sand color scheme.
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ─── Tokens ─── */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  /* Warm peach & sand palette — dark variant */
  --bg:           #D4B896;
  --peach:        #CDA47A;
  --peach-dark:   #9E5A2A;
  --peach-light:  #E8D4BE;
  --blush:        #C47A9A;
  --black:        #1A1A1A;
  --black-light:  #2D2D2D;

  /* Remapped stone palette to warm equivalents — deeper */
  --stone-50:     #E8D4BE;
  --stone-100:    #DECCA8;
  --stone-200:    #CBB090;
  --stone-300:    #B8977A;
  --stone-400:    #8C6038;
  --stone-500:    #7A5230;
  --stone-600:    #8C5A30;
  --stone-700:    #704828;
  --stone-800:    #4D3018;
  --stone-900:    #1A1A1A;
  --stone-950:    #0F0F0F;

  --white:        #F5E6D6;
  --true-white:   #FFFFFF;

  /* State palette — warmed, organic */
  --state-baseline:       #D9A57E;
  --state-focused:        #10B981;
  --state-hyperfocused:   #14B8A6;
  --state-flow:           #4B8FFF;
  --state-understimulated:#A375D5;
  --state-fatigued:       #E8A55C;
  --state-overwhelmed:    #F55858;
  --state-degrading:      #FB8C3B;
  --state-volatile:       #E74A6B;
  --state-recovering:     #34D399;

  /* Ambient — the active state color, set via JS */
  --ambient: var(--state-baseline);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}


/* ─── Reset ─── */

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

html {
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--black);
  background: var(--bg);
  overflow: hidden;
}


/* ─── App Shell ─── */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* mobile Safari: accounts for URL bar */
  position: relative;
}


/* ─── Ambient Bar ───
   A thin line at the very top that breathes with the user's state.
   The only overt sign of awareness. Everything else is in the response. */

.ambient-bar {
  height: 3px;
  width: 100%;
  background: var(--ambient);
  opacity: 0.6;
  transition: background 1.2s var(--ease-in-out), opacity 1.2s var(--ease-in-out);
  flex-shrink: 0;
}

.ambient-bar.active {
  opacity: 1;
  height: 3px;
}


/* ─── Header ─── */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

.wordmark {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--black);
}

.wordmark .phase {
  font-weight: 600;
  font-size: 21px;
  color: var(--stone-800);
  margin-left: 8px;
}

nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

nav a {
  font-size: 20px;
  color: var(--black);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

nav a:hover { color: var(--black); }

.user-name {
  font-size: 20px;
  font-weight: 600;
  color: var(--black);
}

.state-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 10px;
  border-radius: 100px;
  border: 1px solid var(--stone-200);
  cursor: pointer;
  transition: border-color 0.3s, background 0.2s;
  user-select: none;
  background: var(--peach-light);
}

.state-pill:hover {
  border-color: var(--peach-dark);
  background: var(--peach);
}

.state-orb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ambient);
  transition: background 1.2s var(--ease-in-out);
  position: relative;
}

/* Subtle glow on the orb */
.state-orb::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--ambient);
  opacity: 0.2;
  filter: blur(3px);
  transition: background 1.2s var(--ease-in-out);
}

.state-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--black-light);
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
  transition: color 0.4s;
}


/* ─── State Detail Panel ─── */

.state-panel-overlay {
  /* Disabled — panel is now a persistent toggle that stays open while typing */
  display: none !important;
}

.state-panel {
  position: fixed;
  top: 60px;
  right: 24px;
  width: 360px;
  background: var(--peach-light);
  border: 1px solid var(--peach-dark);
  border-radius: 14px;
  box-shadow:
    0 4px 6px -1px rgba(0,0,0,0.03),
    0 10px 20px -2px rgba(0,0,0,0.06);
  padding: 24px;
  z-index: 100;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}

.state-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel-title {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--black-light);
}

.panel-profile {
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--ambient);
  transition: color 1.2s var(--ease-in-out);
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.metric + .metric {
  border-top: 1px solid var(--peach);
}

.metric-label {
  font-size: 17px;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--black-light);
}

.metric-val {
  font-size: 22px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--stone-500);
  width: 42px;
  text-align: right;
}

.metric-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.metric-track {
  width: 70px;
  height: 3px;
  background: var(--peach-light);
  border-radius: 2px;
  overflow: hidden;
}

.metric-fill {
  height: 100%;
  background: var(--peach-dark);
  border-radius: 2px;
  transition: width 0.8s var(--ease-out), background 0.8s;
}

/* ─── Temporal Context ─── */

.panel-divider {
  height: 1px;
  background: var(--peach-dark);
  opacity: 0.3;
  margin: 18px 0;
}

.temporal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
}

.temporal-scale {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.temporal-label {
  font-size: 15px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--stone-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.temporal-val {
  font-size: 20px;
  font-family: var(--font-mono);
  color: var(--black);
  font-weight: 600;
}

.temporal-val.trend-accelerating { color: var(--state-focused); }
.temporal-val.trend-decelerating { color: var(--state-fatigued); }
.temporal-val.trend-oscillating { color: var(--state-volatile); }
.temporal-val.trend-stable { color: var(--stone-500); }
.temporal-val.phase-yes { color: var(--state-volatile); }


/* ─── Chat Area ─── */

.chat-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.chat-scroll {
  max-width: 780px;
  margin: 0 auto;
  padding: 36px 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: 100%;
}


/* ─── Empty State ─── */

.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 28px;
  min-height: 400px;
}

.welcome-orb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ambient);
  opacity: 0.15;
  margin-bottom: 36px;
  transition: background 1.2s var(--ease-in-out);
  animation: breathe 4s var(--ease-in-out) infinite;
}

.welcome-mark {
  margin-bottom: 36px;
  opacity: 0.85;
  animation: breathe 4s var(--ease-in-out) infinite;
}

.calibration-track {
  width: 100%;
  height: 4px;
  background: var(--peach, #F5E6D3);
  border-radius: 2px;
  overflow: hidden;
}

.calibration-fill {
  height: 100%;
  width: 0%;
  background: var(--ambient, #a8a29e);
  border-radius: 2px;
  transition: width 0.6s var(--ease-out, ease-out);
}

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.12; }
  50% { transform: scale(1.08); opacity: 0.2; }
}

.welcome h1 {
  font-size: 39px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--black);
  margin-bottom: 14px;
}

.welcome p {
  font-size: 22px;
  line-height: 1.7;
  color: var(--black-light);
  font-weight: 500;
  max-width: 480px;
}

.welcome .subtle {
  font-size: 18px;
  color: var(--stone-800);
  font-weight: 600;
  margin-top: 28px;
  font-family: var(--font-mono);
}


/* ─── Messages ─── */

.msg {
  display: flex;
  flex-direction: column;
  gap: 5px;
  animation: msgIn 0.35s var(--ease-out);
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-user { align-items: flex-end; }
.msg-ai { align-items: flex-start; }

.msg-bubble {
  max-width: 82%;
  padding: 16px 22px;
  font-size: 21px;
  font-weight: 500;
  line-height: 1.6;
  border-radius: 18px;
}

.msg-user .msg-bubble {
  background: var(--black);
  color: var(--true-white);
  border-bottom-right-radius: 4px;
}

.msg-ai .msg-bubble {
  background: var(--peach-light);
  border: 1px solid var(--peach-dark);
  border-bottom-left-radius: 4px;
  color: var(--black);
}

.msg-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 5px;
  height: 22px;
}

.msg-profile {
  font-size: 14px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color 0.4s;
  color: var(--black-light);
}

.msg-words {
  font-size: 14px;
  font-weight: 500;
  color: var(--stone-400);
  font-family: var(--font-mono);
}


/* ─── Streaming indicator ─── */

.dots {
  display: flex;
  gap: 5px;
  padding: 16px 22px;
  background: var(--peach-light);
  border: 1px solid var(--peach-dark);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--peach-dark);
  animation: pulse 1.4s var(--ease-in-out) infinite;
}

.dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
  0%, 70%, 100% { opacity: 0.3; transform: scale(0.85); }
  35% { opacity: 1; transform: scale(1); }
}


/* ─── Markdown in AI messages ─── */

.msg-bubble p { margin-bottom: 0.6em; }
.msg-bubble p:last-child { margin-bottom: 0; }

.msg-bubble ul,
.msg-bubble ol {
  padding-left: 1.4em;
  margin: 0.4em 0;
}

.msg-bubble li { margin-bottom: 0.2em; }

.msg-bubble code {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  background: var(--peach);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--black);
}

.msg-bubble pre {
  background: var(--true-white);
  border: 1px solid var(--peach);
  padding: 16px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 0.6em 0;
  font-size: 18px;
  color: var(--black);
}

.msg-bubble pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.msg-bubble strong { font-weight: 700; }
.msg-bubble em { font-style: italic; }


/* ─── Input Area ─── */

.input-area {
  flex-shrink: 0;
  padding: 0 28px 28px;
}

.input-container {
  max-width: 780px;
  margin: 0 auto;
  position: relative;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--peach-light);
  border: 1px solid var(--peach-dark);
  border-radius: 16px;
  padding: 5px 5px 5px 22px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-row:focus-within {
  border-color: var(--peach);
  box-shadow: 0 0 0 3px rgba(242, 201, 163, 0.1);
}

textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--black);
  padding: 12px 0;
  min-height: 30px;
  max-height: 180px;
  background: transparent;
}

textarea::placeholder {
  color: var(--stone-400);
  font-weight: 500;
}

.send-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--black);
  color: var(--true-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}

.send-btn:hover { opacity: 0.85; }
.send-btn:active { transform: scale(0.95); }

.send-btn:disabled {
  opacity: 0.15;
  cursor: default;
  transform: none;
}

.send-btn svg {
  width: 20px;
  height: 20px;
}

.input-hint {
  text-align: center;
  margin-top: 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--stone-400);
  font-family: var(--font-mono);
}


/* ─── Connection indicator ─── */

.conn {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--stone-300);
  transition: background 0.4s;
  flex-shrink: 0;
}

.conn.on {
  background: var(--state-focused);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}


/* ─── Scrollbar ─── */

.chat-area::-webkit-scrollbar { width: 6px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb {
  background: var(--peach);
  border-radius: 3px;
}
.chat-area::-webkit-scrollbar-thumb:hover { background: var(--peach-dark); }


/* ─── Login Overlay ─── */

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.3s var(--ease-out);
}

.login-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.login-card {
  background: var(--peach-light);
  border: 2px solid var(--peach-dark);
  border-radius: 18px;
  padding: 56px 48px;
  max-width: 460px;
  width: 90%;
  box-shadow:
    0 20px 25px -5px rgba(0,0,0,0.1),
    0 10px 10px -5px rgba(0,0,0,0.04);
  animation: slideUp 0.3s var(--ease-out);
}

.login-wordmark {
  font-size: 34px;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.login-sub {
  font-size: 21px;
  font-weight: 500;
  color: var(--black-light);
  margin-bottom: 28px;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-card h1 {
  font-size: 45px;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.login-card p {
  font-size: 22px;
  font-weight: 500;
  color: var(--black-light);
  margin-bottom: 36px;
  line-height: 1.6;
}

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

.login-input {
  width: 100%;
  padding: 14px 20px;
  border: 1px solid var(--peach-dark);
  border-radius: 12px;
  background: var(--true-white);
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 500;
  color: var(--black);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-input::placeholder {
  color: var(--stone-400);
  font-weight: 500;
}

.login-input:focus {
  outline: none;
  border-color: var(--peach);
  box-shadow: 0 0 0 3px rgba(242, 201, 163, 0.15);
}

.login-btn {
  width: 100%;
  padding: 14px 20px;
  background: var(--black);
  color: var(--true-white);
  border: none;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  margin-top: 10px;
}

.login-btn:hover {
  opacity: 0.9;
}

.login-btn:active {
  transform: scale(0.98);
}

.login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


/* ─── User Grid (Landing Page) ─── */

.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

.user-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 14px;
  background: var(--true-white);
  border: 1px solid var(--peach-dark);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.user-card:hover {
  background: var(--peach);
  border-color: var(--black-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.user-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--black);
  color: var(--true-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-family: var(--font-sans);
}

.user-card-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--black);
  text-align: center;
  word-break: break-word;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  color: var(--stone-400);
  font-size: 16px;
  font-weight: 500;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--peach-dark);
  opacity: 0.5;
}

.new-user-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.new-user-row .login-input {
  flex: 1;
}

.new-user-row .login-btn {
  width: auto;
  padding: 14px 28px;
  margin-top: 0;
  flex-shrink: 0;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.login-input.shake {
  animation: shake 0.4s ease;
  border-color: var(--state-overwhelmed);
}


/* ─── User Switcher (Header Dropdown) ─── */

.user-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
  padding: 6px 12px;
  border-radius: 10px;
  transition: background 0.2s;
}

.user-switcher:hover {
  background: var(--peach-light);
}

.user-caret {
  opacity: 0.5;
  transition: transform 0.2s;
}

.user-dropdown.open ~ .user-caret,
.user-switcher:has(.user-dropdown.open) .user-caret {
  transform: rotate(180deg);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--peach-light);
  border: 1px solid var(--peach-dark);
  border-radius: 12px;
  box-shadow:
    0 4px 6px -1px rgba(0,0,0,0.05),
    0 10px 20px -2px rgba(0,0,0,0.08);
  padding: 8px;
  z-index: 150;
  opacity: 0;
  transform: translateY(-4px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.15s var(--ease-out), transform 0.15s var(--ease-out);
}

.user-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.user-dropdown-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dropdown-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 17px;
  font-weight: 600;
  color: var(--black);
  transition: background 0.15s;
}

.dropdown-user:hover {
  background: var(--peach);
}

.dropdown-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--black);
  color: var(--true-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-dropdown-new {
  padding: 10px 12px;
  margin-top: 4px;
  border-top: 1px solid var(--peach);
  font-size: 16px;
  font-weight: 600;
  color: var(--stone-500);
  cursor: pointer;
  border-radius: 0 0 8px 8px;
  transition: color 0.15s, background 0.15s;
}

.user-dropdown-new:hover {
  color: var(--black);
  background: var(--peach);
}


/* ─── A/B Toggle in Header ─── */

.ab-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--stone-100);
  border-radius: 22px;
  border: 1px solid var(--stone-200);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 17px;
  font-weight: 600;
  color: var(--black-light);
  font-family: var(--font-mono);
}

.ab-toggle:hover {
  border-color: var(--peach-dark);
  background: var(--peach-light);
}

.ab-toggle.active {
  background: var(--peach);
  border-color: var(--peach-dark);
  color: var(--black);
  box-shadow: 0 0 8px rgba(242, 201, 163, 0.4);
}

.ab-toggle::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stone-400);
  transition: background 0.2s;
}

.ab-toggle.active::before {
  background: var(--peach-dark);
}

.ab-switch {
  display: flex;
  align-items: center;
  width: 16px;
  height: 10px;
  border-radius: 5px;
  background: var(--stone-300);
  position: relative;
  margin-left: 3px;
}

.ab-toggle.active .ab-switch {
  background: var(--peach-dark);
}

.ab-knob {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--white);
  position: absolute;
  left: 1px;
  transition: left 0.2s;
}

.ab-toggle.active .ab-knob {
  left: 7px;
}


/* ─── A/B Response Container ─── */

.ab-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

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

.ab-label {
  font-size: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--black-light);
  padding: 0 5px;
}

.ab-column .msg {
  width: 100%;
}

.ab-column .msg-bubble {
  max-width: 100%;
}

.ab-column .dots {
  max-width: 100%;
}

@media (max-width: 900px) {
  .ab-container {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}


/* ─── Session History Drawer ─── */

.history-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  background: rgba(0, 0, 0, 0.2);
}

.history-overlay.open {
  display: block;
}

.history-drawer {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 340px;
  background: var(--peach-light);
  border-right: 1px solid var(--peach-dark);
  padding: 24px;
  overflow-y: auto;
  z-index: 110;
  transform: translateX(-100%);
  transition: transform 0.3s var(--ease-out);
}

.history-drawer.open {
  transform: translateX(0);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--black-light);
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--peach);
}

.history-title {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--black-light);
}

.history-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--black-light);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.history-close:hover {
  color: var(--black);
}

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

.history-item {
  padding: 14px 14px;
  background: var(--peach-light);
  border: 1px solid var(--peach-dark);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 18px;
  font-weight: 500;
  color: var(--black);
}

.history-item:hover {
  background: var(--stone-50);
  border-color: var(--peach);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.history-item.active {
  background: var(--peach);
  border-color: var(--peach-dark);
  color: var(--black);
  font-weight: 600;
}

.history-item-title {
  font-weight: 600;
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-time {
  font-size: 15px;
  color: var(--stone-500);
  font-family: var(--font-mono);
  font-weight: 500;
}

.history-item.active .history-item-time {
  color: var(--black-light);
}

.history-id {
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font-mono);
  margin-bottom: 3px;
}

.history-date {
  font-size: 15px;
  font-weight: 500;
  color: var(--stone-500);
  font-family: var(--font-mono);
}

.history-count {
  font-size: 14px;
  font-weight: 500;
  color: var(--stone-400);
  font-family: var(--font-mono);
}

.history-new {
  width: 100%;
  padding: 12px;
  margin-top: 18px;
  background: var(--peach-light);
  border: 1px solid var(--peach-dark);
  border-radius: 10px;
  font-size: 17px;
  font-weight: 600;
  color: var(--black);
  cursor: pointer;
  transition: all 0.2s;
}

.history-new:hover {
  background: var(--peach);
  border-color: var(--peach-dark);
}

.empty-msg {
  padding: 24px;
  text-align: center;
  color: var(--stone-500);
  font-size: 18px;
  font-weight: 500;
}

.history-drawer::-webkit-scrollbar { width: 5px; }
.history-drawer::-webkit-scrollbar-track { background: transparent; }
.history-drawer::-webkit-scrollbar-thumb {
  background: var(--peach);
  border-radius: 3px;
}
.history-drawer::-webkit-scrollbar-thumb:hover { background: var(--peach-dark); }


/* ─── History Drawer Toggle Button ─── */

.history-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--stone-200);
  border-radius: 10px;
  background: var(--peach-light);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--black-light);
}

.history-btn:hover {
  border-color: var(--peach-dark);
  background: var(--peach-light);
}

.history-btn svg {
  width: 20px;
  height: 20px;
}

.history-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--stone-200);
  border-radius: 10px;
  background: var(--peach-light);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--black-light);
}

.history-toggle:hover {
  border-color: var(--peach-dark);
  background: var(--peach-light);
}

.history-toggle svg {
  width: 20px;
  height: 20px;
}


/* ─── Responsive ─── */

@media (max-width: 600px) {
  header { padding: 14px 18px; }
  .chat-scroll { padding: 28px 18px 36px; }
  .input-area { padding: 0 18px 18px; }
  .msg-bubble { max-width: 90%; }
  nav { gap: 14px; }
  .state-panel { right: 18px; width: 320px; }
  .history-drawer { width: 100%; }
  .ab-container { gap: 14px; }
  .login-card { padding: 44px 28px; }
}

/* ─── Onboarding Overlay ─── */

.onboarding-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.onboarding-overlay.hidden {
  display: none;
}

.onboarding-card {
  background: #F5E6D3;
  border-radius: 16px;
  padding: 40px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid #9E5A2A;
}

.onboarding-logo {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #9E5A2A;
  margin-bottom: 8px;
}

.onboarding-card h1 {
  margin: 0 0 28px;
  font-size: 24px;
  font-weight: 700;
  color: #1A1A1A;
  letter-spacing: -0.02em;
}

.onboarding-card h2 {
  margin: 24px 0 8px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4D3018;
}

.onboarding-content p {
  margin: 6px 0;
  line-height: 1.6;
  color: #333;
  font-size: 15px;
}

.onboarding-content p.lede {
  margin: 0 0 12px;
  font-size: 17px;
  line-height: 1.55;
  color: #1A1A1A;
}

.onboarding-content em {
  color: #4D3018;
  font-style: normal;
  font-weight: 600;
}

.onboarding-content a {
  color: #9E5A2A;
  text-decoration: underline;
}

.consent-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 28px 0 16px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.5;
  color: #1A1A1A;
}

.consent-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: #059669;
}

.onboarding-btn {
  background: #1A1A1A;
  color: #F5E6D3;
  border: none;
  padding: 14px 24px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
}

.onboarding-btn:hover:not(:disabled) {
  background: #333;
  transform: translateY(-1px);
}

.onboarding-btn:disabled {
  background: #999;
  cursor: not-allowed;
}

/* ─── Mobile Notice ─── */

.mobile-notice {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  padding: 20px;
}

.mobile-notice.hidden {
  display: none;
}

.mobile-notice-card {
  background: #F5E6D3;
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  border: 1px solid #9E5A2A;
}

.mobile-notice-card h2 {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 700;
  color: #1A1A1A;
}

.mobile-notice-card p {
  margin: 0 0 24px;
  font-size: 15px;
  line-height: 1.5;
  color: #333;
}

.mobile-notice-btn {
  background: #1A1A1A;
  color: #F5E6D3;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* ─── Auth Error ─── */

.auth-error {
  background: #fef2f2;
  border: 1px solid #ef4444;
  color: #dc2626;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
  text-align: center;
}

.auth-error.hidden {
  display: none;
}

/* ─── Mobile Responsive ─── */

@media (max-width: 768px) {
  .header {
    padding: 8px 12px;
  }

  .onboarding-card {
    padding: 24px;
  }

  .onboarding-card h1 {
    font-size: 20px;
  }

  .state-panel {
    width: 100%;
    right: 0;
  }

  .msg-bubble {
    max-width: 95%;
  }

  .ab-container {
    flex-direction: column;
  }
}


/* ─── Settings & FAQ Panels ─── */

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: var(--peach);
  color: var(--black-light);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.panel-icon-btn:hover {
  background: var(--peach-dark);
  color: var(--true-white);
}

.panel-icon-btn.active {
  background: var(--black);
  color: var(--true-white);
}

.panel-icon-btn svg {
  width: 16px;
  height: 16px;
}

/* Panel sections for simple/detailed view */
.panel-section {
  transition: opacity 0.3s var(--ease-out), display 0.3s var(--ease-out);
}

.panel-simple-view {
  padding: 8px 0;
}

.simple-description {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--black);
  padding: 16px 0;
  border-top: 1px solid var(--peach);
  border-bottom: 1px solid var(--peach);
}

.panel-detailed-view {
  padding: 0;
}

/* FAQ view lives inside state panel — no separate overlay needed */

/* ===================================================================
   v11.1.2 — Ka goal-picker UI
   =================================================================== */

.goal-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--stone-300, #d6d3d1);
  border-radius: 16px;
  font-size: 13px;
  color: var(--stone-700, #44403c);
  background: var(--peach, #F5E6D3);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
  margin-right: 8px;
}
.goal-pill:hover { background: #EFD9C0; }
.goal-pill:active { transform: scale(0.97); }
.goal-pill-icon {
  font-size: 14px;
  color: #9E5A2A;
}
.goal-pill-label {
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.goal-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1990;
  display: none;
}
.goal-panel-overlay.open { display: block; }

.goal-panel {
  position: fixed;
  top: 70px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: 80vh;
  overflow-y: auto;
  background: #F5E6D3;
  border: 1px solid #9E5A2A;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18);
  z-index: 2000;
  display: none;
}
.goal-panel.open { display: block; }

.goal-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.goal-panel-title {
  font-size: 15px;
  font-weight: 700;
  color: #1A1A1A;
}
.goal-panel-close {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--stone-500, #78716c);
  padding: 0 4px;
}
.goal-panel-close:hover { color: #1A1A1A; }

.goal-panel-subtitle {
  font-size: 12px;
  color: var(--stone-500, #78716c);
  line-height: 1.5;
  margin-bottom: 14px;
}

.goal-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.goal-preset-btn {
  background: #FFF;
  border: 1px solid var(--stone-300, #d6d3d1);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  font-family: inherit;
}
.goal-preset-btn:hover {
  background: #FBF6EE;
  border-color: #9E5A2A;
}
.goal-preset-btn.active {
  background: #9E5A2A;
  border-color: #9E5A2A;
  color: #F5E6D3;
}
.goal-preset-btn-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}
.goal-preset-btn-desc {
  display: block;
  font-size: 11px;
  color: var(--stone-500, #78716c);
  line-height: 1.4;
}
.goal-preset-btn.active .goal-preset-btn-desc { color: #EFD9C0; }

.goal-custom-label {
  display: block;
  font-size: 12px;
  color: var(--stone-500, #78716c);
  margin-bottom: 6px;
}
.goal-custom-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.goal-custom-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--stone-300, #d6d3d1);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.goal-custom-input:focus {
  outline: none;
  border-color: #9E5A2A;
}
.goal-custom-submit {
  padding: 8px 14px;
  background: #1A1A1A;
  color: #F5E6D3;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.goal-custom-submit:hover { background: #2C2C2C; }
.goal-custom-submit:disabled {
  background: var(--stone-400, #a8a29e);
  cursor: not-allowed;
}
.goal-custom-status {
  font-size: 11px;
  color: var(--stone-500, #78716c);
  min-height: 14px;
  margin-bottom: 14px;
}

.goal-current {
  border-top: 1px solid var(--stone-300, #d6d3d1);
  padding-top: 12px;
  font-size: 12px;
  color: var(--stone-500, #78716c);
}
.goal-current-label { margin-right: 6px; }
.goal-current-value {
  font-weight: 700;
  color: #1A1A1A;
}
