/* ═══════════════════════════════════════════════════════════
   ProcrastiKill — style.css
   Dark Void Theme | Space Grotesk | Glassmorphism
═══════════════════════════════════════════════════════════ */

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

/* ── CSS CUSTOM PROPERTIES ───────────────────────────── */
:root {
  /* Backgrounds */
  --bg-primary:    #07070f;
  --bg-surface:    #0f0f1a;
  --bg-card:       #13131e;
  --bg-card-hover: #191928;
  --bg-glass:      rgba(19, 19, 30, 0.85);

  /* Brand accent */
  --accent:        #7c3aed;
  --accent-light:  #9d5df0;
  --accent-dim:    rgba(124, 58, 237, 0.18);
  --accent-glow:   rgba(124, 58, 237, 0.35);

  /* Semantic */
  --clr-red:       #dc2626;
  --clr-red-dim:   rgba(220, 38, 38, 0.18);
  --clr-red-glow:  rgba(220, 38, 38, 0.35);
  --clr-amber:     #d97706;
  --clr-amber-dim: rgba(217, 119, 6, 0.18);
  --clr-green:     #10b981;
  --clr-green-dim: rgba(16, 185, 129, 0.18);
  --clr-cyan:      #06b6d4;

  /* Text */
  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #4b5563;

  /* Border */
  --border:        rgba(255, 255, 255, 0.07);
  --border-accent: rgba(124, 58, 237, 0.45);

  /* Layout */
  --sidebar-w:     242px;
  --header-h:      68px;
  --radius-xs:     6px;
  --radius-sm:     10px;
  --radius-md:     14px;
  --radius-lg:     20px;
  --radius-xl:     28px;

  /* Transition */
  --t-fast: 0.15s ease;
  --t-med:  0.28s ease;
  --t-slow: 0.5s  ease;

  /* Shadow */
  --shadow-card:   0 4px 28px rgba(0,0,0,0.45);
  --shadow-purple: 0 0 48px rgba(124,58,237,0.18);
  --shadow-red:    0 0 48px rgba(220,38,38,0.18);
}

/* ── BASE ──────────────────────────────────────────────── */
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--t-slow), color var(--t-slow);
}

a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: #c4b5fd; text-decoration: underline; }

/* ── FORM ELEMENTS ────────────────────────────────────── */
input, select, textarea {
  font-family: inherit;
  font-size: 0.93rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder { color: var(--text-muted); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
select option { background: var(--bg-surface); }

/* ── UTILITIES ─────────────────────────────────────────── */
.hidden   { display: none !important; }
.success  { color: var(--clr-green)  !important; }
.danger   { color: var(--clr-red)    !important; }
.warn     { color: var(--clr-amber)  !important; }
.stat-val { font-weight: 700; font-family: 'Fira Code', monospace; }

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t-fast);
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--t-fast);
}
.btn:hover::after { background: rgba(255,255,255,0.06); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 6px 26px var(--accent-glow); transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); }

.btn-danger {
  background: linear-gradient(135deg, var(--clr-red), #991b1b);
  color: #fff;
  box-shadow: 0 4px 16px var(--clr-red-glow);
}
.btn-danger:hover { box-shadow: 0 6px 26px var(--clr-red-glow); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-muted); }

.btn-sync {
  padding: 8px 15px;
  font-size: 0.82rem;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-sync:hover { border-color: var(--clr-cyan); color: var(--clr-cyan); }

.btn-full { width: 100%; margin-top: 8px; }

/* ══════════════════════════════════════════
   ONBOARDING MODAL
══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7,7,15,0.93);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-overlay.hidden { display: none !important; }

.onboarding-card {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  max-width: 530px;
  width: 100%;
  box-shadow: var(--shadow-card), var(--shadow-purple);
  animation: slideUp 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(48px) scale(0.93); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.onboard-hero { text-align: center; margin-bottom: 28px; }

.onboard-avatar-preview {
  font-size: 68px;
  display: block;
  margin-bottom: 10px;
  animation: float 3.5s ease-in-out infinite;
  filter: drop-shadow(0 0 24px var(--accent-glow));
}
@keyframes float {
  0%,100% { transform: translateY(0);   }
  50%     { transform: translateY(-9px);}
}

.onboard-title {
  font-size: 2.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 30%, var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.onboard-sub { color: var(--text-secondary); font-size: 0.95rem; margin-top: 6px; }
.onboard-sub em { color: var(--clr-red); font-style: normal; font-weight: 600; }

/* Steps */
.onboard-step { display: none; }
.onboard-step.active { display: block; animation: fadeSlide 0.3s ease; }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: translateX(0);    }
}

.onboard-step h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-secondary);
}

/* Form helpers */
.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}

.form-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.4;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.badge-optional {
  background: var(--clr-amber-dim);
  color: var(--clr-amber);
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid rgba(217,119,6,0.4);
  font-weight: 600;
  vertical-align: middle;
}

/* Onboarding nav */
.onboard-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.step-dots { display: flex; gap: 7px; }

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all var(--t-med);
}
.dot.active { width: 22px; border-radius: 4px; background: var(--accent); }

/* Agreement screen */
.agreement-screen { }

.agreement-list {
  list-style: none;
  margin: 0 0 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agreement-list li {
  background: var(--bg-surface);
  border-left: 3px solid var(--clr-green);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  padding: 9px 12px;
  font-size: 0.87rem;
  color: var(--text-secondary);
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.checkbox-label input { margin-top: 2px; }

/* ══════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════ */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ══════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--t-med);
  z-index: 200;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 18px 18px;
  border-bottom: 1px solid var(--border);
}
.brand-skull { font-size: 1.4rem; }
.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff, var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Mini avatar in sidebar */
.sidebar-avatar-mini {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 14px 12px 6px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.avatar-bubble {
  font-size: 1.9rem;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--bg-primary);
  flex-shrink: 0;
  border: 2px solid var(--border);
  transition: border-color var(--t-med);
}

.avatar-info { display: flex; flex-direction: column; min-width: 0; }

.avatar-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.avatar-health-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--t-fast);
  position: relative;
}
.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  text-decoration: none;
}
.nav-item.active {
  background: var(--accent-dim);
  color: var(--text-primary);
  border: 1px solid rgba(124,58,237,0.28);
}

.nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; }

.nav-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  min-width: 20px;
  text-align: center;
  line-height: 1.6;
}

.lock-icon { font-size: 0.8rem; }

/* Sidebar footer */
.sidebar-footer {
  padding: 14px 12px 4px;
  border-top: 1px solid var(--border);
}

.bedtime-countdown {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: border-color var(--t-med), color var(--t-med);
}

/* ══════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════ */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ══════════════════════════════════════════
   HEADER
══════════════════════════════════════════ */
#app-header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  flex-shrink: 0;
  z-index: 50;
  position: relative;
}

/* Subtle gradient line on top of header */
#app-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}

.header-left { display: flex; align-items: center; gap: 14px; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-xs);
  transition: color var(--t-fast);
  display: none;
}
.sidebar-toggle:hover { color: var(--text-primary); }

#header-greeting-text {
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.25;
}
.header-date { font-size: 0.76rem; color: var(--text-muted); margin-top: 1px; }

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

/* Score Ring */
.score-display { display: flex; align-items: center; gap: 11px; }
.score-ring { width: 46px; height: 46px; }

.circular-chart { width: 100%; height: 100%; }

.circle-bg {
  fill: none;
  stroke: var(--bg-card);
  stroke-width: 3.2;
}
.circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3.2;
  stroke-linecap: round;
  transition: stroke-dasharray 0.7s cubic-bezier(0.4,0,0.2,1), stroke 0.4s ease;
}

.score-percentage {
  fill: var(--text-primary);
  font-size: 7.5px;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  text-anchor: middle;
}

.score-info { display: flex; flex-direction: column; }
.score-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.score-status {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--clr-green);
  transition: color var(--t-med);
}

/* ══════════════════════════════════════════
   VIEWS
══════════════════════════════════════════ */
.view {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px;
  animation: fadeIn 0.22s ease;
}
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.view-header h2 { font-size: 1.35rem; font-weight: 700; }

/* ══════════════════════════════════════════
   CARDS
══════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--t-fast), transform var(--t-fast);
}

/* Shimmer line on card top */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 15%; right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124,58,237,0.5), transparent);
  opacity: 0.6;
}

.card:hover { border-color: rgba(124,58,237,0.22); }

.card-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 14px;
}

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

.view-all-link { font-size: 0.8rem; color: var(--accent-light); }

/* ══════════════════════════════════════════
   DASHBOARD GRID
══════════════════════════════════════════ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto auto auto;
  gap: 18px;
}

/* Avatar card spans 2 rows */
.card-avatar {
  grid-row: 1 / 3;
  text-align: center;
  padding: 28px 18px;
  background: linear-gradient(170deg, var(--bg-card) 0%, var(--bg-primary) 100%);
  border-color: rgba(124,58,237,0.25);
}

/* Avatar */
.avatar-stage-container {
  position: relative;
  display: inline-block;
  margin-bottom: 14px;
}

.avatar-glow {
  position: absolute;
  inset: -28px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 68%);
  animation: glow-pulse 3.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes glow-pulse {
  0%,100% { opacity: 0.55; transform: scale(1);    }
  50%      { opacity: 1;    transform: scale(1.12); }
}

.avatar-main {
  font-size: 82px;
  display: block;
  position: relative;
  z-index: 1;
  animation: avatar-float 4.2s ease-in-out infinite;
  transition: filter 0.6s ease;
  filter: drop-shadow(0 0 22px var(--accent-glow));
  line-height: 1;
}
@keyframes avatar-float {
  0%,100% { transform: translateY(0)    rotate(0deg);  }
  33%     { transform: translateY(-7px) rotate(-1deg); }
  66%     { transform: translateY(-3px) rotate(1deg);  }
}

.avatar-name-tag {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  font-weight: 500;
}

/* Health bar */
.health-bar-container { margin-bottom: 10px; }
.health-bar-track {
  height: 7px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 5px;
}
.health-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--clr-green), #34d399);
  transition: width 0.85s cubic-bezier(0.4,0,0.2,1), background 0.55s ease;
}
.health-value {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-family: 'Fira Code', monospace;
}

.avatar-stage-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.streak-display {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 5px 16px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* Mini stats card */
.card-stats-mini { display: flex; flex-direction: column; }

.mini-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.mini-stat {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
}
.mini-stat-val {
  display: block;
  font-size: 1.9rem;
  font-weight: 700;
  font-family: 'Fira Code', monospace;
  color: var(--accent-light);
  line-height: 1.1;
  margin-bottom: 3px;
}
.mini-stat-label { font-size: 0.72rem; color: var(--text-muted); }

/* Roast banner */
.card-roast {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  background: linear-gradient(135deg, rgba(220,38,38,0.07), rgba(124,58,237,0.07));
  border-color: rgba(220,38,38,0.22);
  border-radius: var(--radius-lg);
}

.roast-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
  animation: shake-icon 2.5s ease-in-out infinite;
}
@keyframes shake-icon {
  0%,100% { transform: rotate(0deg);  }
  20%     { transform: rotate(-8deg); }
  40%     { transform: rotate(8deg);  }
  60%     { transform: rotate(-4deg); }
  80%     { transform: rotate(4deg);  }
}

.roast-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.55;
  flex: 1;
}

/* Mini timeline */
.card-timeline-preview { grid-column: 1 / -1; }

.timeline-mini {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 210px;
  overflow-y: auto;
}

.timeline-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 18px;
}

/* ══════════════════════════════════════════
   TIMELINE ITEMS
══════════════════════════════════════════ */
.timeline-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.84rem;
  transition: all var(--t-fast);
}
.timeline-item:hover { background: var(--bg-card-hover); }

.timeline-item.done    { border-left-color: var(--clr-green); opacity: 0.68; }
.timeline-item.failed  { border-left-color: var(--clr-red);   }
.timeline-item.skipped { border-left-color: var(--text-muted); opacity: 0.55; }
.timeline-item.active-now {
  border-left-color: var(--clr-amber);
  background: rgba(217,119,6,0.06);
  animation: pulse-border 2.2s ease-in-out infinite;
}
@keyframes pulse-border {
  0%,100% { box-shadow: inset 3px 0 0 var(--clr-amber); }
  50%     { box-shadow: inset 3px 0 0 transparent;       }
}

.timeline-time {
  font-family: 'Fira Code', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 110px;
  flex-shrink: 0;
}
.timeline-task-title { flex: 1; font-weight: 500; }
.timeline-status { font-size: 0.95rem; }

/* Priority badges */
.timeline-priority {
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.priority-low      { background: var(--clr-green-dim); color: var(--clr-green); }
.priority-medium   { background: var(--clr-amber-dim); color: var(--clr-amber); }
.priority-high     { background: var(--clr-red-dim);   color: var(--clr-red);   }
.priority-critical {
  background: var(--clr-red);
  color: #fff;
  animation: blink-crit 1s step-end infinite;
}
@keyframes blink-crit { 50% { opacity: 0.65; } }

/* Empty state */
.timeline-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; display: block; }

/* Full timeline items */
.timeline-full { display: flex; flex-direction: column; gap: 11px; }

.timeline-item-full {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  transition: all var(--t-fast);
}
.timeline-item-full:hover { border-top-color: var(--accent); transform: translateX(5px); }
.timeline-item-full.done    { border-left-color: var(--clr-green); opacity: 0.7; }
.timeline-item-full.failed  { border-left-color: var(--clr-red);   }
.timeline-item-full.active-now {
  border-left-color: var(--clr-amber);
  box-shadow: 0 0 22px rgba(217,119,6,0.1);
}

.tif-time {
  font-family: 'Fira Code', monospace;
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 110px;
  flex-shrink: 0;
  line-height: 1.5;
}
.tif-body  { flex: 1; }
.tif-title { font-weight: 600; font-size: 0.98rem; margin-bottom: 3px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tif-tip   { font-size: 0.79rem; color: var(--text-muted); font-style: italic; margin-top: 5px; }
.tif-actions { display: flex; gap: 7px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }

.btn-task-done, .btn-task-snooze {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.76rem;
  padding: 5px 11px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all var(--t-fast);
}
.btn-task-done:hover   { background: var(--clr-green-dim); border-color: var(--clr-green); color: var(--clr-green); }
.btn-task-snooze:hover { background: var(--clr-amber-dim); border-color: var(--clr-amber); color: var(--clr-amber); }

/* ══════════════════════════════════════════
   AI CHAT
══════════════════════════════════════════ */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h) - 110px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Edit counter */
.edit-counter { display: flex; align-items: center; gap: 10px; }
.edit-label   { font-size: 0.82rem; color: var(--text-muted); }
.edit-pips    { display: flex; gap: 6px; }

.pip {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  transition: all var(--t-med);
}
.pip.used { background: var(--bg-card-hover); border: 1px solid var(--border); }
.pip.last { background: var(--clr-red); animation: blink-crit 1s step-end infinite; }

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: msgIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

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

.msg-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.msg-bubble {
  max-width: 72%;
  padding: 11px 15px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.55;
}

.ai-message .msg-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top-left-radius: 3px;
}
.user-message .msg-bubble {
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  color: #fff;
  border-top-right-radius: 3px;
}

.msg-decision-approved { border-left: 3px solid var(--clr-green) !important; }
.msg-decision-rejected { border-left: 3px solid var(--clr-red)   !important; }

/* Chat input */
.chat-input-area {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}
.chat-input-wrapper { display: flex; gap: 10px; margin-bottom: 10px; }

.chat-quick-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.quick-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.76rem;
  padding: 5px 12px;
  border-radius: 99px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.quick-btn:hover { border-color: var(--accent); color: var(--text-primary); }

/* Loading dots animation in chat */
.loading-dots::after {
  content: '';
  animation: dots 1.4s step-end infinite;
}
@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
}

/* ══════════════════════════════════════════
   STATS VIEW
══════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.stats-card h3 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 18px;
}

/* Bar chart */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  height: 120px;
}
.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  height: 100%;
  justify-content: flex-end;
}
.bar-fill {
  width: 100%;
  min-height: 4px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(to top, var(--accent), var(--accent-light));
  transition: height 0.7s cubic-bezier(0.4,0,0.2,1);
}
.bar-label { font-size: 0.68rem; color: var(--text-muted); }

/* Donut chart */
.donut-chart-container {
  display: flex;
  align-items: center;
  justify-content: center;
}
.donut-chart { width: 140px; height: 140px; }
.donut-bg   { fill: none; stroke: var(--bg-surface); stroke-width: 11; }
.donut-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 11;
  stroke-linecap: round;
  transition: stroke-dasharray 1.1s ease;
}
.donut-label {
  fill: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  text-anchor: middle;
  dominant-baseline: middle;
}

/* AI stats rows */
.ai-stats { display: flex; flex-direction: column; gap: 0; }
.ai-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.ai-stat-row:last-child { border-bottom: none; }

/* Avatar history */
.avatar-history { display: flex; gap: 8px; flex-wrap: wrap; }
.avatar-hist-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.avatar-hist-emoji { font-size: 1.5rem; }

/* ══════════════════════════════════════════
   LOCK OVERLAY
══════════════════════════════════════════ */
#view-stats, #view-themes { position: relative; }

.lock-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7,7,15,0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}

.lock-message { text-align: center; padding: 40px 30px; max-width: 380px; }
.lock-big-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 14px;
  animation: float 3s ease-in-out infinite;
}
.lock-message h3 { font-size: 1.35rem; margin-bottom: 10px; }
.lock-message p  { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.5; }

.redemption-progress {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 22px;
}
.redemption-day {
  padding: 7px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: all var(--t-med);
}
.redemption-day.complete {
  background: var(--clr-green-dim);
  border-color: var(--clr-green);
  color: var(--clr-green);
  font-weight: 600;
}

/* ══════════════════════════════════════════
   THEMES
══════════════════════════════════════════ */
.themes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.theme-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--text-secondary);
  transition: all var(--t-fast);
}
.theme-card:hover  { border-color: rgba(124,58,237,0.5); color: var(--text-primary); transform: translateY(-2px); }
.theme-card.active { border-color: var(--accent); color: var(--text-primary); }

.theme-preview {
  height: 76px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.theme-default { background: linear-gradient(135deg, #07070f 40%, #7c3aed); }
.theme-blood   { background: linear-gradient(135deg, #0a0000 40%, #dc2626); }
.theme-matrix  { background: linear-gradient(135deg, #000500 40%, #059669); }
.theme-ocean   { background: linear-gradient(135deg, #030a1a 40%, #06b6d4); }
.theme-gold    { background: linear-gradient(135deg, #0a0700 40%, #d97706); }

/* ══════════════════════════════════════════
   SETTINGS
══════════════════════════════════════════ */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}

.settings-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.danger-zone {
  border-color: rgba(220,38,38,0.25);
  grid-column: 1 / -1;
}
.danger-zone h3 { color: var(--clr-red); }

.bedtime-locked-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.lock-badge {
  font-size: 0.74rem;
  color: var(--clr-amber);
  background: var(--clr-amber-dim);
  border: 1px solid rgba(217,119,6,0.3);
  padding: 3px 9px;
  border-radius: 99px;
}

/* ══════════════════════════════════════════
   GENERIC MODAL
══════════════════════════════════════════ */
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  padding: 28px 30px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-card);
  animation: slideUp 0.35s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.modal-header h2 { font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: color var(--t-fast);
}
.modal-close:hover { color: var(--text-primary); }

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

/* ══════════════════════════════════════════
   TOAST
══════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 22px; right: 22px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 2000;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  font-size: 0.88rem;
  box-shadow: var(--shadow-card);
  animation: toastIn 0.32s cubic-bezier(0.34,1.56,0.64,1);
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 270px;
  max-width: 350px;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(44px) scale(0.88); }
  to   { opacity: 1; transform: translateX(0)    scale(1);    }
}

.toast-success { border-left: 3px solid var(--clr-green); }
.toast-error   { border-left: 3px solid var(--clr-red);   }
.toast-warn    { border-left: 3px solid var(--clr-amber);  }
.toast-info    { border-left: 3px solid var(--accent);     }

/* ══════════════════════════════════════════
   LOADING OVERLAY
══════════════════════════════════════════ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7,7,15,0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.loading-content { text-align: center; }

.loading-spinner {
  width: 46px; height: 46px;
  border: 3px solid var(--bg-card);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { color: var(--text-secondary); font-size: 0.92rem; }

/* ══════════════════════════════════════════
   AVATAR STATE OVERRIDES (CSS body classes)
══════════════════════════════════════════ */
body.avatar-tired .avatar-main {
  filter: drop-shadow(0 0 18px rgba(217,119,6,0.35)) saturate(0.7);
}
body.avatar-stressed .avatar-main {
  filter: drop-shadow(0 0 18px rgba(220,38,38,0.3)) saturate(0.5);
  animation: avatar-float 2s ease-in-out infinite, avatar-shake 4s ease-in-out infinite;
}
body.avatar-sick .avatar-main {
  filter: drop-shadow(0 0 22px rgba(220,38,38,0.5)) hue-rotate(70deg) saturate(0.6);
}
body.avatar-zombie .avatar-main {
  filter: drop-shadow(0 0 22px rgba(16,185,129,0.4)) grayscale(0.55) hue-rotate(100deg);
  animation: zombie-wobble 2.2s ease-in-out infinite !important;
}
body.avatar-skeleton .avatar-main {
  filter: grayscale(1) drop-shadow(0 0 18px rgba(148,163,184,0.4));
  animation: shake-heavy 0.9s ease-in-out infinite !important;
}

@keyframes avatar-shake {
  0%,90%,100% { transform: translateY(0) rotate(0deg); }
  92% { transform: translateY(-4px) rotate(-2deg); }
  96% { transform: translateY(-4px) rotate(2deg); }
}
@keyframes zombie-wobble {
  0%,100% { transform: rotate(-4deg) translateY(0);    }
  50%     { transform: rotate(4deg)  translateY(-5px); }
}
@keyframes shake-heavy {
  0%,100% { transform: translateX(0);  }
  25%     { transform: translateX(-5px); }
  75%     { transform: translateX(5px);  }
}

/* Glow color by avatar stage */
body.avatar-tired    #avatar-glow { background: radial-gradient(circle, rgba(217,119,6,0.4) 0%, transparent 70%); }
body.avatar-stressed #avatar-glow { background: radial-gradient(circle, rgba(251,146,60,0.4) 0%, transparent 70%); }
body.avatar-sick     #avatar-glow { background: radial-gradient(circle, rgba(220,38,38,0.4) 0%, transparent 70%); }
body.avatar-zombie   #avatar-glow { background: radial-gradient(circle, rgba(16,185,129,0.35) 0%, transparent 70%); }
body.avatar-skeleton #avatar-glow { background: radial-gradient(circle, rgba(100,116,139,0.35) 0%, transparent 70%); }

/* ══════════════════════════════════════════
   THEME VARIANTS
══════════════════════════════════════════ */
body.theme-blood {
  --accent:       #dc2626;
  --accent-light: #ef4444;
  --accent-dim:   rgba(220,38,38,0.15);
  --accent-glow:  rgba(220,38,38,0.35);
  --border-accent:rgba(220,38,38,0.4);
}
body.theme-matrix {
  --accent:       #10b981;
  --accent-light: #34d399;
  --accent-dim:   rgba(16,185,129,0.15);
  --accent-glow:  rgba(16,185,129,0.35);
  --border-accent:rgba(16,185,129,0.4);
  --bg-primary:   #000500;
  --bg-surface:   #020d02;
  --bg-card:      #050e05;
}
body.theme-ocean {
  --accent:       #06b6d4;
  --accent-light: #22d3ee;
  --accent-dim:   rgba(6,182,212,0.15);
  --accent-glow:  rgba(6,182,212,0.35);
  --border-accent:rgba(6,182,212,0.4);
  --bg-primary:   #030a1a;
}
body.theme-gold {
  --accent:       #d97706;
  --accent-light: #f59e0b;
  --accent-dim:   rgba(217,119,6,0.15);
  --accent-glow:  rgba(217,119,6,0.35);
  --border-accent:rgba(217,119,6,0.4);
  --bg-primary:   #0a0700;
}

/* ══════════════════════════════════════════
   SCROLLBAR
══════════════════════════════════════════ */
::-webkit-scrollbar             { width: 5px; height: 5px; }
::-webkit-scrollbar-track       { background: transparent; }
::-webkit-scrollbar-thumb       { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 960px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .card-avatar    { grid-row: auto; }
  .stats-grid     { grid-template-columns: 1fr; }
  .settings-grid  { grid-template-columns: 1fr; }
  .danger-zone    { grid-column: 1; }
}

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 300;
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 36px rgba(0,0,0,0.6);
  }
  .sidebar-toggle { display: block !important; }
  .view           { padding: 14px 16px; }
  #app-header     { padding: 0 14px; }
  .onboarding-card { padding: 24px 18px; }
  .chat-container { height: calc(100vh - var(--header-h) - 80px); }
}

@media (max-width: 520px) {
  .form-row { grid-template-columns: 1fr; }
  .msg-bubble { max-width: 88%; }
  .header-right .btn-sync span { display: none; }
}
