/* ============================================================
   Cannula Club — vibrant, upbeat tracker
   ============================================================ */

:root {
  color-scheme: light;

  /* Brand — muted, refined */
  --coral:        #d76a86;
  --coral-deep:   #c25572;
  --violet:       #6459c9;
  --violet-deep:  #524699;
  --sunshine:     #d9a84a;
  --mint:         #3bbf98;

  /* Surfaces & ink */
  --page:         #faf8f6;
  --surface:      #ffffff;
  --ink:          #22202b;
  --ink-2:        #605b6c;
  --ink-3:        #98929f;
  --hairline:     rgba(34, 32, 43, 0.09);
  --grid:         #eeebf0;

  /* Viz (single-series, validated) */
  --series-1:     #6647ea;
  --chart-surface:#ffffff;

  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-card: 0 4px 18px rgba(34, 32, 43, 0.06), 0 1px 2px rgba(34, 32, 43, 0.04);
  --shadow-pop:  0 6px 18px rgba(82, 70, 153, 0.22);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --coral:         #d6738c;
    --coral-deep:    #c76078;
    --violet:        #8175d6;
    --violet-deep:   #9a8fe0;
    --page:          #16141c;
    --surface:       #201d29;
    --ink:           #f3f1f7;
    --ink-2:         #b6b0c2;
    --ink-3:         #837d90;
    --hairline:      rgba(255, 255, 255, 0.09);
    --grid:          #2e2a38;
    --series-1:      #8b72ff;
    --chart-surface: #201d29;
    --shadow-card: 0 4px 18px rgba(0, 0, 0, 0.28);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* The `hidden` attribute must beat component display rules (grid/flex). */
[hidden] { display: none !important; }

body {
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: min(1060px, calc(100% - 40px));
  margin-inline: auto;
}

/* ============ Top bar ============ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
}

.topbar-inner {
  width: min(1060px, calc(100% - 40px));
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--coral), var(--violet));
  color: #fff;
}

.brand-mark svg { width: 20px; height: 20px; }

/* ============ Player chip / switcher ============ */

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.player-chip {
  --player-color: var(--violet);
  font: inherit;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  border: 2px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease;
}

.player-chip:hover { transform: translateY(-1px); border-color: var(--player-color); }

.player-emoji {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--player-color) 22%, var(--surface));
  font-size: 0.95rem;
}

.player-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-caret { color: var(--ink-3); font-size: 0.7rem; }

@media (max-width: 560px) {
  .player-name { display: none; }
}

/* ============ Modal / onboarding ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: color-mix(in srgb, var(--ink) 55%, transparent);
  backdrop-filter: blur(4px);
  animation: fade-in 0.18s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: relative;
  width: min(460px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.30);
  padding: 28px;
  animation: pop-in 0.2s ease;
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* old Edge */
}

/* Scrollable but no visible bar — applies to the modal and its inner feed. */
.modal::-webkit-scrollbar { display: none; }
.player-detail .feed { scrollbar-width: none; -ms-overflow-style: none; }
.player-detail .feed::-webkit-scrollbar { display: none; }

.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  border: none;
  background: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ink-3);
  cursor: pointer;
}

.modal-close:hover { color: var(--ink); }

.modal-title { font-size: 1.25rem; font-weight: 850; letter-spacing: -0.01em; }
.modal-sub { font-size: 0.82rem; color: var(--ink-3); font-weight: 600; margin-top: 4px; margin-bottom: 18px; }

.profile-list { display: flex; flex-direction: column; gap: 8px; }

.profile-item {
  --player-color: var(--violet);
  font: inherit;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 2px solid var(--hairline);
  background: var(--page);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.profile-item:hover { transform: translateY(-1px); border-color: var(--player-color); }

.profile-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--player-color) 24%, var(--surface));
  font-size: 1.2rem;
  flex: none;
}

.profile-item-name { flex: 1; }
.profile-item-meta { font-size: 0.82rem; font-weight: 600; color: var(--ink-3); }

.new-profile {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--hairline);
}

.new-profile-head { font-weight: 800; margin-bottom: 12px; }
.picker-label { font-size: 0.82rem; font-weight: 800; color: var(--ink-2); margin: 14px 0 8px; }

.emoji-row, .color-row { display: flex; flex-wrap: wrap; gap: 8px; }

.emoji-opt {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 2px solid var(--hairline);
  background: var(--page);
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.emoji-opt:hover { transform: translateY(-1px); }
.emoji-opt[aria-pressed="true"] { border-color: var(--violet); background: color-mix(in srgb, var(--violet) 12%, var(--surface)); }

.color-opt {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.color-opt:hover { transform: translateY(-1px); }
.color-opt[aria-pressed="true"] { border-color: var(--ink); }

.new-profile .btn-block { margin-top: 20px; }

.browse-link {
  display: block;
  width: 100%;
  margin: 2px 0 18px;
  padding: 10px;
  border: 1.5px solid var(--hairline);
  border-radius: var(--radius-md);
  background: none;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s ease, color 0.12s ease;
}

.browse-link:hover { border-color: var(--violet); color: var(--ink); }

/* Guest "Sign in" chip: the avatar bubble is just a wave, no player colour. */
.player-chip.is-guest .player-emoji { background: color-mix(in srgb, var(--violet) 16%, var(--surface)); }

.pin-input {
  letter-spacing: 0.5em;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
}

.pin-back {
  border: none;
  background: none;
  font: inherit;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  padding: 0;
  margin-bottom: 14px;
}

.pin-back:hover { color: var(--ink); }

.pin-who {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.pin-who-name { font-size: 1.3rem; font-weight: 850; }

.pin-error { color: var(--coral-deep); font-weight: 700; font-size: 0.86rem; margin-top: 8px; }

@media (prefers-color-scheme: dark) {
  .pin-error { color: #ec9aa8; }
}

#pin-view .btn-block { margin-top: 16px; }

/* ============ Buttons ============ */

.btn {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn-primary {
  background: var(--coral-deep);
  color: #fff;
  box-shadow: 0 2px 8px rgba(194, 85, 114, 0.20);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-pop); }
.btn-primary:active { transform: translateY(0); filter: brightness(0.96); }
.btn-block { width: 100%; margin-top: 10px; padding-block: 12px; font-size: 0.92rem; letter-spacing: 0.01em; }

/* Header log button collapses its label on small screens. */
.btn-label-short { display: none; }

/* ============ Hero ============ */

.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(900px 460px at 78% -20%, rgba(215, 106, 134, 0.45), transparent 60%),
    linear-gradient(150deg, #3d3579 0%, #524699 46%, #8a5a86 100%);
  color: #fff;
  text-align: center;
  padding: 66px 20px 80px;
}

.hero-inner { position: relative; }

.hero-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.26em;
  font-weight: 700;
  font-size: 0.72rem;
  opacity: 0.75;
}

.hero-count {
  font-size: clamp(4rem, 11vw, 6.75rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  margin-top: 12px;
}

.hero-caption { font-size: 1.05rem; font-weight: 600; margin-top: 8px; opacity: 0.92; }

.hero-streak {
  display: inline-block;
  margin-top: 20px;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-weight: 600;
  font-size: 0.88rem;
}

.hero-level {
  width: min(340px, 100%);
  margin: 22px auto 0;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  padding: 12px 16px;
}

.hero-level-top { display: flex; align-items: center; gap: 8px; }

.hero-level-badge {
  font-weight: 800;
  font-size: 0.78rem;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #524699;
}

.hero-level-title { font-weight: 700; font-size: 0.92rem; }

.hero-level-bar {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
  margin: 10px 0 6px;
}

.hero-level-fill {
  height: 100%;
  border-radius: 999px;
  background: #fff;
  transition: width 0.6s ease;
}

.hero-level-xp { font-size: 0.76rem; font-weight: 600; opacity: 0.85; }

/* ============ Tabs ============ */

.tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  margin-block: 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  width: max-content;
}

.tab {
  font: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 9px 22px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab[aria-selected="true"] { background: var(--violet-deep); color: #fff; }
.tab:not([aria-selected="true"]):hover { color: var(--ink); }

@media (prefers-color-scheme: dark) {
  .tab[aria-selected="true"] { background: var(--violet); }
}

/* ============ The Club ============ */

.club { margin-top: 8px; }

.club-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.club-title { font-size: 1.35rem; font-weight: 850; letter-spacing: -0.01em; }
.club-sub { font-size: 0.8rem; color: var(--ink-3); font-weight: 600; }

.seg {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 999px;
}

.seg-btn {
  font: inherit;
  font-weight: 800;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 7px 14px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
}

.seg-btn[aria-selected="true"] { background: color-mix(in srgb, var(--violet) 14%, var(--surface)); color: var(--ink); }

/* .card is defined later with equal specificity, so qualify to win the padding. */
.ward.card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px 28px;
  padding: 16px 22px;
  margin-bottom: 16px;
}

.ward-hero { display: flex; align-items: center; gap: 12px; }

/* line-height 1 keeps the big figure optically centred against the label. */
.ward-num {
  font-size: 2.1rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--coral-deep);
}

.ward-label {
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--ink-2);
  font-weight: 600;
}

.ward-stats { display: flex; gap: 30px; }

.ward-stat { display: flex; flex-direction: column; gap: 2px; }

.ward-stat-num { font-size: 1.05rem; font-weight: 800; line-height: 1.1; }

.ward-stat-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

@media (max-width: 620px) {
  .ward-stats { gap: 22px; }
}

.board { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.board-row {
  display: grid;
  grid-template-columns: 34px auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 15px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.board-row-you {
  border-color: color-mix(in srgb, var(--violet) 55%, var(--hairline));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--violet) 22%, transparent), var(--shadow-card);
}

.board-rank {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 0.78rem;
  background: var(--grid);
  color: var(--ink-2);
}

.board-rank-1 { background: linear-gradient(135deg, #f6d365, #d9a84a); color: #4a3600; }
.board-rank-2 { background: linear-gradient(135deg, #dfe4ea, #b6bcc6); color: #3a3f47; }
.board-rank-3 { background: linear-gradient(135deg, #e6a978, #cf8351); color: #4a2a10; }

.board-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  font-size: 1.1rem;
  flex: none;
}

.board-main { min-width: 0; }
.board-name { font-size: 0.92rem; font-weight: 800; display: flex; align-items: center; gap: 7px; }

.board-you-tag {
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--violet) 16%, transparent);
  color: var(--violet-deep);
}

@media (prefers-color-scheme: dark) {
  .board-you-tag { color: #b6a5ff; }
}

.board-level { font-size: 0.72rem; font-weight: 600; color: var(--ink-3); }
.board-metrics { display: flex; gap: 16px; text-align: right; }
.board-metric-num { font-weight: 800; font-size: 0.95rem; }
.board-metric-num.xp { color: var(--violet-deep); }
.board-metric-label { font-size: 0.62rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }

@media (prefers-color-scheme: dark) {
  .board-metric-num.xp { color: #b6a5ff; }
}

.board-empty { text-align: center; color: var(--ink-3); font-weight: 600; padding: 30px 0; }

.board-row { cursor: pointer; transition: transform 0.12s ease, border-color 0.12s ease; }
.board-row:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--violet) 35%, var(--hairline)); }

/* ============ Badges ============ */

.badges-section { margin-top: 18px; }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.badge-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  background: var(--page);
  opacity: 0.55;
  filter: grayscale(0.7);
}

/* Earned-on date — revealed on hover only. */
.badge-date {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(3px);
  background: var(--ink);
  color: var(--page);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 6;
}

.badge-tile.earned:hover .badge-date { opacity: 1; transform: translateX(-50%) translateY(0); }

.badge-tile.earned {
  opacity: 1;
  filter: none;
  background: color-mix(in srgb, var(--violet) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--violet) 30%, var(--hairline));
}

.badge-icon { font-size: 1.4rem; line-height: 1; flex: none; }
.badge-info { display: flex; flex-direction: column; min-width: 0; }
.badge-title { font-weight: 800; font-size: 0.85rem; }
.badge-desc { font-size: 0.72rem; font-weight: 600; color: var(--ink-3); }

/* ============ Player drill-in ============ */

.player-detail { width: min(520px, 100%); }

.pd-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.pd-head .profile-avatar { width: 46px; height: 46px; font-size: 1.3rem; }
.pd-level { color: var(--ink-2); font-weight: 600; font-size: 0.78rem; margin-top: 3px; }

.pd-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.pd-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 6px;
  border-radius: var(--radius-md);
  background: var(--page);
  border: 1px solid var(--hairline);
}

.pd-stat-num { font-size: 1.15rem; font-weight: 900; }
.pd-stat-label { font-size: 0.62rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; text-align: center; }

.player-detail .badge-grid { grid-template-columns: 1fr 1fr; }
.player-detail .feed { max-height: 260px; overflow-y: auto; }

.pd-gauges { display: flex; flex-wrap: wrap; gap: 8px; }

.pd-gauge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--page);
  font-weight: 700;
  font-size: 0.86rem;
}

.pd-gauge-n {
  font-weight: 900;
  font-size: 0.8rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--violet) 14%, transparent);
  color: var(--violet-deep);
}

@media (prefers-color-scheme: dark) {
  .pd-gauge-n { color: #b6a5ff; }
}

.pd-none { color: var(--ink-3); font-weight: 600; font-size: 0.86rem; }

@media (max-width: 520px) {
  .pd-stats { grid-template-columns: repeat(3, 1fr); }
  .player-detail .badge-grid { grid-template-columns: 1fr; }
}

/* ============ Celebration toast ============ */

.toast {
  position: fixed;
  top: 78px;
  left: 50%;
  transform: translate(-50%, -18px);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-icon { font-size: 1.6rem; line-height: 1; }
.toast-text { display: flex; flex-direction: column; }
.toast-title { font-weight: 850; font-size: 0.98rem; }
.toast-sub { font-size: 0.82rem; font-weight: 600; color: var(--ink-2); }

@media (max-width: 620px) {
  .board-row { grid-template-columns: 32px auto 1fr; }
  .board-metrics { grid-column: 1 / -1; justify-content: flex-start; padding-left: 46px; }
  .board-metric-label { text-align: left; }
  .board-metrics { text-align: left; }
}


/* ============ Stat tiles ============ */

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-top: -40px;
  position: relative;
  z-index: 5;
}

.stat-tile {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-card);
  padding: 15px 16px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Labels stay on one line — they're short enough now to never wrap. */
.stat-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-top: 3px;
  color: var(--ink);
}

.stat-value-text {
  font-size: 1.1rem;
  padding-top: 7px;
  color: var(--coral-deep);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pinned to the bottom so subs line up even when the value is text, not a number. */
.stat-sub {
  margin-top: auto;
  padding-top: 2px;
  font-size: 0.74rem;
  color: var(--ink-2);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============ Cards / columns ============ */

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 26px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-card);
  padding: 26px;
  /* Grid items default to min-width: auto, so an over-wide child would stretch
     the card past its column instead of being constrained by it. */
  min-width: 0;
}

.card-head { display: flex; align-items: center; justify-content: space-between; }

.card-title {
  font-size: 1.12rem;
  font-weight: 850;
  letter-spacing: -0.01em;
  margin-bottom: 18px;
}

.pill {
  background: color-mix(in srgb, var(--violet) 14%, transparent);
  color: var(--violet-deep);
  font-weight: 800;
  font-size: 0.8rem;
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 18px;
}

@media (prefers-color-scheme: dark) {
  .pill { color: #b6a5ff; }
}

/* ============ Form ============ */

.field { margin-bottom: 17px; }

/* Micro uppercase labels, echoing the stat tiles — recessive next to the controls. */
.field-label {
  display: block;
  font-weight: 800;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 7px;
  color: var(--ink-2);
}

.input {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--hairline);
  background: var(--page);
  color: var(--ink);
  transition: border-color 0.15s ease;
}

.input:focus { outline: none; border-color: var(--violet); }

/* WebKit gives date inputs an intrinsic minimum width that `width: 100%` can't
   shrink below, so on phones the field spills past the card's right edge.
   Dropping the native appearance lets it obey the box; the picker still works. */
.input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 100%;
}

.input[type="date"]::-webkit-date-and-time-value { text-align: left; }

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }

.chip {
  font: inherit;
  font-weight: 700;
  font-size: 0.81rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1.5px solid var(--hairline);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.chip:hover { transform: translateY(-1px); border-color: var(--ink-3); }

.chip[aria-checked="true"] {
  border-color: var(--violet);
  background: color-mix(in srgb, var(--violet) 10%, var(--surface));
  color: var(--ink);
}

.chip-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* switch */
.switch {
  width: 52px;
  height: 30px;
  border-radius: 999px;
  border: none;
  background: var(--grid);
  position: relative;
  cursor: pointer;
  transition: background 0.18s ease;
}

.switch-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: left 0.18s ease;
}

.switch[aria-checked="true"] { background: var(--mint); }
.switch[aria-checked="true"] .switch-thumb { left: 26px; }

/* ============ Feed ============ */

.feed {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--grid) transparent;
}

/* Match the log card's height exactly: the list flexes from a 0 basis so its
   content never inflates the grid row, and "Show more" pins to the bottom. */
.feed-card { display: flex; flex-direction: column; }
.feed-card .feed { flex: 1 1 0; min-height: 0; }

.show-more {
  margin-top: 12px;
  align-self: center;
  flex: none;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--hairline);
  background: none;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease;
}

.show-more:hover { border-color: var(--violet); color: var(--ink); }

.feed::-webkit-scrollbar { width: 6px; }
.feed::-webkit-scrollbar-track { background: transparent; }
.feed::-webkit-scrollbar-thumb { background: var(--grid); border-radius: 999px; }

.feed-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  background: var(--page);
  animation: pop-in 0.25s ease;
}

@keyframes pop-in {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.gauge-badge {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.72rem;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.feed-main { flex: 1; min-width: 0; }
.feed-site { font-size: 0.88rem; font-weight: 800; }
.feed-meta { font-size: 0.72rem; color: var(--ink-3); font-weight: 600; }

.feed-badges { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }

.badge {
  font-size: 0.67rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-first { background: color-mix(in srgb, var(--mint) 18%, transparent); color: #0c7a5b; }
.badge-retry { background: color-mix(in srgb, var(--sunshine) 26%, transparent); color: #8a6100; }
.badge-us    { background: color-mix(in srgb, var(--violet) 14%, transparent); color: var(--violet-deep); }
.badge-miss  { background: color-mix(in srgb, var(--coral) 20%, transparent); color: var(--coral-deep); }

@media (prefers-color-scheme: dark) {
  .badge-first { color: #4ce0b5; }
  .badge-retry { color: #ffd36e; }
  .badge-us    { color: #b6a5ff; }
  .badge-miss  { color: #ec9aa8; }
}

/* Missed attempts read as secondary — the gauge chip goes flat grey. */
.feed-item-miss .gauge-badge-miss {
  background: var(--grid) !important;
  color: var(--ink-3);
  text-shadow: none;
}

.feed-empty {
  text-align: center;
  color: var(--ink-3);
  font-weight: 600;
  padding: 30px 0;
}

/* ============ Charts ============ */

.viz-root { position: relative; }

.chart-months {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 190px;
  padding-top: 10px;
  border-bottom: 2px solid var(--grid);
}

.month-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 0;
  cursor: default;
}

.month-bar {
  width: min(38px, 100%);
  background: var(--series-1);
  border-radius: 4px 4px 0 0;
  transition: filter 0.12s ease;
  min-height: 2px;
}

.month-col:hover .month-bar { filter: brightness(1.15); }

.month-value {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.chart-labels {
  display: flex;
  gap: 14px;
  margin-top: 8px;
}

.month-label {
  flex: 1;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-3);
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: var(--page);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  transform: translate(-50%, -110%);
  white-space: nowrap;
  z-index: 10;
}

/* site bars */
.chart-sites { display: flex; flex-direction: column; gap: 13px; }

.site-row { display: grid; grid-template-columns: 92px 1fr 30px; align-items: center; gap: 10px; }

.site-name { font-size: 0.86rem; font-weight: 700; color: var(--ink-2); }

.site-track {
  height: 14px;
  border-radius: 4px;
  background: var(--grid);
  overflow: hidden;
}

.site-fill {
  height: 100%;
  background: var(--series-1);
  border-radius: 0 4px 4px 0;
  transition: width 0.5s ease;
}

.site-count { font-size: 0.86rem; font-weight: 800; text-align: right; }

/* ============ Confetti burst ============ */

.confetti-piece {
  position: fixed;
  width: 7px;
  height: 7px;
  z-index: 100;
  pointer-events: none;
  animation: confetti-fall 1.2s ease-in forwards;
}

@keyframes confetti-fall {
  0%   { opacity: 0.85; }
  100% { transform: translateY(42vh) rotate(360deg); opacity: 0; }
}

/* ============ Footer ============ */

.footer {
  text-align: center;
  color: var(--ink-3);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 44px 20px 34px;
}

.footer-status {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
}

.footer-status:empty { display: none; }
.footer-status[data-kind="ok"]    { background: color-mix(in srgb, var(--mint) 16%, transparent); color: #0c7a5b; }
.footer-status[data-kind="demo"]  { background: color-mix(in srgb, var(--sunshine) 24%, transparent); color: #8a6100; }
.footer-status[data-kind="error"] { background: color-mix(in srgb, var(--coral) 18%, transparent); color: var(--coral-deep); }

@media (prefers-color-scheme: dark) {
  .footer-status[data-kind="ok"]    { color: #4ce0b5; }
  .footer-status[data-kind="demo"]  { color: #ffd36e; }
  .footer-status[data-kind="error"] { color: #ec9aa8; }
}

/* ============ Responsive ============ */

@media (max-width: 1000px) {
  .columns { grid-template-columns: 1fr; }

  /* Stacked, there is no sibling card to match height to, so the card is only
     as tall as its content — and a 0-basis flex item collapses to nothing.
     Let the list size to its own content and scroll the page instead. */
  .feed-card .feed { flex: none; overflow-y: visible; padding-right: 0; }
}

/* Tiles are compact enough to stay 5-across well below the old cutoff. */
@media (max-width: 820px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 1.6rem; }
  .hero { padding: 56px 16px 72px; }

  /* Two badges leave nothing beside the site name at this width — they drop to
     their own row, indented under the text, rather than squeezing it. */
  .feed-item { flex-wrap: wrap; row-gap: 7px; }
  .feed-item:has(.badge:nth-child(2)) .feed-badges {
    flex-basis: 100%;
    padding-left: 49px;
    justify-content: flex-start;
  }

  /* Compact header: shorter log button, tighter spacing. */
  .btn-label-full { display: none; }
  .btn-label-short { display: inline; }
  #jump-to-log { padding: 9px 15px; }
  .topbar-actions { gap: 8px; }
  .btn { font-size: 0.9rem; }
  .topbar-inner { width: min(1060px, calc(100% - 24px)); }
}

/* Only the tightest phones drop the wordmark to the icon alone. */
@media (max-width: 380px) {
  .brand-name { display: none; }
}
