/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Dark theme ─────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2e3248;
  --text:      #e2e8f0;
  --text-muted:#8892a4;
  --header-bg: #111827;
}
[data-theme="dark"] body,
body[data-theme="dark"],
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }

/* Header */
[data-theme="dark"] .site-header { background: var(--header-bg); }
[data-theme="dark"] .brand-text,
[data-theme="dark"] .nav-username { color: #e2e8f0; }

/* Cards & surfaces */
[data-theme="dark"] .gym-card,
[data-theme="dark"] .table-card,
[data-theme="dark"] .stats-card,
[data-theme="dark"] .lb-card,
[data-theme="dark"] .profile-gym-card,
[data-theme="dark"] .profile-settings-card,
[data-theme="dark"] .map-card,
[data-theme="dark"] .hc-sector-card,
[data-theme="dark"] .auth-card,
[data-theme="dark"] .boulder-form,
[data-theme="dark"] .info-card,
[data-theme="dark"] .comment-bubble { background: var(--surface); border: 1px solid var(--border); box-shadow: none; }

/* Homepage gym card text */
[data-theme="dark"] .gym-card h2     { color: var(--text); }
[data-theme="dark"] .gym-location    { color: var(--text-muted); }
[data-theme="dark"] .boulder-count   { background: var(--surface2); color: var(--text-muted); }

/* Tables */
[data-theme="dark"] table            { background: var(--surface); }
[data-theme="dark"] thead th         { background: var(--surface2); color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] tbody tr         { border-color: var(--border); }
[data-theme="dark"] tbody tr:active  { background: var(--surface2); }
[data-theme="dark"] td               { border-color: var(--border); color: var(--text); }
[data-theme="dark"] tr:hover td      { background: var(--surface2); }
[data-theme="dark"] .row-topped td   { background: color-mix(in srgb, #22c55e 8%, var(--surface)); color: var(--text); }
[data-theme="dark"] .row-tried td    { background: color-mix(in srgb, #f59e0b 8%, var(--surface)); color: var(--text); }
/* Hard-coded column colours that would be invisible on dark bg */
[data-theme="dark"] .col-tops        { color: var(--text); }
[data-theme="dark"] .col-sector,
[data-theme="dark"] .col-setter,
[data-theme="dark"] .col-date        { color: var(--text-muted); }
[data-theme="dark"] .hc-table td      { border-color: var(--border); }
[data-theme="dark"] .hc-sector-header { background: var(--surface2); border-color: var(--border); }
[data-theme="dark"] .hc-sector-name   { color: var(--text); }
[data-theme="dark"] .hc-sector-progress { color: var(--text-muted); }
[data-theme="dark"] .hc-progress-done { color: #4ade80; }
[data-theme="dark"] .hc-col-num       { color: var(--text-muted); }
[data-theme="dark"] .hc-missing td    { background: rgba(245,158,11,0.10); }

/* Sort links */
[data-theme="dark"] .sort-link        { color: var(--text-muted); }
[data-theme="dark"] .sort-link:hover  { color: var(--text); }
[data-theme="dark"] .sort-link.active { color: var(--text); }

/* Map */
[data-theme="dark"] .gym-map > rect            { fill: var(--surface); }
[data-theme="dark"] .gym-map > g:nth-child(2)  { fill: var(--surface2); stroke: var(--border); }

/* Profile */
[data-theme="dark"] .profile-gym-name          { color: var(--text); }
[data-theme="dark"] .profile-color-name        { color: var(--text-muted); }
[data-theme="dark"] .profile-color-count       { color: var(--text); }
[data-theme="dark"] .profile-color-count.zero  { color: var(--text-muted); }
[data-theme="dark"] .profile-color-total       { color: var(--text-muted); }
[data-theme="dark"] .prog-track                { background: var(--surface2); }
[data-theme="dark"] .profile-all-badge         { background: #14532d; color: #86efac; border: 1px solid rgba(134,239,172,0.2); }
[data-theme="dark"] .profile-gym-footer,
[data-theme="dark"] .profile-boulder-lists,
[data-theme="dark"] .profile-boulder-group     { border-color: var(--border); }
[data-theme="dark"] .profile-boulder-group-label.topped { color: #4ade80; }
[data-theme="dark"] .profile-boulder-group-label.tried  { color: #fbbf24; }
[data-theme="dark"] .lb-unranked               { color: var(--text-muted); }

/* Leaderboard */
[data-theme="dark"] .lb-rank                   { color: var(--text-muted); }
[data-theme="dark"] .lb-card:nth-child(1) .lb-rank { color: #c9993a; }
[data-theme="dark"] .lb-card:nth-child(2) .lb-rank { color: #909090; }
[data-theme="dark"] .lb-card:nth-child(3) .lb-rank { color: #a0684a; }
[data-theme="dark"] .lb-stats                  { color: var(--text-muted); }
[data-theme="dark"] .score-pill.zero           { opacity: 0.35; }

/* Detail view */
[data-theme="dark"] .detail-item               { background: var(--surface); border: 1px solid var(--border); }
[data-theme="dark"] .detail-label              { color: var(--text-muted); }
[data-theme="dark"] .detail-value              { color: var(--text); }

/* Page intro */
[data-theme="dark"] .page-intro p              { color: var(--text-muted); }

/* Forms & buttons */
[data-theme="dark"] .flash                     { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea                   { background: var(--surface2); color: var(--text); border-color: var(--border); }
/* Forms */
[data-theme="dark"] .boulder-form     { background: var(--surface); box-shadow: none; }
[data-theme="dark"] .form-group label { color: var(--text-muted); }
[data-theme="dark"] .form-group input[type="text"],
[data-theme="dark"] .form-group input[type="date"],
[data-theme="dark"] .form-group input[type="email"],
[data-theme="dark"] .form-group input[type="password"],
[data-theme="dark"] .form-group input[type="number"],
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea { background: var(--surface2); color: var(--text); border-color: var(--border); }
/* Profile stat pills */
[data-theme="dark"] .profile-stat     { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
[data-theme="dark"] .btn-ghost                 { color: var(--text); border-color: var(--border); }
[data-theme="dark"] .btn-ghost:hover           { background: var(--surface2); }
[data-theme="dark"] .btn-retire:hover          { background: rgba(220,38,38,0.15); }
[data-theme="dark"] .btn-restore:hover         { background: rgba(22,163,74,0.12); }
[data-theme="dark"] .btn-edit                  { color: var(--text-muted); background: var(--surface2); }
[data-theme="dark"] .btn-edit:hover            { background: var(--border); }
[data-theme="dark"] .settings-divider          { color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .pref-toggle               { border-color: var(--border); }
[data-theme="dark"] .pref-label                { color: var(--text); }
[data-theme="dark"] .pref-hint                 { color: var(--text-muted); }
[data-theme="dark"] .checkbox-row              { color: var(--text); }
[data-theme="dark"] .profile-settings-title    { color: var(--text-muted); }

/* Auth card */
[data-theme="dark"] .auth-card                { background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,0.4); }
[data-theme="dark"] .auth-sub,
[data-theme="dark"] .auth-switch              { color: var(--text-muted); }
[data-theme="dark"] .auth-switch a            { color: var(--text); }

/* Filter bar */
[data-theme="dark"] .filter-bar               { border-color: var(--border); }
[data-theme="dark"] .filter-select            { background: var(--surface2); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .filter-clear             { color: var(--text-muted); }
[data-theme="dark"] .filter-clear:hover       { color: var(--text); }
[data-theme="dark"] .hide-topped-btn          { background: var(--surface2); color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .hide-topped-btn.active   { background: #1e3a5f; color: #93c5fd; border-color: #3b82f6; }

/* Dark mode spheres: replace floor-glow white blob with dark bg reflection */
[data-theme="dark"] .hold-sphere {
  background:
    radial-gradient(ellipse 70% 54% at 50% 6%,  rgba(255,255,255,.16) 0%, rgba(255,255,255,0) 100%),
    radial-gradient(circle  at 50% 50%, transparent 36%, rgba(0,0,0,.62) 100%),
    linear-gradient(to bottom, transparent 46%, rgba(0,0,0,.24) 100%),
    var(--hc, #999);
  box-shadow: 0 1.5px 4px rgba(0,0,0,.38), inset 0 -1px 2px rgba(0,0,0,.16);
}
[data-theme="dark"] .hold-sphere.no-tex {
  background:
    radial-gradient(ellipse 20% 16% at 30% 24%, rgba(255,255,255,1.0) 0%, rgba(255,255,255,.56) 50%, rgba(255,255,255,0) 100%),
    radial-gradient(ellipse 16% 12% at 28% 66%, rgba(255,255,255,.98) 0%, rgba(255,255,255,.42) 48%, rgba(255,255,255,0) 100%),
    radial-gradient(ellipse 12%  9% at 74% 76%, rgba(255,255,255,.52) 0%, rgba(255,255,255,0) 100%),
    radial-gradient(ellipse 88% 58% at 50% 110%, rgba(15,17,23,.60) 0%, rgba(15,17,23,.26) 44%, rgba(15,17,23,0) 70%),
    radial-gradient(circle at 50% 50%, transparent 20%, rgba(0,0,0,.80) 100%),
    linear-gradient(to bottom, transparent 46%, rgba(0,0,0,.26) 100%),
    var(--hc, #999);
}
[data-theme="dark"] .hold-sphere.dual-tex::after {
  background:
    radial-gradient(ellipse 16% 12% at 28% 66%, rgba(255,255,255,.98) 0%, rgba(255,255,255,.42) 48%, rgba(255,255,255,0) 100%),
    radial-gradient(ellipse 12%  9% at 74% 76%, rgba(255,255,255,.52) 0%, rgba(255,255,255,0) 100%),
    radial-gradient(ellipse 88% 58% at 50% 110%, rgba(15,17,23,.60) 0%, rgba(15,17,23,.26) 44%, rgba(15,17,23,0) 70%);
}

/* Row state text inside topped/tried */
[data-theme="dark"] .row-topped .col-number a,
[data-theme="dark"] .row-tried  .col-number a  { color: var(--text); }

/* Boulder detail: review section */
[data-theme="dark"] .review-heading            { color: var(--text-muted); }
[data-theme="dark"] .review-pill               { color: var(--text-muted); }
[data-theme="dark"] .review-pill:hover         { color: var(--text); }
[data-theme="dark"] .kw-chip                   { background: var(--surface2); color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .kw-chip:hover             { border-color: var(--text-muted); }
[data-theme="dark"] .kw-chip.selected          { background: #2d3f6b; color: var(--text); border-color: #4a5f9e; }
[data-theme="dark"] .go-chip                   { background: var(--surface2); color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .go-chip:hover             { border-color: var(--text-muted); }
[data-theme="dark"] .go-chip.selected          { background: #14532d; color: #bbf7d0; border-color: #166534; }
[data-theme="dark"] .go-label                  { color: var(--text-muted); }
[data-theme="dark"] .go-consensus              { color: var(--text-muted); }
[data-theme="dark"] .go-consensus-label        { color: #4ade80; }
[data-theme="dark"] .kw-sm                     { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
[data-theme="dark"] .flash-toggle-label        { background: var(--surface2); color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .flash-toggle input:checked + .flash-toggle-label { background: rgba(245,158,11,.18); border-color: #f59e0b; color: #fbbf24; }
[data-theme="dark"] .community-stats           { border-color: var(--border); }
[data-theme="dark"] .star-row .star            { color: var(--border); }
[data-theme="dark"] .autosave-status           { color: var(--text-muted); }

/* Tops log page */
[data-theme="dark"] #tops-count                { color: var(--text-muted); }
[data-theme="dark"] .tops-footer               { background: linear-gradient(transparent, var(--bg) 20%); }

/* Form input focus */
[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group textarea:focus { background: var(--surface2); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }

/* Color scheme table (gym admin form) */
[data-theme="dark"] .color-scheme-table-wrap   { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .color-scheme-table th     { background: var(--surface2); color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .color-scheme-table td     { border-color: var(--border); color: var(--text); }
[data-theme="dark"] .color-scheme-table input[type="text"],
[data-theme="dark"] .color-scheme-table input[type="number"],
[data-theme="dark"] .color-scheme-table select { background: var(--surface2); color: var(--text); border-color: var(--border); }

/* Flash borders */
[data-theme="dark"] .flash-success { border-color: rgba(34,197,94,0.3); }
[data-theme="dark"] .flash-error   { border-color: rgba(220,38,38,0.3); }

/* Community keyword chips in boulder detail */
[data-theme="dark"] .kw-display-chip { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }

/* Profile gym footer "top category!" label */
[data-theme="dark"] .profile-top { color: #4ade80; }

/* Toggle slider track (unchecked state) */
[data-theme="dark"] .pref-slider { background: var(--border); }

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

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  background: #1e2a4a;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 52px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}
.brand-icon { font-size: 1.3rem; line-height: 1; }

.gym-name {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.55);
  text-align: right;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Tab nav ─────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  background: #162039;
  padding: 0 0.5rem;
  gap: 0.25rem;
}
.tab-link {
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  border-bottom: 3px solid transparent;
  transition: color 0.15s;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.tab-link:hover { color: rgba(255,255,255,0.9); }
.tab-link.active { color: #fff; border-bottom-color: #4fc3f7; }

/* ── Main content ────────────────────────────────────────── */
.main-content {
  padding: 1.25rem 1rem 3rem;
  max-width: 960px;
  margin: 0 auto;
}

/* ── Page intro ──────────────────────────────────────────── */
.page-intro {
  margin-bottom: 1.25rem;
}
.page-intro h1 {
  font-size: 1.35rem;
  font-weight: 700;
}
.page-intro p {
  color: #666;
  font-size: 0.875rem;
  margin-top: 0.2rem;
}

/* ── Gym grid ────────────────────────────────────────────── */
.gym-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.gym-card {
  background: #fff;
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  transition: box-shadow 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.gym-card:active { transform: scale(0.98); }

.gym-card-body { flex: 1; min-width: 0; }
.gym-card h2 { font-size: 1.1rem; font-weight: 700; }
.gym-location { color: #777; font-size: 0.8rem; margin-top: 0.2rem; }
.gym-meta { margin-top: 0.75rem; }
.boulder-count {
  font-size: 0.8rem;
  background: #f0f2f5;
  padding: 3px 10px;
  border-radius: 20px;
  color: #555;
  font-weight: 500;
}

.gym-card-colors {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.1);
  display: block;
}

/* ── Boulder table card ──────────────────────────────────── */
.table-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

thead th {
  background: #f7f8fc;
  padding: 0.65rem 0.75rem;
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
  border-bottom: 1px solid #eaecf0;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #f0f2f5;
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:active { background: #f4f6ff; }

td {
  padding: 0.7rem 0.75rem;
  font-size: 0.9rem;
  vertical-align: middle;
}

/* Column sizing */
.col-number { font-weight: 600; font-size: 0.85rem; white-space: nowrap; }
.col-sector { color: #555; }
.col-setter { color: #777; font-size: 0.85rem; }
.col-tops { font-weight: 600; color: #1e2a4a; }
.col-date { color: #aaa; font-size: 0.8rem; white-space: nowrap; }

/* ── Sort link ───────────────────────────────────────────── */
.sort-link {
  color: #999;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
  min-height: 36px;
}
.sort-link:hover { color: #333; }
.sort-link.active { color: #1e2a4a; font-weight: 700; }

/* ── Difficulty badge ────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
  border: 1.5px solid rgba(0,0,0,0.08);
  letter-spacing: 0.02em;
}
.badge-unknown { background: #eee; color: #999; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: #aaa;
  padding: 3rem 1rem;
  font-size: 0.9rem;
}
.empty-state code {
  background: #f0f2f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85rem;
}

/* ── Toolbar (title + action buttons) ───────────────────────── */
.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.toolbar .page-intro { margin-bottom: 0; }
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding-top: 0.15rem;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  min-height: 44px;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: #1e2a4a; color: #fff; }
.btn-primary:hover { opacity: 0.88; }
.btn-ghost {
  background: transparent;
  color: #555;
  border: 1.5px solid #ddd;
}
.btn-ghost:hover { background: #f0f2f5; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; min-height: 36px; }

/* row-level retire / restore button */
.btn-row-action {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 6px 8px;
  border-radius: 6px;
  line-height: 1;
  min-width: 32px;
  min-height: 36px;
  transition: background 0.1s;
}
.btn-retire { color: #bbb; }
.btn-retire:hover { background: #fff0f0; color: #e53935; }
.btn-restore { color: #4CAF50; }
.btn-restore:hover { background: #f0fff0; }
.col-action { padding: 0.4rem 0.5rem; width: 40px; }

/* ── Inactive row ────────────────────────────────────────────── */
.row-inactive td { opacity: 0.4; }
.row-inactive .col-action td { opacity: 1; }

/* ── Flash messages ──────────────────────────────────────────── */
.flash {
  padding: 0.8rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}
.flash-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.flash-error   { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }

/* ── Boulder form ────────────────────────────────────────────── */
.boulder-form {
  background: #fff;
  border-radius: 14px;
  padding: 1.5rem 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  max-width: 560px;
}

.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.required { color: #e53935; }
.optional { color: #aaa; font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 0.78rem; }

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  background: #fafafa;
  color: #1a1a2e;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 48px;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #1e2a4a;
  box-shadow: 0 0 0 3px rgba(30,42,74,0.08);
  background: #fff;
}
.form-group textarea { resize: vertical; min-height: 72px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* ── Color picker (radio pills) ──────────────────────────────── */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.color-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}
.color-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: border-color 0.12s, transform 0.1s, box-shadow 0.12s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  justify-content: center;
}
.color-pill:active { transform: scale(0.95); }
.cp-name { font-size: 0.8rem; font-weight: 700; text-transform: capitalize; line-height: 1.2; }
.cp-range { font-size: 0.65rem; opacity: 0.8; line-height: 1.2; }
.color-option input[type="radio"]:checked + .color-pill {
  border-color: #1e2a4a;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  transform: scale(1.06);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.75rem;
}
.form-actions .btn { flex: 1; }

/* ── Participant box ─────────────────────────────────────────── */
.participant-box {
  background: #fff;
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-bottom: 1.25rem;
}
.selector-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}
.selector-row {
  display: flex;
  gap: 0.5rem;
}
.participant-select,
.participant-add-form input[type="text"] {
  flex: 1;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  background: #fafafa;
  color: #1a1a2e;
  min-height: 48px;
  appearance: none;
  -webkit-appearance: none;
}
.participant-select:focus,
.participant-add-form input:focus {
  outline: none;
  border-color: #1e2a4a;
  background: #fff;
}
.participant-divider {
  text-align: center;
  color: #bbb;
  font-size: 0.8rem;
  margin: 0.75rem 0;
  position: relative;
}
.participant-divider::before,
.participant-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 1.5rem);
  height: 1px;
  background: #e8e8e8;
}
.participant-divider::before { left: 0; }
.participant-divider::after  { right: 0; }

/* ── Tops header ─────────────────────────────────────────────── */
.tops-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding: 0 0.25rem;
}
.tops-who { font-weight: 700; font-size: 1rem; }
.tops-count {
  font-size: 0.82rem;
  background: #e8eaf6;
  color: #3949ab;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}

/* ── Tops table ──────────────────────────────────────────────── */
.col-topped-hdr { width: 2.5rem; text-align: center; }
.col-topped-cell { text-align: center; padding: 0.5rem 0.25rem; }

/* ── 3-state toggle button ───────────────────────────────────── */
.state-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #ddd;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: background 0.12s, border-color 0.12s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
.state-btn:active { transform: scale(0.88); }

/* topped: green circle with white checkmark */
.state-topped {
  background: #16a34a;
  border-color: #16a34a;
}
.state-topped::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -62%) rotate(45deg);
  width: 5px;
  height: 9px;
  border: 2.5px solid #fff;
  border-top: none;
  border-left: none;
}

/* tried: red circle with white × */
.state-tried {
  background: #dc2626;
  border-color: #dc2626;
}
.state-tried::before,
.state-tried::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2.5px;
  background: #fff;
  border-radius: 2px;
}
.state-tried::before { transform: translate(-50%, -50%) rotate(45deg); }
.state-tried::after  { transform: translate(-50%, -50%) rotate(-45deg); }

.row-topped { background: #f0fff4; }
.row-topped td { color: #555; }
.row-tried  { background: #fff5f5; }
.row-tried td  { color: #555; }

/* hide less-important columns on small screens */
@media (max-width: 639px) {
  .col-hide-sm { display: none; }
}

/* ── Sticky save footer ──────────────────────────────────────── */
.tops-footer {
  position: sticky;
  bottom: 0;
  background: linear-gradient(transparent, #f0f2f5 20%);
  padding: 1rem 0 1.5rem;
  margin-top: -1rem;
}
.btn-full { width: 100%; }

/* ── Header user area ────────────────────────────────────────── */
.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.nav-username {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.75);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-username:hover { color: #fff; text-decoration: underline; }
.btn-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  min-height: 32px;
  transition: background 0.15s;
}
.btn-logout:hover { background: rgba(255,255,255,0.1); }
.logout-form { display: inline; }
.btn-nav-auth {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 5px 12px;
  border-radius: 6px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s;
}
.btn-nav-auth:hover { background: rgba(255,255,255,0.1); }
.btn-dark-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: 4px 6px;
  border-radius: 6px; transition: background 0.15s;
  display: inline-flex; align-items: center;
}
.btn-dark-toggle:hover { background: rgba(255,255,255,0.1); }

/* ── Category legend ─────────────────────────────────────────── */
.cat-badge { font-size: 0.75rem; padding: 3px 9px; }

/* ── Leaderboard list ────────────────────────────────────────── */
.lb-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.lb-card {
  background: #fff;
  border-radius: 14px;
  padding: 0.9rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.lb-rank {
  font-size: 1.1rem;
  font-weight: 800;
  color: #aaa;
  min-width: 36px;
  flex-shrink: 0;
  padding-top: 2px;
}
.lb-card:nth-child(1) .lb-rank { color: #c9993a; }
.lb-card:nth-child(2) .lb-rank { color: #909090; }
.lb-card:nth-child(3) .lb-rank { color: #a0684a; }

.lb-body { flex: 1; min-width: 0; }

.lb-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}
.lb-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-age {
  font-size: 0.75rem;
  color: #aaa;
  font-weight: 400;
}
.profile-stats-inline {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}
.profile-stat {
  font-size: 0.75rem;
  color: #888;
  background: #f3f3f3;
  border-radius: 20px;
  padding: 1px 8px;
}
.profile-ape { font-weight: 600; }
.lb-cat-badge { font-size: 0.75rem; padding: 3px 9px; flex-shrink: 0; }
.lb-unranked { font-size: 0.8rem; color: #ccc; }

/* per-color score pills */
.lb-colors {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 22px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid rgba(0,0,0,0.06);
}
.score-pill.zero { opacity: 0.18; }

.lb-stats {
  font-size: 0.78rem;
  color: #888;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.lb-sep { color: #ddd; }

/* ── Auth pages ──────────────────────────────────────────────── */
.auth-wrap {
  display: flex;
  justify-content: center;
  padding-top: 1rem;
}
.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 2rem 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 420px;
}
.auth-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}
.auth-sub {
  color: #777;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}
.auth-form { display: flex; flex-direction: column; }
.auth-switch {
  text-align: center;
  font-size: 0.85rem;
  color: #777;
  margin-top: 1.25rem;
}
.auth-switch a { color: #1e2a4a; font-weight: 600; }

/* ── Profile page ────────────────────────────────────────── */
.profile-gym-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.profile-gym-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.profile-gym-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: #1e2a4a;
}
.profile-gym-name:hover { text-decoration: underline; }

.profile-colors { display: flex; flex-direction: column; gap: 0.55rem; }
.profile-color-row {
  display: grid;
  grid-template-columns: 14px 4.5rem 1fr 3rem auto;
  align-items: center;
  gap: 0.5rem;
}
.profile-color-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.12);
  flex-shrink: 0;
}
.profile-color-name { font-size: 0.82rem; color: #444; }
.prog-track {
  height: 7px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
  min-width: 2px;
}
.profile-color-count {
  font-size: 0.82rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.profile-color-count.zero { color: #bbb; font-weight: 400; }
.profile-color-total { font-weight: 400; color: #aaa; }
.profile-all-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: #e6f4ea;
  color: #2e7d32;
  padding: 1px 5px;
  border-radius: 8px;
  white-space: nowrap;
}

.profile-gym-footer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f0f2f5;
  font-size: 0.85rem;
  color: #666;
}
.profile-next { display: flex; align-items: center; gap: 0.3rem; }
.profile-next-badge { font-size: 0.7rem; padding: 1px 7px; }
.profile-top { color: #2e7d32; font-weight: 600; }

.profile-boulder-lists { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid #f0f2f5; }
.profile-boulder-group { margin-top: 0.75rem; }
.profile-boulder-group:first-child { margin-top: 0; }
.profile-boulder-group-label {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}
.profile-boulder-group-label.topped { color: #2e7d32; }
.profile-boulder-group-label.tried  { color: #b45309; }
.profile-boulder-table { margin: 0; }
.profile-boulder-table td { padding: 0.3rem 0.6rem; }
.profile-sort-table thead button.sort-link { background: none; border: none; cursor: pointer; font-family: inherit; }

/* ── Profile settings card ───────────────────────────────── */
.profile-settings-card {
  background: #fff;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-top: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.profile-settings-title {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: #888; margin-bottom: 0.75rem;
}
.pref-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.55rem 0; cursor: pointer; gap: 1rem;
  border-top: 1px solid #f0f2f5;
}
.pref-toggle:first-of-type { border-top: none; }
.pref-label { font-size: 0.9rem; color: #333; }
.pref-hint  { font-size: 0.78rem; color: #999; }
.pref-toggle input { display: none; }
.pref-slider {
  flex-shrink: 0; width: 40px; height: 22px; border-radius: 11px;
  background: #ccc; position: relative; transition: background .2s;
}
.pref-slider::after {
  content: ''; position: absolute; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; top: 2px; left: 2px;
  transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.pref-toggle input:checked + .pref-slider { background: #1e2a4a; }
.pref-toggle input:checked + .pref-slider::after { transform: translateX(18px); }


/* ── Settings page ───────────────────────────────────────── */
.settings-divider {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888;
  border-top: 1px solid #e5e7eb;
  padding-top: 1.25rem;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}

/* ── Leaderboard name link ───────────────────────────────── */
a.lb-name { color: inherit; }
a.lb-name:hover { text-decoration: underline; }

/* ── Row action cluster ──────────────────────────────────── */
.row-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.btn-edit {
  color: #1e2a4a;
  background: rgba(30,42,74,0.07);
}
.btn-edit:hover { background: rgba(30,42,74,0.15); }

/* ── Form hints ──────────────────────────────────────────── */
.form-hint {
  display: block;
  font-size: 0.78rem;
  color: #888;
  margin-top: 0.25rem;
}
.checkbox-row {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.9rem; cursor: pointer;
}
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* ── Gym color-scheme table ──────────────────────────────── */
.color-scheme-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
}
.color-scheme-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.color-scheme-table th {
  background: #f8f9fb;
  padding: 0.5rem 0.6rem;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}
.color-scheme-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #f0f2f5;
}
.color-scheme-table tbody tr:last-child td { border-bottom: none; }
.color-scheme-table input[type="text"],
.color-scheme-table input[type="number"],
.color-scheme-table select {
  padding: 0.3rem 0.4rem;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 0.82rem;
  background: #fff;
}

/* ── Boulder detail ─────────────────────────────────────── */
.boulder-num-link { color: inherit; font-weight: 700; text-decoration: none; }
.boulder-num-link:hover { text-decoration: underline; }

.badge-lg { font-size: 1rem; padding: 0.35rem 0.9rem; border-radius: 8px; }

.detail-sector {
  margin-left: 0.8rem;
  color: #666;
  font-size: 1rem;
  font-weight: 400;
  vertical-align: middle;
}

.map-card {
  background: #fff;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.gym-map { width: 100%; height: auto; border-radius: 8px; display: block; }
.map-sector { fill: #334155; }
.map-sector.active { fill: #dc2626; }
.gym-map.interactive .map-sector { cursor: pointer; }
.gym-map.interactive .map-sector:hover { fill: #475569; }
.gym-map.interactive .map-sector.active:hover { fill: #b91c1c; }
.boulders-map .gym-map { max-height: 260px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.detail-item {
  background: #fff;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.detail-item-full { grid-column: 1 / -1; }
.detail-label {
  display: block;
  font-size: 0.72rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.detail-value { font-weight: 600; font-size: 0.95rem; }

/* ── Auto-save status ───────────────────────────────────── */
.autosave-status {
  font-size: 0.78rem;
  color: #9ca3af;
  transition: opacity 0.4s;
  min-width: 60px;
  text-align: right;
}
.autosave-status.saving { color: #6b7280; }
.autosave-status.saved  { color: #16a34a; }

/* ── Review pill (compact summary in topped cell) ────────── */
.review-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  color: #555;
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
  user-select: none;
}
.review-pill:hover { color: #1e2a4a; }

/* ── Review row (flash / stars / keywords) ──────────────── */
.review-hidden { display: none; }

.review-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.5rem 0 0.6rem 0.2rem;
}

.flash-toggle { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.flash-toggle input[type="checkbox"] { display: none; }
.flash-toggle-label {
  font-size: 0.82rem;
  color: #555;
  padding: 3px 10px;
  border: 1.5px solid #d1d5db;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.flash-toggle input:checked + .flash-toggle-label {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
  font-weight: 600;
}

.flash-badge {
  font-size: 0.82rem;
  margin-left: 3px;
  vertical-align: middle;
}

.star-row {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}
.star-row .star {
  font-size: 1.3rem;
  color: #d1d5db;
  cursor: pointer;
  line-height: 1;
  transition: color 0.1s;
  user-select: none;
}
.star-row .star.lit   { color: #f59e0b; }
.star-row .star.hover { color: #fbbf24; }

.kw-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.kw-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  border: 1.5px solid #d1d5db;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  background: #fff;
  color: #555;
  transition: all 0.15s;
  user-select: none;
}
.kw-chip:hover { border-color: #94a3b8; }
.kw-chip.selected {
  background: #1e2a4a;
  color: #fff;
  border-color: #1e2a4a;
}
.kw-chip.maxed:not(.selected) { opacity: 0.4; cursor: not-allowed; }

/* ── Grade opinion chips ─────────────────────────────────── */
.go-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.go-label { font-size: 0.78rem; color: #888; margin-right: 2px; }
.go-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 3px 10px;
  border: 1.5px solid #d1d5db;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: #555;
  transition: all 0.15s;
  user-select: none;
}
.go-chip:hover { border-color: #94a3b8; }
.go-chip.selected {
  background: #166534;
  color: #fff;
  border-color: #166534;
}
.go-consensus {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: #555;
}
.go-consensus-label { font-weight: 700; color: #166534; }

/* ── Compact tag chips in table (read-only) ─────────────── */
.col-tags { white-space: nowrap; }
.kw-sm {
  padding: 2px 7px;
  font-size: 0.72rem;
  background: #f1f5f9;
  border-radius: 12px;
  color: #475569;
  margin-right: 3px;
}

/* ── Boulder detail stats ────────────────────────────────── */
.review-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}
.review-heading { font-weight: 700; font-size: 0.85rem; color: #444; text-transform: uppercase; letter-spacing: 0.05em; }
.star-hint { font-size: 0.75rem; color: #aaa; margin-left: 6px; }
.community-stats {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid #f0f2f5;
}
.community-label {
  display: block;
  font-size: 0.72rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.stats-card {
  background: #fff;
  border-radius: 16px;
  padding: 1rem 1.2rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
}
.stats-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-bottom: 0.75rem;
}
.flash-big { font-size: 0.9rem; font-weight: 700; color: #92400e; }
.flash-count { font-size: 0.82rem; color: #666; }

.avg-stars { display: flex; align-items: center; gap: 4px; }
.detail-star { font-size: 1.4rem; color: #d1d5db; line-height: 1; }
.detail-star.lit { color: #f59e0b; }
.detail-star.half-lit { color: #fcd34d; }
.avg-rating-num { font-size: 1rem; font-weight: 700; margin-left: 4px; }
.rating-votes { font-size: 0.78rem; color: #888; font-weight: 400; }

.kw-display { display: flex; flex-wrap: wrap; gap: 6px; }
.kw-display-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: #f1f5f9;
  border-radius: 20px;
  font-size: 0.82rem;
  color: #334155;
}
.kw-count {
  background: #1e2a4a;
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 2px;
}

/* ── Grade dot (difficulty, no text) ─────────────────────── */
.grade-dot {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.18);
  vertical-align: middle;
  flex-shrink: 0;
}
.setter-grades { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.setter-grade-chip { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.setter-grade-count { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.grade-dot-lg {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.15);
  vertical-align: middle;
  flex-shrink: 0;
}

/* ── Hold sphere ─────────────────────────────────────────── */
/*
 * Three surface types, set via CSS class on .hold-sphere:
 *   (none)      = tex     — fully textured matte rubber, feTurbulence grain
 *   .no-tex     = no-tex  — fully smooth gloss, mirror-ball specular
 *   .dual-tex   = dual-tex — top half tex + bottom half gloss
 *
 * Grain filter #hold-grain is defined in base.html as an inline SVG.
 * Grain clip-path for dual-tex uses path() coords for a 22×22px sphere.
 */
.hold-sphere {
  display: inline-block;
  width: 22px; height: 22px;
  border-radius: 50%;
  flex-shrink: 0; vertical-align: middle;
  cursor: default;
  position: relative; overflow: hidden;
  /* T4: overhead fill + deep vignette + bottom shadow */
  background:
    radial-gradient(ellipse 70% 54% at 50% 6%,  rgba(255,255,255,.16) 0%, rgba(255,255,255,0) 100%),
    radial-gradient(circle  at 50% 50%, transparent 36%, rgba(0,0,0,.40) 100%),
    linear-gradient(to bottom, transparent 46%, rgba(0,0,0,.16) 100%),
    var(--hc, #999);
  filter: saturate(.76);
  box-shadow: 0 1.5px 4px rgba(0,0,0,.25), inset 0 -1px 2px rgba(0,0,0,.10);
}

/* Grain overlay — tex and dual-tex only (not no-tex) */
.hold-sphere:not(.no-tex)::before {
  content: ''; position: absolute; inset: 0;
  background: #808080;
  filter: url(#hold-grain);
  mix-blend-mode: overlay;
  opacity: .36;
}

/* Dual-tex: clip grain to spherical upper half.
   Path coords for 22×22px: equator dips 2px at centre (like DT4). */
.hold-sphere.dual-tex::before {
  clip-path: path('M 0 11 C 6 13 16 13 22 11 L 22 0 L 0 0 Z');
}

/* Dual-tex: lower-half no-tex specular via ::after (S5 shine) */
.hold-sphere.dual-tex::after {
  content: ''; position: absolute; inset: 0;
  background:
    /* crisp mirror spot lower-left */
    radial-gradient(ellipse 16% 12% at 28% 66%, rgba(255,255,255,.98) 0%, rgba(255,255,255,.42) 48%, rgba(255,255,255,0) 100%),
    /* LR secondary glint */
    radial-gradient(ellipse 12%  9% at 74% 76%, rgba(255,255,255,.52) 0%, rgba(255,255,255,0) 100%),
    /* floor glow */
    radial-gradient(ellipse 88% 58% at 50% 110%, rgba(255,255,255,.60) 0%, rgba(255,255,255,.26) 44%, rgba(255,255,255,0) 70%);
}

/* No-tex: fully glossy — N2 mirror ball (upper key) + S5 lower spot */
.hold-sphere.no-tex {
  background:
    /* key spot upper-left */
    radial-gradient(ellipse 20% 16% at 30% 24%, rgba(255,255,255,1.0) 0%, rgba(255,255,255,.56) 50%, rgba(255,255,255,0) 100%),
    /* crisp lower-left spot (S5) */
    radial-gradient(ellipse 16% 12% at 28% 66%, rgba(255,255,255,.98) 0%, rgba(255,255,255,.42) 48%, rgba(255,255,255,0) 100%),
    /* LR secondary glint */
    radial-gradient(ellipse 12%  9% at 74% 76%, rgba(255,255,255,.52) 0%, rgba(255,255,255,0) 100%),
    /* floor glow */
    radial-gradient(ellipse 88% 58% at 50% 110%, rgba(255,255,255,.60) 0%, rgba(255,255,255,.26) 44%, rgba(255,255,255,0) 70%),
    /* deep vignette */
    radial-gradient(circle at 50% 50%, transparent 20%, rgba(0,0,0,.55) 100%),
    linear-gradient(to bottom, transparent 46%, rgba(0,0,0,.18) 100%),
    var(--hc, #999);
  filter: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.48), inset 0 -2px 3px rgba(0,0,0,.22);
}
.hc-input-row { display: flex; align-items: center; gap: 0.4rem; }

/* ── Filter bar ─────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.filter-select {
  padding: 0.35rem 0.55rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  color: #1a1a2e;
  cursor: pointer;
}
.filter-select:focus { outline: 2px solid #3b82f6; outline-offset: 1px; }
.filter-clear {
  font-size: 0.8rem;
  color: #6b7280;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.2rem 0;
}
.filter-clear:hover { color: #374151; }
.grade-filter-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.grade-filter-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.1s, box-shadow 0.1s;
}
.grade-filter-dot:hover { transform: scale(1.18); }
.grade-filter-dot.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px #334155;
  transform: scale(1.18);
}
.hide-topped-btn {
  margin-left: auto;
  height: 26px;
  padding: 0 0.6rem;
  font-size: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 13px;
  background: #f9fafb;
  color: #6b7280;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.hide-topped-btn.active {
  background: #eff6ff;
  color: #2563eb;
  border-color: #93c5fd;
}

/* ── Hold color editor ──────────────────────────────────── */
.hc-sector-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-bottom: 1rem;
  overflow: hidden;
}
.hc-sector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}
.hc-sector-name { font-weight: 600; font-size: 0.88rem; }
.hc-sector-progress { font-size: 0.78rem; color: #6b7280; font-weight: 500; }
.hc-progress-done { color: #16a34a; font-weight: 700; }
.hc-table-scroll { overflow-x: auto; }
.hc-table { width: 100%; border-collapse: collapse; }
.hc-table td { padding: 0.4rem 0.75rem; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
.hc-table tr:last-child td { border-bottom: none; }
.hc-col-grade { width: 36px; text-align: center; }
.hc-dot {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.18);
  vertical-align: middle;
}
.hc-col-num { font-family: monospace; font-size: 0.82rem; color: #374151; white-space: nowrap; width: 60px; }
.hc-col-input { min-width: 150px; }
.hc-col-status { width: 40px; text-align: right; white-space: nowrap; }
.hc-missing td { background: #fffbeb; }
.hc-input {
  width: 100%;
  padding: 0.28rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.82rem;
  background: #fff;
}
.hc-input:focus { outline: 2px solid #3b82f6; border-color: transparent; }
.hc-status { font-size: 0.75rem; }
.hc-status.hc-saved { color: #16a34a; }
.hc-status.hc-saving { color: #f59e0b; }
.hc-status.hc-err { color: #ef4444; }

/* ── Desktop tweaks (≥640px) ─────────────────────────────── */
@media (min-width: 640px) {
  .main-content { padding: 1.75rem 1.5rem 3rem; }
  .gym-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .gym-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); transform: translateY(-2px); }
  .header-top { padding: 0 1.5rem; }
  .tab-nav { padding: 0 1rem; }
  .gym-card-colors { flex-direction: row; align-self: center; }
  td { padding: 0.75rem 1rem; }
  thead th { padding: 0.7rem 1rem; }
  .form-actions .btn { flex: unset; }
  .boulder-form { padding: 2rem; }
}

/* ── Admin stats ─────────────────────────────────────────── */
.admin-table { min-width: 560px; }
.col-name  { font-weight: 600; }
.col-email { font-size: 0.82rem; color: #666; }
.col-num   { text-align: right; font-variant-numeric: tabular-nums; width: 3.5rem; }
.col-flags { white-space: nowrap; }
.admin-legacy { color: #aaa; }
.admin-flag {
  display: inline-block;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px; border-radius: 4px; margin-right: 3px;
}
.admin-flag-admin  { background: #1e2a4a; color: #fff; }
.admin-flag-anon   { background: #f3f4f6; color: #6b7280; }
.admin-flag-legacy { background: #fef3c7; color: #92400e; }

[data-theme="dark"] .col-email         { color: var(--text-muted); }
[data-theme="dark"] .admin-legacy      { color: var(--text-muted); }
[data-theme="dark"] .admin-flag-admin  { background: #2d3f6b; color: #93c5fd; }
[data-theme="dark"] .admin-flag-anon   { background: var(--surface2); color: var(--text-muted); }
[data-theme="dark"] .admin-flag-legacy { background: rgba(245,158,11,.15); color: #fbbf24; }

/* ── Landing page hero ───────────────────────────────────── */
.hero {
  padding: 1.75rem 0 1.5rem;
  max-width: 600px;
}
.hero-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 0.65rem;
}
.hero-sub {
  font-size: 0.95rem;
  color: #555;
  line-height: 1.6;
  margin-bottom: 1.25rem;
}
.feature-list {
  list-style: none;
  padding: 0; margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #444;
}
.feature-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 0.05rem;
}
.gym-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1.75rem 0 0.75rem;
}
.gym-list-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888;
}

[data-theme="dark"] .hero-sub      { color: var(--text-muted); }
[data-theme="dark"] .feature-list li { color: var(--text-muted); }
[data-theme="dark"] .gym-list-label  { color: var(--text-muted); }

/* ── Gym info page ───────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.info-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 1.1rem 1.25rem;
}
.info-card-full { grid-column: 1 / -1; }
.info-card-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888;
  margin-bottom: 0.75rem;
}
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid #f0f2f5;
  font-size: 0.88rem;
}
.info-row:last-child { border-bottom: none; }
.info-row-full { border-bottom: none; color: #555; }
.info-label { color: #888; flex-shrink: 0; }
.info-value { font-weight: 500; text-align: right; }
.info-link { font-weight: 500; color: #1e2a4a; word-break: break-all; text-align: right; }
.info-link:hover { text-decoration: underline; }
.info-prose {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #444;
  white-space: pre-line;
}
.info-grade-list { display: flex; flex-direction: column; gap: 0.45rem; }
.info-grade-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
}
.info-grade-name { font-weight: 600; min-width: 5rem; }
.info-grade-range { color: #888; font-size: 0.82rem; }

@media (max-width: 540px) {
  .info-grid { grid-template-columns: 1fr; }
  .info-card-full { grid-column: unset; }
}

[data-theme="dark"] .info-card          { background: var(--surface); box-shadow: none; }
[data-theme="dark"] .info-card-title    { color: var(--text-muted); }
[data-theme="dark"] .info-row           { border-color: var(--border); }
[data-theme="dark"] .info-label         { color: var(--text-muted); }
[data-theme="dark"] .info-value         { color: var(--text); }
[data-theme="dark"] .info-link          { color: #93c5fd; }
[data-theme="dark"] .info-prose         { color: var(--text); }
[data-theme="dark"] .info-row-full      { color: var(--text-muted); }
[data-theme="dark"] .info-grade-range   { color: var(--text-muted); }

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.78rem;
  color: #9ca3af;
}
.site-footer a { color: #9ca3af; text-decoration: underline; }

/* ── Comments ────────────────────────────────────────────── */
.comment-section { margin-top: 1.5rem; }
.comment-total {
  font-size: 0.75rem; font-weight: 700;
  background: #e8eaf6; color: #3949ab;
  padding: 2px 8px; border-radius: 12px;
}
#comment-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.comment-bubble {
  background: #f7f8fc;
  border-radius: 12px;
  padding: 0.6rem 0.85rem;
}
.comment-meta {
  display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.3rem;
}
.comment-author { font-weight: 700; font-size: 0.85rem; }
.comment-time { font-size: 0.72rem; color: #9ca3af; }
.comment-body { font-size: 0.9rem; line-height: 1.45; word-break: break-word; }
.comment-actions {
  display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem;
}
.comment-like-btn {
  background: none; border: none; cursor: pointer;
  font-size: 0.78rem; color: #9ca3af;
  padding: 2px 6px; border-radius: 20px;
  border: 1px solid transparent;
  transition: color 0.12s, background 0.12s;
  line-height: 1.4;
}
.comment-like-btn:hover { color: #e53935; background: #fff0f0; }
.comment-like-btn.liked { color: #e53935; font-weight: 600; }
.comment-likes-static { font-size: 0.78rem; color: #9ca3af; }
.comment-delete-btn {
  background: none; border: none; cursor: pointer;
  font-size: 0.7rem; color: #d1d5db; padding: 2px 5px;
  border-radius: 6px; line-height: 1; margin-left: auto;
  transition: color 0.1s, background 0.1s;
}
.comment-delete-btn:hover { color: #e53935; background: #fff0f0; }
.comment-empty { font-size: 0.85rem; color: #9ca3af; margin: 0 0 0.75rem; }
.comment-login-hint { font-size: 0.85rem; color: #9ca3af; margin-top: 0.5rem; }
.comment-form { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.25rem; }
.comment-form textarea {
  width: 100%; box-sizing: border-box;
  padding: 0.6rem 0.8rem; font-size: 0.9rem; font-family: inherit;
  border: 1.5px solid #ddd; border-radius: 10px;
  background: #fafafa; color: inherit; resize: vertical;
  transition: border-color 0.15s;
}
.comment-form textarea:focus { outline: none; border-color: #1e2a4a; }
.comment-form-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.comment-error { font-size: 0.8rem; color: #e53935; flex: 1; }

/* Dark mode — comments */
[data-theme="dark"] .comment-bubble        { background: var(--surface2); }
[data-theme="dark"] .comment-time         { color: var(--text-muted); }
[data-theme="dark"] .comment-like-btn     { color: var(--text-muted); }
[data-theme="dark"] .comment-like-btn:hover { color: #f87171; background: rgba(239,68,68,.15); }
[data-theme="dark"] .comment-like-btn.liked { color: #f87171; }
[data-theme="dark"] .comment-delete-btn   { color: var(--border); }
[data-theme="dark"] .comment-delete-btn:hover { color: #f87171; background: rgba(239,68,68,.15); }
[data-theme="dark"] .comment-empty,
[data-theme="dark"] .comment-login-hint,
[data-theme="dark"] .comment-likes-static { color: var(--text-muted); }
[data-theme="dark"] .comment-total        { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
[data-theme="dark"] .comment-form textarea { background: var(--surface2); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .comment-form textarea:focus { border-color: #3b82f6; }
.site-footer a:hover { color: #6b7280; }
