  :root {
    --bg: #07080a;
    --bg-1: #0d0f12;
    --bg-2: #14171c;
    --bg-3: #1c2026;
    --line: rgba(255,255,255,0.06);
    --line-2: rgba(255,255,255,0.10);
    --text: #f5f5f4;
    --text-dim: rgba(245,245,244,0.62);
    --text-faint: rgba(245,245,244,0.38);
    --accent: #22c55e;
    --accent-soft: rgba(34,197,94,0.16);
    --accent-glow: rgba(34,197,94,0.45);
    --danger: #ef4444;
    --warn: #f59e0b;

    --mood-1: #ef4444; /* awful */
    --mood-2: #f97316; /* meh */
    --mood-3: #eab308; /* okay */
    --mood-4: #84cc16; /* good */
    --mood-5: #22c55e; /* great */

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;

    --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --font-mono: 'Geist Mono', ui-monospace, monospace;
    --font-serif: 'Instrument Serif', serif;
  }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overscroll-behavior: none;
  }
  body {
    background:
      radial-gradient(1200px 600px at 80% -10%, rgba(34,197,94,0.07), transparent 60%),
      radial-gradient(900px 500px at -10% 110%, rgba(34,197,94,0.05), transparent 60%),
      var(--bg);
    min-height: 100vh;
  }
  button { font: inherit; color: inherit; cursor: pointer; }
  input, textarea { font: inherit; color: inherit; }
  /* Tabular numbers everywhere relevant */
  .tnum { font-variant-numeric: tabular-nums; }

  /* Scrollbars */
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
  ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); background-clip: content-box; border: 2px solid transparent; }

  /* App shell */
  .app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
  }
  @media (max-width: 880px) {
    .app { grid-template-columns: 1fr; }
  }

  /* Sidebar (desktop) */
  .sidebar {
    border-right: 1px solid var(--line);
    padding: 20px 16px 24px;
    position: sticky; top: 0; align-self: start;
    height: 100vh;
    display: flex; flex-direction: column;
    gap: 4px;
  }
  @media (max-width: 880px) { .sidebar { display: none; } }
  .brand {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px 18px;
  }
  .brand-mark {
    width: 32px; height: 32px; border-radius: 10px;
    background:
      radial-gradient(circle at 30% 25%, rgba(255,255,255,0.35), transparent 55%),
      linear-gradient(135deg, var(--accent) 0%, #16a34a 100%);
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.3),
      inset 0 -1px 0 rgba(0,0,0,0.25),
      0 0 0 1px rgba(255,255,255,0.06),
      0 0 24px var(--accent-glow);
    display: grid; place-items: center;
    position: relative;
  }
  .brand-mark svg { width: 18px; height: 18px; color: #07080a; }
  .brand-name {
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.03em;
    text-transform: lowercase;
    display: inline-flex;
    align-items: center;
  }
  .brand-name em {
    font-style: normal;
    color: var(--accent);
    margin-left: 1px;
    text-shadow: 0 0 12px var(--accent-glow);
  }

  .nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--r-md);
    color: var(--text-dim);
    border: 0; background: transparent;
    text-align: left;
    transition: background .15s, color .15s;
  }
  .nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
  .nav-item.active { background: var(--bg-2); color: var(--text); }
  .nav-item .ico { width: 18px; height: 18px; flex: none; opacity: 0.9; }
  .nav-item.active .ico { color: var(--accent); }

  .sidebar-foot {
    margin-top: auto;
    padding: 12px;
    border-radius: var(--r-md);
    background: var(--bg-1);
    border: 1px solid var(--line);
    display: flex; align-items: center; gap: 10px;
  }
  .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 13px;
  }

  /* Main content */
  .main {
    padding: 32px 40px 120px;
    min-width: 0;
  }
  @media (max-width: 880px) {
    .main { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  }

  .topbar {
    display: flex; align-items: end; justify-content: space-between;
    gap: 16px; margin-bottom: 28px;
  }
  .greeting { display: flex; flex-direction: column; gap: 6px; }
  .greeting .date {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }
  .greeting h1 {
    margin: 0;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 34px;
    letter-spacing: -0.035em;
    line-height: 1.05;
  }
  .greeting h1 em { font-style: normal; color: var(--accent); font-weight: 500; }
  @media (max-width: 880px) {
    .greeting h1 { font-size: 28px; }
  }

  .topbar-right { display: flex; align-items: center; gap: 8px; }
  @media (max-width: 880px) { .desktop-only { display: none !important; } }
  .icon-btn {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: var(--r-md);
    background: var(--bg-1);
    border: 1px solid var(--line);
    color: var(--text-dim);
    transition: all .15s;
  }
  .icon-btn:hover { color: var(--text); border-color: var(--line-2); background: var(--bg-2); }

  /* Streak hero */
  .hero-row {
    display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 16px;
    margin-bottom: 24px;
  }
  @media (max-width: 880px) {
    .hero-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    .hero-row .hero-card-wide { grid-column: 1 / -1; }
  }
  .stat-card {
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    position: relative; overflow: hidden;
  }
  .stat-card .label {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
  }
  .stat-card .value {
    margin-top: 8px;
    font-family: var(--font-mono);
    font-size: 40px;
    font-weight: 500;
    letter-spacing: -0.04em;
    line-height: 1;
    display: flex; align-items: baseline; gap: 6px;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "ss01", "ss02", "zero";
  }
  .stat-card .value .unit {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-faint);
  }
  .stat-card .delta {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-dim);
  }
  .stat-card .delta.up { color: var(--accent); }

  .hero-card-wide {
    background: linear-gradient(135deg, rgba(34,197,94,0.10) 0%, rgba(34,197,94,0.02) 60%), var(--bg-1);
    border: 1px solid rgba(34,197,94,0.22);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 0 60px -20px var(--accent-glow);
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
  }
  .flame {
    width: 64px; height: 64px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-soft), transparent 70%);
    font-size: 36px;
    filter: drop-shadow(0 0 12px var(--accent-glow));
  }
  @media (max-width: 880px) {
    .stat-card .value { font-size: 32px; }
    .flame { width: 48px; height: 48px; font-size: 28px; }
  }

  /* Section heading */
  .section-h {
    display: flex; align-items: center; justify-content: space-between;
    margin: 28px 0 14px;
  }
  .section-h h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-dim);
  }
  .section-h .meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-faint);
  }

  /* Habit list */
  .habit-list { display: flex; flex-direction: column; gap: 10px; }
  .habit-card {
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 14px 16px;
    display: flex; align-items: center; gap: 14px;
    transition: all .18s;
    position: relative;
  }
  .habit-card:hover { border-color: var(--line-2); }
  .habit-card.done {
    background: linear-gradient(90deg, rgba(34,197,94,0.08), rgba(34,197,94,0.02));
    border-color: rgba(34,197,94,0.25);
  }

  .check {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--line-2);
    background: transparent;
    display: grid; place-items: center;
    flex: none;
    transition: all .18s;
    color: transparent;
  }
  .check:hover { border-color: var(--text-dim); }
  .check.done {
    background: var(--accent);
    border-color: var(--accent);
    color: #07080a;
    box-shadow: 0 0 0 4px var(--accent-soft), 0 0 20px var(--accent-glow);
  }
  .check svg { width: 16px; height: 16px; stroke-width: 3; }

  .habit-info { flex: 1; min-width: 0; }
  .habit-info .name {
    font-size: 15px; font-weight: 500;
    display: flex; align-items: center; gap: 8px;
  }
  .habit-info .name .emoji { font-size: 16px; }
  .habit-card.done .habit-info .name { color: var(--text-dim); }
  .habit-info .meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 2px;
    display: flex; align-items: center; gap: 10px;
  }
  .streak-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px;
    border-radius: 100px;
    background: rgba(245,158,11,0.12);
    color: var(--warn);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
  }
  .streak-pill.cold {
    background: rgba(255,255,255,0.04);
    color: var(--text-faint);
  }

  .habit-actions { display: flex; gap: 6px; }
  .habit-actions button {
    width: 30px; height: 30px;
    border-radius: 8px;
    border: 0; background: transparent;
    color: var(--text-faint);
    display: grid; place-items: center;
  }
  .habit-actions button:hover { background: rgba(255,255,255,0.06); color: var(--text); }

  /* Mood selector */
  .mood-card {
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    margin-bottom: 16px;
  }
  .mood-card .head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
  }
  .mood-card .head .label {
    font-size: 13px; color: var(--text-dim);
  }
  .mood-card .head .selected {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
  }
  .mood-row { display: flex; gap: 8px; }
  .mood-btn {
    flex: 1;
    aspect-ratio: 1.2;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--bg-2);
    display: grid; place-items: center;
    font-size: 22px;
    transition: all .15s;
    position: relative;
  }
  .mood-btn:hover { transform: translateY(-2px); border-color: var(--line-2); }
  .mood-btn.active {
    transform: translateY(-3px);
    box-shadow: 0 0 0 2px var(--mood-c, var(--accent)), 0 8px 24px -8px var(--mood-c, var(--accent));
    border-color: transparent;
  }
  .mood-btn[data-m="1"] { --mood-c: var(--mood-1); }
  .mood-btn[data-m="2"] { --mood-c: var(--mood-2); }
  .mood-btn[data-m="3"] { --mood-c: var(--mood-3); }
  .mood-btn[data-m="4"] { --mood-c: var(--mood-4); }
  .mood-btn[data-m="5"] { --mood-c: var(--mood-5); }

  /* Note */
  .note-card {
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 16px 18px;
  }
  .note-card .head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
  }
  .note-card .label { font-size: 13px; color: var(--text-dim); }
  .note-card .count { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
  .note-card textarea {
    width: 100%;
    min-height: 90px;
    background: transparent;
    border: 0;
    resize: vertical;
    outline: none;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
  }
  .note-card textarea::placeholder { color: var(--text-faint); }

  /* Bottom nav (mobile) */
  .bottom-nav {
    display: none;
  }
  @media (max-width: 880px) {
    .bottom-nav {
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      position: fixed; left: 0; right: 0; bottom: 0;
      background: rgba(13,15,18,0.85);
      backdrop-filter: blur(16px) saturate(160%);
      -webkit-backdrop-filter: blur(16px) saturate(160%);
      border-top: 1px solid var(--line);
      padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
      z-index: 100;
    }
    .bottom-nav button {
      background: transparent; border: 0;
      display: flex; flex-direction: column; align-items: center; gap: 3px;
      color: var(--text-faint);
      padding: 6px 4px;
      border-radius: 10px;
      font-size: 10px;
    }
    .bottom-nav button.active { color: var(--accent); }
    .bottom-nav button .ico { width: 22px; height: 22px; }
  }

  /* Mobile header */
  .mobile-top {
    display: none;
  }
  @media (max-width: 880px) {
    .mobile-top {
      display: flex; align-items: center; justify-content: space-between;
      margin-bottom: 18px;
    }
    .mobile-top .brand { padding: 0; }
  }

  /* Heatmap */
  .heatmap {
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 16px;
    overflow-x: auto;
  }
  .heatmap-grid {
    display: grid;
    grid-template-columns: 140px repeat(7, minmax(36px, 1fr));
    gap: 4px;
    align-items: center;
    min-width: 480px;
  }
  .heatmap-grid .col-h {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-faint);
    text-align: center;
    text-transform: uppercase;
  }
  .heatmap-grid .col-h.today { color: var(--accent); font-weight: 600; }
  .heatmap-grid .row-h {
    font-size: 13px;
    color: var(--text-dim);
    padding-right: 8px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .heatmap-grid .cell {
    aspect-ratio: 1;
    border-radius: 6px;
    background: var(--bg-3);
    border: 1px solid var(--line);
    transition: transform .15s;
    cursor: default;
  }
  .heatmap-grid .cell.done {
    background: var(--accent);
    border-color: transparent;
    box-shadow: 0 0 12px -2px var(--accent-glow);
  }
  .heatmap-grid .cell.future {
    background: transparent;
    border: 1px dashed var(--line);
  }
  .heatmap-grid .cell:hover { transform: scale(1.1); }

  /* Calendar */
  .calendar {
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 18px;
  }
  .calendar-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
  }
  .calendar-head h3 {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.025em;
  }
  .cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
  }
  .cal-grid .dow {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-faint);
    text-align: center;
    text-transform: uppercase;
    padding: 4px 0;
  }
  .cal-day {
    aspect-ratio: 1;
    border-radius: 10px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    display: flex; flex-direction: column; align-items: center; justify-content: space-between;
    padding: 6px 4px;
    position: relative;
    cursor: pointer;
    transition: transform .12s, border-color .12s;
  }
  .cal-day:hover { border-color: var(--line-2); }
  .cal-day.empty { background: transparent; border: 0; cursor: default; }
  .cal-day.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
  .cal-day .num {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-dim);
  }
  .cal-day.today .num { color: var(--accent); font-weight: 600; }
  .cal-day .dot-row {
    display: flex; gap: 2px; flex-wrap: wrap; justify-content: center;
  }
  .cal-day .dot {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--accent);
  }
  .cal-day .dot.dim { background: var(--text-faint); opacity: 0.4; }
  .cal-day .perf {
    position: absolute; inset: 0; border-radius: 10px;
    background: var(--accent);
    opacity: var(--p, 0);
    pointer-events: none;
  }

  /* Month table */
  .month-table-wrap {
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 18px;
  }
  .month-table-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
  }
  .month-table-head h3 {
    margin: 0;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 17px;
    letter-spacing: -0.025em;
  }
  .month-table {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--bg-0);
  }
  .mt-grid {
    display: grid;
    align-items: stretch;
  }
  .mt-row {
    border-bottom: 1px solid var(--line);
    min-height: 38px;
  }
  .mt-row:last-child { border-bottom: 0; }
  .mt-header {
    background: var(--bg-2);
    position: sticky; top: 0; z-index: 2;
    min-height: 46px;
  }
  .mt-cell {
    display: flex; align-items: center; justify-content: center;
    border-right: 1px solid var(--line);
    padding: 4px 6px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-dim);
    position: relative;
    min-width: 0;
  }
  .mt-cell:last-child { border-right: 0; }
  .mt-row.is-today { background: color-mix(in oklab, var(--accent) 8%, transparent); }
  .mt-row.is-today .mt-date { color: var(--accent); }
  .mt-row.is-today .mt-day-num { color: var(--accent); font-weight: 700; }
  .mt-row.is-weekend { background: color-mix(in oklab, var(--bg-2) 60%, transparent); }
  .mt-row.is-weekend.is-today { background: color-mix(in oklab, var(--accent) 8%, transparent); }
  .mt-row.is-future { opacity: 0.5; }

  .mt-date {
    flex-direction: column; gap: 0;
    background: var(--bg-2);
    border-right: 1px solid var(--line);
  }
  .mt-day-num {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
  }
  .mt-day-dow {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 2px;
  }
  .mt-date-h {
    background: var(--bg-2);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-faint);
    font-weight: 600;
  }
  .mt-habit-h {
    flex-direction: column; gap: 2px;
    padding: 6px 4px;
  }
  .mt-h-emoji { font-size: 16px; line-height: 1; }
  .mt-h-name {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
  }
  .mt-mood-h {
    background: var(--bg-2);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-faint);
    font-weight: 600;
  }

  .mt-mark.done {
    background: color-mix(in oklab, var(--accent) 22%, transparent);
    color: var(--accent);
  }
  .mt-mark.done .mt-tick {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
  }
  .mt-mark.missed { background: transparent; }
  .mt-mark.missed .mt-cross { color: var(--text-faint); opacity: 0.4; font-size: 14px; }
  .mt-mark.unscheduled { background: repeating-linear-gradient(45deg, transparent 0 4px, color-mix(in oklab, var(--text-faint) 8%, transparent) 4px 5px); }
  .mt-mark.unscheduled .mt-rest { color: var(--text-faint); opacity: 0.35; font-size: 11px; }
  .mt-mark.future { background: transparent; }

  .mt-mood {
    background: transparent;
    position: relative;
    z-index: 0;
    padding: 0;
    border-left: 1px solid var(--line);
  }
  .mt-mood-num {
    position: relative;
    z-index: 3;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
    font-weight: 600;
    background: var(--bg-2);
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid var(--line);
  }
  .mt-mood-h {
    background: transparent;
    flex-direction: column; gap: 2px;
    padding: 6px 4px;
    border-left: 1px solid var(--line);
  }
  .mt-mood-scale {
    display: flex; justify-content: space-between;
    width: calc(100% - 24px);
    font-family: var(--font-mono);
    font-size: 8px;
    color: var(--text-faint);
    opacity: 0.6;
  }
  .mt-mood-chart { display: block; }

  .mt-legend {
    display: flex; flex-wrap: wrap; gap: 16px;
    margin-top: 12px;
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
  }
  .mt-legend span { display: inline-flex; align-items: center; gap: 6px; }
  .mt-dot {
    width: 12px; height: 12px; border-radius: 4px;
    display: inline-block;
  }
  .mt-dot.done { background: color-mix(in oklab, var(--accent) 22%, transparent); border: 1px solid var(--accent); }
  .mt-dot.missed { background: var(--bg-0); border: 1px solid var(--line); }
  .mt-dot.unscheduled { background: repeating-linear-gradient(45deg, var(--bg-0) 0 4px, color-mix(in oklab, var(--text-faint) 18%, var(--bg-0)) 4px 5px); border: 1px solid var(--line); }
  .mt-dot.future { background: transparent; border: 1px dashed var(--line-2); }

  @media (max-width: 720px) {
    .month-table-wrap { padding: 10px; overflow-x: auto; }
    .month-table { min-width: 560px; }
  }

  /* Stats */
  .stats-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px;
    margin-bottom: 18px;
  }
  @media (max-width: 880px) { .stats-grid { grid-template-columns: 1fr 1fr; } }

  .chart-card {
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 18px;
  }
  .chart-card h3 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
  }
  .chart-card .sub { font-size: 12px; color: var(--text-faint); margin-bottom: 14px; }

  .badge-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px;
  }
  .badge {
    padding: 14px 10px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    text-align: center;
    position: relative;
  }
  .badge.locked { opacity: 0.4; filter: grayscale(0.6); }
  .badge .icon {
    font-size: 28px;
    margin-bottom: 6px;
    filter: drop-shadow(0 0 8px var(--accent-glow));
  }
  .badge.locked .icon { filter: none; }
  .badge .name { font-size: 12px; font-weight: 500; }
  .badge .desc { font-size: 10px; color: var(--text-faint); margin-top: 2px; }

  /* Habit edit modal */
  .modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    display: grid; place-items: center;
    padding: 16px;
  }
  .modal {
    width: 100%; max-width: 440px;
    background: var(--bg-1);
    border: 1px solid var(--line-2);
    border-radius: var(--r-xl);
    padding: 24px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
  }
  .modal h2 {
    margin: 0 0 18px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 22px;
    letter-spacing: -0.03em;
  }
  .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
  .field label {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
  }
  .field input, .field select {
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 15px;
    outline: none;
    color: var(--text);
    -webkit-text-fill-color: var(--text);
    width: 100%;
    font-family: inherit;
  }
  .field input::placeholder { color: var(--text-faint); }
  .field input:focus, .field select:focus { border-color: var(--accent); }

  .emoji-row {
    display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px;
  }
  .emoji-pick {
    aspect-ratio: 1;
    border: 1px solid var(--line);
    background: var(--bg-2);
    border-radius: 8px;
    font-size: 18px;
    display: grid; place-items: center;
  }
  .emoji-pick.active { border-color: var(--accent); background: var(--accent-soft); }

  .day-row { display: flex; gap: 4px; }
  .day-pick {
    flex: 1;
    aspect-ratio: 1.4;
    border: 1px solid var(--line);
    background: var(--bg-2);
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-dim);
  }
  .day-pick.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

  .modal-actions {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 22px; gap: 10px;
  }
  .btn {
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--bg-2);
    font-size: 14px; font-weight: 500;
    transition: all .15s;
  }
  .btn:hover { border-color: var(--line-2); background: var(--bg-3); }
  .btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #07080a;
    box-shadow: 0 0 24px -6px var(--accent-glow);
  }
  .btn.primary:hover { filter: brightness(1.08); }
  .btn.danger { color: var(--danger); border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.06); }
  .btn.danger:hover { background: rgba(239,68,68,0.12); }

  .fab {
    position: fixed;
    right: 20px; bottom: calc(80px + env(safe-area-inset-bottom));
    width: 54px; height: 54px;
    border-radius: 50%;
    background: var(--accent);
    color: #07080a;
    border: 0;
    display: grid; place-items: center;
    box-shadow: 0 8px 28px -4px var(--accent-glow), 0 0 0 1px rgba(255,255,255,0.06);
    z-index: 90;
  }
  .fab svg { width: 24px; height: 24px; stroke-width: 2.5; }
  @media (min-width: 881px) {
    .fab { bottom: 24px; right: 24px; }
  }

  /* Empty / friends panel */
  .friends-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px;
  }
  .friend-card {
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 14px;
    display: flex; align-items: center; gap: 12px;
  }
  .friend-card .avatar { width: 40px; height: 40px; }
  .friend-card .info { flex: 1; min-width: 0; }
  .friend-card .name { font-size: 14px; font-weight: 500; }
  .friend-card .sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }

  /* Subtle entrance */
  @keyframes fade-up {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
  }
  .fade { animation: fade-up .3s ease both; }

  /* Density variants */
  body[data-density="compact"] .habit-card { padding: 10px 14px; }
  body[data-density="compact"] .stat-card { padding: 14px 16px; }
  body[data-density="compact"] .stat-card .value { font-size: 32px; }
  body[data-density="comfy"] .habit-card { padding: 18px 20px; }
  body[data-density="comfy"] .stat-card { padding: 22px 24px; }

  /* Card style variants */
  body[data-cardstyle="pill"] .habit-card { border-radius: 100px; padding-left: 22px; padding-right: 22px; }
  body[data-cardstyle="minimal"] .habit-card {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    padding: 14px 4px;
  }
  body[data-cardstyle="minimal"] .habit-card.done { background: transparent; }

  /* Reminder badge in habit card */
  .rem-badge {
    display: inline-flex; align-items: center; gap: 3px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-faint);
  }

  /* ─── Login screen ─────────────────────────────────────── */
  .login-shell {
    min-height: 100vh; min-height: 100dvh;
    display: grid; place-items: center;
    padding: 24px; position: relative;
    overflow: hidden;
  }
  .login-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
  .login-bg-blob {
    position: absolute; border-radius: 50%;
    filter: blur(80px); opacity: 0.5;
  }
  .login-bg-blob.a {
    width: 500px; height: 500px;
    background: radial-gradient(circle, var(--accent), transparent 60%);
    top: -150px; right: -150px;
  }
  .login-bg-blob.b {
    width: 600px; height: 600px;
    background: radial-gradient(circle, #06b6d4, transparent 60%);
    bottom: -200px; left: -200px;
    opacity: 0.25;
  }
  .login-card {
    position: relative; z-index: 1;
    width: 100%; max-width: 420px;
    background: rgba(13,15,18,0.7);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid var(--line-2);
    border-radius: 24px;
    padding: 32px 28px;
    box-shadow: 0 40px 80px -20px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
  }
  .login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
  .login-title {
    margin: 0 0 8px;
    font-family: var(--font-sans);
    font-size: 28px; font-weight: 600;
    letter-spacing: -0.035em;
    line-height: 1.1;
  }
  .login-title em { font-style: normal; color: var(--accent); }
  .login-sub {
    margin: 0 0 24px;
    font-size: 14px; color: var(--text-dim); line-height: 1.45;
  }
  .social-row {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    margin-bottom: 18px;
  }
  .social-btn {
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    color: var(--text);
    display: flex; align-items: center; justify-content: center; gap: 6px;
    font-size: 13px; font-weight: 500;
    transition: all .15s;
  }
  .social-btn:hover { border-color: var(--line-2); background: var(--bg-3); }
  .social-btn:disabled { opacity: 0.5; cursor: not-allowed; }
  .login-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 18px 0;
    font-size: 11px; color: var(--text-faint);
    font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em;
  }
  .login-divider::before, .login-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--line);
  }
  .login-form .field { margin-bottom: 14px; }
  .login-form input {
    color: var(--text) !important;
    -webkit-text-fill-color: var(--text);
    caret-color: var(--accent);
  }
  .login-form input:-webkit-autofill,
  .login-form input:-webkit-autofill:hover,
  .login-form input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px var(--bg-2) inset;
    box-shadow: 0 0 0 1000px var(--bg-2) inset;
    caret-color: var(--accent);
    transition: background-color 9999s ease-in-out 0s;
  }
  .pw-wrap { position: relative; }
  .pw-wrap input { padding-right: 40px; width: 100%; }
  .pw-toggle {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    background: transparent; border: 0;
    width: 30px; height: 30px;
    color: var(--text-faint);
    border-radius: 6px;
  }
  .pw-toggle:hover { background: rgba(255,255,255,0.06); color: var(--text); }
  .forgot-link {
    color: var(--accent); text-decoration: none;
    font-size: 11px; font-family: var(--font-mono);
    text-transform: none; letter-spacing: 0;
  }
  .forgot-link:hover { text-decoration: underline; }
  .login-error {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.3);
    color: var(--danger);
    border-radius: 8px; padding: 8px 12px;
    font-size: 13px; margin-bottom: 12px;
  }
  .login-submit { width: 100%; padding: 12px; font-size: 15px; margin-top: 4px; }
  .login-submit:disabled { opacity: 0.6; cursor: wait; }
  .login-foot {
    margin-top: 18px; text-align: center;
    font-size: 13px; color: var(--text-dim);
  }
  .login-foot a { color: var(--accent); text-decoration: none; font-weight: 500; }
  .login-foot a:hover { text-decoration: underline; }
  .login-foot-tagline {
    position: relative; z-index: 1;
    margin-top: 24px;
    font-family: var(--font-mono); font-size: 11px;
    color: var(--text-faint); text-align: center;
    letter-spacing: 0.04em;
  }

  /* ─── User menu / dropdown ─────────────────────────────── */
  .user-menu-wrap { position: relative; }
  .user-dropdown {
    position: absolute;
    background: var(--bg-1);
    border: 1px solid var(--line-2);
    border-radius: 14px;
    padding: 6px;
    min-width: 240px;
    box-shadow: 0 20px 50px -10px rgba(0,0,0,0.7);
    z-index: 150;
    animation: fade-up .15s ease both;
  }
  .user-dropdown.up { bottom: calc(100% + 8px); left: 0; }
  .user-dropdown.down { top: calc(100% + 8px); right: 0; }
  .user-dropdown-head {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 8px;
  }
  .user-dropdown-divider {
    height: 1px; background: var(--line); margin: 4px 0;
  }
  .user-dropdown-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 9px 10px;
    background: transparent; border: 0;
    color: var(--text);
    border-radius: 8px;
    text-align: left;
    font-size: 14px;
  }
  .user-dropdown-item:hover { background: rgba(255,255,255,0.06); }
  .user-dropdown-item.danger { color: var(--danger); }
  .user-dropdown-item.danger:hover { background: rgba(239,68,68,0.1); }

  /* ─── Profile modal ────────────────────────────────────── */
  .profile-modal { max-width: 540px; }
  .profile-tabs {
    display: flex; gap: 4px;
    background: var(--bg-2);
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 18px;
  }
  .profile-tab {
    flex: 1;
    padding: 8px 10px;
    background: transparent; border: 0;
    color: var(--text-dim);
    border-radius: 7px;
    font-size: 13px; font-weight: 500;
    transition: all .15s;
  }
  .profile-tab:hover { color: var(--text); }
  .profile-tab.active {
    background: var(--bg-3);
    color: var(--text);
    box-shadow: 0 1px 0 rgba(255,255,255,0.04);
  }
  .profile-stats {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
    margin: 18px 0 8px;
  }
  @media (max-width: 480px) { .profile-stats { grid-template-columns: repeat(2, 1fr); } }
  .profile-stat {
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    text-align: center;
  }
  .profile-stat .num {
    font-family: var(--font-mono);
    font-size: 22px; font-weight: 500;
    letter-spacing: -0.03em;
    color: var(--accent);
  }
  .profile-stat .lbl {
    font-size: 10px; color: var(--text-faint);
    text-transform: uppercase; letter-spacing: 0.06em;
    font-family: var(--font-mono);
    margin-top: 2px;
  }

  /* Settings rows */
  .settings-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; padding: 14px 0;
    border-bottom: 1px solid var(--line);
  }
  .settings-row:last-child { border-bottom: 0; }
  .settings-row .s-name { font-size: 14px; font-weight: 500; }
  .settings-row .s-desc { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
  .settings-row.danger-row { margin-top: 8px; }

  .seg {
    display: flex; gap: 2px;
    background: var(--bg-2); border-radius: 8px; padding: 2px;
  }
  .seg button {
    background: transparent; border: 0;
    padding: 6px 12px; font-size: 12px;
    color: var(--text-dim); border-radius: 6px;
  }
  .seg button.active { background: var(--bg-3); color: var(--text); }

  .settings-select, .settings-time {
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 10px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
  }
  .settings-time { font-family: var(--font-mono); }

  .switch {
    width: 38px; height: 22px;
    background: var(--bg-3);
    border: 1px solid var(--line);
    border-radius: 100px;
    padding: 1px;
    position: relative;
    transition: all .2s;
    cursor: pointer;
  }
  .switch.on { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
  .switch-thumb {
    position: absolute; top: 1px; left: 1px;
    width: 18px; height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  }
  .switch.on .switch-thumb { transform: translateX(16px); }

  /* ─── Admin view ────────────────────────────────────────── */
  .admin-toolbar {
    display: flex; gap: 10px; align-items: center;
    margin-bottom: 16px; flex-wrap: wrap;
  }
  .admin-search {
    flex: 1; min-width: 220px;
    position: relative;
    display: flex; align-items: center;
  }
  .admin-search svg {
    position: absolute; left: 12px; color: var(--text-faint);
  }
  .admin-search input {
    width: 100%;
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 12px 9px 34px;
    color: var(--text);
    outline: none;
    font-size: 14px;
  }
  .admin-search input:focus { border-color: var(--line-2); }
  .admin-filters { display: flex; gap: 4px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
  .admin-filter {
    background: transparent; border: 0;
    padding: 6px 12px; font-size: 12px; font-weight: 500;
    color: var(--text-dim); border-radius: 7px;
    display: inline-flex; align-items: center; gap: 6px;
  }
  .admin-filter.active { background: var(--bg-3); color: var(--text); }
  .admin-filter .cnt {
    font-family: var(--font-mono); font-size: 11px;
    color: var(--text-faint); padding: 1px 6px;
    background: rgba(255,255,255,0.05); border-radius: 100px;
  }
  .admin-filter.active .cnt { background: var(--accent-soft); color: var(--accent); }

  .admin-table {
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow: hidden;
  }
  .admin-row {
    display: grid;
    grid-template-columns: 2fr 1.1fr 1fr 0.7fr 1fr 1fr;
    gap: 14px; align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
  }
  .admin-row:last-child { border-bottom: 0; }
  .admin-row.admin-head {
    font-family: var(--font-mono); font-size: 10px;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-faint);
    padding: 10px 16px;
    background: rgba(255,255,255,0.02);
  }
  .admin-row:not(.admin-head):hover { background: rgba(255,255,255,0.02); }
  .admin-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .admin-user .avatar { width: 34px; height: 34px; font-size: 13px; flex: none; }
  .u-name { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .u-email { font-size: 12px; color: var(--text-faint); font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .self-badge {
    font-family: var(--font-mono); font-size: 9px;
    padding: 1px 6px; border-radius: 100px;
    background: var(--accent-soft); color: var(--accent);
    text-transform: uppercase; letter-spacing: 0.08em;
  }
  .role-select {
    background: var(--bg-2); border: 1px solid var(--line);
    border-radius: 7px; padding: 4px 8px;
    color: var(--text); font-size: 12px; font-family: inherit;
    outline: none;
  }
  .role-select:disabled { opacity: 0.5; cursor: not-allowed; }
  .status-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 8px; border-radius: 100px;
    font-size: 11px; font-weight: 500;
    background: rgba(255,255,255,0.04);
  }
  .status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .status-pill.s-active { color: var(--accent); background: var(--accent-soft); }
  .status-pill.s-inactive { color: var(--text-faint); }
  .status-pill.s-pending { color: var(--warn); background: rgba(245,158,11,0.12); }
  .admin-actions { display: flex; gap: 4px; justify-content: flex-end; }
  .action-btn {
    width: 28px; height: 28px;
    border-radius: 7px; border: 1px solid var(--line);
    background: var(--bg-2);
    color: var(--text-dim);
    display: grid; place-items: center;
  }
  .action-btn:hover { color: var(--text); border-color: var(--line-2); }
  .action-btn.danger:hover { color: var(--danger); border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.08); }
  .action-btn:disabled { opacity: 0.3; cursor: not-allowed; }

  @media (max-width: 880px) {
    .admin-row { grid-template-columns: 1fr auto; gap: 8px; padding: 12px; }
    .admin-row.admin-head { display: none; }
    .admin-row > div:nth-child(2),
    .admin-row > div:nth-child(3),
    .admin-row > div:nth-child(4),
    .admin-row > div:nth-child(5) { grid-column: 1; font-size: 12px; color: var(--text-dim); display: inline-flex; gap: 8px; }
    .admin-row > div:nth-child(2)::before { content: 'Szerep:'; color: var(--text-faint); }
    .admin-row > div:nth-child(4)::before { content: 'Streak:'; color: var(--text-faint); }
    .admin-row > div:nth-child(5)::before { content: 'Csatlakozott:'; color: var(--text-faint); }
    .admin-actions { grid-row: 1 / span 5; grid-column: 2; flex-direction: column; }
    .admin-toolbar { flex-direction: column; align-items: stretch; }
  }

  .toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--bg-1); border: 1px solid var(--accent);
    color: var(--text);
    padding: 10px 16px; border-radius: 100px;
    box-shadow: 0 10px 30px -8px rgba(0,0,0,0.6), 0 0 24px var(--accent-soft);
    font-size: 13px; font-weight: 500;
    display: inline-flex; align-items: center; gap: 8px;
    z-index: 250;
    animation: fade-up .25s ease both;
  }
  .toast svg { color: var(--accent); }
  @media (max-width: 880px) { .toast { bottom: calc(80px + env(safe-area-inset-bottom)); } }
