/* ==============================
   Theme
   ============================== */
:root{
  --bg:#f8fafc;
  --panel:#fff;
  --panel2:#f1f5f9;
  --text:#0f172a;
  --subtext:#64748b;
  --border:#e2e8f0;
  --btn:#2563eb;
}

*{ box-sizing:border-box }
html,body{ height:100% }
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif;
}

.wrap{ max-width:1200px; margin:0 auto; padding:1rem }

/* Header */
.app-header{
  position:sticky; top:0; z-index:10;
  display:flex; align-items:center; justify-content:space-between;
  padding:1rem 1.25rem; border-bottom:1px solid var(--border);
  background:#fff; height:64px;
}

.brand-area{ display:flex; align-items:center; gap:.75rem }
.brand-area img{ height:32px }
.brand-placeholder{
  height:32px; width:32px; background:var(--panel2); border-radius:8px;
  display:flex; align-items:center; justify-content:center; color:var(--subtext); font-size:.8rem;
}
.brand-title{ font-size:1.1rem; font-weight:700 }
.brand-subtitle{ font-size:.85rem; color:var(--subtext); margin-top:-2px }
.top-nav a{ margin-left:1rem; color:var(--text); text-decoration:none }

/* ==============================
   Layout: Left Rail (Sidebar) + Right Content (Conversation)
   ============================== */
.grid{
  display:grid;
  grid-template-columns: 1fr 2fr;            /* left rail : right content */
  grid-template-areas: "sidebar conversation";
  gap:1.25rem;
  align-items:start;                         /* prevents stretch-induced creep */
}
.col{ min-width:0 }
.sidebar{ grid-area: sidebar }
.conversation{ grid-area: conversation }

/* Rail behavior: full-height, its own scroll, no drift */
.sidebar{
  position: sticky;                          /* pin to viewport while scrolling */
  top: 64px;                                  /* equal to .app-header height */
  align-self: start;
  height: calc(100vh - 64px);                 /* full viewport minus header */
  min-height: calc(100vh - 64px);
}

.sidebar .card{
  height: 100%;
  overflow: auto;                             /* independent scroll inside rail */
  margin-bottom: 0;                           /* avoid margin-collapsing creep */
  display: block;
}

/* Cards & Conversation */
.card{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  padding:1rem;
  box-shadow:0 8px 24px rgba(0,0,0,.04);
  margin-bottom:1rem;
}
.conversation h2{ margin:0 0 .75rem }

/* Chat message */
.chat-msg{
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--panel);
  padding:.85rem;
  margin-bottom:.85rem;
}
.msg-header{ display:flex; align-items:center; justify-content:space-between }
.msg-body{ white-space:pre-wrap; margin-top:.25rem }

/* Rows & chips */
.rows .row{ margin-bottom:.75rem }
.chips{ display:flex; flex-wrap:wrap; gap:.45rem }
/* Better chips (no underline, subtle depth) */
.chips .chip{
  text-decoration:none;
  background:#ffffff;
  border:1px solid var(--border);
  border-radius:999px;
  padding:.35rem .8rem;
  font-weight:600;
  letter-spacing:.2px;
  box-shadow:0 1px 0 rgba(0,0,0,.04), 0 6px 16px rgba(0,0,0,.06);
}
.chips .chip:hover{ filter:brightness(.98) }
.chips .chip.active{
  background:#eaf2ff;
  border-color:#c8dcff;
  color:#0b3b77;
  box-shadow:0 1px 0 rgba(0,0,0,.04), 0 8px 20px rgba(59,130,246,.18);
}

/* Score chip becomes an obvious button */
.btn-chip{
  border:none; cursor:pointer;
  padding:.25rem .5rem; border-radius:999px; color:#fff;
  font-weight:700; line-height:1;
}

/* Modal padding + textarea comfort */
.modal-body{ padding:1.25rem 1.5rem !important }
#improvedText{
  width:100%; min-height:200px; border:1px solid var(--border);
  border-radius:8px; padding:.75rem; font:inherit;
}

/* Long reply safety */
.chat-msg{ overflow: visible }
.msg-body{ white-space:pre-wrap; word-break:break-word; overflow-wrap:anywhere; }
.msg-body pre{ white-space:pre-wrap; overflow:auto; }

/* Toggle pill radios (from earlier step) keep active look */
.toggle3{ display:inline-grid; grid-template-columns:1fr 1fr 1fr; border:1px solid var(--border); border-radius:10px; overflow:hidden; background:#f8fafc; }
.toggle3 input{ position:absolute; opacity:0; pointer-events:none; width:0; height:0; }
.toggle3 .t3{ display:flex; align-items:center; justify-content:center; padding:.5rem .8rem; cursor:pointer; user-select:none; font-size:.9rem; color:var(--text); background:transparent; border:none; transition: background .15s ease, color .15s ease; }
.toggle3 .t3:hover{ background:#eef2f7 }
#im-never:checked   + label.t3,
#im-suggest:checked + label.t3,
#im-auto:checked    + label.t3{ background:var(--btn); color:#fff; }
#im-never   + label.t3, #im-suggest + label.t3{ border-right:1px solid var(--border) }

.muted{ color:var(--subtext) }
.small{ font-size:.9rem }
.info{ background:#f0f7ff; border:1px solid #cfe3ff; padding:.5rem; border-radius:6px }
.warn{ background:#fef9c3; border:1px solid #fde047; padding:.5rem; border-radius:6px }

/* Metrics grid */
.metrics{ margin-top:.5rem }
.metrics-grid{ display:grid; grid-template-columns:1fr 1fr; gap:.25rem }

/* Traffic-light dots */
.score-dot{
  display:inline-block; width:10px; height:10px; border-radius:50%;
  margin-right:6px; vertical-align:middle;
}
.score-dot.red{ background:#fca5a5; box-shadow:0 0 0 2px #fee2e2 inset }
.score-dot.amber{ background:#fcd34d; box-shadow:0 0 0 2px #fef3c7 inset }
.score-dot.green{ background:#86efac; box-shadow:0 0 0 2px #dcfce7 inset }

/* Score chip */
.score-chip{ color:#fff; border:none; border-radius:999px; padding:.25rem .6rem; font-weight:700 }
.score-chip.chip-red{ background:#ef4444 }
.score-chip.chip-amber{ background:#f59e0b }
.score-chip.chip-green{ background:#10b981 }

/* Buttons */
.btn{
  background:var(--btn); color:#fff; border:none; border-radius:8px;
  padding:.6rem 1rem; cursor:pointer;
}
.btn[disabled]{ opacity:.6; cursor:not-allowed }
.btn.secondary{ background:#94a3b8; color:#fff; text-decoration:none; display:inline-block }
.btn.ghost{ background:#e5e7eb; color:#111827; border:none }
.btn.ghost:hover{ filter:brightness(.97) }

.caption{ color:var(--subtext); font-size:.85rem }

/* ==============================
   Composer (fixed at bottom)
   ============================== */
.conversation{ position:relative; padding-bottom:120px } /* reserve space under messages */

.composer{
  position:fixed;
  left:auto; right:auto;
  width:66%; max-width:800px;
  background:#fff; border-top:1px solid var(--border); padding:1rem; z-index:9999;
  bottom: 0;
}
.composer textarea[name="message"]{
  width:100% !important; max-width:100% !important; min-height:80px; resize:none;
}
.composer-actions{ display:flex; gap:.5rem; justify-content:flex-end; margin-top:.5rem }

/* Keep the composer above everything if needed */
.composer{ z-index: 9999 }

/* ==============================
   Floating RI Coach
   ============================== */
.ri-coach{
  position:fixed; right:24px; bottom:96px; width:360px; max-width:92vw;
  z-index:9998; background:#fff; border:1px solid var(--border);
  border-radius:12px; box-shadow:0 14px 48px rgba(0,0,0,.18); overflow:hidden;
}
.coach-header{
  background:#1e3a8a; color:#fff; padding:.6rem .9rem; font-weight:700;
  cursor:grab; user-select:none;
}
.coach-header.dragging{ cursor:grabbing }
.coach-body{ padding:.8rem .9rem }
.coach-row{ display:flex; align-items:center; justify-content:space-between; margin-bottom:.5rem }
.coach-title{ font-weight:600 }
.coach-pill{ background:#0ea5e9; color:#fff; border-radius:999px; padding:.2rem .6rem; font-weight:700 }
.coach-grid{ display:grid; grid-template-columns:1fr 1fr; gap:.5rem }
.coach-metric{
  background:#f8fafc; border:1px solid var(--border); padding:.5rem; border-radius:8px;
  display:flex; align-items:center; justify-content:space-between;
}
.coach-subtitle{ font-weight:600; margin:.5rem 0 }

/* ==============================
   Modal (Lead Capture)
   ============================== */
/* ==============================
   Modal (Lead / Improve)
   ============================== */
.modal-overlay{
  position:fixed; inset:0;
  background: radial-gradient(1200px 600px at 20% 10%, rgba(59,130,246,.18), transparent),
              radial-gradient(900px 600px at 80% 90%, rgba(16,185,129,.18), transparent),
              rgba(2,6,23,.60); /* slate-950 w/ alpha */
  backdrop-filter: saturate(130%) blur(6px);
  display:flex; align-items:center; justify-content:center;
  opacity:0; pointer-events:none; transition:opacity .2s ease;
  z-index:10000; padding:24px;
}
.modal-overlay.open{ opacity:1; pointer-events:auto }

.modal{
  width:min(560px, 92vw);
  background: linear-gradient(#ffffff, #fcfcff);
  color:var(--text);
  border:1px solid rgba(2,6,23,.06);
  border-radius:16px;
  box-shadow:
    0 24px 60px rgba(2,6,23,.28),
    0 4px 16px rgba(2,6,23,.12);
  transform: translateY(8px) scale(.98);
  opacity:0;
  transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .18s ease;
}
.modal-overlay.open .modal{ transform:translateY(0) scale(1); opacity:1 }

.modal-header{
  display:flex; align-items:center; justify-content:space-between;
  padding:20px 22px 0;
}
.modal-title{ font-size:1.1rem; font-weight:700; letter-spacing:.2px }
.modal-close{
  appearance:none; border:0; background:transparent;
  font-size:22px; line-height:1; cursor:pointer; opacity:.55;
}
.modal-close:hover{ opacity:1 }

.modal-body{ padding:16px 22px; display:grid; gap:.75rem }
.modal-copy{ margin:0 0 .25rem .125rem; color:#475569 }

.modal-actions{
  display:flex; justify-content:flex-end; gap:.5rem;
  padding:0 22px 18px;
}

/* Form elements inside modals */
.form-row{ display:flex; gap:.75rem }
.input, .textarea, .select{
  width:100%;
  border:1px solid var(--border);
  border-radius:10px;
  padding:.65rem .75rem;
  font:inherit;
  background:#fff;
  box-shadow: inset 0 1px 0 rgba(0,0,0,.02);
}
.textarea{ min-height:140px; resize:vertical }

/* Make the existing improve textarea look good too */
#improvedText{
  width:100%;
  min-height:160px;
  border:1px solid var(--border);
  border-radius:10px;
  padding:.75rem;
  font:inherit;
}

.composer-metrics .score-dot{
  display:inline-block; width:10px; height:10px; border-radius:50%;
  margin-right:6px; vertical-align:middle; background:#e5e7eb;
}
/* Three-phase toggle (Never / Suggest / Auto) — radio+label version */
.toggle3{
  display:inline-grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items:stretch;
  gap:0;
  border:1px solid var(--border);
  border-radius:10px;
  overflow:hidden;
  background:#f8fafc;
}
.toggle3 input{
  /* hide the radios but keep them accessible */
  position:absolute;
  opacity:0;
  pointer-events:none;
  width:0; height:0;
}
.toggle3 .t3{
  display:flex; align-items:center; justify-content:center;
  padding:.5rem .8rem;
  cursor:pointer; user-select:none;
  font-size:.9rem;
  color:var(--text);
  background:transparent;
  border:none;
  transition: background .15s ease, color .15s ease;
}
.toggle3 .t3:hover{ background:#eef2f7 }
.toggle3 .t3:focus-visible{
  outline:2px solid #93c5fd; outline-offset:2px; z-index:1;
}

/* Selected state — pure CSS */
#im-never:checked   + label.t3,
#im-suggest:checked + label.t3,
#im-auto:checked    + label.t3{
  background:var(--btn);
  color:#fff;
}

/* Vertical separators between labels */
#im-never   + label.t3 { border-right:1px solid var(--border) }
#im-suggest + label.t3 { border-right:1px solid var(--border) }


/* Enhanced Metrics Block Styling */
.metrics {
  background: linear-gradient(145deg, #1a252f 0%, #1e2a3a 100%);
  border-top: 1px solid #2c3e50;
  overflow: hidden;
  transition: all 0.3s ease;
  margin-top: 0.5rem;
}

.metrics[open] {
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.2);
}

.metrics summary {
  list-style: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  outline: none;
}

.metrics summary::-webkit-details-marker {
  display: none;
}

/* Enhanced Metrics Container */
.metrics-container {
  padding: 1.5rem;
  background: linear-gradient(145deg, #1e2a3a 0%, #2c3e50 100%);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Enhanced Individual Metric Cards */
.metric-card {
  background: linear-gradient(145deg, #34495e 0%, #2c3e50 100%);
  border: 1px solid #3498db;
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--metric-color);
  opacity: 0.7;
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(52, 152, 219, 0.2);
  border-color: #5dade2;
}

.metric-label {
  font-size: 0.8rem;
  color: #85c1e9;
  margin-bottom: 0.5rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-score {
  font-size: 1.5rem;
  font-weight: bold;
  color: #ffffff;
  margin-bottom: 0.25rem;
}

.metric-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.metric-bar-fill {
  height: 100%;
  background: var(--metric-color);
  border-radius: 2px;
  transition: width 0.8s ease;
  position: relative;
}

.metric-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Metric Color Variables */
.metric-card.positivity { --metric-color: #2ecc71; }
.metric-card.warmth { --metric-color: #f39c12; }
.metric-card.clarity { --metric-color: #3498db; }
.metric-card.safety { --metric-color: #9b59b6; }

/* Enhanced Summary Section */
.summary-section {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.15) 0%, rgba(41, 128, 185, 0.08) 100%);
  border: 1px solid #2980b9;
  border-radius: 10px;
  padding: 1rem;
  margin-top: 1rem;
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.summary-title {
  color: #aed6f1;
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-badges {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.summary-badge {
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: white;
}

.summary-badge.score {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.summary-badge.latency {
  background: linear-gradient(135deg, #3498db, #2980b9);
}

.summary-insight {
  color: #e0e0e0;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border-left: 3px solid #3498db;
}

/* Animation for when metrics load */
.metric-card {
  animation: slideInUp 0.5s ease forwards;
}

.metric-card:nth-child(1) { animation-delay: 0.1s; }
.metric-card:nth-child(2) { animation-delay: 0.2s; }
.metric-card:nth-child(3) { animation-delay: 0.3s; }
.metric-card:nth-child(4) { animation-delay: 0.4s; }

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

/* Responsive Design */
@media (max-width: 768px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .summary-header {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }
}

/* Baseline Scores Display */
.baseline-scores {
  padding: 0.75rem 1rem;
  background: linear-gradient(to right, rgba(41, 128, 185, 0.08) 0%, rgba(52, 152, 219, 0.05) 100%);
  border-top: 1px solid #2c3e50;
  border-bottom: 1px solid #2c3e50;
}

.baseline-header {
  font-size: 0.8rem;
  font-weight: 600;
  color: #85c1e9;
  margin-bottom: 0.75rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.baseline-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.baseline-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: linear-gradient(145deg, rgba(30, 42, 58, 0.6) 0%, rgba(26, 31, 46, 0.4) 100%);
  border-radius: 6px;
  border: 1px solid rgba(44, 62, 80, 0.3);
}

.baseline-name {
  font-size: 0.75rem;
  color: #85c1e9;
  font-weight: 500;
}

.baseline-value {
  font-size: 0.8rem;
  font-weight: 700;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  min-width: 2.5rem;
  text-align: center;
}

.baseline-value.positive {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
  color: white;
  box-shadow: 0 1px 3px rgba(46, 204, 113, 0.3);
}

.baseline-value.negative {
  background: linear-gradient(135deg, #c0392b, #e74c3c);
  color: white;
  box-shadow: 0 1px 3px rgba(231, 76, 60, 0.3);
}

.baseline-value.neutral {
  background: linear-gradient(145deg, #34495e, #2c3e50);
  color: #85c1e9;
  box-shadow: 0 1px 3px rgba(52, 73, 94, 0.3);
}

/* Responsive baseline scores */
@media (max-width: 600px) {
  .baseline-grid {
    grid-template-columns: 1fr;
    gap: 0.375rem;
  }

  .baseline-metric {
    padding: 0.375rem;
  }
}

/* Minimized state - hide baseline scores */
.ri-coach-fab.minimized .baseline-scores {
  display: none;
}

/* Enhanced Settings Panel */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #85c1e9;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Custom Select Styling */
.select-wrapper {
  position: relative;
  display: block;
}

.setting-select {
  width: 100%;
  appearance: none;
  background: linear-gradient(145deg, #1a252f 0%, #1e2a3a 100%);
  color: #e0e0e0;
  border: 1px solid #2c3e50;
  border-radius: 8px;
  padding: 0.75rem 2.5rem 0.75rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.setting-select:hover {
  border-color: #3498db;
  background: linear-gradient(145deg, #1e2a3a 0%, #2c3e50 100%);
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
}

.setting-select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
  background: linear-gradient(145deg, #1e2a3a 0%, #2c3e50 100%);
}

/* Custom dropdown arrow */
.select-arrow {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #85c1e9;
  transition: all 0.3s ease;
}

.select-wrapper:hover .select-arrow {
  color: #aed6f1;
  transform: translateY(-50%) scale(1.1);
}

.setting-select:focus + .select-arrow {
  color: #3498db;
  transform: translateY(-50%) rotate(180deg);
}

/* Select options styling (limited browser support but progressive enhancement) */
.setting-select option {
  background: #1e2a3a;
  color: #e0e0e0;
  padding: 0.5rem;
}

/* Setting divider */
.setting-divider {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, #2c3e50, transparent);
  margin: 0.5rem 0;
}

/* Usage Status Section */
.usage-status {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  background: linear-gradient(145deg, rgba(30, 42, 58, 0.6) 0%, rgba(26, 31, 46, 0.4) 100%);
  border: 1px solid rgba(44, 62, 80, 0.3);
  border-radius: 10px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}

.status-indicator.premium .status-dot {
  background: #2ecc71;
  box-shadow: 0 0 8px rgba(46, 204, 113, 0.6);
}

.status-indicator.premium {
  color: #2ecc71;
}

.status-indicator.trial .status-dot {
  background: #f39c12;
  box-shadow: 0 0 8px rgba(243, 156, 18, 0.6);
}

.status-indicator.trial {
  color: #f39c12;
}

.status-indicator.limited .status-dot {
  background: #e74c3c;
  box-shadow: 0 0 8px rgba(231, 76, 60, 0.6);
}

.status-indicator.limited {
  color: #e74c3c;
}

.usage-info {
  color: #85c1e9;
  font-size: 0.8rem;
  padding: 0.5rem 0;
  border-top: 1px solid rgba(44, 62, 80, 0.2);
}

.usage-info strong {
  color: #aed6f1;
  font-weight: 700;
}

.upgrade-btn {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.625rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(231, 76, 60, 0.3);
}

.upgrade-btn:hover {
  background: linear-gradient(135deg, #c0392b, #a93226);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .settings-form {
    gap: 1rem;
  }

  .setting-select {
    padding: 0.625rem 2rem 0.625rem 0.625rem;
    font-size: 0.8rem;
  }

  .select-arrow {
    right: 0.625rem;
  }
}

/* Focus ring for accessibility */
.setting-select:focus-visible {
  outline: 2px solid #3498db;
  outline-offset: 2px;
}

/* Remove existing chip-based styling */
.chips {
  display: none;
}

/* Hide weights list */
.muted.small {
  display: none;
}

/* Ensure conversation has proper bottom spacing */
.conversation {
  position: relative;
  padding-bottom: 140px; /* Default padding for composer */
  min-height: calc(100vh - 64px); /* Ensure full height minus header */
}

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Ensure messages are properly spaced from composer */
.chat-message:last-child {
  margin-bottom: 1rem;
}

/* Sticky Conversation Header */
.conversation-header {
  position: sticky;
  top: 64px; /* Height of main app header */
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  background: linear-gradient(145deg, #1e2a3a 0%, #1a1f2e 100%);
  border-bottom: 1px solid #2c3e50;
  margin: -1rem -1rem 1rem -1rem; /* Extend to card edges */
  padding-left: 1rem;
  padding-right: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
}

.conversation-header h2 {
  margin: 0;
  color: #aed6f1;
  font-size: 1.25rem;
}

.restart-form {
  margin: 0;
}

.restart-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.85rem;
  border-radius: 8px;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.restart-btn svg {
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.restart-btn:hover svg {
  transform: rotate(180deg);
}

.restart-btn:hover {
  transform: translateY(-1px);
}

/* Messages container with proper spacing */
.messages-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* Adjust conversation padding for sticky header */
.conversation {
  padding-top: 0; /* Remove top padding since header handles it */
  padding-bottom: 140px; /* Keep bottom padding for composer */
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .conversation-header {
    padding: 0.75rem;
    margin: -1rem -1rem 0.75rem -1rem;
  }

  .conversation-header h2 {
    font-size: 1.1rem;
  }

  .restart-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  .restart-btn span {
    display: none; /* Hide text on very small screens, keep icon */
  }
}

@media (max-width: 480px) {
  .restart-btn {
    padding: 0.5rem;
    min-width: 40px;
    justify-content: center;
  }
}

/* Ensure sticky header doesn't interfere with auto-scroll */
.conversation-header + .messages-container .chat-message:first-child {
  scroll-margin-top: 120px; /* Account for sticky header height */
}

/* Add smooth transition when header becomes sticky */
.conversation-header {
  transition: all 0.3s ease;
}

/* Optional: Add a subtle shadow when scrolled */
.conversation-header.scrolled {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}