/* ─── RESET & VARS ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg:    #0a0a0a;
  --bg2:   #111111;
  --bg3:   #181818;
  --line:  rgba(255,255,255,.07);
  --line2: rgba(255,255,255,.12);
  --white: #f0f0f0;
  --soft:  rgba(240,240,240,.45);
  --softer:rgba(240,240,240,.22);
  --green: #22c55e;
  --red:   #ef4444;
  --yellow:#eab308;
  --blue:  #3b82f6;
  --accent:#d4c9b8;
  --mono:  'SF Mono', 'Fira Code', 'Consolas', monospace;
  --sans:  system-ui, -apple-system, sans-serif;
  --sidebar-w: 200px;
  --panel-w:   280px;
}

html { background: var(--bg); }
body {
  background: var(--bg); color: var(--white);
  font-family: var(--sans); font-size: 14px;
  -webkit-font-smoothing: antialiased;
  height: 100dvh; overflow: hidden;
}

/* ─── SCREENS ───────────────────────────────────────────────────── */
.screen { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100dvh; padding: 24px; gap: 28px; }
.hidden { display: none !important; }

/* ─── LOGIN ─────────────────────────────────────────────────────── */
.login-logo { font-size: 11px; font-weight: 600; letter-spacing: .5em; text-transform: uppercase; color: var(--softer); }
.login-title { font-size: clamp(2.5rem, 10vw, 4rem); font-weight: 200; letter-spacing: .3em; text-transform: uppercase; }
.login-sub { font-size: 13px; color: var(--soft); text-align: center; max-width: 280px; line-height: 1.65; }
.btn-google {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 22px; border: 1px solid var(--line2);
  background: var(--bg2); color: var(--white);
  text-decoration: none; border-radius: 4px; font-size: 13px;
  transition: border-color .15s, background .15s; cursor: pointer;
}
.btn-google:hover { border-color: rgba(255,255,255,.25); background: var(--bg3); }
.btn-demo {
  padding: 8px 18px; border: none; background: none;
  color: var(--softer); font-size: 12px; cursor: pointer;
  text-decoration: underline; text-decoration-color: transparent;
  transition: color .15s;
}
.btn-demo:hover { color: var(--soft); }

/* ─── APP LAYOUT ─────────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
  grid-template-rows: 1fr;
  height: 100dvh;
}

/* ─── SIDEBAR ────────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 20px 0;
  overflow: visible;
  position: relative;
}
.sidebar-brand {
  padding: 0 18px 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .4em;
  text-transform: uppercase; color: var(--softer);
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; color: var(--soft);
  background: none; border: none; cursor: pointer;
  font-size: 13px; width: 100%; text-align: left;
  border-left: 2px solid transparent;
  transition: color .15s, background .15s, border-color .15s;
}
.nav-btn:hover { color: var(--white); background: rgba(255,255,255,.04); }
.nav-btn.active { color: var(--white); border-left-color: var(--white); background: rgba(255,255,255,.05); }
.nav-btn .icon { width: 16px; text-align: center; font-style: normal; flex-shrink: 0; }
.sidebar-bottom {
  margin-top: auto; padding: 12px 18px 0;
  border-top: 1px solid var(--line);
}
.user-line {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; font-size: 12px; color: var(--softer);
}
.user-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.demo-badge {
  display: inline-block; padding: 2px 7px; border-radius: 999px;
  background: rgba(234,179,8,.12); border: 1px solid rgba(234,179,8,.25);
  font-size: 10px; color: var(--yellow); font-weight: 600; letter-spacing: .05em;
}
.logout-btn {
  width: 100%; padding: 8px 0; border: none; background: none;
  color: var(--softer); font-size: 12px; cursor: pointer; text-align: left;
  transition: color .15s;
}
.logout-btn:hover { color: var(--red); }
.bell-btn {
  width: 100%; padding: 7px 0; border: none; background: none;
  color: var(--softer); font-size: 16px; cursor: pointer;
  text-align: left; transition: color .15s;
}
.bell-btn:hover { color: var(--white); }
.bell-btn.bell-on { color: var(--yellow); }
.push-panel {
  position: absolute; left: var(--sidebar-w); bottom: 0;
  width: 220px; background: var(--bg3); border: 1px solid var(--line2);
  border-radius: 4px; padding: 14px; z-index: 50;
  animation: fadeSlide .15s ease;
}
.push-panel-title {
  font-size: 10px; font-weight: 700; letter-spacing: .15em;
  text-transform: uppercase; color: var(--softer); margin-bottom: 10px;
}
.push-status { font-size: 11px; color: var(--soft); margin-bottom: 10px; line-height: 1.5; }
.push-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.push-label { font-size: 11px; color: var(--soft); }
.push-time {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 3px; color: var(--white); font-size: 12px;
  padding: 4px 8px; outline: none; color-scheme: dark;
}
.push-actions { display: flex; flex-direction: column; gap: 6px; }
.push-unsub { color: rgba(239,68,68,.7) !important; border-color: rgba(239,68,68,.2) !important; }

/* ─── CHAT AREA ──────────────────────────────────────────────────── */
.chat {
  display: flex; flex-direction: column;
  background: var(--bg); overflow: hidden;
  border-right: 1px solid var(--line);
}
.chat-header {
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  font-size: 11px; font-weight: 600; letter-spacing: .2em;
  text-transform: uppercase; color: var(--softer);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-header-right { display: flex; align-items: center; gap: 10px; }
#messages {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 2px; }

/* ─── ENTRY CARD ─────────────────────────────────────────────────── */
.entry-card {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 4px; padding: 14px 16px;
  position: relative; group: true;
  animation: fadeSlide .2s ease;
}
.entry-card:hover .entry-delete { opacity: 1; }
@keyframes fadeSlide { from { opacity:0; transform:translateY(6px) } to { opacity:1; transform:translateY(0) } }
.entry-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.entry-tag {
  font-size: 10px; font-weight: 600; letter-spacing: .08em;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,.07); color: var(--soft);
  font-family: var(--mono);
}
.entry-time { font-size: 11px; color: var(--softer); }
.entry-source { font-size: 10px; color: var(--softer); }
.energy-dots { display: flex; gap: 3px; }
.energy-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--line2);
}
.energy-dot.filled { background: var(--accent); }
.energy-dot.filled.high { background: var(--green); }
.energy-dot.filled.low  { background: var(--red); }
.entry-text { font-size: 13px; color: var(--white); line-height: 1.55; }
.entry-delete {
  position: absolute; top: 10px; right: 12px;
  width: 20px; height: 20px; border-radius: 2px;
  background: none; border: none; color: var(--softer);
  font-size: 16px; cursor: pointer; opacity: 0;
  display: grid; place-items: center;
  transition: opacity .15s, color .15s;
}
.entry-delete:hover { color: var(--red); }

/* ─── WIDGET CARD ────────────────────────────────────────────────── */
.widget-card {
  background: var(--bg3); border: 1px solid var(--line);
  border-radius: 4px; padding: 16px;
  animation: fadeSlide .2s ease;
}
.widget-header {
  font-size: 10px; font-weight: 600; letter-spacing: .2em;
  text-transform: uppercase; color: var(--softer); margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.widget-close { background: none; border: none; color: var(--softer); cursor: pointer; font-size: 16px; }
.widget-close:hover { color: var(--white); }
.widget-chart { position: relative; height: 180px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-block {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 4px; padding: 12px 14px;
}
.stat-label { font-size: 9px; font-weight: 600; letter-spacing: .15em; text-transform: uppercase; color: var(--softer); margin-bottom: 4px; }
.stat-val { font-size: 24px; font-weight: 300; color: var(--white); }
.stat-sub { font-size: 10px; color: var(--softer); margin-top: 2px; }
.entries-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.entry-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.entry-row:last-child { border-bottom: none; }
.entry-row-tag { font-family: var(--mono); font-size: 10px; color: var(--softer); min-width: 60px; padding-top: 1px; }
.entry-row-text { font-size: 12px; color: var(--soft); line-height: 1.5; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--softer); font-size: 13px; }

/* ─── INPUT BAR ──────────────────────────────────────────────────── */
.input-bar {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  display: flex; flex-direction: column; gap: 10px;
}
.input-row { display: flex; align-items: flex-end; gap: 8px; }
.tag-input {
  width: 90px; padding: 8px 10px;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 4px; color: var(--white); font-size: 12px;
  font-family: var(--mono); outline: none;
  transition: border-color .15s;
}
.tag-input:focus { border-color: var(--line2); }
.tag-input::placeholder { color: var(--softer); }
.energy-picker { display: flex; gap: 5px; padding: 8px 2px; }
.epick {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line2); background: none; cursor: pointer;
  font-size: 10px; font-weight: 700; color: var(--softer);
  display: grid; place-items: center;
  transition: background .12s, border-color .12s, color .12s;
}
.epick.sel { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.text-input {
  flex: 1; padding: 8px 12px; min-height: 38px; max-height: 120px;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 4px; color: var(--white); font-size: 13px;
  font-family: var(--sans); outline: none; resize: none;
  transition: border-color .15s; line-height: 1.5;
}
.text-input:focus { border-color: var(--line2); }
.text-input::placeholder { color: var(--softer); }
.send-btn {
  width: 38px; height: 38px; border-radius: 4px; flex-shrink: 0;
  background: var(--white); color: var(--bg);
  border: none; cursor: pointer; font-size: 16px;
  display: grid; place-items: center;
  transition: background .15s, transform .1s;
}
.send-btn:hover { background: var(--accent); }
.send-btn:active { transform: scale(.95); }
.send-btn:disabled { background: var(--bg3); color: var(--softer); cursor: not-allowed; transform: none; }

/* ─── ATTACHMENTS ────────────────────────────────────────────────── */
.attach-btn {
  width: 38px; height: 38px; border-radius: 4px; flex-shrink: 0;
  background: var(--bg2); border: 1px solid var(--line);
  color: var(--softer); cursor: pointer; font-size: 15px;
  display: grid; place-items: center;
  transition: border-color .15s, color .15s;
}
.attach-btn:hover { border-color: var(--line2); color: var(--white); }
.attach-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: var(--bg2);
  border: 1px solid var(--line2); border-radius: 4px;
  font-size: 11px; color: var(--soft);
}
.attach-chip span:first-child {
  flex: 1; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 280px;
}
.attach-count { font-family: var(--mono); color: var(--softer); font-size: 10px; flex-shrink: 0; }
.attach-chip button {
  background: none; border: none; color: var(--softer);
  cursor: pointer; font-size: 14px; padding: 0; line-height: 1;
  transition: color .12s; flex-shrink: 0;
}
.attach-chip button:hover { color: var(--red); }

/* ─── RIGHT PANEL ────────────────────────────────────────────────── */
.panel {
  background: var(--bg2);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.panel-header {
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  font-size: 11px; font-weight: 600; letter-spacing: .2em;
  text-transform: uppercase; color: var(--softer);
}
.panel-body { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.panel-body::-webkit-scrollbar { width: 3px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 2px; }
.fn-btn {
  width: 100%; padding: 10px 14px; text-align: left;
  background: var(--bg3); border: 1px solid var(--line);
  border-radius: 4px; color: var(--soft); font-size: 12px;
  cursor: pointer; transition: border-color .15s, color .15s, background .15s;
  display: flex; align-items: center; gap: 8px;
}
.fn-btn:hover { border-color: var(--line2); color: var(--white); background: rgba(255,255,255,.04); }
.fn-btn .fni { width: 16px; text-align: center; font-style: normal; }
.fn-divider { height: 1px; background: var(--line); margin: 6px 0; }
.range-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.range-tab {
  flex: 1; padding: 5px; border: 1px solid var(--line); background: none;
  color: var(--softer); font-size: 10px; border-radius: 3px; cursor: pointer;
  transition: all .12s;
}
.range-tab.active { border-color: var(--line2); color: var(--white); background: rgba(255,255,255,.05); }

/* ─── SEED BANNER ────────────────────────────────────────────────── */
.seed-bar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 8px 16px; background: rgba(234,179,8,.08);
  border-bottom: 1px solid rgba(234,179,8,.15);
  font-size: 12px; color: rgba(234,179,8,.8);
}
.seed-bar button {
  padding: 4px 10px; border: 1px solid rgba(234,179,8,.3); border-radius: 3px;
  background: none; color: rgba(234,179,8,.9); font-size: 11px; cursor: pointer;
  transition: background .12s;
}
.seed-bar button:hover { background: rgba(234,179,8,.1); }

/* ─── RESPONSIVE ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #app { grid-template-columns: var(--sidebar-w) 1fr; }
  .panel { display: none; }
}
@media (max-width: 640px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar { display: none; }
}
/* ─── CHAT BUBBLES ───────────────────────────────────────────────── */
.user-bubble {
  align-self: flex-end; max-width: 80%;
  background: rgba(212,201,184,.08); border: 1px solid rgba(212,201,184,.18);
  border-radius: 4px; padding: 11px 14px;
  font-size: 13px; color: var(--white); line-height: 1.55;
  animation: fadeSlide .2s ease; white-space: pre-wrap;
}
.ai-bubble {
  max-width: 92%;
  background: var(--bg3); border: 1px solid var(--line);
  border-radius: 4px; padding: 12px 14px;
  animation: fadeSlide .2s ease;
}
.ai-tag { font-size: 9px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--softer); margin-bottom: 6px; }
.ai-bubble p { font-size: 13px; color: var(--soft); line-height: 1.65; margin: 0; white-space: pre-wrap; }
.thinking { display: flex; align-items: center; gap: 5px; padding: 8px 2px; }
.thinking span { width: 5px; height: 5px; border-radius: 50%; background: var(--softer); animation: blink 1.2s ease-in-out infinite; }
.thinking span:nth-child(2) { animation-delay: .2s; }
.thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.15} 40%{opacity:.9} }
.confirm-card {
  background: rgba(34,197,94,.06); border: 1px solid rgba(34,197,94,.22);
  border-radius: 4px; padding: 10px 14px;
  font-size: 12px; color: rgba(34,197,94,.85);
  animation: fadeSlide .2s ease;
}
.confirm-card strong { font-weight: 600; }
.chat-session-sep {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0; font-size: 10px; color: var(--softer); letter-spacing: .1em;
}
.chat-session-sep::before, .chat-session-sep::after { content:''; flex:1; height:1px; background:var(--line); }

@media (prefers-reduced-motion: reduce) {
  *, .entry-card, .widget-card { animation: none !important; transition: none !important; }
}
