/* ==========================================================================
   Autofocus — design tokens
   ========================================================================== */
:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f1f2f8;
  --surface-3: #e6e8f2;
  --text: #161827;
  --text-2: #3d4157;
  --muted: #6c7190;
  --border: #e4e6f0;
  --primary: #5b4cf0;
  --primary-2: #8a5cf6;
  --primary-ink: #ffffff;
  --primary-soft: #efedff;
  --accent: #19b89b;
  --warm: #f0702a;
  --warm-soft: #fff0e6;
  --gold: #f5b301;
  --success: #12a05c;
  --success-soft: #e4f7ed;
  --danger: #e0445a;
  --danger-soft: #fdecee;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(22, 24, 39, .05);
  --shadow: 0 1px 2px rgba(22, 24, 39, .04), 0 6px 24px -6px rgba(22, 24, 39, .08);
  --shadow-lg: 0 20px 50px -12px rgba(40, 30, 120, .25);
  --sidebar: 264px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e16;
    --surface: #161824;
    --surface-2: #1e2131;
    --surface-3: #2a2e44;
    --text: #eef0fa;
    --text-2: #c9cde2;
    --muted: #9097b5;
    --border: #262a3d;
    --primary: #8b7fff;
    --primary-2: #b18cff;
    --primary-ink: #0d0e16;
    --primary-soft: #25224a;
    --accent: #3fd6b8;
    --warm: #ff9a52;
    --warm-soft: #3a2416;
    --success: #3ccf8a;
    --success-soft: #13301f;
    --danger: #ff6b7d;
    --danger-soft: #3b1a22;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -8px rgba(0, 0, 0, .5);
    --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0e16;
  --surface: #161824;
  --surface-2: #1e2131;
  --surface-3: #2a2e44;
  --text: #eef0fa;
  --text-2: #c9cde2;
  --muted: #9097b5;
  --border: #262a3d;
  --primary: #8b7fff;
  --primary-2: #b18cff;
  --primary-ink: #0d0e16;
  --primary-soft: #25224a;
  --accent: #3fd6b8;
  --warm: #ff9a52;
  --warm-soft: #3a2416;
  --success: #3ccf8a;
  --success-soft: #13301f;
  --danger: #ff6b7d;
  --danger-soft: #3b1a22;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -8px rgba(0, 0, 0, .5);
  --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4rem; letter-spacing: -.02em; }
h1 { font-size: 1.85rem; font-weight: 800; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 .8rem; }
ul, ol { margin: 0; padding: 0; list-style: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.center { text-align: center; }
.em { font-weight: 600; }
.inline { display: inline; margin: 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 50%, transparent); outline-offset: 2px; border-radius: 6px; }

/* ==========================================================================
   Brand
   ========================================================================== */
.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -.03em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  position: relative;
  box-shadow: 0 4px 12px -2px color-mix(in srgb, var(--primary) 60%, transparent);
}
.brand-mark::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2.5px solid #fff;
  border-radius: 50%;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 11.5px;
  background: #fff;
  border-radius: 50%;
}

/* ==========================================================================
   App shell — sidebar (desktop), top bar + tab bar (mobile)
   ========================================================================== */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem 1rem;
  gap: 1.1rem;
  z-index: 30;
  overflow-y: auto;
}
.sidebar .brand { padding: 0 .4rem; }
.side-cta { margin-top: .25rem; }
.side-nav { display: grid; gap: 2px; }
.side-nav a, .side-groups a {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .7rem;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 600;
  font-size: .92rem;
}
.side-nav a:hover, .side-groups a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.side-nav a.active, .side-groups a.active { background: var(--primary-soft); color: var(--primary); }
.side-nav .icon { width: 1.2rem; height: 1.2rem; }
.side-nav .badge { margin-left: auto; }
.side-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 0 .7rem .35rem;
}
.side-groups { display: grid; gap: 1px; }
.side-groups a { font-weight: 500; }
.side-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-group-pct { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { width: 9px; height: 9px; border-radius: 3px; flex: none; background: hsl(var(--h, 250) 70% 58%); }
.side-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: .25rem;
  padding-top: .9rem;
  border-top: 1px solid var(--border);
}
.side-user { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; color: var(--text); padding: .3rem; border-radius: var(--radius-sm); }
.side-user:hover { background: var(--surface-2); text-decoration: none; }
.side-user span { display: grid; min-width: 0; line-height: 1.25; }
.side-user strong, .side-user small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user small { color: var(--muted); font-size: .78rem; }

.app-main { margin-left: var(--sidebar); min-height: 100vh; }
.content { max-width: 1180px; margin: 0 auto; padding: 2rem 2rem 4rem; }

.mobile-bar, .tabbar { display: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: none;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn .icon { width: 1.15rem; height: 1.15rem; }
.icon-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* theme toggle shows the icon for the current mode */
.i-light, .i-dark, .i-system { display: none; }
:root:not([data-theme]) .i-system,
:root[data-theme="light"] .i-light,
:root[data-theme="dark"] .i-dark { display: block; }

.badge {
  background: var(--danger);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 .38rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ==========================================================================
   Public shell
   ========================================================================== */
.pub-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.pub-inner { max-width: 1180px; margin: 0 auto; padding: .8rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.pub-nav { display: flex; align-items: center; gap: .5rem; }
.pub-main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.pub-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1rem 2.5rem; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  font: inherit;
  font-weight: 650;
  font-size: .92rem;
  padding: .62rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  white-space: nowrap;
  transition: transform .08s, box-shadow .15s, background .15s, filter .15s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, var(--primary-2)));
  color: var(--primary-ink);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--primary) 70%, transparent);
}
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--primary) 80%, transparent); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { padding: .4rem .8rem; font-size: .84rem; }
.btn-lg { padding: .8rem 1.4rem; font-size: 1rem; }
.btn-block { width: 100%; }
.is-following { color: var(--muted); }

/* ==========================================================================
   Cards & page structure
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card-flush { padding: .5rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .9rem; }
.card-head h2 { margin: 0; display: inline-flex; align-items: center; gap: .5rem; }
.card-head h2 .icon { color: var(--primary); }
.card-tools { display: flex; align-items: center; gap: .75rem; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head p { margin: .2rem 0 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.center-actions { justify-content: center; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 0 0 .75rem; }
.section-title h2 { margin: 0; font-size: 1.1rem; }
.narrow { max-width: 680px; margin: 0 auto; }
.narrow-sm { max-width: 460px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

.empty { text-align: center; padding: 2.5rem 1.5rem; }
.empty.slim { padding: 1.5rem 1rem; }
.empty h3 { margin-bottom: .3rem; }
.empty p { max-width: 420px; margin-left: auto; margin-right: auto; }
.empty-icon {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--primary-soft);
  color: var(--primary);
  margin-bottom: .8rem;
}
.empty-icon .icon { width: 26px; height: 26px; }
.empty-note { padding: .25rem 0; margin: 0; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .22rem .6rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
}
.chip .icon { width: .95rem; height: .95rem; }
.chip-warm { background: var(--warm-soft); color: var(--warm); }
.chip-gold { background: color-mix(in srgb, var(--gold) 20%, transparent); color: color-mix(in srgb, var(--gold) 70%, var(--text)); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  padding: .3rem .75rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}
.eyebrow.light { color: #fff; background: rgba(255, 255, 255, .16); }

/* ==========================================================================
   Forms
   ========================================================================== */
.form { display: grid; gap: 1rem; }
.form-lg { padding: 1.6rem; gap: 1.2rem; }
.form label { display: grid; gap: .4rem; font-weight: 600; font-size: .9rem; color: var(--text-2); }
.form label .muted, .hint { font-weight: 400; }
.hint { color: var(--muted); font-size: .82rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; padding-top: .25rem; }

input, select, textarea {
  font: inherit;
  font-size: .95rem;
  width: 100%;
  padding: .65rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent);
}
input[type="checkbox"], input[type="radio"] { width: auto; }
textarea { resize: vertical; min-height: 5rem; }

.check-row { display: flex !important; align-items: center; gap: .6rem; font-weight: 500 !important; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); }

.code-input {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: .35em;
  text-transform: uppercase;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  padding: .9rem;
}

.switch { display: inline-flex; align-items: center; gap: .5rem; font-size: .84rem; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui { width: 34px; height: 20px; border-radius: 999px; background: var(--surface-3); position: relative; transition: background .2s; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch input:checked + .switch-ui { background: var(--primary); }
.switch input:checked + .switch-ui::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-ui { outline: 3px solid color-mix(in srgb, var(--primary) 50%, transparent); outline-offset: 2px; }

.search { position: relative; display: flex; gap: .5rem; margin-bottom: 1.75rem; }
.search > .icon { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 2.6rem; }

/* template picker */
.tpl-picker { border: 0; padding: 0; margin: 0; }
.tpl-picker legend { font-weight: 600; font-size: .9rem; color: var(--text-2); margin-bottom: .5rem; padding: 0; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .65rem; }
.tpl-option { cursor: pointer; display: block !important; }
.tpl-option input { position: absolute; opacity: 0; pointer-events: none; }
.tpl-card {
  display: grid;
  gap: .25rem;
  height: 100%;
  padding: .95rem;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.tpl-card strong { font-size: .9rem; color: var(--text); line-height: 1.3; }
.tpl-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); margin-bottom: .35rem; }
.tpl-option:hover .tpl-card { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.tpl-option input:checked + .tpl-card { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
.tpl-option input:checked + .tpl-card .tpl-icon { background: var(--primary); color: var(--primary-ink); }
.tpl-option input:focus-visible + .tpl-card { outline: 3px solid color-mix(in srgb, var(--primary) 50%, transparent); outline-offset: 2px; }

/* flash messages */
.flash {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .75rem .9rem;
  border-radius: 12px;
  margin-bottom: 1.25rem;
  font-size: .92rem;
  font-weight: 500;
  transition: opacity .4s;
}
.flash > span { flex: 1; }
.flash-success { background: var(--success-soft); color: var(--success); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash.fade { opacity: 0; pointer-events: none; }
.flash-close { background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: .2rem; display: grid; }
.flash-close:hover { opacity: 1; }

/* ==========================================================================
   Avatars, rings, progress
   ========================================================================== */
.avatar {
  --size: 38px;
  width: var(--size);
  height: var(--size);
  flex: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: calc(var(--size) * .37);
  color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 70% 60%), hsl(calc(var(--h) + 30) 65% 48%));
  letter-spacing: 0;
  user-select: none;
}
.avatar-lg { --size: 88px; }
.avatar-sm { --size: 30px; }
.avatar-xs { --size: 22px; box-shadow: 0 0 0 2px var(--surface); }
.avatar-more { background: var(--surface-3); color: var(--text-2); font-size: .7rem; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -8px; }

.ring { --size: 52px; position: relative; width: var(--size); height: var(--size); flex: none; display: inline-block; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ring circle { fill: none; stroke-width: 3.6; }
.ring-track { stroke: var(--surface-3); }
.ring-fill { stroke: var(--primary); stroke-linecap: round; transition: stroke-dasharray .6s cubic-bezier(.3, .7, .3, 1); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: calc(var(--size) * .24); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ring-lg { --size: 76px; }

.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .5s cubic-bezier(.3, .7, .3, 1);
}

.rank {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.rank[data-rank="1"] { background: linear-gradient(135deg, #ffd54a, #f5a300); color: #3b2800; box-shadow: 0 3px 10px -2px rgba(245, 163, 0, .55); }
.rank[data-rank="2"] { background: linear-gradient(135deg, #e7eaf0, #b9c0cc); color: #252a33; }
.rank[data-rank="3"] { background: linear-gradient(135deg, #f0b48a, #c97a48); color: #2d1606; }

/* ==========================================================================
   Landing
   ========================================================================== */
.landing-hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 3rem; align-items: center; padding: 3.5rem 0 3rem; }
.landing-copy h1 { font-size: clamp(2.4rem, 5.5vw, 4rem); line-height: 1.05; letter-spacing: -.045em; margin-bottom: 1rem; }
.grad { background: linear-gradient(120deg, var(--primary), var(--primary-2) 50%, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 34rem; }
.hero-cta { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1.75rem 0 1rem; }
.landing-visual { position: relative; padding: 1rem 0 2.5rem; }
.landing-visual::before {
  content: "";
  position: absolute;
  inset: -10% -5% 0 5%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--primary) 28%, transparent), transparent);
  filter: blur(20px);
  z-index: 0;
}
.mock-card { position: relative; z-index: 1; box-shadow: var(--shadow-lg); display: grid; gap: .9rem; padding: 1.4rem; transform: rotate(-1.5deg); margin: 0; }
.mock-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .2rem; }
.mock-head > div { display: grid; gap: .1rem; }
.mock-row { display: flex; align-items: center; gap: .65rem; }
.mock-name { font-weight: 600; font-size: .88rem; width: 6.5rem; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mock-row .progress { flex: 1; }
.mock-pct { font-size: .8rem; font-weight: 700; width: 2.6rem; text-align: right; font-variant-numeric: tabular-nums; }
.mock-toast {
  position: absolute;
  z-index: 2;
  right: -4%;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .8rem 1rem;
  margin: 0;
  font-size: .86rem;
  box-shadow: var(--shadow-lg);
  transform: rotate(1.5deg);
  max-width: 300px;
}
.mock-toast .icon { color: var(--success); width: 1.4rem; height: 1.4rem; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin: 1rem 0 2.5rem; }
.feature { padding: 1.4rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.feature p { color: var(--muted); margin: 0; font-size: .92rem; }
.feature-icon { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); margin-bottom: .9rem; }
.steps { padding: 2rem; text-align: center; }
.steps ol { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin: 1.5rem 0 1.75rem; text-align: left; }
.steps li { display: flex; gap: .8rem; }
.steps li > span { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-weight: 800; }
.steps li p { margin: .15rem 0 0; font-size: .9rem; }

/* ==========================================================================
   Auth
   ========================================================================== */
.auth { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; align-items: stretch; max-width: 1020px; margin: 1.5rem auto; }
.auth-art {
  border-radius: 24px;
  padding: 2.5rem;
  color: #fff;
  background:
    radial-gradient(circle at 85% 10%, rgba(255, 255, 255, .22), transparent 40%),
    linear-gradient(145deg, #5b4cf0, #8a5cf6 55%, #19b89b);
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-lg);
}
.auth-art h2 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -.03em; font-weight: 800; }
.auth-art p { opacity: .85; }
.mock-board { margin-top: 1.75rem; display: grid; gap: .7rem; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); border-radius: 16px; padding: 1.1rem; backdrop-filter: blur(6px); }
.mock-board .progress { background: rgba(255, 255, 255, .2); }
.mock-board .progress > span { background: #fff; }
.mock-board .rank:not([data-rank="1"]):not([data-rank="2"]):not([data-rank="3"]) { background: rgba(255, 255, 255, .2); color: #fff; }
.auth-form { align-self: center; padding: 1rem 0; max-width: 420px; width: 100%; justify-self: center; }
.auth-form h1 { font-size: 1.75rem; }
.auth-form > .muted { margin-bottom: 1.5rem; }
.auth-switch { margin-top: 1.25rem; }

/* ==========================================================================
   Dashboard
   ========================================================================== */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.75rem; }
.stat {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: 1.1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat > div { display: grid; line-height: 1.15; }
.stat strong { font-size: 1.6rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat span:not(.stat-icon) { font-size: .8rem; color: var(--muted); font-weight: 500; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.stat-icon .icon { width: 1.3rem; height: 1.3rem; }
.stat-warm .stat-icon { background: var(--warm-soft); color: var(--warm); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
.group-list { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.group-card {
  display: flex;
  flex-direction: column;
  gap: .9rem;
  color: inherit;
  margin: 0;
  position: relative;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.group-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, hsl(var(--h) 70% 58%), hsl(calc(var(--h) + 40) 70% 55%)); }
.group-card:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, hsl(var(--h) 70% 58%) 40%, var(--border)); }
.group-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.group-card-title { min-width: 0; }
.group-card h3 { margin: 0 0 .25rem; font-size: 1.08rem; }
.group-card-title p { margin: 0; font-size: .86rem; display: flex; gap: .35rem; align-items: center; }
.group-card .ring-fill { stroke: hsl(var(--h) 70% 58%); }
.group-card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.group-card-foot .small { display: inline-flex; align-items: center; gap: .15rem; opacity: 0; transform: translateX(-4px); transition: opacity .15s, transform .15s; }
.group-card:hover .group-card-foot .small { opacity: 1; transform: none; }

.feed { display: grid; gap: 1rem; }
.feed li { display: flex; gap: .7rem; align-items: flex-start; font-size: .9rem; line-height: 1.45; }

.heatmap { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.hm-cell { aspect-ratio: 1; border-radius: 3px; background: var(--surface-3); display: block; }
.hm-1 { background: color-mix(in srgb, var(--primary) 30%, var(--surface-3)); }
.hm-2 { background: color-mix(in srgb, var(--primary) 55%, var(--surface-3)); }
.hm-3 { background: color-mix(in srgb, var(--primary) 80%, var(--surface-3)); }
.hm-4 { background: var(--primary); }
.hm-future { background: transparent; }
.hm-legend { display: flex; align-items: center; justify-content: flex-end; gap: 3px; margin-top: .7rem; }
.hm-legend .hm-cell { width: 11px; }
.hm-legend .hm-cell:first-of-type { margin-left: .3rem; }
.hm-legend .hm-cell:last-of-type { margin-right: .3rem; }

/* ==========================================================================
   Group page
   ========================================================================== */
.group-hero {
  --h: 250;
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  padding: 1.75rem 1.9rem;
  margin-bottom: 1.5rem;
  color: #fff;
  background:
    radial-gradient(circle at 90% -20%, rgba(255, 255, 255, .25), transparent 45%),
    linear-gradient(135deg, hsl(var(--h) 72% 54%), hsl(calc(var(--h) + 45) 70% 46%));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
  box-shadow: 0 18px 40px -18px hsl(var(--h) 70% 40%);
}
.group-hero h1 { font-size: 2rem; margin: .4rem 0 .3rem; }
.group-hero-main { min-width: 0; flex: 1 1 320px; }
.crumb { color: rgba(255, 255, 255, .8); font-size: .82rem; font-weight: 600; display: inline-flex; gap: .35rem; align-items: center; }
.crumb:hover { color: #fff; text-decoration: none; }
.goal-line { font-weight: 600; display: flex; gap: .45rem; align-items: center; margin-bottom: .4rem; }
.group-desc { opacity: .88; max-width: 46rem; margin: .4rem 0 0; font-size: .92rem; }
.group-hero-stats { display: flex; gap: .6rem; flex-wrap: wrap; }
.hero-stat {
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .2);
  backdrop-filter: blur(6px);
  border-radius: 16px;
  padding: .75rem 1rem;
  min-width: 96px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  line-height: 1.15;
}
.hero-stat strong { font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hero-stat span { font-size: .76rem; opacity: .85; }
.hero-ring { gap: .3rem; padding: .6rem .9rem; }
.hero-ring .ring-track { stroke: rgba(255, 255, 255, .25); }
.hero-ring .ring-fill { stroke: #fff; }

.group-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
.group-side { position: sticky; top: 1.5rem; }

.section { border-top: 1px solid var(--border); }
.section:first-of-type { border-top: 0; }
.section summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .8rem .4rem;
  font-weight: 700;
  list-style: none;
  border-radius: var(--radius-sm);
  user-select: none;
}
.section summary::-webkit-details-marker { display: none; }
.section summary:hover { background: var(--surface-2); }
.section-caret { color: var(--muted); transition: transform .2s; }
.section:not([open]) .section-caret { transform: rotate(-90deg); }
.section-name { flex: 1; min-width: 0; }
.section-bar { width: 70px; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; flex: none; }
.section-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; transition: width .4s; }
.section-count { font-size: .78rem; font-weight: 700; color: var(--muted); min-width: 2.6rem; text-align: right; font-variant-numeric: tabular-nums; }
.section.is-complete .section-count { color: var(--success); }
.section.is-complete .section-bar span { background: var(--success); }

.topics { padding: 0 0 .6rem; }
.topic {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .55rem .5rem .6rem;
  margin-left: 1.4rem;
  border-radius: var(--radius-sm);
  transition: background .15s, opacity .2s, transform .2s;
}
.topic:hover { background: var(--surface-2); }
.topic:target, .topic.flash-row { background: var(--primary-soft); }
.topic.removing { opacity: 0; transform: translateX(12px); }
.topic-main { display: flex; align-items: center; gap: .75rem; flex: 1; cursor: pointer; min-width: 0; }
.topic-title { overflow-wrap: anywhere; transition: color .2s; }
.topic.is-done .topic-title { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.hide-done .topic.is-done { display: none; }

.topic-check {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 2px solid color-mix(in srgb, var(--muted) 50%, var(--border));
  border-radius: 7px;
  cursor: pointer;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--surface);
  transition: background .15s, border-color .15s, transform .15s;
}
.topic-check:hover { border-color: var(--primary); }
.topic-check:checked { background: var(--success); border-color: var(--success); animation: pop .3s ease; }
.topic-check:checked::after {
  content: "";
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
@keyframes pop { 50% { transform: scale(1.2); } }

.topic-others { display: inline-flex; align-items: center; padding-left: 6px; }
.topic-others .avatar + .avatar { margin-left: -6px; }
.topic-others .more { font-size: .72rem; color: var(--muted); margin-left: .3rem; font-weight: 600; }
.topic-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.topic-actions .icon-btn { width: 30px; height: 30px; }
.topic-actions .icon { width: 1rem; height: 1rem; }
.topic:hover .topic-actions, .topic:focus-within .topic-actions { opacity: 1; }
@media (hover: none) { .topic-actions { opacity: .75; } }

.topic.editing { background: var(--surface-2); flex-wrap: wrap; }
.topic.editing > :not(form) { display: none; }
.topic-edit-form { display: grid; grid-template-columns: 2fr 1fr auto; gap: .5rem; width: 100%; align-items: center; }
.topic-edit-form input { padding: .5rem .7rem; font-size: .9rem; }
.topic-edit-actions { display: flex; gap: .4rem; }

.leaderboard { display: grid; gap: 1rem; }
.lb-row { display: flex; align-items: center; gap: .7rem; padding: .15rem 0; }
.lb-body { flex: 1; min-width: 0; }
.lb-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .9rem; margin-bottom: .35rem; }
.lb-top a { color: var(--text); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-count { font-weight: 800; font-size: .88rem; font-variant-numeric: tabular-nums; }
.lb-sub { margin-top: .25rem; font-size: .76rem; }
.lb-row.is-me .lb-top a { color: var(--primary); }
.lb-row.is-me { background: var(--primary-soft); margin: 0 -.6rem; padding: .55rem .6rem; border-radius: 12px; }

.invite {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin: .5rem 0 .7rem;
  background: var(--surface-2);
  border: 1.5px dashed var(--surface-3);
  border-radius: 12px;
  padding: .55rem .55rem .55rem 1rem;
}
.invite code { font-size: 1.35rem; font-weight: 800; letter-spacing: .22em; color: var(--text); }
.danger-zone { padding: 0 .1rem; margin-bottom: 1.25rem; }

/* ==========================================================================
   Join
   ========================================================================== */
.join-card { text-align: center; padding: 2.25rem 1.75rem; margin-top: 1.5rem; }
.join-card h1 { font-size: 1.6rem; }
.join-card .goal-line { justify-content: center; color: var(--text-2); }
.join-card .chips { margin: 1rem 0 1.5rem; }
.join-card .form { margin-top: 1.25rem; }
.join-badge {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  margin-bottom: 1rem;
  color: #fff;
  background: linear-gradient(135deg, hsl(var(--h, 250) 72% 58%), hsl(calc(var(--h, 250) + 45) 70% 48%));
  box-shadow: 0 10px 24px -10px hsl(var(--h, 250) 70% 45%);
}
.join-badge .icon { width: 28px; height: 28px; }

/* ==========================================================================
   Notifications
   ========================================================================== */
.notif-list li + li { border-top: 1px solid var(--border); }
.notif-list a { display: flex; gap: .9rem; align-items: center; padding: .85rem .8rem; color: var(--text); border-radius: 12px; }
.notif-list a:hover { background: var(--surface-2); text-decoration: none; }
.notif-list .unread a { background: color-mix(in srgb, var(--primary-soft) 70%, transparent); }
.notif-avatar { position: relative; flex: none; }
.notif-kind {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 2px var(--surface);
}
.notif-kind .icon { width: 11px; height: 11px; stroke-width: 3; }
.notif-kind.n-done { background: var(--success); }
.notif-kind.n-join { background: var(--warm); }
.notif-body { display: grid; flex: 1; min-width: 0; gap: .1rem; font-size: .92rem; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); flex: none; }

/* ==========================================================================
   People & profile
   ========================================================================== */
.people { display: grid; gap: .2rem; }
.person { display: flex; align-items: center; gap: .8rem; padding: .5rem .4rem; border-radius: 12px; }
.person:hover { background: var(--surface-2); }
.person-name { flex: 1; color: var(--text); min-width: 0; display: grid; line-height: 1.3; }
.person-name strong, .person-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-name span { font-size: .82rem; }
.person-name:hover { text-decoration: none; }

.profile-head { padding: 0; overflow: hidden; }
.profile-cover { height: 120px; background: radial-gradient(circle at 80% 0%, rgba(255, 255, 255, .3), transparent 50%), linear-gradient(135deg, hsl(var(--h) 72% 58%), hsl(calc(var(--h) + 50) 70% 48%)); }
.profile-body { display: flex; align-items: flex-end; gap: 1.1rem; padding: 0 1.5rem; margin-top: -44px; flex-wrap: wrap; }
.profile-body .avatar-lg { box-shadow: 0 0 0 5px var(--surface); }
.profile-info { flex: 1; min-width: 180px; padding-bottom: .2rem; }
.profile-info h1 { margin: 0; font-size: 1.6rem; }
.profile-info p { margin: .1rem 0 0; }
.profile-actions { padding-bottom: .3rem; }
.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--border); margin-top: 1.25rem; }
.profile-stats > div { display: grid; justify-items: center; padding: .9rem .5rem; text-align: center; }
.profile-stats > div + div { border-left: 1px solid var(--border); }
.profile-stats strong { font-size: 1.35rem; font-weight: 800; }
.profile-stats span { font-size: .78rem; color: var(--muted); display: inline-flex; align-items: center; gap: .25rem; }
.profile-stats .icon { color: var(--warm); }

.link-list li + li { border-top: 1px solid var(--border); }
.link-list a { display: flex; align-items: center; gap: .8rem; padding: .7rem .3rem; color: var(--text); }
.link-list a:hover { text-decoration: none; background: var(--surface-2); border-radius: 10px; }
.link-list a > span:not(.dot) { flex: 1; display: grid; }
.link-list a > .icon { color: var(--muted); }

/* ==========================================================================
   Toasts, modal, confetti
   ========================================================================== */
#toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; display: grid; gap: .5rem; z-index: 100; max-width: calc(100vw - 2rem); }
.toast {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: var(--text);
  color: var(--bg);
  padding: .75rem 1rem;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .25s cubic-bezier(.3, .7, .3, 1.2);
  font-size: .9rem;
  font-weight: 500;
}
.toast.success .icon { color: var(--success); }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s; }
@keyframes toast-in { from { transform: translateY(12px) scale(.96); opacity: 0; } }

.modal {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
  width: min(420px, calc(100vw - 2rem));
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.modal[open] { animation: modal-in .2s ease; }
.modal::backdrop { background: rgba(10, 10, 25, .45); backdrop-filter: blur(3px); }
.modal-msg { font-size: 1rem; font-weight: 500; margin-bottom: 1.4rem; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; }
@keyframes modal-in { from { transform: translateY(10px) scale(.97); opacity: 0; } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.confetti i { position: absolute; top: -16px; width: 8px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid, .group-grid { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .app-main { margin-left: 0; }
  .content { padding: 1.25rem 1rem calc(6rem + env(safe-area-inset-bottom, 0px)); }

  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 25;
    padding: calc(.65rem + env(safe-area-inset-top, 0px)) 1rem .65rem;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .mobile-actions { display: flex; gap: .25rem; }

  .tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    padding: .4rem .5rem calc(.4rem + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--border);
  }
  .tabbar a {
    position: relative;
    display: grid;
    justify-items: center;
    gap: .15rem;
    padding: .35rem 0;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 600;
  }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--primary); }
  .tabbar .icon { width: 1.35rem; height: 1.35rem; }
  .tabbar .badge { position: absolute; top: 0; left: calc(50% + 4px); min-width: 1.05rem; height: 1.05rem; font-size: .62rem; }
  .tab-cta {
    width: 50px;
    height: 50px;
    margin: -1.4rem auto 0;
    border-radius: 16px;
    place-items: center !important;
    color: var(--primary-ink) !important;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--primary) 80%, transparent);
  }

  #toasts { bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); left: 1rem; right: 1rem; }

  .dash-grid, .group-grid, .two-col { grid-template-columns: 1fr; }
  .group-side { position: static; }
  .landing-hero { grid-template-columns: 1fr; padding-top: 2rem; gap: 2rem; }
  .mock-toast { right: 0; }
  .auth { grid-template-columns: 1fr; margin-top: .5rem; }
  .auth-art { display: none; }
  .steps ol { grid-template-columns: 1fr; }
  h1 { font-size: 1.55rem; }
  .group-hero { padding: 1.4rem; border-radius: 18px; }
  .group-hero h1 { font-size: 1.6rem; }
  .group-hero-stats { width: 100%; }
  .hero-stat { flex: 1; min-width: 0; padding: .65rem .5rem; }
  .ring-lg { --size: 60px; }
}

@media (max-width: 560px) {
  .form-row, .topic-edit-form { grid-template-columns: 1fr; }
  .topic-edit-actions { justify-content: flex-end; }
  .topic { margin-left: 0; }
  .section-bar { display: none; }
  .profile-stats { grid-template-columns: repeat(2, 1fr); }
  .profile-stats > div:nth-child(3) { border-left: 0; }
  .profile-stats > div:nth-child(n+3) { border-top: 1px solid var(--border); }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .stat { padding: .9rem; gap: .7rem; }
  .stat strong { font-size: 1.35rem; }
  .stat-icon { width: 36px; height: 36px; }
  .pub-nav .btn-ghost { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
