/* ============================================================
   KARNA — Design System v4
   Theme: Paper & Circuit

   Philosophy:
   • Warm parchment is the ground. Calm, not cold.
   • Paper-grain texture: organic, hand-pressed beneath the surface.
   • Glass cards float above — frosted ivory, not dark mirror.
   • Cerulean-steel (#4f86c6) is the one neo note. Circuit, not coral.
   • The console IS the room. No seam between tool and feeling.

   To retheme: edit :root variables only.
   ============================================================ */

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* --- Surfaces: parchment ground --- */
  --bg:            #f5f0e8;   /* warm ivory — the canvas */
  --bg-elevated:   rgba(245,237,220,0.80);
  --bg-hover:      rgba(230,222,205,0.85);
  --bg-overlay:    rgba(30,22,14,0.72);
  --bg-glass:      rgba(252,248,240,0.72);
  --bg-glass-deep: rgba(248,243,233,0.92);

  /* --- Typography: ink-dark on parchment --- */
  --text-primary:   #1a1410;   /* near-black with warm undertone — ink */
  --text-heading:   #1a1410;
  --text-secondary: #5a5248;   /* mid warm-grey — aged ink */
  --text-label:     #7a7068;
  --text-muted:     #9a9088;
  --text-body:      rgba(50,44,38,0.80);

  /* --- Cerulean-steel: the one neo note --- */
  --accent:        #4f86c6;   /* muted steel-blue — circuit, not cold */
  --accent-bright: #6b9fd4;
  --accent-dim:    rgba(79,134,198,0.08);
  --accent-glow:   rgba(79,134,198,0.22);

  /* --- Structure --- */
  --border:        rgba(30,22,14,0.12);
  --border-accent: rgba(79,134,198,0.45);
  --border-glass:  rgba(30,22,14,0.10);
  --border-error:  rgba(180,50,40,0.38);

  /* --- Radii --- */
  --radius-sm:  4px;
  --radius-md:  10px;
  --radius-lg:  17px;
  --radius-xl:  22px;

  /* --- Glass blur --- */
  --blur-sm:  blur(8px);
  --blur-md:  blur(14px);
  --blur-lg:  blur(24px);

  /* --- Shadows: warm, not cold --- */
  --shadow-card:  0 4px 24px rgba(30,20,10,0.10);
  --shadow-float: 0 8px 32px rgba(30,20,10,0.14);
  --shadow-coral: 0 0 20px rgba(79,134,198,0.18);

  /* --- Semantic --- */
  --danger:  #b43228;   /* ink-red */
  --warning: #c47a2a;   /* amber-ochre */
  --success: #3d7a58;   /* muted forest */

  /* --- Typography --- */
  --font-heading:     'Cormorant Garamond', Georgia, serif;
  --font-body:        'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:        'DM Mono', 'JetBrains Mono', monospace;
  --font-typewriter:  'Courier Prime', 'Courier New', 'Courier', monospace;

  /* --- Safe areas --- */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

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

/* ============================================================
   BASE — warm parchment ground with paper-grain overlay
   ============================================================ */
html, body {
  height: 100%;

  /*
    PAPER GROUND
    SVG tile: 200×200px, feTurbulence fractalNoise grain
    Simulates cold-press watercolor / sumi-e paper texture
    Base fill #f5f0e8 (warm ivory)
    Micro-grain as very faint warm marks at opacity 0.035
    Layered over a warm vignette so edges are slightly darker
  */
  background-color: #f5f0e8;
  background-image:
    /* Paper grain SVG tile */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='grain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeBlend in='SourceGraphic' mode='multiply'/%3E%3C/filter%3E%3Crect width='200' height='200' fill='%23f5f0e8'/%3E%3Crect width='200' height='200' filter='url(%23grain)' opacity='0.035'/%3E%3C/svg%3E"),
    /* Vignette — edges slightly warmer/darker, parchment aging */
    radial-gradient(
      ellipse 120% 120% at 50% 50%,
      rgba(245,240,232,0.0)  0%,
      rgba(210,200,185,0.25) 100%
    );
  background-attachment: fixed;
  background-size: 200px 200px, 100% 100%;

  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

/* ============================================================
   GLASS MIXIN — applied via class
   ============================================================ */
.glass {
  background: var(--bg-glass);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-card);
}

/* ============================================================
   GLASS OVERRIDES
   Elements with inline style="" that use surface tokens.
   ============================================================ */
[style*="background:var(--bg-elevated)"],
[style*="background: var(--bg-elevated)"] {
  background: var(--bg-glass) !important;
  backdrop-filter: var(--blur-md) !important;
  -webkit-backdrop-filter: var(--blur-md) !important;
  border-color: var(--border-glass) !important;
}

[style*="background:var(--bg);"],
[style*="background:var(--bg) "],
[style*="background: var(--bg)"] {
  background: rgba(245,240,232,0.90) !important;
  backdrop-filter: var(--blur-sm) !important;
  -webkit-backdrop-filter: var(--blur-sm) !important;
}

[style*="background:var(--bg-hover)"],
[style*="background: var(--bg-hover)"] {
  background: var(--bg-hover) !important;
}

/* Fix old teal rgba in inline tag styles */
[style*="rgba(79,209,197"] {
  background: var(--accent-dim) !important;
  color: var(--accent-bright) !important;
}

/* Inputs/selects in inline styles */
input[style*="background:var(--bg)"],
select[style*="background:var(--bg)"],
textarea[style*="background:var(--bg)"],
input[style*="background:var(--bg-elevated)"],
textarea[style*="background:var(--bg-elevated)"] {
  background: rgba(255,255,255,0.50) !important;
  backdrop-filter: none !important;
  border-color: rgba(30,22,14,0.16) !important;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-left: calc(16px + var(--safe-left));
  padding-right: calc(16px + var(--safe-right));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-glass-deep);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  z-index: 10;
  position: relative;
}

/* Coral hairline under topbar */
.topbar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 2px; }

.topbar-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 10px;
  border-radius: var(--radius-md);
  transition: color 0.2s, background 0.2s;
  font-size: 22px;
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.topbar-btn:hover  { color: var(--text-primary); background: var(--bg-hover); }
.topbar-btn:active { color: var(--accent); background: var(--accent-dim); }
.topbar-btn.active { color: var(--accent); background: var(--accent-dim); }

.topbar-title {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 3.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Status dot — coral pulse */
.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  display: inline-block;
  animation: coralpulse 3s infinite;
}
@keyframes coralpulse {
  0%,100% { opacity: 1; box-shadow: 0 0 6px var(--accent-glow); }
  50%      { opacity: 0.4; box-shadow: none; }
}

.thread-title-display {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 6px;
}

/* ============================================================
   NOTIFICATION BELL
   ============================================================ */
.notif-btn { position: relative; }
.notif-badge {
  position: absolute;
  top: 6px; right: 6px;
  min-width: 15px; height: 15px;
  background: var(--accent);
  color: #f5f0e8;
  font-size: 9px; font-weight: 700;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}
.notif-badge.hidden { display: none; }

.notif-dropdown {
  position: fixed;
  top: 62px; right: 12px;
  width: 320px;
  max-width: calc(100vw - 24px);
  max-height: 400px;
  background: var(--bg-glass-deep);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  z-index: 120;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: dropIn 0.18s ease;
}
@keyframes dropIn { from{opacity:0;transform:translateY(-6px)} to{opacity:1;transform:translateY(0)} }
.notif-dropdown.open { display: flex; }

.notif-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.notif-header-title {
  font-size: 10px; font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-muted);
}
.notif-list { flex: 1; overflow-y: auto; padding: 4px 0; min-height: 0; }
.notif-item {
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { border-left: 2px solid var(--accent); }
.notif-item-title {
  font-size: 13px; font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
  overflow-wrap: break-word; word-break: break-word;
}
.notif-item-body {
  font-size: 12px; color: var(--text-muted);
  line-height: 1.4;
  overflow-wrap: break-word; word-break: break-word;
}
.notif-item-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.notif-empty { padding: 32px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ============================================================
   MAIN CONTENT + CHAT AREA
   ============================================================ */
.main-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.chat-area {
  flex: 1;
  overflow-y: auto;
  position: relative;
  padding: 28px 18px;
  padding-left:  calc(18px + var(--safe-left));
  padding-right: calc(18px + var(--safe-right));
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.chat-area::-webkit-scrollbar { width: 2px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.message-group {
  max-width: 680px;
  margin: 0 auto 24px;
  animation: riseIn 0.25s ease;
}
@keyframes riseIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

.msg-user {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.55;
}

.msg-assistant {
  color: #1a1410;
  font-family: var(--font-typewriter);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.75;
  letter-spacing: 0.01em;
}
.msg-assistant strong { color: #1a1410; font-weight: 700; }
.msg-assistant em     { color: #3a302a; font-style: italic; }
.msg-assistant h1, .msg-assistant h2, .msg-assistant h3, .msg-assistant h4 {
  font-family: var(--font-heading);
  color: #1a1410;
  font-weight: 600;
  line-height: 1.2;
  margin: 6px 0 2px;
}
.msg-assistant h1 { font-size: 20px; }
.msg-assistant h2 { font-size: 18px; }
.msg-assistant h3 { font-size: 16px; }
.msg-assistant h4 { font-size: 15px; font-weight: 600; color: #5a5248; }
.msg-assistant hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}
.msg-assistant code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: rgba(79,134,198,0.08);
  border: 1px solid rgba(79,134,198,0.15);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent);
}
.msg-assistant pre {
  background: rgba(30,22,14,0.06);
  backdrop-filter: none;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin: 12px 0;
  overflow-x: auto;
  border: 1px solid var(--border);
}
.msg-assistant pre code { background: none; border: none; padding: 0; color: var(--text-secondary); }
.msg-assistant ul, .msg-assistant ol { padding-left: 18px; margin: 8px 0; }
.msg-assistant li { margin: 5px 0; }
.msg-assistant a { color: var(--accent-bright); text-decoration: none; }
.msg-assistant a:hover { text-decoration: underline; }
.msg-assistant a.msg-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  border: 1px solid rgba(79,134,198,0.15);
  transition: background 0.2s;
  word-break: break-all;
}
.msg-assistant a.msg-link:hover { background: var(--accent-glow); text-decoration: none; }
.msg-assistant a.yt-link { background: rgba(255,60,60,0.08); color: #d97272; border-color: rgba(255,60,60,0.12); }
.msg-assistant a.yt-link:hover { background: rgba(255,60,60,0.14); }

.link-icon  { font-size: 11px; flex-shrink: 0; }
.yt-icon    { color: #c94444; }
.map-icon   { color: #5a9c6a; }

/* ============================================================
   THINKING / STREAMING INDICATORS
   ============================================================ */
.thinking {
  max-width: 680px;
  margin: 0 auto;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.3px;
}
.thinking-cursor {
  display: inline-block;
  width: 2px; height: 14px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 1.1s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 49%{opacity:1} 50%{opacity:0} }

.progress-bar {
  position: fixed;
  top: var(--safe-top); left: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright), transparent);
  width: 0;
  transition: width 0.3s;
  z-index: 100;
  opacity: 0;
}
.progress-bar.active { opacity: 1; animation: progressPulse 2.2s infinite; }
@keyframes progressPulse { 0%{width:0} 55%{width:65%} 100%{width:88%} }

/* ============================================================
   TOOL EXECUTION INDICATORS
   ============================================================ */
.tool-indicator {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 11px;
  background: rgba(30,22,14,0.04);
  backdrop-filter: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 6px 0;
  font-size: 12px;
  color: var(--text-muted);
  animation: riseIn 0.2s ease;
}
.tool-indicator.running   { border-color: rgba(79,134,198,0.35); }
.tool-indicator.completed { border-color: rgba(61,122,88,0.35);  }
.tool-indicator.error     { border-color: rgba(180,50,40,0.35);  }

.tool-spinner {
  width: 13px; height: 13px;
  border: 1.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}
.tool-check      { color: var(--success); font-size: 14px; }
.tool-error-icon { color: var(--danger);  font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

.tool-name   { font-weight: 500; color: var(--text-primary); font-size: 12px; }
.tool-result { font-size: 11px; color: var(--text-muted); margin-top: 3px; max-height: 48px; overflow: hidden; text-overflow: ellipsis; }

.streaming-response { max-width: 680px; margin: 0 auto; }
.streaming-text { color: #1a1410; font-family: var(--font-typewriter); font-weight: 400; font-size: 15px; line-height: 1.75; min-height: 20px; }

/* ============================================================
   INPUT AREA
   ============================================================ */
.input-area {
  padding: 10px 14px;
  padding-bottom: calc(10px + var(--safe-bottom));
  padding-left:  calc(14px + var(--safe-left));
  padding-right: calc(14px + var(--safe-right));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-glass-deep);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
}

.input-wrap {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(252,248,240,0.82);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  border: 1px solid rgba(30,22,14,0.14);
  border-radius: var(--radius-xl);
  padding: 8px 8px 8px 16px;
  box-shadow: 0 2px 8px rgba(30,20,10,0.07);
  transition: border-color 0.2s, box-shadow 0.25s;
}
.input-wrap:focus-within {
  border-color: rgba(79,134,198,0.38);
  box-shadow: 0 4px 20px rgba(30,20,10,0.10), 0 0 0 3px rgba(79,134,198,0.11);
}

.input-field {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
  caret-color: var(--accent);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  min-height: 120px; /* 5 lines × 16px × 1.5 line-height */
}
.input-field:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}
.input-field::placeholder { color: var(--text-muted); }

.input-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s;
  min-width: 40px; min-height: 40px;
  -webkit-tap-highlight-color: transparent;
}
.input-btn:hover  { color: var(--text-secondary); background: var(--bg-hover); }
.input-btn.send-btn {
  background: var(--accent);
  color: #f5f0e8;
  border-radius: 50%;
  font-size: 18px;
  min-width: 38px; min-height: 38px;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(79,134,198,0.25);
}
.input-btn.send-btn:hover {
  background: var(--accent-bright);
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(79,134,198,0.45);
}
.input-btn.send-btn:active { transform: scale(0.97); }

.file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  color: var(--accent-bright);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  margin-bottom: 6px;
}
.file-chip button { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; padding: 0 2px; }

/* ============================================================
   DASHBOARD
   Navy ground with water drop decorators and glass cards.
   ============================================================ */

/* Dashboard scroll container — allow vertical scroll */
.chat-area:has(.dashboard) {
  position: relative;
  overflow-y: auto;
}

/* Water drops — lens blobs that refract the denim beneath
   backdrop-filter: brightness+contrast makes the SVG texture
   visibly lighter and sharper inside each drop — true lens effect */
/* .dash-drop removed */

.dashboard {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 0;
  position: relative;
  z-index: 1;
}

/* Dashboard — sumi-e watermark applied directly to the container,
   mirroring the auth-screen approach. ::before overlay dims it to ~40%. */
.chat-area.has-dash-bg {
  background-image: url('/static/karna-hero.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.chat-area.has-dash-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-color: var(--bg);
  opacity: 0.62;
  pointer-events: none;
  z-index: 0;
}

.dashboard > *:not(.dash-hero-bg) {
  position: relative;
  z-index: 1;
}

.dash-greeting {
  font-family: var(--font-heading);
  font-size: 40px;
  font-weight: 300;
  color: var(--text-heading);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}
.dash-subtitle {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 26px;
}

.dash-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 40px;
}

/* Glass stat card — paper glass */
.dash-card {
  width: 100%;
  min-height: 125px;
  background: rgba(252,248,240,0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(30,22,14,0.10);
  border-radius: 17px;
  padding: 22px;
  box-shadow: 0 4px 24px rgba(30,20,10,0.10);
  position: relative;
  transition: all 0.3s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(30,20,10,0.14);
  border-color: rgba(30,22,14,0.16);
}
.dash-card:active { transform: scale(0.97); }

/* Error card */
.dash-card.dash-card-error {
  background: rgba(248,238,234,0.80);
  border: 1.5px solid rgba(180,50,40,0.35);
  box-shadow:
    0 4px 24px rgba(30,20,10,0.10),
    0 0 18px rgba(180,50,40,0.10);
}
.dash-card.dash-card-error:hover {
  border-color: rgba(180,50,40,0.50);
  box-shadow:
    0 8px 32px rgba(30,20,10,0.14),
    0 0 24px rgba(180,50,40,0.16);
}

.dash-card-icon  {
  font-size: 26px;
  margin-bottom: 12px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
.dash-card-value {
  font-size: 52px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -1px;
}
.dash-card.dash-card-error .dash-card-value { color: var(--danger); }
/* Gmail card — coral number */
#dashGmailCard .dash-card-value { color: var(--accent); }

.dash-card-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 6px;
}

/* Section header */
.dash-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 38px 0 18px 0;
}

.dash-threads { display: flex; flex-direction: column; gap: 13px; }

/* Conversation items */
.dash-thread {
  background: rgba(248,243,233,0.80);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(30,22,14,0.10);
  border-radius: 15px;
  padding: 20px 26px;
  cursor: pointer;
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
  box-shadow: 0 2px 12px rgba(30,20,10,0.08);
}
.dash-thread:hover {
  background: rgba(240,234,222,0.88);
  transform: scale(1.02);
  border-color: rgba(30,22,14,0.14);
}
.dash-thread:active { background: rgba(232,226,214,0.90); transform: scale(0.99); }

.dash-thread-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-thread-meta {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  display: flex; gap: 14px;
  margin-bottom: 8px;
}
.dash-thread-preview {
  font-size: 13px;
  color: var(--text-body);
  line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* CTA button — cerulean border, transparent */
.dash-new-btn {
  width: 330px;
  height: 50px;
  background: rgba(79,134,198,0.06);
  border: 1.5px solid rgba(79,134,198,0.50);
  border-radius: 12px;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 24px auto 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(79,134,198,0.10);
  -webkit-tap-highlight-color: transparent;
}
.dash-new-btn:hover {
  background: rgba(79,134,198,0.12);
  box-shadow: 0 6px 20px rgba(79,134,198,0.18);
  transform: translateY(-1px);
}
.dash-new-btn:active {
  transform: scale(0.98);
  background: rgba(79,134,198,0.16);
}

/* ============================================================
   OVERLAY SYSTEM (threads + settings)
   ============================================================ */
.overlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--bg-overlay);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  z-index: 50;
  display: none; opacity: 0;
  transition: opacity 0.22s ease;
}
.overlay.active { display: flex; opacity: 1; }
#threadsOverlay.active { background: transparent; backdrop-filter: none; }
#threadsOverlay .overlay-close { background: transparent; }

.overlay-panel {
  width: 340px;
  max-width: 100%;
  height: 100%;
  background: var(--bg-glass-deep);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  border-right: 1px solid var(--border-glass);
  padding: 0;
  overflow: hidden;
  animation: slideIn 0.22s ease;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}
.overlay-panel.right {
  margin-left: auto;
  border-right: none;
  border-left: 1px solid var(--border-glass);
  animation: slideInRight 0.22s ease;
  padding: 0;
  padding-top: var(--safe-top);
}

.settings-header {
  padding: 16px 16px 0;
  padding-right: calc(16px + var(--safe-right));
  flex-shrink: 0;
}
.settings-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 16px;
  padding-right:  calc(16px + var(--safe-right));
  padding-bottom: calc(16px + var(--safe-bottom));
  min-height: 0;
}

@keyframes slideIn      { from{transform:translateX(-16px);opacity:0} to{transform:translateX(0);opacity:1} }
@keyframes slideInRight { from{transform:translateX(16px);opacity:0}  to{transform:translateX(0);opacity:1} }

.overlay-close { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; }

/* ============================================================
   THREAD SIDEBAR
   ============================================================ */
.thread-sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
}
.thread-sidebar-header .panel-title { margin: 0; }

.thread-sidebar-footer {
  flex-shrink: 0;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  display: flex; gap: 6px;
  padding-bottom: calc(8px + var(--safe-bottom));
}
.thread-footer-btn {
  flex: 1;
  background: rgba(30,22,14,0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 10px 8px;
  border-radius: var(--radius-md);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px;
  -webkit-tap-highlight-color: transparent;
}
.thread-footer-btn:active { color: var(--text-primary); border-color: var(--border-accent); background: var(--accent-dim); }
.thread-footer-btn span  { font-size: 20px; }

.thread-new-btn {
  background: var(--accent);
  color: #f5f0e8;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  min-height: 42px;
  -webkit-tap-highlight-color: transparent;
}
.thread-new-btn:active { background: var(--accent-bright); }

.thread-list { flex: 1; overflow-y: auto; padding: 6px 10px; -webkit-overflow-scrolling: touch; }

.thread-item {
  padding: 11px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.13s;
  margin-bottom: 2px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.thread-item:active { background: var(--bg-hover); }
.thread-item.active {
  background: var(--accent-dim);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}
.thread-item-title {
  font-size: 13px; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.thread-item-preview { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-item-meta    { font-size: 10px; color: var(--text-muted); margin-top: 3px; display: flex; justify-content: space-between; }
.thread-item-actions { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: none; gap: 2px; background: var(--bg); border-radius: var(--radius-sm); padding: 0 2px; }
.thread-item:hover .thread-item-actions { display: flex; }

.thread-action-btn {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 13px; padding: 8px;
  border-radius: var(--radius-sm);
  min-width: 36px; min-height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.thread-action-btn:hover        { color: var(--text-primary); background: rgba(30,22,14,0.06); }
.thread-action-btn.danger:hover { color: var(--danger); }

.thread-section-label {
  font-size: 9px; font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 12px 5px;
}

/* ============================================================
   SETTINGS OVERLAY (right panel)
   ============================================================ */
.panel-title {
  font-size: 10px; font-weight: 600;
  letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0;
  flex-shrink: 0;
}

.settings-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* Back to Dashboard — mobile first, always visible */
.settings-back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  min-height: 36px;
  display: flex; align-items: center; gap: 5px;
  -webkit-tap-highlight-color: transparent;
}
.settings-back-btn:hover  { color: var(--accent-bright); background: var(--accent-dim); }
.settings-back-btn:active { background: var(--accent-dim); }

.tabs-wrap {
  position: relative;
  flex-shrink: 0;
}
.tabs-wrap::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 1px;
  width: 32px;
  background: linear-gradient(to right, transparent, var(--bg-glass-deep));
  pointer-events: none;
  z-index: 1;
}
.tabs {
  display: flex; gap: 0;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 10px 9px;
  font-size: 10.5px; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.18s, border-color 0.18s;
  white-space: nowrap;
  min-height: 40px;
  display: flex; align-items: center;
  -webkit-tap-highlight-color: transparent;
}
.tab:active { color: var(--text-secondary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content        { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   AUTH SCREENS — Hero image + floating paper card
   ============================================================ */
.auth-screen {
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  padding: 24px;

  /* Full-bleed sumi-e hero image */
  background-image: url('/static/karna-hero.jpg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;

  /* Fallback gradient when image is absent */
  background-color: #e8e0d0;
}


.auth-form {
  position: relative;
  z-index: 1;
  width: 340px;
  max-width: 100%;
  background: rgba(252, 248, 240, 0.88);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid rgba(200, 190, 170, 0.55);
  border-radius: 18px;
  padding: 36px 32px;
  box-shadow:
    0 8px 40px rgba(30, 20, 10, 0.18),
    0 1px 0 rgba(255, 255, 255, 0.80) inset;
}

.auth-title {
  font-family: var(--font-heading);
  font-size: 42px;
  font-weight: 300;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #1a1410;
  text-align: center;
  margin-bottom: 4px;
  line-height: 1.1;
}
/* Cerulean rule beneath title */
.auth-title::after {
  content: '';
  display: block;
  width: 32px;
  height: 1.5px;
  background: var(--accent);
  margin: 10px auto 0;
  opacity: 0.7;
}

.auth-tagline {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--accent);
  text-align: center;
  margin-top: 14px;
  margin-bottom: 2px;
  opacity: 0.85;
}

.auth-subtitle {
  font-family: var(--font-heading);
  font-style: italic;
  font-weight: 300;
  font-size: 15px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 32px;
  letter-spacing: 0.3px;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 10px; font-weight: 500;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input, .field textarea, .field select {
  width: 100%;
  background: rgba(255,255,255,0.55);
  backdrop-filter: none;
  border: 1px solid rgba(30,22,14,0.18);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}
.field input:focus, .field textarea:focus {
  border-color: rgba(79,134,198,0.50);
  box-shadow: 0 0 0 2px rgba(79,134,198,0.10);
}
.field textarea { min-height: 80px; resize: vertical; }

/* Primary action button */
.btn {
  width: 100%;
  padding: 13px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 12px; font-weight: 500;
  letter-spacing: 1.5px; text-transform: uppercase;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}
.btn:active {
  background: var(--accent);
  color: #f5f0e8;
  box-shadow: var(--shadow-coral);
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-small    { width: auto; padding: 8px 16px; font-size: 11px; min-height: 36px; }

.btn-danger        { border-color: var(--danger); color: var(--danger); }
.btn-danger:active { background: rgba(180,50,40,0.10); }

.error-text   { color: var(--danger); font-size: 13px; margin-top: 8px; }
.success-text { color: var(--accent-bright); font-size: 13px; margin-top: 8px; }

/* ============================================================
   ITEM CARDS
   ============================================================ */
.item-card {
  padding: 12px;
  background: var(--bg-glass);
  backdrop-filter: var(--blur-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: border-color 0.18s;
  overflow: hidden; min-width: 0;
}
.item-card:hover { border-color: rgba(30,22,14,0.18); }

.item-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px; gap: 8px; flex-wrap: wrap;
}
.item-card-title {
  font-size: 13px; font-weight: 500;
  color: var(--text-primary);
  min-width: 0; overflow-wrap: break-word; word-break: break-word;
}
.item-card-meta { font-size: 11px; color: var(--text-muted); }
.item-card-body {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.55;
  overflow-wrap: break-word; word-break: break-word; white-space: pre-wrap;
}

/* Tag */
.tag {
  display: inline-block;
  font-size: 9px; font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--accent-dim);
  border: 1px solid rgba(79,134,198,0.20);
  color: var(--accent-bright);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */
.toggle { position: relative; width: 36px; height: 20px; cursor: pointer; }
.toggle input { display: none; }
.toggle-track {
  width: 100%; height: 100%;
  background: rgba(30,22,14,0.10);
  border-radius: 10px;
  transition: background 0.2s;
  border: 1px solid var(--border);
}
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(16px); }

/* ============================================================
   WELCOME SCREEN
   ============================================================ */
.welcome {
  max-width: 680px;
  margin: 0 auto;
  text-align: center;
  padding-top: 10vh;
}
.welcome h2 {
  font-size: 18px;
  font-weight: 300;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.welcome p { font-size: 13px; color: var(--text-muted); line-height: 1.65; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: calc(12px + var(--safe-top));
  right: calc(12px + var(--safe-right));
  z-index: 200;
  display: flex; flex-direction: column; gap: 6px;
}
.toast {
  background: var(--bg-glass-deep);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  animation: dropIn 0.2s ease;
  max-width: 300px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-float);
}
.toast.success { border-color: rgba(74,140,111,0.35); }
.toast.error   { border-color: rgba(245,69,56,0.35); }

/* ============================================================
   FEATURE STATUS BADGES
   ============================================================ */
.feat-proposed    { color: var(--accent-bright); }
.feat-approved    { color: var(--accent); }
.feat-rejected    { color: var(--danger); }
.feat-in_progress { color: #7fa8c9; }
.feat-implemented { color: var(--success); }
.feat-deferred    { color: var(--text-muted); }

/* ============================================================
   DOCUMENTS VIEW
   ============================================================ */
.documents-container { max-width: 860px; margin: 0 auto; padding: 20px; }
.documents-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.documents-title  { font-size: 18px; font-weight: 600; color: var(--text-primary); }

.documents-upload-area {
  border: 1px dashed var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 36px;
  text-align: center;
  background: var(--bg-glass);
  backdrop-filter: var(--blur-sm);
  transition: border-color 0.2s;
}
.documents-upload-area:hover { border-color: var(--border-accent); }
.documents-upload-area.dragover { border-color: var(--accent); background: var(--accent-dim); }

.documents-upload-btn {
  background: var(--accent); color: #f5f0e8;
  border: none; padding: 11px 24px;
  border-radius: var(--radius-md); font-weight: 600;
  cursor: pointer; margin-top: 14px;
}
.documents-list { display: grid; gap: 10px; margin-top: 20px; }

.document-card {
  background: var(--bg-glass);
  backdrop-filter: var(--blur-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px; display: flex; gap: 14px; align-items: flex-start;
}
.document-icon    { font-size: 28px; flex-shrink: 0; }
.document-info    { flex: 1; }
.document-name    { font-weight: 500; color: var(--text-primary); margin-bottom: 3px; }
.document-meta    { font-size: 12px; color: var(--text-muted); }
.document-summary { font-size: 13px; color: var(--text-secondary); margin-top: 6px; line-height: 1.5; }
.document-actions { display: flex; gap: 6px; margin-top: 10px; }
.document-btn {
  background: rgba(30,22,14,0.04);
  border: none; color: var(--text-secondary);
  padding: 5px 11px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 12px; transition: all 0.18s;
}
.document-btn:hover { background: var(--accent-dim); color: var(--accent-bright); }

.documents-search { display: flex; gap: 10px; margin-bottom: 16px; }
.documents-search input {
  flex: 1;
  background: var(--bg-glass); border: 1px solid var(--border);
  color: var(--text-primary); padding: 9px 14px;
  border-radius: var(--radius-md); font-size: 14px;
}
.documents-chat-area {
  background: rgba(30,22,14,0.04); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px;
  margin-top: 14px; max-height: 280px; overflow-y: auto;
}
.documents-chat-msg           { margin-bottom: 10px; font-size: 13px; }
.documents-chat-msg.user      { color: var(--accent-bright); }
.documents-chat-msg.assistant { color: var(--text-secondary); }
.documents-chat-input         { display: flex; gap: 8px; margin-top: 10px; }
.documents-chat-input input   {
  flex: 1; background: rgba(255,255,255,0.55);
  border: 1px solid var(--border); color: var(--text-primary);
  padding: 9px; border-radius: var(--radius-sm);
}
.documents-comparison {
  background: var(--bg-glass); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 18px; margin-top: 14px;
}

/* Status badges */
.status-badge            { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 10px; margin-left: 6px; }
.status-badge.processing { background: rgba(79,134,198,0.10); color: var(--accent); border: 1px solid rgba(79,134,198,0.30); }
.status-badge.completed  { background: rgba(74,140,111,0.15); color: var(--success); }
.status-badge.failed     { background: rgba(245,69,56,0.15);  color: var(--danger); }

/* ============================================================
   MOBILE — portrait-first
   ============================================================ */
@media (max-width: 640px) {
  html, body { font-size: 15px; }

  .overlay-panel { width: 100%; border-radius: 0; }
  .overlay-panel.right { padding: 0; padding-top: calc(16px + var(--safe-top)); }
  .settings-header { padding: 14px 14px 0; }
  .settings-scroll { padding: 0 14px 14px; padding-bottom: calc(14px + var(--safe-bottom)); }

  .chat-area { padding: 16px 14px; padding-left: calc(14px + var(--safe-left)); padding-right: calc(14px + var(--safe-right)); }

  .input-area { padding: 8px 10px; padding-bottom: calc(8px + var(--safe-bottom)); }
  .input-wrap { border-radius: var(--radius-xl); padding: 7px 7px 7px 14px; box-shadow: 0 1px 6px rgba(30,20,10,0.06); }
  .input-field { font-size: 16px; }

  /* 2-col dash cards on mobile */
  .dash-cards      { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .dash-card       { padding: 16px 14px; border-radius: 14px; min-height: 110px; }
  .dash-card-value { font-size: 36px; }
  .dash-card-icon  { font-size: 22px; margin-bottom: 10px; }
  .dash-greeting   { font-size: 28px; }
  .dash-new-btn    { width: 100%; }
  .auth-form       { padding: 28px 22px; border-radius: 14px; }
  .auth-title      { font-size: 36px; }
  .dash-thread     { border-radius: 12px; padding: 14px 16px; }
  .dash-thread-title { font-size: 15px; }

  .thread-title-display { display: none; }
  .topbar { padding: 8px 10px; }
  .topbar-btn { min-width: 46px; min-height: 46px; font-size: 20px; padding: 10px; }

  .thread-item-actions { display: flex; }
  .thread-item { padding: 12px 72px 12px 11px; }

  .message-group { margin-bottom: 18px; }
  .tabs .tab { padding: 10px 9px; font-size: 11px; }
  .notif-dropdown { top: 58px; }

  .input-btn { min-width: 42px; min-height: 42px; }
  .input-btn.send-btn { min-width: 40px; min-height: 40px; }

  /* Dashboard section spacing */
  .dash-section-title { margin: 22px 0 12px; }

  /* Welcome screen: less vertical breathing room on portrait */
  .welcome { padding-top: 5vh; }
  .welcome h2 { font-size: 16px; }

  /* Documents view: tighten padding */
  .documents-container  { padding: 14px; }
  .documents-upload-area { padding: 22px 14px; }

  /* Code blocks: prevent horizontal blowout on narrow screens */
  .msg-assistant pre { padding: 10px 12px; }
  .msg-assistant pre code { font-size: 12px; }

  /* ── Portrait hero image — mobile only ────────────────────────────── */
  /* Auth screen: swap to portrait crop, add contrast wash for the light image */
  .auth-screen {
    position: relative;
    background-image: url('/static/karna-hero-mobile.jpg');
    background-position: center top;
  }
  .auth-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(30,22,14,0.18);
    pointer-events: none;
    z-index: 0;
  }

  /* Dashboard: swap to portrait crop, lighter overlay */
  .chat-area.has-dash-bg {
    background-image: url('/static/karna-hero-mobile.jpg');
    background-position: center 40%;
  }
  .chat-area.has-dash-bg::before { opacity: 0.50; }
}

@media (max-width: 400px) {
  /* Ultra-narrow phones (320–400px): tighten auth form */
  .auth-form     { padding: 24px 16px; }
  .auth-title    { font-size: 32px; letter-spacing: 2px; }
  .auth-subtitle { font-size: 13px; }
}

@media (max-width: 380px) {
  .dash-cards      { grid-template-columns: 1fr 1fr; }
  .dash-card       { padding: 12px 10px; }
  .dash-card-value { font-size: 28px; }
  .topbar-title    { letter-spacing: 2.5px; }
}

/* ============================================================
   DESKTOP SHOWCASE
   ============================================================ */
@media (min-width: 900px) {
  .chat-area { padding: 36px 24px; }
  .message-group, .streaming-response, .thinking { max-width: 720px; }
  .input-wrap { max-width: 720px; }
  .dashboard  { max-width: 720px; }
  .dash-cards { grid-template-columns: repeat(4, 1fr); gap: 18px; }
  .dash-greeting { font-size: 44px; }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar       { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(30,22,14,0.10); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(79,134,198,0.28); }

/* ============================================================
   SELECTION
   ============================================================ */
::selection { background: rgba(79,134,198,0.22); color: var(--text-primary); }

/* ============================================================
   FOCUS VISIBLE
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   SETTINGS & SKILLS PAGES — Full-screen page views (PWA-first)
   ============================================================ */

/* Shared page layout */
.page-view { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.page-header {
  display: flex; align-items: center; gap: 10px;
  padding: calc(14px + var(--safe-top, 0px)) 16px 14px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
  background: var(--bg-glass-deep); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.page-back-btn {
  background: none; border: none; color: var(--accent);
  font-size: 14px; font-weight: 500;
  padding: 8px 4px; min-width: 44px; min-height: 44px;
  display: flex; align-items: center; cursor: pointer; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.page-back-btn:hover { opacity: 0.8; }
.page-title {
  flex: 1; font-size: 16px; font-weight: 600;
  color: var(--text-primary); font-family: var(--font-heading); margin: 0;
}

/* Settings grouped list */
.settings-page {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(20px + var(--safe-bottom, 0px));
}
.settings-group { margin-top: 28px; }
.settings-group:first-child { margin-top: 16px; }
.settings-group-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.4px; color: var(--text-muted); padding: 0 20px 8px;
}
.settings-row {
  display: flex; align-items: center;
  padding: 15px 20px; border-top: 1px solid var(--border);
  cursor: pointer; gap: 14px; min-height: 52px;
  -webkit-tap-highlight-color: transparent; transition: background 0.15s;
}
.settings-row:last-child { border-bottom: 1px solid var(--border); }
.settings-row:active, .settings-row:hover { background: var(--accent-dim); }
.settings-row-icon { font-size: 18px; width: 28px; text-align: center; flex-shrink: 0; }
.settings-row-label { flex: 1; font-size: 15px; font-weight: 500; color: var(--text-primary); }
.settings-row-chevron { color: var(--text-muted); font-size: 14px; }
.settings-section-content {
  padding: 16px 16px calc(60px + var(--safe-bottom, 0px));
  overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch;
}

/* Desktop two-column settings */
@media (min-width: 900px) {
  .settings-two-col { display: flex; flex: 1; overflow: hidden; }
  .settings-nav-col { width: 240px; flex-shrink: 0; border-right: 1px solid var(--border); overflow-y: auto; padding: 12px 0; }
  .settings-content-col { flex: 1; overflow-y: auto; padding: 24px; }
  .settings-nav-group-label {
    font-size: 9px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 1.2px; color: var(--text-muted); padding: 12px 16px 4px;
  }
  .settings-nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; cursor: pointer; border-radius: var(--radius-md);
    margin: 2px 8px; font-size: 13px; font-weight: 500;
    color: var(--text-secondary); transition: background 0.15s, color 0.15s; min-height: 36px;
    -webkit-tap-highlight-color: transparent;
  }
  .settings-nav-item:hover { background: var(--accent-dim); color: var(--text-primary); }
  .settings-nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
  .settings-nav-item-icon { font-size: 14px; width: 20px; text-align: center; }
}

/* Skills page */
.skills-page {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(80px + var(--safe-bottom, 0px));
}
.skill-card {
  background: rgba(30,22,14,0.03); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px;
  transition: border-color 0.2s;
}
.skill-card:active { border-color: var(--border-accent); }
.skill-card-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.skill-card-slug { font-size: 11px; font-family: var(--font-mono); color: var(--accent); margin: 3px 0; }
.skill-card-desc { font-size: 13px; color: var(--text-secondary); margin: 6px 0 4px; line-height: 1.5; }
.skill-card-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.skill-card-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.skill-disabled { opacity: 0.55; }
.skills-empty { text-align: center; padding: 56px 24px; }
.skills-empty-icon { font-size: 40px; margin-bottom: 14px; }
.skills-empty-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; font-family: var(--font-heading); }
.skills-empty-hint { font-size: 13px; color: var(--text-muted); line-height: 1.7; }
.skills-empty-hint code {
  background: var(--accent-dim); color: var(--accent);
  padding: 2px 6px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 12px;
}
