:root {
  --bg: #0b0f1a;
  --bg-2: #0e1424;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef2ff;
  --muted: #8a93ad;
  --faint: #5b6479;
  --gavin: #38bdf8;
  --devin: #fb923c;
  --good: #34d399;
  --radius: 18px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: radial-gradient(1200px 700px at 15% -10%, #16203a 0%, transparent 55%),
              radial-gradient(1000px 700px at 100% 0%, #1a1330 0%, transparent 50%),
              var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding: 0 clamp(14px, 4vw, 40px) 80px;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(600px 300px at 50% 120%, rgba(56, 189, 248, 0.08), transparent 70%);
  z-index: 0;
}

h1, h2, h3 { font-family: "Space Grotesk", sans-serif; letter-spacing: -0.01em; }

/* ---------- Topbar ---------- */
.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  max-width: 1100px;
  margin: 0 auto;
  padding: 26px 0 18px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  font-size: 30px;
  display: grid;
  place-items: center;
  width: 54px; height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(56,189,248,0.22), rgba(251,146,60,0.22));
  border: 1px solid var(--border-strong);
}
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.who-label { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; margin-right: 4px; }
.who-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 15px; border-radius: 999px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .12s ease, border-color .15s, background .15s, box-shadow .15s;
}
.who-chip .who-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 10px var(--pc); }
.who-chip:hover { transform: translateY(-1px); }
.who-chip.active {
  border-color: var(--pc);
  background: color-mix(in srgb, var(--pc) 16%, transparent);
  box-shadow: 0 0 0 1px var(--pc), 0 8px 24px color-mix(in srgb, var(--pc) 30%, transparent);
}

/* ---------- Week panel ---------- */
.week-panel {
  position: relative; z-index: 1;
  max-width: 1100px; margin: 0 auto 22px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  backdrop-filter: blur(8px);
}
.week-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.week-head h2 { margin: 0; font-size: 16px; }
.week-range { color: var(--muted); font-size: 13px; }
.week-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }

.wc {
  border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; background: var(--panel-2);
  display: flex; align-items: center; gap: 14px;
}
.wc-ring { flex: none; }
.wc-info { min-width: 0; flex: 1; }
.wc-name { font-weight: 700; font-family: "Space Grotesk", sans-serif; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.wc-name .tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.wc-tag-hit { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.wc-tag-go { background: rgba(255,255,255,0.07); color: var(--muted); }
.wc-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.wc-dots { display: flex; gap: 6px; margin-top: 9px; }
.wc-dots i {
  width: 22px; height: 7px; border-radius: 4px;
  background: rgba(255,255,255,0.1); display: block;
}
.wc-dots i.on { background: var(--pc); box-shadow: 0 0 8px var(--pc); }

/* ---------- Layout ---------- */
.layout {
  position: relative; z-index: 1;
  max-width: 1100px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 300px; gap: 22px;
  align-items: start;
}
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

/* ---------- Calendar ---------- */
.cal-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px 22px;
  box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cal-head h2 { margin: 0; font-size: 19px; flex: none; min-width: 190px; }
.nav-btn {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  font-size: 20px; line-height: 1; cursor: pointer; transition: background .15s, border-color .15s;
}
.nav-btn:hover { background: var(--panel); border-color: var(--border-strong); }
.today-btn {
  margin-left: auto; background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: 10px; padding: 8px 14px; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: color .15s, border-color .15s;
}
.today-btn:hover { color: var(--text); border-color: var(--border-strong); }

.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-dow { margin-bottom: 8px; }
.cal-dow span { text-align: center; color: var(--faint); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

.day {
  position: relative; min-height: 78px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel-2); padding: 8px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .15s, background .15s, transform .1s;
}
.day:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.day.out { opacity: 0.32; }
.day.today { border-color: var(--gavin); box-shadow: inset 0 0 0 1px var(--gavin); }
.day.future { opacity: 0.55; }
.day-num { font-size: 13px; font-weight: 600; color: var(--muted); }
.day.today .day-num { color: var(--gavin); }
.day-pills { display: flex; gap: 5px; margin-top: auto; flex-wrap: wrap; }
.pill {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  border: 1px solid var(--border); background: rgba(255,255,255,0.04);
  color: var(--faint); cursor: pointer;
  transition: transform .1s, box-shadow .15s, background .15s, color .15s;
}
.pill:hover { transform: scale(1.08); }
.pill.on { color: #06121f; background: var(--pc); border-color: var(--pc); box-shadow: 0 0 12px color-mix(in srgb, var(--pc) 60%, transparent); }
.pill.has-note::after {
  content: ""; position: absolute; margin: -12px 0 0 14px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--good);
}

/* ---------- Stats ---------- */
.stats-col { display: flex; flex-direction: column; gap: 16px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; backdrop-filter: blur(8px);
}
.stat-card h3 { margin: 0 0 14px; font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--border); }
.stat-row:first-of-type { border-top: none; }
.stat-who { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; }
.stat-who .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 8px var(--pc); }
.stat-val { font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 20px; }
.stat-val small { font-size: 12px; color: var(--faint); font-weight: 500; margin-left: 2px; }
.streak-flame { font-size: 15px; }

/* ---------- Day sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(4, 7, 14, 0.6); backdrop-filter: blur(3px); z-index: 40; }
.sheet {
  position: fixed; z-index: 50; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(460px, 100%); background: var(--bg-2);
  border: 1px solid var(--border-strong); border-bottom: none;
  border-radius: 22px 22px 0 0; padding: 14px 22px 30px;
  box-shadow: 0 -20px 60px rgba(0,0,0,0.5);
  animation: rise .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.sheet-grip { width: 42px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-head h3 { margin: 0; font-size: 18px; }
.sheet-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.sheet-person { padding: 16px 0; border-top: 1px solid var(--border); }
.sheet-person:first-child { border-top: none; }
.sp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sp-name { display: flex; align-items: center; gap: 9px; font-weight: 700; font-family: "Space Grotesk", sans-serif; }
.sp-name .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 8px var(--pc); }
.sp-toggle {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--muted);
  border-radius: 999px; padding: 7px 16px; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: all .15s;
}
.sp-toggle.on { background: var(--pc); color: #06121f; border-color: var(--pc); box-shadow: 0 0 14px color-mix(in srgb, var(--pc) 55%, transparent); }
.sp-note {
  width: 100%; background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 11px; font-size: 13.5px; font-family: inherit; resize: vertical;
  min-height: 40px;
}
.sp-note:focus { outline: none; border-color: var(--pc); }
.sp-note::placeholder { color: var(--faint); }

/* ============ COOL FEATURES ============ */

/* ---- Hype / trash-talk banner ---- */
.hype {
  position: relative; z-index: 1; max-width: 1100px; margin: 0 auto 18px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 14px;
  background: linear-gradient(90deg, rgba(56,189,248,0.08), rgba(251,146,60,0.08));
  padding: 12px 18px; font-size: 14.5px; font-weight: 500; color: var(--text);
  min-height: 46px;
}
.hype .spark { font-size: 18px; }
.hype b { font-family: "Space Grotesk", sans-serif; }

/* ---- Quick "log today" button on week cards ---- */
.wc-log {
  margin-top: 9px; display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px dashed color-mix(in srgb, var(--pc) 55%, transparent);
  color: var(--pc); border-radius: 999px; padding: 5px 12px; font-size: 12px;
  font-weight: 700; cursor: pointer; transition: background .15s, transform .1s;
}
.wc-log:hover { background: color-mix(in srgb, var(--pc) 14%, transparent); transform: translateY(-1px); }
.wc-log.done { border-style: solid; background: color-mix(in srgb, var(--pc) 18%, transparent); }

/* ---- Head-to-head arena ---- */
.h2h {
  position: relative; z-index: 1; max-width: 1100px; margin: 0 auto 22px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; backdrop-filter: blur(8px);
}
.h2h-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.h2h-head h2 { margin: 0; font-size: 16px; }
.h2h-head .sub { color: var(--muted); font-size: 12.5px; }
.h2h-grid { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.h2h-side { text-align: center; padding: 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--panel-2); position: relative; transition: box-shadow .2s, border-color .2s; }
.h2h-side.lead { border-color: var(--pc); box-shadow: 0 0 0 1px var(--pc), 0 10px 30px color-mix(in srgb, var(--pc) 22%, transparent); }
.h2h-crown { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); font-size: 20px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); opacity: 0; transition: opacity .2s; }
.h2h-side.lead .h2h-crown { opacity: 1; }
.h2h-name { font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; }
.h2h-name .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 8px var(--pc); }
.h2h-big { font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 40px; line-height: 1.1; margin: 6px 0 2px; color: var(--pc); }
.h2h-cap { color: var(--muted); font-size: 12px; }
.h2h-vs { font-family: "Space Grotesk", sans-serif; font-weight: 700; color: var(--faint); font-size: 15px; }
.h2h-foot { display: flex; justify-content: center; gap: 26px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.h2h-stat { text-align: center; }
.h2h-stat .n { font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 18px; }
.h2h-stat .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }

/* ---- Achievements ---- */
.badges { display: grid; grid-template-columns: 1fr; gap: 10px; }
.badge {
  display: flex; align-items: center; gap: 12px; padding: 10px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2);
}
.badge.locked { opacity: 0.45; filter: grayscale(0.7); }
.badge-ico { font-size: 22px; width: 34px; text-align: center; }
.badge-info { flex: 1; min-width: 0; }
.badge-name { font-weight: 700; font-size: 13.5px; font-family: "Space Grotesk", sans-serif; }
.badge-desc { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.badge-who { display: flex; gap: 5px; }
.badge-who i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,0.12); }
.badge-who i.on { background: var(--wc); box-shadow: 0 0 7px var(--wc); }

/* ---- Heatmap ---- */
.heat-card {
  position: relative; z-index: 1; max-width: 1100px; margin: 22px auto 0;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; backdrop-filter: blur(8px);
}
.heat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.heat-head h2 { margin: 0; font-size: 16px; }
.heat-legend { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.heat-legend .k { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--border); }
.heat-scroll { overflow-x: auto; padding-bottom: 6px; }
.heat-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); gap: 3px; }
.heat-cell { width: 13px; height: 13px; border-radius: 3px; background: rgba(255,255,255,0.05); }
.heat-cell.today { outline: 1.5px solid var(--text); outline-offset: 1px; }

/* ---- Confetti ---- */
.confetti-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 100; }

@media (max-width: 560px) {
  .h2h-big { font-size: 32px; }
  .h2h-foot { gap: 16px; }
}

/* ---- Brand photo (header avatar) ---- */
.brand-mark { overflow: hidden; padding: 0; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---- Random peek (subtle popup) ---- */
.peek {
  position: fixed; z-index: 9999; width: 200px; max-width: 42vw;
  border-radius: 14px; overflow: hidden; background: #000;
  border: 2px solid var(--border-strong);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.55);
  animation: peek-in 0.35s cubic-bezier(0.2, 0.9, 0.2, 1);
}
.peek img { width: 100%; display: block; }
.peek-close {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%; border: none;
  background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 12px;
  cursor: pointer; display: grid; place-items: center; line-height: 1;
  backdrop-filter: blur(4px); transition: background 0.15s;
}
.peek-close:hover { background: rgba(0, 0, 0, 0.85); }
@keyframes peek-in { from { transform: translateY(14px) scale(0.95); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .peek { animation: none; } }

/* ============ AUTH PAGES ============ */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-card {
  position: relative; z-index: 1; width: min(400px, 100%);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 30px 28px; box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand h1 { margin: 0; font-size: 20px; }
.auth-sub { color: var(--muted); font-size: 13.5px; margin: 10px 0 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.auth-form input {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 11px 13px; font-size: 15px; font-family: inherit;
}
.auth-form input:focus { outline: none; border-color: var(--gavin); }
.auth-hint { font-weight: 400; font-size: 11.5px; color: var(--faint); }
.auth-btn {
  margin-top: 4px; background: linear-gradient(135deg, var(--gavin), #0ea5e9);
  color: #06121f; border: none; border-radius: 10px; padding: 12px;
  font-size: 15px; font-weight: 700; font-family: "Space Grotesk", sans-serif; cursor: pointer;
  transition: transform .1s, box-shadow .15s;
}
.auth-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(56,189,248,0.35); }
.auth-alt { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 0 0; }
.auth-alt a { color: var(--gavin); text-decoration: none; font-weight: 600; }
.auth-error {
  background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.4);
  color: #fca5a5; border-radius: 10px; padding: 10px 13px; font-size: 13px; margin-bottom: 16px;
}

/* ---- Logged-in user chip + logout in header ---- */
.userbar { display: flex; align-items: center; gap: 10px; }
.userbar .me {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px;
  border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px;
  background: color-mix(in srgb, var(--pc) 14%, transparent);
}
.userbar .me .who-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 10px var(--pc); }
.userbar .logout {
  color: var(--muted); font-size: 13px; text-decoration: none; font-weight: 600;
  border: 1px solid var(--border); border-radius: 999px; padding: 8px 13px; transition: color .15s, border-color .15s;
}
.userbar .logout:hover { color: var(--text); border-color: var(--border-strong); }

/* Read-only calendar pills for other people (you can only log yourself) */
.pill.readonly { cursor: default; pointer-events: none; }

/* Read-only rows in the day sheet (other people) */
.sp-status { font-size: 13px; font-weight: 700; color: var(--faint); }
.sp-status.on { color: var(--good); }
.sp-note-ro { color: var(--muted); font-size: 13px; margin-top: 8px; padding-left: 20px; border-left: 2px solid var(--border); }
.sp-you { font-size: 10px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; background: rgba(255,255,255,0.07); padding: 1px 6px; border-radius: 999px; vertical-align: middle; }

/* Leaderboard (3+ people) */
.lb { display: flex; flex-direction: column; gap: 8px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2); }
.lb-row.me { border-color: var(--pc); box-shadow: inset 0 0 0 1px var(--pc); }
.lb-rank { font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 16px; width: 26px; color: var(--muted); }
.lb-name { flex: 1; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.lb-name .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 8px var(--pc); }
.lb-bar { flex: 2; height: 8px; border-radius: 999px; background: rgba(255,255,255,0.07); overflow: hidden; }
.lb-bar i { display: block; height: 100%; background: var(--pc); border-radius: 999px; }
.lb-n { font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 16px; min-width: 20px; text-align: right; }
