/* ========== RESET & BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #111;
  background: #fff;
  min-height: 100dvh;
  overscroll-behavior: none;
}

/* ========== TOKENS ========== */
:root {
  --c-bg: #ffffff;
  --c-bg2: #f7f7f5;
  --c-bg3: #f0efed;
  --c-border: rgba(0,0,0,0.1);
  --c-border2: rgba(0,0,0,0.18);
  --c-text: #111111;
  --c-text2: #555555;
  --c-text3: #999999;
  --c-accent: #111111;
  --c-accent-bg: #111111;
  --c-accent-fg: #ffffff;
  --c-red: #E24B4A;
  --c-red-bg: #FCEBEB;
  --c-green: #3B6D11;
  --c-green-bg: #EAF3DE;
  --c-blue: #185FA5;
  --c-blue-bg: #E6F1FB;
  --c-purple: #534AB7;
  --c-purple-bg: #EEEDFE;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #111111;
    --c-bg2: #1c1c1e;
    --c-bg3: #2c2c2e;
    --c-border: rgba(255,255,255,0.1);
    --c-border2: rgba(255,255,255,0.18);
    --c-text: #f0f0f0;
    --c-text2: #aaaaaa;
    --c-text3: #666666;
    --c-accent: #f0f0f0;
    --c-accent-bg: #f0f0f0;
    --c-accent-fg: #111111;
    --c-red-bg: #2a1010;
    --c-green-bg: #0f1f07;
    --c-blue-bg: #071828;
    --c-purple-bg: #130f30;
  }
}

/* ========== LAYOUT ========== */
.app { max-width: 960px; margin: 0 auto; }

/* ========== TOPBAR ========== */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--c-bg);
  border-bottom: 0.5px solid var(--c-border);
  padding: 14px 24px;
  display: flex; justify-content: space-between; align-items: center;
}
.topbar-left .t-date { font-size: 11px; color: var(--c-text3); letter-spacing: 0.06em; text-transform: uppercase; }
.topbar-left h1 { font-size: 17px; font-weight: 500; color: var(--c-text); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.streak-pill {
  font-size: 12px; color: var(--c-text2);
  padding: 4px 10px;
  border: 0.5px solid var(--c-border);
  border-radius: 20px;
  background: var(--c-bg2);
}
.sync-badge {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--c-text3);
  padding: 4px 9px;
  border: 0.5px solid var(--c-border);
  border-radius: 20px;
  background: var(--c-bg2);
  cursor: pointer;
  transition: background 0.15s;
}
.sync-badge:hover { background: var(--c-bg3); }
.sync-badge[data-status="synced"] { color: var(--c-green); border-color: var(--c-green); }
.sync-badge[data-status="error"]  { color: var(--c-red);   border-color: var(--c-red); }
.sync-badge[data-status="pending"],
.sync-badge[data-status="syncing"] { color: var(--c-blue); }
.sync-icon { font-size: 13px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: var(--c-bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%; max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--c-text3); padding: 4px; }
.modal-desc { font-size: 13px; color: var(--c-text2); line-height: 1.5; margin-bottom: 16px; }
.modal-label { display: block; font-size: 12px; font-weight: 500; color: var(--c-text2); margin-bottom: 6px; }
.modal-input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--c-border2); border-radius: var(--radius-sm);
  background: var(--c-bg2); color: var(--c-text);
  font-size: 15px; font-family: inherit;
  outline: none;
}
.modal-input:focus { border-color: var(--c-purple); }
.modal-hint { font-size: 11px; color: var(--c-text3); margin-top: 6px; margin-bottom: 12px; }
.sync-modal-status { font-size: 13px; min-height: 20px; margin-bottom: 12px; }
.sync-modal-status.ok    { color: var(--c-green); }
.sync-modal-status.error { color: var(--c-red); }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-btn {
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; cursor: pointer; border: none;
  font-family: inherit;
}
.modal-btn.primary { background: var(--c-accent-bg); color: var(--c-accent-fg); flex: 1; }
.modal-btn.ghost   { background: var(--c-bg3); color: var(--c-text2); }

/* ========== DASHBOARD LAYOUT ========== */
.dash {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100dvh - 53px);
}

/* ========== SIDEBAR ========== */
.sidebar {
  border-right: 0.5px solid var(--c-border);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 53px; height: calc(100dvh - 53px);
  overflow-y: auto;
}
.sb-label {
  font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--c-text3);
  padding: 8px 10px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--c-text2);
  cursor: pointer; transition: all 0.12s;
  border: none; background: none; width: 100%; text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: var(--c-bg2); color: var(--c-text); }
.nav-item.active { background: var(--c-bg3); color: var(--c-text); font-weight: 500; }
.nav-item svg { flex-shrink: 0; }

.sidebar-goals { padding: 4px 0; }
.goal-sidebar-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  font-size: 12px; color: var(--c-text2);
  border-radius: var(--radius-sm);
  cursor: pointer; margin-bottom: 2px;
}
.goal-sidebar-item:hover { background: var(--c-bg2); }
.goal-sidebar-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.goal-sidebar-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-sidebar-pct { font-size: 10px; color: var(--c-text3); }

.sidebar-bottom { margin-top: auto; padding-top: 12px; border-top: 0.5px solid var(--c-border); }

/* ========== MAIN ========== */
.main { padding: 24px; overflow-y: auto; }

/* ========== PANELS ========== */
.panel { display: none; }
.panel.active { display: block; }

/* ========== SECTION HEAD ========== */
.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 16px;
}
.section-head h2 { font-size: 17px; font-weight: 500; color: var(--c-text); }
.sh-btn {
  font-size: 12px; color: var(--c-text3); cursor: pointer;
  border: none; background: none; font-family: inherit; padding: 0;
}
.sh-btn:hover { color: var(--c-text); }

/* ========== STATS ROW ========== */
.stats-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 24px; }
.stat-card {
  background: var(--c-bg2);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.stat-card .sv { font-size: 24px; font-weight: 500; color: var(--c-text); }
.stat-card .sl { font-size: 11px; color: var(--c-text3); margin-top: 2px; }

/* ========== TODAY GRID ========== */
.today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ========== TASK LIST ========== */
.task-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 0;
  border-bottom: 0.5px solid var(--c-border);
  transition: opacity 0.15s;
}
.task-item:last-child { border-bottom: none; }
.task-check {
  width: 17px; height: 17px; border-radius: 5px;
  border: 1px solid var(--c-border2);
  flex-shrink: 0; margin-top: 2px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.task-check.checked { background: var(--c-accent); border-color: var(--c-accent); }
.task-check.checked::after {
  content: '';
  display: block; width: 5px; height: 8px;
  border: 1.5px solid var(--c-accent-fg);
  border-top: none; border-left: none;
  transform: rotate(45deg) translateY(-1px);
}
.task-body { flex: 1; }
.task-title { font-size: 13px; color: var(--c-text); line-height: 1.4; }
.task-item.done .task-title { text-decoration: line-through; color: var(--c-text3); }
.task-meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.task-time { font-size: 11px; color: var(--c-text3); }
.tag { font-size: 10px; padding: 1px 7px; border-radius: 8px; }
.tag-work { background: var(--c-blue-bg); color: var(--c-blue); }
.tag-health { background: var(--c-green-bg); color: var(--c-green); }
.tag-learn { background: var(--c-purple-bg); color: var(--c-purple); }
.tag-other { background: var(--c-bg3); color: var(--c-text2); }

.add-task-row { display: flex; gap: 8px; margin-top: 12px; }
.add-task-row input {
  flex: 1; font-size: 13px;
  padding: 8px 10px;
  border: 0.5px solid var(--c-border2);
  border-radius: var(--radius-sm);
  color: var(--c-text); background: var(--c-bg);
  font-family: inherit;
}
.add-task-row input:focus { outline: none; border-color: var(--c-accent); }
.add-task-row button {
  padding: 8px 14px; background: var(--c-accent-bg);
  color: var(--c-accent-fg); border: none;
  border-radius: var(--radius-sm); font-size: 14px; cursor: pointer;
}

/* ========== VOICE BOX ========== */
.voice-box {
  margin-top: 16px;
  border: 0.5px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 14px;
}
.voice-box-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.voice-box-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-text3); }
.voice-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 0.5px solid var(--c-border);
  border-radius: 20px; font-size: 12px;
  color: var(--c-text2); background: var(--c-bg);
  cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.voice-btn.recording { background: var(--c-red-bg); border-color: var(--c-red); color: var(--c-red); }
.vdot { width: 7px; height: 7px; border-radius: 50%; background: var(--c-text3); }
.voice-btn.recording .vdot { background: var(--c-red); animation: blink 0.8s ease-in-out infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }
.voice-transcript {
  font-size: 13px; color: var(--c-text); line-height: 1.65;
  min-height: 44px;
}
.voice-transcript .interim { color: var(--c-text3); }
.voice-transcript.empty { color: var(--c-text3); font-style: italic; }
.voice-ctrl { display: flex; gap: 8px; margin-top: 10px; }
.vc-btn {
  padding: 6px 12px; font-size: 12px;
  border: 0.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg); color: var(--c-text2);
  cursor: pointer; font-family: inherit;
}
.vc-btn.primary {
  background: var(--c-accent-bg); color: var(--c-accent-fg);
  border-color: var(--c-accent-bg);
}

/* ========== AI BOX ========== */
.ai-box {
  background: var(--c-bg2);
  border-radius: var(--radius-md);
  padding: 14px;
}
.ai-box-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ai-icon {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--c-accent-bg); flex-shrink: 0;
}
.ai-label { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-text3); }
.ai-msg { font-size: 13px; color: var(--c-text); line-height: 1.65; min-height: 50px; }
.ai-dots { display: flex; gap: 4px; padding: 8px 0; }
.ai-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--c-text3); animation: pulse 1.2s ease-in-out infinite; }
.ai-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%,80%,100%{opacity:0.3} 40%{opacity:1} }
.ai-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.ai-action {
  font-size: 11px; padding: 5px 10px;
  border: 0.5px solid var(--c-border);
  border-radius: 20px; background: var(--c-bg);
  color: var(--c-text2); cursor: pointer; font-family: inherit;
}
.ai-action:hover { color: var(--c-text); border-color: var(--c-border2); }

/* ========== GOALS PANEL ========== */
.goals-list { display: flex; flex-direction: column; gap: 12px; }
.goal-card {
  border: 0.5px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.goal-card-head {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 10px;
}
.goal-cat-badge {
  font-size: 10px; padding: 2px 8px;
  border-radius: 8px; margin-bottom: 4px;
  display: inline-block;
}
.goal-title { font-size: 15px; font-weight: 500; color: var(--c-text); }
.goal-horizon { font-size: 11px; color: var(--c-text3); margin-top: 2px; }
.goal-pct { font-size: 22px; font-weight: 500; color: var(--c-text); }
.prog-bar { height: 3px; background: var(--c-bg3); border-radius: 2px; margin-bottom: 12px; }
.prog-fill { height: 100%; border-radius: 2px; background: var(--c-accent); transition: width 0.5s ease; }
.milestones { display: flex; flex-direction: column; gap: 5px; }
.ms-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--c-text2); }
.ms-dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--c-border2); flex-shrink: 0; }
.ms-dot.done { background: var(--c-accent); border-color: var(--c-accent); }
.goal-plan-text { font-size: 12px; color: var(--c-text2); line-height: 1.6; margin-top: 12px; padding-top: 12px; border-top: 0.5px solid var(--c-border); white-space: pre-line; }

/* ========== NOTES PANEL ========== */
.notes-list { display: flex; flex-direction: column; gap: 10px; }
.note-card {
  border: 0.5px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 14px;
}
.note-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.note-date { font-size: 11px; color: var(--c-text3); }
.note-type-badge { font-size: 10px; padding: 2px 8px; border-radius: 8px; }
.type-voice { background: var(--c-purple-bg); color: var(--c-purple); }
.type-text { background: var(--c-green-bg); color: var(--c-green); }
.type-ai { background: var(--c-blue-bg); color: var(--c-blue); }
.note-body { font-size: 13px; color: var(--c-text); line-height: 1.6; }
.note-insight {
  font-size: 12px; color: var(--c-text2);
  margin-top: 8px; padding-top: 8px;
  border-top: 0.5px solid var(--c-border);
  font-style: italic; line-height: 1.5;
}

/* ========== ONBOARDING ========== */
.onboard {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 24px;
}
.onboard-card {
  width: 100%; max-width: 520px;
}
.step-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 36px; }
.step-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c-bg3); transition: all 0.3s; }
.step-dot.active { background: var(--c-accent); width: 22px; border-radius: 3px; }
.step-dot.done { background: var(--c-text3); }
.onboard-card h2 { font-size: 22px; font-weight: 500; color: var(--c-text); margin-bottom: 8px; text-align: center; }
.onboard-card .sub { font-size: 14px; color: var(--c-text2); text-align: center; margin-bottom: 28px; line-height: 1.65; }
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }
.cat-card {
  padding: 14px; border: 0.5px solid var(--c-border);
  border-radius: var(--radius-md); cursor: pointer;
  transition: all 0.15s; text-align: left;
  background: var(--c-bg);
}
.cat-card:hover { border-color: var(--c-border2); background: var(--c-bg2); }
.cat-card.selected { border: 1.5px solid var(--c-accent); background: var(--c-bg2); }
.cat-icon { font-size: 22px; margin-bottom: 6px; }
.cat-title { font-size: 13px; font-weight: 500; color: var(--c-text); margin-bottom: 2px; }
.cat-desc { font-size: 11px; color: var(--c-text2); line-height: 1.4; }
.horizon-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.h-chip {
  padding: 7px 14px; border: 0.5px solid var(--c-border);
  border-radius: 20px; font-size: 12px; color: var(--c-text2);
  cursor: pointer; transition: all 0.15s; background: var(--c-bg);
  font-family: inherit;
}
.h-chip.selected { background: var(--c-accent-bg); color: var(--c-accent-fg); border-color: var(--c-accent-bg); }
.ob-textarea {
  width: 100%; padding: 12px 14px;
  border: 0.5px solid var(--c-border2);
  border-radius: var(--radius-md); font-size: 14px;
  color: var(--c-text); background: var(--c-bg);
  font-family: inherit; resize: none; line-height: 1.6;
  margin-bottom: 16px;
}
.ob-textarea:focus { outline: none; border-color: var(--c-accent); }
.ob-textarea::placeholder { color: var(--c-text3); }
.ob-btn {
  width: 100%; padding: 13px;
  background: var(--c-accent-bg); color: var(--c-accent-fg);
  border: none; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  cursor: pointer; transition: opacity 0.15s;
  font-family: inherit; margin-top: 6px;
}
.ob-btn:disabled { opacity: 0.3; cursor: default; }
.ob-btn.secondary {
  background: transparent; color: var(--c-text2);
  border: 0.5px solid var(--c-border); margin-top: 8px;
}
.thinking {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px; padding: 48px 0; text-align: center;
}
.spinner {
  width: 32px; height: 32px;
  border: 1.5px solid var(--c-bg3);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.thinking p { font-size: 13px; color: var(--c-text2); }

/* ========== MOBILE ========== */
@media (max-width: 640px) {
  .dash { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .today-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(3,1fr); }
  .main { padding: 16px; }
  .bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--c-bg);
    border-top: 0.5px solid var(--c-border);
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    z-index: 100;
  }
  .bn-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; gap: 3px;
    font-size: 10px; color: var(--c-text3);
    cursor: pointer; padding: 4px 0; border: none; background: none;
    font-family: inherit;
  }
  .bn-item.active { color: var(--c-text); }
  .main { padding-bottom: 80px; }
}
@media (min-width: 641px) { .bottom-nav { display: none; } }

/* ========== EMPTY STATE ========== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--c-text3); font-size: 13px; }
.empty-state .es-icon { font-size: 32px; margin-bottom: 10px; }

/* ========== UTILITY ========== */
.hidden { display: none !important; }
button { font-family: inherit; }
textarea, input { font-family: inherit; }
