:root {
  --bg: #0A0A0A;
  --level-0: #0A0A0A;
  --level-1: #121212;
  --level-2: #1A1A1A;
  --surface-container-high: #2a2a2a;
  --surface-container-lowest: #0e0e0e;
  --border: #262626;
  --border-strong: #444933;
  --on-surface: #e5e2e1;
  --on-surface-variant: #9a9a98;
  --white: #ffffff;

  --primary: #c3f400;      
  --primary-dim: #abd600;
  --on-primary: #283500;
  --secondary: #ff5708;  
  --on-secondary: #2b1000;
  --error: #ffb4ab;

  --radius: 4px;
  --radius-lg: 8px;
  --radius-full: 9999px;
  --touch-min: 48px;
  --gutter: 16px;
  --stack-gap: 12px;

  --font-display: 'Archivo Narrow', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--on-surface);
  font-family: var(--font-body);
  min-height: 100vh;
}

h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); }

a { color: inherit; text-decoration: none; }

button, input, select { font-family: inherit; color: inherit; }

/* ---------- Layout shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--touch-min);
  padding: 0 var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.02em;
  color: var(--primary-dim);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--primary-dim);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-container-high); }

main.page {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 24px var(--gutter) 100px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

@media (min-width: 768px) {
  main.page { padding-left: calc(96px + var(--gutter)); padding-right: 32px; max-width: 760px; }
}

section.block { display: flex; flex-direction: column; gap: var(--stack-gap); }

.block-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 1px solid var(--surface-container-high);
  padding-bottom: 8px;
}
.block-header h3 { font-size: 22px; }
.block-header .meta { font-family: var(--font-mono); font-size: 13px; color: var(--on-surface-variant); }

/* ---------- Bottom nav ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px var(--gutter);
  background: var(--surface-container-lowest);
  border-top: 1px solid var(--border);
}

@media (min-width: 768px) {
  .bottom-nav {
    top: 64px;
    bottom: 0;
    left: 0;
    width: 96px;
    height: auto;
    flex-direction: column;
    justify-content: flex-start;
    gap: 28px;
    padding-top: 32px;
    border-top: none;
    border-right: 1px solid var(--border);
  }
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 12px;
  color: var(--on-surface-variant);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: transform 0.15s ease;
  cursor: pointer;
}
.nav-item:active { transform: scale(0.92); }
.nav-item.nav-active {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--touch-min);
  border-radius: var(--radius);
  border: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
  width: 100%;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-dim); }

.btn-ghost {
  background: var(--level-1);
  color: var(--on-surface);
  border: 1px solid var(--border);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 15px;
}
.btn-ghost:hover { background: var(--level-2); }

.btn.export-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.export-icon {
  flex-shrink: 0;
  color: var(--primary-dim);
}

.btn-destructive {
  background: transparent;
  border: 1px solid var(--secondary);
  color: var(--secondary);
  font-family: var(--font-body);
  font-weight: 500;
}

/* ---------- Cards ---------- */

.card {
  background: var(--level-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.card-flush { padding: 0; overflow: hidden; }

.log-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: var(--level-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.log-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--surface-container-high);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-dim);
  flex-shrink: 0;
  font-size: 22px;
}
.log-main { flex: 1; display: flex; flex-direction: column; }
.log-name { font-weight: 600; }
.log-time { font-family: var(--font-mono); font-size: 12px; color: var(--on-surface-variant); }
.log-metrics { text-align: right; display: flex; flex-direction: column; }
.log-metric-primary { font-family: var(--font-mono); font-weight: 700; font-size: 18px; color: var(--primary-dim); }
.log-metric-secondary { font-family: var(--font-mono); font-size: 12px; color: var(--on-surface-variant); }
.log-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.log-delete, .log-edit { color: var(--on-surface-variant); background: none; border: none; cursor: pointer; padding: 4px; }
.log-delete:hover { color: var(--secondary); }
.log-edit:hover { color: var(--primary-dim); }

/* ---------- Inputs ---------- */

.metric-input-container {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--level-2);
  padding: 6px 12px 8px;
}
.metric-input-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--on-surface-variant);
  margin-bottom: 2px;
}
.metric-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--on-surface);
}

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--on-surface-variant);
}
select.control, input.control {
  width: 100%;
  height: var(--touch-min);
  background: var(--level-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--on-surface);
  padding: 0 14px;
  font-size: 15px;
}
select.control:focus, input.control:focus { outline: none; border-color: var(--primary-dim); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Progress ---------- */

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--level-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-track.lg { height: 16px; }
.progress-fill {
  height: 100%;
  background: var(--primary);
  box-shadow: 0 0 8px rgba(195, 244, 0, 0.4);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* ---------- Sync controls ---------- */

.sync-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--touch-min);
  padding: 0 16px;
  background: var(--level-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  width: 100%;
}
.sync-btn:hover { background: var(--level-2); }
.sync-btn-label { display: flex; align-items: center; gap: 10px; }

.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-on { background: var(--primary); box-shadow: 0 0 6px rgba(195,244,0,0.6); }
.dot-off { background: var(--border); }
.dot-warn { background: var(--secondary); }

/* ---------- Hero / metrics ---------- */

.hero-label { font-family: var(--font-mono); font-size: 13px; color: var(--primary-dim); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 4px; }
.hero-value { font-family: var(--font-display); font-weight: 700; font-size: 56px; line-height: 1; color: var(--white); }

.stat-card { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; color: var(--on-surface-variant); letter-spacing: 0.06em; }
.stat-value { font-family: var(--font-display); font-weight: 700; font-size: 40px; color: var(--primary-dim); }
.stat-value .unit { font-family: var(--font-mono); font-size: 14px; color: var(--on-surface-variant); font-weight: 500; margin-left: 4px; }

.pr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pr-card { display: flex; flex-direction: column; gap: 10px; }
.pr-title { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; color: var(--primary-dim); letter-spacing: 0.05em; }
.pr-value { font-family: var(--font-display); font-weight: 700; font-size: 34px; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; background: var(--level-2); border-radius: 3px 3px 0 0; overflow: hidden; }
.bar-fill { background: var(--primary); opacity: 0.55; }
.bar-fill.peak { opacity: 1; box-shadow: 0 0 8px rgba(195,244,0,0.35); }
.bar-labels { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 11px; color: var(--on-surface-variant); opacity: 0.7; text-transform: uppercase; padding: 0 2px; }

/* ---------- Goals ---------- */

.priority-goal { border: 1px solid var(--primary-dim); border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column; gap: 10px; background: linear-gradient(180deg, rgba(195,244,0,0.06), transparent); }
.goal-card { display: flex; flex-direction: column; gap: 10px; }
.goal-row { display: flex; justify-content: space-between; align-items: center; }
.goal-name { font-weight: 600; }
.goal-pct { font-family: var(--font-mono); font-weight: 700; color: var(--primary-dim); }
.goal-footer { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 12px; color: var(--on-surface-variant); }
.goal-completed { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(68,73,51,0.3); opacity: 0.7; }
.goal-completed .name { text-decoration: line-through; color: var(--on-surface-variant); }

/* ---------- Badges ---------- */

.status-card { text-align: center; border: 1px solid var(--primary-dim); border-radius: var(--radius-lg); padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.status-label { font-family: var(--font-mono); font-size: 12px; color: var(--on-surface-variant); text-transform: uppercase; letter-spacing: 0.08em; }
.status-level { font-family: var(--font-display); font-size: 44px; font-weight: 700; color: var(--primary-dim); }

.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.badge-card { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 20px 12px; }
.badge-hex {
  width: 64px; height: 64px;
  clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0% 50%);
  display: flex; align-items: center; justify-content: center;
  background: rgba(195,244,0,0.12);
  color: var(--primary-dim);
  font-size: 28px;
}
.badge-card.locked .badge-hex { background: var(--level-2); color: var(--on-surface-variant); }
.badge-card.locked { opacity: 0.6; }
.badge-name { font-weight: 700; }
.badge-desc { font-size: 12px; color: var(--on-surface-variant); }

.locked-row { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.locked-row .top { display: flex; justify-content: space-between; align-items: center; color: var(--on-surface-variant); }
.locked-row .progress-num { font-family: var(--font-mono); font-size: 12px; }

/* ---------- Empty states / toast ---------- */

.empty-state { padding: 24px; text-align: center; color: var(--on-surface-variant); font-size: 14px; }

#toast-host { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--level-2);
  border: 1px solid var(--border);
  color: var(--on-surface);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-warn { border-color: var(--secondary); color: var(--secondary); }

.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24; font-size: 22px; vertical-align: middle; }

/* Social icons */
.social-row .social-icons {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding: 8px 0;
}
.social-row .social-icons a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--level-1);
  border: 1px solid var(--border);
  color: var(--on-surface-variant);
  transition: background 0.2s, color 0.2s;
}
.social-row .social-icons a:hover {
  background: var(--surface-container-high);
  color: var(--primary-dim);
}
.social-row .social-icons a svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Weekly recap banner */
.weekly-banner {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--level-2);
  border: 1px solid var(--primary-dim);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  max-width: 90%;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
}
.weekly-banner .content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.weekly-banner .title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--primary-dim);
}
.weekly-banner .stats {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--on-surface);
}
.weekly-banner .close-btn {
  background: none;
  border: none;
  color: var(--on-surface-variant);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
}