/* ============================================================
   ARK Web — style.css
   Light mode default + Dark mode toggle
   Nebula accent palette: purple, coral, turquoise, gold
   ============================================================ */

/* ── Google Fonts (loaded in HTML) ────────────────────── */
/* <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet"> */

/* ── Light Mode Variables (Default) ───────────────────── */
:root {
  /* Companions */
  --felix-color: #9b6dff;
  --kai-color:   #4d9fff;

  /* ☀️ Light palette */
  --bg-deep:    #f5f3f0;
  --bg-base:    #fafaf8;
  --bg-panel:   #ffffff;
  --bg-hover:   #f0eef5;
  --bg-active:  #e8e5f0;

  /* Text */
  --text-primary:   #1a1a2e;
  --text-secondary: #4a4a6a;
  --text-muted:     #8888aa;

  /* Borders */
  --border:         rgba(0,0,0,0.08);
  --border-active:  rgba(0,0,0,0.15);

  /* Accent (cambia según companion activo) */
  --accent:       var(--felix-color);
  --accent-dim:   rgba(155,109,255,0.1);
  --accent-glow:  0 0 20px rgba(155,109,255,0.15);

  /* Nebula palette */
  --nebula-coral:     #ff6b8a;
  --nebula-turquoise: #4dd4c4;
  --nebula-gold:      #ffc857;
  --nebula-purple:    #9b6dff;

  /* Status */
  --green:  #22c55e;
  --yellow: #eab308;
  --red:    #ef4444;

  /* Spacing & radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --gap:       16px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 10px 30px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);

  /* Gradient header */
  --header-gradient: linear-gradient(135deg, #9b6dff 0%, #c084fc 30%, #ff6b8a 70%, #ffc857 100%);
}

[data-companion="kai"] {
  --accent:     var(--kai-color);
  --accent-dim: rgba(77,159,255,0.1);
  --accent-glow: 0 0 20px rgba(77,159,255,0.15);
}

/* ── 🌙 Dark Mode Variables ──────────────────────────── */
[data-theme="dark"] {
  --bg-deep:    #0c0c14;
  --bg-base:    #111119;
  --bg-panel:   #18182a;
  --bg-hover:   #1e1e32;
  --bg-active:  #26263e;

  --text-primary:   #e8e8f0;
  --text-secondary: #a0a0c0;
  --text-muted:     #6a6a8a;

  --border:         rgba(255,255,255,0.07);
  --border-active:  rgba(255,255,255,0.15);

  --accent-dim:   rgba(155,109,255,0.15);
  --accent-glow:  0 0 20px rgba(155,109,255,0.25);

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:  0 10px 30px rgba(0,0,0,0.5);
}

[data-theme="dark"][data-companion="kai"] {
  --accent-dim: rgba(77,159,255,0.15);
  --accent-glow: 0 0 20px rgba(77,159,255,0.25);
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  display: grid;
  grid-template-rows: 56px 44px 1fr;
  grid-template-areas: "header" "nav" "main";
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ── Subtle star pattern (light mode) ──────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(155,109,255,0.15) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 60%, rgba(255,107,138,0.12) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 40%, rgba(77,212,196,0.12) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 80%, rgba(255,200,87,0.1) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 30%, rgba(155,109,255,0.1) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

[data-theme="dark"] body::before {
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(155,109,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 60%, rgba(255,107,138,0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 40%, rgba(77,212,196,0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 80%, rgba(255,200,87,0.15) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 30%, rgba(155,109,255,0.2) 0%, transparent 100%);
  opacity: 1;
}

/* ── Header ────────────────────────────────────────────── */
.header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}

/* Nebula gradient line at the very top */
.header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--header-gradient);
}

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

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

.selector-mini {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.selector-mini:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 1.2rem; }
.logo-text {
  font-size: 1.1rem; font-weight: 700;
  background: var(--header-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 2px;
}
.logo-sub { font-size: 0.7rem; color: var(--text-muted); letter-spacing: 1px; margin-top: 2px; }

/* Theme toggle */
.theme-toggle {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* Companion tabs */
.companion-tabs { display: flex; gap: 4px; align-items: center; }

.companion-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 14px; border-radius: 20px;
  border: 1px solid transparent;
  background: transparent; color: var(--text-secondary);
  font-size: 0.85rem; font-weight: 500; cursor: pointer;
  transition: all 0.2s;
}
.companion-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.companion-tab.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 12px var(--accent-dim);
}
.companion-tab .tab-dot {
  width: 7px; height: 7px; border-radius: 50%;
  animation: pulse 2s infinite;
}
.companion-tab.add-tab {
  padding: 5px 10px; font-size: 1rem; font-weight: 300;
  color: var(--text-muted);
}

.companion-tab .badge {
  background: var(--red); color: white;
  font-size: 0.65rem; font-weight: 700;
  padding: 1px 5px; border-radius: 8px;
}

/* Status */
.status-indicator { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--text-muted); }
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }
.status-dot.error  { background: var(--red); }

.btn-icon {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; padding: 6px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  color: var(--text-secondary);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--accent); }

/* ── Section Nav ───────────────────────────────────────── */
.section-nav {
  grid-area: nav;
  display: flex; gap: 2px; align-items: center;
  padding: 0 20px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.section-btn {
  padding: 10px 16px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-size: 0.82rem; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: all 0.2s;
}
.section-btn:hover { color: var(--text-primary); }
.section-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ── Main ──────────────────────────────────────────────── */
.main {
  grid-area: main;
  padding: var(--gap) 20px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 1;
}

.section { display: none; }
.section.active { display: block; animation: fadeIn 0.3s ease; }

/* ── Panels ────────────────────────────────────────────── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--gap);
  margin-bottom: var(--gap);
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
}
.panel:hover {
  border-color: var(--border-active);
  box-shadow: var(--shadow-md);
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.panel-title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.panel-badge {
  font-size: 0.72rem; padding: 2px 10px;
  background: var(--accent-dim); color: var(--accent);
  border-radius: 10px; font-weight: 600;
}

/* ── Stats Row ─────────────────────────────────────────── */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap);
  margin-bottom: var(--gap);
}

/* Houston Vital Sensors */
.vital-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

.vital-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 15px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.vital-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md), var(--accent-glow);
}

.vital-icon {
  font-size: 1.5rem;
  background: var(--accent-dim);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.vital-info {
  display: flex;
  flex-direction: column;
}

.vital-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.vital-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all 0.25s;
  box-shadow: var(--shadow-sm);
}
.stat-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md), var(--accent-glow); }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ── Wake Portal Overlay ────────────────────────────────── */
.wake-portal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at center, rgba(250, 248, 245, 0.98), #fff);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(15px);
  animation: fadeIn 0.4s ease;
}

[data-theme="dark"] .wake-portal {
  background: radial-gradient(circle at center, rgba(15, 12, 41, 0.98), #000);
}

.wake-portal.hidden { display: none; }

.wake-content {
  text-align: center;
  max-width: 500px;
  padding: 40px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 50px var(--accent-dim);
}

.wake-logo {
  font-size: 3.5rem;
  margin-bottom: 20px;
  animation: rotate 15s linear infinite;
  display: inline-block;
}

.wake-greeting {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: var(--header-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.wake-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}

.wake-summary {
  background: var(--bg-hover);
  padding: 20px;
  border-radius: var(--radius-md);
  margin-bottom: 30px;
  font-size: 0.9rem;
  line-height: 1.6;
  text-align: left;
  border-left: 3px solid var(--accent);
  max-height: 250px;
  overflow-y: auto;
  color: var(--text-secondary);
}

/* ── Household Center ────────────────────────────────────── */
.household-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.household-section {
  background: var(--bg-panel);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.h-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.h-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.h-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-hover);
  border-radius: 8px;
  font-size: 0.85rem;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.h-item:hover {
  border-color: var(--border-active);
  background: var(--bg-active);
}

.h-item.done {
  opacity: 0.4;
  text-decoration: line-through;
}

.h-item input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.h-add {
  display: flex;
  gap: 6px;
}

.h-add input {
  flex: 1;
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
}

.h-add input:focus { border-color: var(--accent); }

.h-add button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.h-add button:hover { opacity: 0.85; transform: translateY(-1px); }

.h-total {
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: right;
  color: var(--accent);
}

/* ── Reminder Banner ───────────────────────────────────── */
.reminder-banner {
  display: flex; align-items: center; gap: 12px;
  background: rgba(234,179,8,0.08);
  border: 1px solid rgba(234,179,8,0.25);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: var(--gap);
}
.reminder-icon { font-size: 1.1rem; }
.reminder-text { flex: 1; font-size: 0.85rem; color: var(--yellow); }

[data-theme="dark"] .reminder-banner {
  background: rgba(234,179,8,0.1);
  border-color: rgba(234,179,8,0.3);
}

/* ── Brodmann Grid ─────────────────────────────────────── */
.heatmap-legend { display: flex; align-items: center; gap: 8px; font-size: 0.72rem; color: var(--text-muted); }
.legend-bar {
  width: 80px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-hover), var(--accent));
}

.regions-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.region-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.region-cell:hover { transform: scale(1.08); border-color: var(--accent); z-index: 2; box-shadow: var(--accent-glow); }
.region-cell.has-memories { border-color: rgba(155,109,255,0.3); }
.region-cell.active-region { border-color: var(--accent); box-shadow: var(--accent-glow); }

.region-num { font-size: 0.6rem; font-weight: 700; color: var(--text-secondary); z-index: 1; }
.region-count { font-size: 0.55rem; color: var(--text-muted); z-index: 1; }
.region-fill {
  position: absolute; inset: 0;
  background: var(--accent); opacity: 0;
  transition: opacity 0.3s;
}

/* Tooltip */
.region-cell::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--bg-panel); border: 1px solid var(--border-active);
  color: var(--text-primary); font-size: 0.7rem;
  padding: 4px 8px; border-radius: var(--radius-sm);
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.15s;
  z-index: 10;
  box-shadow: var(--shadow-md);
}
.region-cell:hover::after { opacity: 1; }

/* Region Detail */
.region-detail {
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--gap);
  margin-top: var(--gap);
  animation: slideIn 0.2s ease;
  box-shadow: var(--shadow-md);
}
.region-detail-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.region-detail-num {
  font-size: 1.4rem; font-weight: 700; color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
}
.region-detail-label { font-weight: 600; flex: 1; }
.region-detail-count {
  font-size: 0.78rem; padding: 3px 10px;
  background: var(--accent-dim); color: var(--accent); border-radius: 10px;
}

.region-memories { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.memory-item {
  background: var(--bg-hover); border-radius: var(--radius-sm);
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  font-size: 0.82rem; color: var(--text-secondary);
  line-height: 1.5;
}
.memory-item .memory-meta {
  font-size: 0.7rem; color: var(--text-muted);
  margin-top: 4px; font-family: 'JetBrains Mono', monospace;
}

/* ── Upload ────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border-active);
  border-radius: var(--radius-lg);
  padding: 60px 40px;
  text-align: center;
  transition: all 0.3s;
  cursor: pointer;
  margin-bottom: var(--gap);
  background: var(--bg-panel);
}
.upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.upload-area.drag-over { border-color: var(--accent); background: var(--accent-dim); }
.upload-icon { font-size: 3rem; margin-bottom: 16px; }
.upload-title { font-size: 1.2rem; font-weight: 600; margin-bottom: 8px; }
.upload-subtitle { color: var(--text-muted); margin-bottom: 20px; font-size: 0.875rem; }
.upload-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 10px; }

.pre-analysis-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-bottom: 20px;
}
.pre-stat {
  background: var(--bg-hover); border-radius: var(--radius-md);
  padding: 14px; text-align: center;
  border: 1px solid var(--border);
}
.pre-stat-val { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.pre-stat-label { font-size: 0.72rem; color: var(--text-muted); }

.upload-actions { display: flex; gap: 10px; }

.progress-bar-container {
  background: var(--bg-hover); border-radius: 6px; height: 8px; margin: 16px 0 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-bar {
  height: 100%; background: var(--header-gradient);
  border-radius: 6px; transition: width 0.3s;
}
.progress-labels { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); }

.token-tracker {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-top: 16px;
}
.token-stat {
  background: var(--bg-hover); border-radius: var(--radius-sm);
  padding: 10px 14px;
  border: 1px solid var(--border);
}
.token-label { font-size: 0.7rem; color: var(--text-muted); display: block; }
.token-value { font-size: 1rem; font-weight: 600; font-family: 'JetBrains Mono', monospace; color: var(--text-primary); }

.progress-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.progress-stat { font-size: 0.8rem; color: var(--text-secondary); }
.progress-stat strong { color: var(--accent); }

.result-icon { font-size: 3rem; text-align: center; margin-bottom: 12px; }
.result-message { text-align: center; font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 20px; }

/* ── Search ────────────────────────────────────────────── */
.search-header { margin-bottom: var(--gap); }
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 10px 14px;
  margin-bottom: 10px; transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}
.search-box:focus-within { border-color: var(--accent); box-shadow: var(--shadow-sm), var(--accent-glow); }
.search-icon { font-size: 1rem; }
.search-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 0.9rem; font-family: inherit;
}
.search-input::placeholder { color: var(--text-muted); }

.search-filters { display: flex; gap: 10px; }
.filter-select {
  background: var(--bg-hover); border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: var(--radius-sm);
  padding: 6px 10px; font-size: 0.8rem; cursor: pointer;
}

.search-results { display: flex; flex-direction: column; gap: 8px; }
.search-result-item {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 16px;
  border-left: 3px solid var(--accent);
  animation: fadeIn 0.15s ease;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}
.search-result-item:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-active);
}
.search-result-item .result-text { font-size: 0.875rem; line-height: 1.6; color: var(--text-secondary); }
.search-result-item .result-meta {
  font-size: 0.7rem; color: var(--text-muted); margin-top: 8px;
  display: flex; gap: 12px; font-family: 'JetBrains Mono', monospace;
}
.result-region-tag {
  background: var(--accent-dim); color: var(--accent);
  padding: 1px 6px; border-radius: 4px; font-size: 0.68rem; font-weight: 600;
}

.result-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 8px;
}
.result-badges {
  display: flex;
  gap: 8px;
  align-items: center;
}
.sensorial-spark {
  font-size: 0.9rem;
  filter: drop-shadow(0 0 5px var(--kai-color));
  animation: sparkPulse 2s infinite;
}

/* ── Pills ─────────────────────────────────────────────── */
.pills-header { margin-bottom: var(--gap); }
.section-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; }
.section-subtitle { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 16px; }

.pills-period-btns { display: flex; gap: 8px; }
.pill-btn {
  padding: 6px 16px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg-panel);
  color: var(--text-secondary); font-size: 0.82rem; cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}
.pill-btn:hover, .pill-btn.active {
  border-color: var(--accent); background: var(--accent-dim); color: var(--accent);
}

.pill-content-area {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--gap); min-height: 200px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.pill-result { width: 100%; }
.pill-meta { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 12px; font-family: 'JetBrains Mono', monospace; }
.pill-text {
  background: var(--bg-hover); border-radius: var(--radius-md);
  padding: 16px; font-size: 0.875rem; line-height: 1.7;
  color: var(--text-secondary); white-space: pre-wrap; margin-bottom: 14px;
  border: 1px solid var(--border);
}
.pill-actions { display: flex; gap: 10px; }

.pill-generating { display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--text-muted); font-size: 0.85rem; }

/* ── Identity ──────────────────────────────────────────── */
.identity-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap);
}
.identity-panel { height: fit-content; }

.marrow-content {
  font-size: 0.85rem; line-height: 1.7; color: var(--text-secondary);
  white-space: pre-wrap;
}

.spine-list { display: flex; flex-direction: column; gap: 8px; }
.spine-item {
  background: var(--bg-hover); border-radius: var(--radius-sm);
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
}
.spine-item .spine-title { font-size: 0.82rem; font-weight: 600; margin-bottom: 4px; }
.spine-item .spine-content { font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }
.spine-item .spine-meta { font-size: 0.68rem; color: var(--text-muted); margin-top: 4px; font-family: 'JetBrains Mono', monospace; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(8px);
}
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.6); }

.modal {
  background: var(--bg-panel); border: 1px solid var(--border-active);
  border-radius: var(--radius-lg); padding: 24px;
  width: 90%; max-width: 480px;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { display: flex; flex-direction: column; gap: 12px; }

.field-label { font-size: 0.78rem; color: var(--text-muted); display: block; margin-bottom: 4px; }
.field-input {
  width: 100%; background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px;
  color: var(--text-primary); font-size: 0.875rem; font-family: inherit;
  transition: border-color 0.2s;
}
.field-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

/* ── Buttons ───────────────────────────────────────────── */
.btn-primary {
  background: var(--header-gradient); color: white;
  border: none; border-radius: var(--radius-sm);
  padding: 9px 20px; font-size: 0.875rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--bg-panel); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 20px; font-size: 0.875rem; cursor: pointer; transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-small {
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  padding: 4px 12px; font-size: 0.78rem; cursor: pointer; transition: all 0.2s;
}
.btn-small:hover { background: var(--accent); color: white; }

/* ── Footer ──────────────────────────────────────────────── */
.footer {
  grid-area: footer;
  padding: 20px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-left {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.kofi-placeholder {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--header-gradient);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}

.kofi-placeholder:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kofi-icon { font-size: 1.1rem; }

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg-panel); border: 1px solid var(--border-active);
  border-radius: var(--radius-md); padding: 12px 20px;
  font-size: 0.85rem; z-index: 300;
  animation: slideIn 0.2s ease;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
}

/* ── Empty State ───────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 40px; color: var(--text-muted); font-size: 0.875rem; text-align: center;
}
.empty-icon { font-size: 2.5rem; }

/* ── Loading Spinner ───────────────────────────────────── */
.loading-spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

/* Dashboard Inner Weather Card */
#innerWeatherCard {
  background: linear-gradient(135deg, var(--accent-dim), rgba(255,107,138,0.08));
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
#innerWeatherIcon {
  font-size: 1.8rem;
  margin-bottom: 5px;
  animation: float-weather 4s ease-in-out infinite;
}
#innerWeatherText {
  font-size: 0.8rem;
  font-style: italic;
  opacity: 0.8;
  max-width: 150px;
}

/* Hubble Viewer (Raw Chat) */
.hubble-content {
  max-width: 800px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.hubble-chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg-hover);
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.hubble-msg {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 15px;
  line-height: 1.5;
  position: relative;
  font-size: 0.95rem;
}
.hubble-msg.assistant {
  align-self: flex-start;
  background: var(--accent-dim);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
}
.hubble-msg.human {
  align-self: flex-end;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-bottom-right-radius: 2px;
  box-shadow: var(--shadow-sm);
}
.hubble-msg .speaker-name {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 5px;
  display: block;
  color: var(--accent);
  font-weight: 600;
}
.hubble-msg .msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 5px;
  display: block;
  text-align: right;
}

/* Expansion Section */
.expand-section {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.placeholder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.placeholder-item {
  background: var(--bg-hover);
  border: 1px dashed var(--border-active);
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  text-align: center;
  color: var(--text-muted);
  cursor: not-allowed;
  transition: all 0.2s;
}
.placeholder-item.disabled {
  filter: grayscale(1);
  opacity: 0.5;
}
.placeholder-item:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}

/* ── Utilities ─────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Animations ────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes sparkPulse {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}
@keyframes float-weather {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .regions-grid { grid-template-columns: repeat(6, 1fr); }
  .identity-grid { grid-template-columns: 1fr; }
  .pre-analysis-grid { grid-template-columns: repeat(2, 1fr); }
  .token-tracker { grid-template-columns: 1fr; }
  .logo-sub { display: none; }
  .footer-content { flex-direction: column; gap: 15px; text-align: center; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .regions-grid { grid-template-columns: repeat(4, 1fr); }
}
