/* ═══════════════════════════════════════════════════════════
   Coastal Homes NZ — Dashboard Styles
   Light professional UI — coastal/architectural tone
   ═══════════════════════════════════════════════════════════ */

/* ─── Base Reset & Tokens ─────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  /* ── Coastal light system (Arlo redesign, Jul 2). Light, airy, architectural.
        Single coherent palette — components USE these, no hardcoded purple/grey/lime. ── */
  --bg-app:         #eaf0f7;                /* soft coastal mist app frame */
  --bg-canvas:      #f7f9fc;                /* conversation canvas — near white, never grey */
  --bg-card:        #ffffff;
  --surface-sand:   #f5f3ee;                /* warm neutral for rails/hover — coastal warmth */
  --border:         rgba(20, 46, 86, 0.10);
  --border-strong:  rgba(20, 46, 86, 0.18);
  --text:           #14263f;                /* deep coastal navy */
  --text-secondary: #45566e;
  --text-muted:     #8494ab;
  --brand:          #284394;                /* Grace-approved Coastal blue — primary accent */
  --brand-700:      #1e336f;                /* darker (active/press) */
  --brand-400:      #4a63b0;                /* lighter (hover/tint) */
  --brand-tint:     rgba(40, 67, 148, 0.08);
  --sky:            #0ea5e9;                /* Mia's live/status accent, ties to her agent colour */
  --accent-fg:      #ffffff;

  /* Typography */
  --font-display:   'Fraunces', Georgia, 'Times New Roman', serif;
  --font-ui:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;
  --radius-xl:      22px;
  --shadow-sm:      0 1px 2px rgba(20,40,80,0.06);
  --shadow-md:      0 6px 20px rgba(20,40,80,0.09);
  --shadow-lg:      0 16px 44px rgba(20,40,80,0.14);
  --transition:     200ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Back-compat aliases — existing rules/inline styles read these names.
        Route them all onto the new coastal tokens so nothing goes stale. ── */
  --bg-base:        var(--bg-app);
  --bg-elevated:    #ffffff;
  --bg-input:       #ffffff;
  --glass:          rgba(255, 255, 255, 0.72);
  --glass-border:   rgba(20, 46, 86, 0.10);
  --text-primary:   var(--text);
  --accent:         var(--brand);
  --accent-fg:      #ffffff;
  --accent-dim:     var(--brand-tint);
  --success:        oklch(0.6 0.16 150);
  --warning:        oklch(0.68 0.15 70);
  --destructive:    oklch(0.58 0.2 25);
  --info:           oklch(0.6 0.15 220);
  --in-progress:    oklch(0.6 0.18 280);
}

html, body, #root {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg-app);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Scrollbars ─────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.35);
}

/* ─── Layout Shell ───────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── Header ─────────────────────────────────────────────── */
.app-header {
  height: 56px;
  background: color-mix(in srgb, var(--bg-canvas) 92%, transparent); /* frosted white — srgb mix, no oklch hue-shift to pink */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 50;
  position: relative;
}

.header-logo {
  height: 40px;
  width: auto;
  display: block;
  flex-shrink: 0;
  /* Coastal colour wordmark on the light header — sized to read as the brand. */
}

.header-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  white-space: nowrap;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

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

/* ─── Reboot Timer ───────────────────────────────────────── */
.reboot-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(20, 46, 86, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.reboot-timer .timer-label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.reboot-timer .timer-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  font-size: 13px;
}

.reboot-timer .timer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ─── Navigation Tabs ────────────────────────────────────── */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  background: color-mix(in srgb, var(--bg-canvas) 65%, transparent); /* frosted white — srgb, matches header glass */
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 44px;
  flex-shrink: 0;
  /* Mobile fix (Jack b39bebb5 2026-05-09): 5 tabs overflow narrow viewports,
     making rightmost tabs (Skills / Design Centre / Admin) un-tappable.
     Add horizontal scroll so all tabs remain reachable via swipe. */
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  position: relative;
  /* Don't shrink tabs into unreadable width on mobile — enforce min size + tap target. */
  flex-shrink: 0;
  min-height: 36px;
}

.nav-tab:hover {
  background: var(--glass);            /* B2: white-alpha instead of slate-alpha */
  color: var(--text-secondary);
}

.nav-tab.active {
  background: var(--accent-dim);       /* B2: sys-accent active-page indicator */
  color: var(--accent);
}

.nav-tab.active::after {
  /* B2: 2px sys-accent underline below active tab — Dojo-style chrome */
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

.nav-tab svg {
  width: 15px;
  height: 15px;
  opacity: 0.7;
  flex-shrink: 0;
}

.nav-tab.active svg {
  opacity: 1;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.chat-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition), opacity var(--transition);
}

.chat-sidebar.collapsed {
  width: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.agent-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.agent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid transparent;
}

.agent-item:hover {
  background: var(--glass);              /* B4: white-alpha; drops slate-blue noise */
}

.agent-item.selected {
  background: var(--accent-dim);         /* B4: sys-accent selected treatment matches .nav-tab.active */
  border-color: var(--accent);
}

.agent-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: rgba(0,0,0,0.7);
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.agent-info {
  flex: 1;
  min-width: 0;
}

.agent-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-role {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.active {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

.status-dot.idle {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.status-dot.offline {
  background: var(--text-muted);
}

.status-dot.busy {
  background: #3b82f6;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.5);
  animation: pulse-busy 1.5s ease-in-out infinite;
}

@keyframes pulse-busy {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ─── Chat Area ──────────────────────────────────────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg-card);
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.chat-header-status {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

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

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.chat-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.chat-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.chat-empty-sub {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.5;
}

/* ─── Message Bubbles ────────────────────────────────────── */
.message-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.message-row.user {
  flex-direction: row-reverse;
}

.message-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message-bubble.user {
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.message-bubble.agent {
  background: var(--bg-card);
  color: var(--text);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--border);
}

.message-timestamp {
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 4px;
  margin-top: 2px;
  text-align: right;
}

.message-row.agent .message-timestamp {
  text-align: left;
}

/* Markdown content inside agent bubbles */
.message-bubble.agent .md-content p {
  margin: 0 0 8px 0;
}
.message-bubble.agent .md-content p:last-child {
  margin-bottom: 0;
}
.message-bubble.agent .md-content strong {
  font-weight: 700;
  color: var(--text-primary);
}
.message-bubble.agent .md-content em {
  font-style: italic;
  color: var(--text-secondary);
}
.message-bubble.agent .md-content code {
  background: var(--brand-tint);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
  color: var(--brand-700);
}
.message-bubble.agent .md-content pre {
  background: #0f1b30;
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid var(--border-strong);
}
.message-bubble.agent .md-content pre code {
  color: #e6edf7;
}
.message-bubble.agent .md-content pre code {
  background: none;
  padding: 0;
  font-size: 12px;
}
.message-bubble.agent .md-content ul,
.message-bubble.agent .md-content ol {
  margin: 6px 0;
  padding-left: 20px;
}
.message-bubble.agent .md-content li {
  margin: 3px 0;
}
.message-bubble.agent .md-content h1,
.message-bubble.agent .md-content h2,
.message-bubble.agent .md-content h3 {
  font-weight: 700;
  margin: 12px 0 6px;
  color: var(--text-primary);
}
.message-bubble.agent .md-content h1 { font-size: 17px; }
.message-bubble.agent .md-content h2 { font-size: 15px; }
.message-bubble.agent .md-content h3 { font-size: 14px; }
.message-bubble.agent .md-content blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-muted);
  font-style: italic;
}
.message-bubble.agent .md-content a {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.message-bubble.agent .md-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

/* ─── Typing Indicator ───────────────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 8px;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  padding: 10px 14px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(1) { animation-delay: 0ms; }
.typing-dot:nth-child(2) { animation-delay: 200ms; }
.typing-dot:nth-child(3) { animation-delay: 400ms; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ─── Chat Input ─────────────────────────────────────────── */
.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 14px 16px 16px;
  background: var(--bg-card);
  flex-shrink: 0;
}

.chat-input-container {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 10px 10px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.chat-input-container:focus-within {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px var(--brand-tint);
}

.chat-input-container.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  font-family: inherit;
  max-height: 160px;
  min-height: 20px;
  overflow-y: auto;
  padding: 0;
  scrollbar-width: thin;
}

.chat-textarea::placeholder {
  color: var(--text-muted);
}

.send-button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: var(--brand);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity var(--transition), transform var(--transition);
}

.send-button:hover:not(:disabled) {
  opacity: 0.9;
  transform: scale(1.04);
}

.send-button:disabled {
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

.input-hint {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* ─── Page Content ───────────────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 40px;
}

.page-header {
  margin-bottom: 28px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition), transform var(--transition);
}

.card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);          /* B4: matches .agent-card hover lift */
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ─── Grid Layouts ───────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ─── Mission Control ────────────────────────────────────── */
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color var(--transition), transform var(--transition);
}

.agent-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.agent-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.agent-card-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: rgba(0,0,0,0.7);
  flex-shrink: 0;
}

.agent-card-info {
  flex: 1;
  min-width: 0;
}

.agent-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.agent-card-role {
  font-size: 12px;
  color: var(--text-muted);
}

.agent-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.agent-status-badge.active {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.agent-status-badge.idle {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.agent-status-badge.offline {
  background: rgba(71, 85, 105, 0.3);
  color: var(--text-muted);
}

.agent-status-badge.busy {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.agent-last-action {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* ─── Stat Tiles ─────────────────────────────────────────── */
.stat-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Skills ─────────────────────────────────────────────── */
.skill-section {
  margin-bottom: 28px;
}

.skill-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.skill-section-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: rgba(0,0,0,0.7);
}

.skill-section-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.skill-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition), transform var(--transition);
}

.skill-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);          /* B4: matches .agent-card / .card hover lift */
}

.skill-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.skill-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: inherit;
  text-decoration: none;
}

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

.btn-primary {
  background: var(--brand);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-700);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-sand);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
}

.btn-success {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.25);
}
.btn-success:hover:not(:disabled) {
  background: rgba(34, 197, 94, 0.25);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 6px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fade-in 150ms ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: slide-up 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.modal-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

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

@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Form Elements ──────────────────────────────────────── */
.form-field {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}

.form-input,
.form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px var(--brand-tint);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* ─── Toggle / Group Chat ────────────────────────────────── */
.toggle-pill {
  display: flex;
  align-items: center;
  background: rgba(20, 46, 86, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.toggle-option {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all var(--transition);
  font-family: inherit;
}

.toggle-option.active {
  background: var(--bg-card);
  color: var(--brand);
  box-shadow: var(--shadow-sm);
}

/* ─── Health Indicators ──────────────────────────────────── */
.health-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.health-row:last-child {
  border-bottom: none;
}

.health-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.health-value {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.health-ok { color: #4ade80; }
.health-warn { color: #fbbf24; }
.health-error { color: #f87171; }

/* ─── Loading States ─────────────────────────────────────── */
.loading-shimmer {
  /* Wave 1B B3 — gradient realigned from slate-blue alpha to white-alpha so
     skeletons match the new --bg-base / --bg-card near-black palette and
     read as content-shaped substrates rather than blue-tinted boxes. */
  background: linear-gradient(90deg,
    oklch(1 0 0 / 4%) 0%,
    oklch(1 0 0 / 10%) 50%,
    oklch(1 0 0 / 4%) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--text-secondary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ─── Toast / Notifications ──────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 250ms cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 340px;
}

.toast.toast-success { border-left: 3px solid #4ade80; }
.toast.toast-error { border-left: 3px solid #f87171; }
.toast.toast-info { border-left: 3px solid #60a5fa; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ─── Design Centre Placeholder ──────────────────────────── */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 40px;
  text-align: center;
}

.coming-soon-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: rgba(148, 163, 184, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.coming-soon-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}

.coming-soon-desc {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 340px;
  line-height: 1.6;
}

/* ─── User Badge ─────────────────────────────────────────── */
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(20, 46, 86, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px 5px 8px;
  font-size: 13px;
  color: var(--text-primary);
}

.user-avatar-small {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--brand-tint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--brand);
}

/* ─── Admin Page ─────────────────────────────────────────── */
.admin-agent-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.admin-agent-row:last-child {
  border-bottom: none;
}

.admin-agent-info {
  flex: 1;
}

.admin-agent-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.admin-agent-role {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ─── Responsive Mobile ──────────────────────────────────── */
@media (max-width: 768px) {
  .chat-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 40;
    box-shadow: var(--shadow-lg);
  }

  .chat-sidebar.collapsed {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
  }

  .chat-sidebar:not(.collapsed) {
    transform: translateX(0);
    opacity: 1;
    width: 260px;
  }

  .page-content {
    padding: 20px 16px 32px;
  }

  .message-bubble {
    max-width: 88%;
  }

  .app-header {
    padding: 0 14px;
  }

  .header-center {
    display: none;
  }

  /* Pippa 2026-05-09 (kai-direct): logo carries brand under 768, title is redundant */
  .header-title {
    display: none;
  }

  /* Arlo 2026-07-02: mobile header was overflowing — the wide wordmark + Mia
     identity block + user badge + sign-out collided. Shrink the logo and drop the
     header identity block on mobile; Mia is already introduced by the greeting and
     her avatar rides every chat message, so the header block is redundant here. */
  .header-logo { height: 30px; }
  /* .app-header prefix raises specificity above the later base .mia-identity /
     .header-divider rules so the mobile hide actually wins the cascade. */
  .app-header .mia-identity,
  .app-header .header-divider { display: none; }

  /* Pippa 2026-05-09 (kai-direct): reveal compact reboot pill on mobile */
  .reboot-timer-mobile-wrap {
    display: inline-flex;
  }
}

/* ─── Transitions ────────────────────────────────────────── */
.fade-enter {
  opacity: 0;
  transform: translateY(4px);
}

.fade-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 200ms ease, transform 200ms ease;
}

/* ─── Dividers ───────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ─── Attention Glow ─────────────────────────────────────── */
.attention-glow {
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.4), 0 0 16px rgba(251, 191, 36, 0.2);
}

/* ─── Section Header ─────────────────────────────────────── */
.section-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ─── Mobile Sidebar Toggle ──────────────────────────────── */
.mobile-sidebar-toggle {
  display: none;
}

@media (max-width: 768px) {
  .mobile-sidebar-toggle {
    display: flex;
  }
}

/* ─── Mobile Overlay ─────────────────────────────────────── */
.mobile-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 35;
}

@media (max-width: 768px) {
  .mobile-overlay {
    display: block;
  }
}

/* ─── Pippa 2026-05-09 (kai-direct): Reboot pill mobile + 414 user-badge trim ─── */
.reboot-timer-mobile-wrap {
  display: none;
}

.reboot-timer.compact {
  padding: 4px 10px;
  gap: 6px;
}

.reboot-timer.compact .timer-value {
  font-size: 12px;
}

@media (max-width: 414px) {
  .user-badge .user-name-text {
    display: none;
  }
  .user-badge {
    padding: 4px;
    gap: 0;
  }
}

/* ─── Pippa 2026-05-09 RA-001 (zara P0): version-mismatch banner ─────────── */
.version-mismatch-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--accent-dim);
  border-bottom: 1px solid var(--accent);
  font-size: 13px;
  color: var(--text-primary);
  flex-shrink: 0;
  z-index: 60;
}

.version-mismatch-text {
  font-weight: 500;
}

.version-mismatch-reload {
  background: var(--accent);
  color: rgba(0, 0, 0, 0.85);
  font-weight: 700;
  border: none;
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: opacity var(--transition);
}

.version-mismatch-reload:hover {
  opacity: 0.88;
}

@media (max-width: 414px) {
  .version-mismatch-banner {
    padding: 8px 12px;
    font-size: 12px;
    gap: 8px;
  }
  .version-mismatch-text {
    flex: 1;
  }
}

/* ═══════════════════════════════════════════════════════════
   COASTAL REDESIGN — Arlo, Jul 2. Single-agent, light, airy.
   New component classes below. Tokens: coastal-blue system above.
   ═══════════════════════════════════════════════════════════ */

/* ─── Round avatar image (real photo, initials fallback) ──── */
.avatar-img {
  object-fit: cover;
  object-position: center top;   /* keep faces out of the crop */
  border-radius: 50%;
  display: block;
  background: var(--surface-sand);
}
.avatar-ring {
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--ring, var(--sky));
}

/* ─── App header — Mia as the product's identity ──────────── */
.mia-identity {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.mia-identity-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.mia-identity-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text);
  white-space: nowrap;
}
.mia-identity-sub {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.mia-identity-role { color: var(--text-muted); }
.mia-online {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--sky);
  font-weight: 600;
}
.mia-online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sky);
  box-shadow: 0 0 0 3px rgba(14,165,233,0.18);
  animation: pulse-dot 2.4s ease-in-out infinite;
}
.header-divider {
  width: 1px;
  height: 26px;
  background: var(--border);
  flex-shrink: 0;
}

@media (max-width: 560px) {
  .mia-identity-sub { display: none; }
  .mia-identity-name { font-size: 15px; }
}

/* ─── History rail (slim, tuckable sessions list) ─────────── */
.history-rail {
  width: 264px;
  flex-shrink: 0;
  background: var(--surface-sand);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition), transform var(--transition);
}
.history-rail-head {
  padding: 16px 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.history-rail-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.history-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
}
.history-new-btn:hover { background: var(--brand-700); }
.history-new-btn:active { transform: translateY(1px); }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
}
.history-item {
  padding: 10px 11px;
  border-radius: var(--radius-md);
  margin-bottom: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid transparent;
  color: var(--text-secondary);
  transition: background var(--transition), border-color var(--transition);
}
.history-item:hover { background: var(--bg-card); }
.history-item.selected {
  background: var(--bg-card);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.history-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-item-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}
.history-item-actions button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 3px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  transition: color var(--transition), background var(--transition);
}
.history-item-actions button:hover { color: var(--brand); background: var(--brand-tint); }

/* ─── Conversation canvas (the hero) ──────────────────────── */
.conversation-canvas {
  flex: 1;
  overflow-y: auto;
  padding: 26px 24px 20px;
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
}
.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-canvas);
  flex-shrink: 0;
}
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color var(--transition), background var(--transition);
}
.icon-btn:hover { color: var(--brand); background: var(--brand-tint); }
.icon-btn.is-active { color: var(--brand); }

/* ─── Message appear motion ───────────────────────────────── */
@keyframes msg-appear {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg-appear { animation: msg-appear 240ms cubic-bezier(0.4, 0, 0.2, 1) both; }

/* ─── Empty state with capability starters ────────────────── */
.empty-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
  padding: 48px 24px;
  animation: msg-appear 340ms ease both;
}
.empty-greeting {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.3px;
  color: var(--text);
  max-width: 22ch;
  text-wrap: balance;
}
.empty-greeting .accent { color: var(--brand); }
.empty-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: -8px;
  max-width: 42ch;
  line-height: 1.5;
}
.starter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 540px;
  margin-top: 4px;
}
.starter-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 13px 15px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.starter-chip:hover {
  transform: translateY(-2px);
  border-color: var(--brand-400);
  background: var(--brand-tint);
  box-shadow: var(--shadow-md);
}
.starter-chip:active { transform: translateY(0); }
.starter-chip-icon {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-tint);
  color: var(--brand);
}
@media (max-width: 560px) {
  .starter-grid { grid-template-columns: 1fr; max-width: 420px; }
  .empty-greeting { font-size: 23px; }
}

/* ─── Draft-approval card (the trust surface) ─────────────── */
.draft-card {
  margin: 8px 0 6px 46px;
  max-width: 76%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: msg-appear 260ms ease both;
}
.draft-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 15px;
  background: var(--brand-tint);
  border-bottom: 1px solid var(--border);
}
.draft-card-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  flex-shrink: 0;
}
.draft-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-700);
  letter-spacing: -0.1px;
}
.draft-card-body {
  padding: 12px 15px 14px;
}
.draft-card-hint {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}
.draft-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.draft-approve {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--brand);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), transform var(--transition);
}
.draft-approve:hover { background: var(--brand-700); }
.draft-approve:active { transform: translateY(1px); }
.draft-secondary {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.draft-secondary:hover { background: var(--surface-sand); color: var(--text); border-color: var(--text-muted); }
.draft-secondary.danger:hover { color: var(--destructive); border-color: var(--destructive); background: transparent; }

@media (max-width: 560px) {
  .draft-card { margin-left: 12px; max-width: 92%; }
}

/* ─── New-messages pill ───────────────────────────────────── */
.new-msg-pill {
  background: var(--brand);
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-lg);
  transition: background var(--transition), transform var(--transition);
}
.new-msg-pill:hover { background: var(--brand-700); transform: translateY(-1px); }

.chat-empty-title { font-family: var(--font-display); font-weight: 600; }

/* ─── Mobile — composer padding + tighter canvas ──────────── */
/* The History rail goes off-canvas via a portal drawer (SessionSidebar mobile
   branch), so it needs no absolute positioning here — the portal owns that. */
@media (max-width: 768px) {
  .conversation-canvas { padding: 18px 14px 16px; }
  .draft-card { max-width: 94%; }
}
