:root {
  --bg: #0f1218;
  --surface: #171c24;
  --surface-2: #1f2632;
  --border: #2c3545;
  --text: #eef2f7;
  --muted: #93a1b5;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --start: #00ff00;
  --middle: #00aaff;
  --feet: #ffaa00;
  --finish: #ff00ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

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

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--start), var(--middle));
  box-shadow: 0 0 12px var(--middle);
}

.subtitle {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

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

.status-badge {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.status-mock {
  background: rgba(59, 130, 246, 0.14);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.4);
}

.status-ok {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.45);
}

.status-err {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.45);
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  gap: 2px;
}

.lang-btn {
  padding: 4px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 400px);
  gap: 18px;
  padding: 18px 20px;
  max-width: 1440px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.card h2 {
  margin: 0 0 12px 0;
  font-size: 1rem;
  font-weight: 600;
}

.wall-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.brush-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.brush-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.brush-btn:hover {
  border-color: #4b5a75;
}

.brush-btn.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}

.btn-primary {
  background: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: #4b5a75;
}

.btn-accent {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(59, 130, 246, 0.25));
  border-color: rgba(59, 130, 246, 0.5);
  color: #e0f2fe;
}

.btn-accent:hover {
  border-color: #60a5fa;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.34), rgba(59, 130, 246, 0.38));
}

.effect-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.effect-select {
  width: auto !important;
  min-width: 135px;
  padding: 6px 10px !important;
  font-size: 0.84rem !important;
}

.debug-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.scenario-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.scenario-group-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.scenario-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.wall-stage {
  background: linear-gradient(180deg, #1b2029 0%, #141820 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}

#wall-svg {
  width: 100%;
  height: auto;
  display: block;
  touch-action: manipulation;
}

.hold-node {
  cursor: pointer;
}

.hold-hover {
  transition: transform 0.14s ease;
  transform-origin: 0 0;
}

.hold-node:hover .hold-hover {
  transform: scale(1.12);
}

.hold-label {
  font-size: 10.5px;
  fill: #94a3b8;
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: central;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(15, 18, 24, 0.92);
  stroke-width: 3.5px;
  stroke-linejoin: round;
}

.hold-led-idx {
  font-size: 9.5px;
  fill: #cbd5e1;
  pointer-events: none;
  text-anchor: middle;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(15, 18, 24, 0.92);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.axis-label {
  font-size: 15px;
  fill: #64748b;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  user-select: none;
}

.wall-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  font-size: 0.8rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-start { background: var(--start); }
.dot-middle { background: var(--middle); }
.dot-feet { background: var(--feet); }
.dot-finish { background: var(--finish); }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.route-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.route-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--muted);
}

.form-row,
.search-row {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
}

input[type="text"],
input[type="number"],
input[type="search"],
select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
}

.feedback {
  min-height: 18px;
  font-size: 0.82rem;
}

.feedback.ok { color: #86efac; }
.feedback.err { color: #fca5a5; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel-header h2 {
  margin: 0;
}

.routes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  max-height: 460px;
  overflow-y: auto;
}

.route-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.route-item:hover {
  border-color: #4b5a75;
}

.route-item.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.16);
}

.route-meta {
  min-width: 0;
}

.route-title {
  font-weight: 600;
  font-size: 0.93rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-sub {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.grade-pill {
  background: #2b3446;
  color: #e2e8f0;
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 700;
}

.route-delete {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
}

.route-delete:hover {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.12);
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Debug wall grid */
.debug-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 380px);
  gap: 18px;
  padding: 18px 20px;
  max-width: 1440px;
  margin: 0 auto;
}

.led-matrix {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 6px;
  max-width: 560px;
  margin: 0 auto;
  background: #10141b;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.led-cell {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 1px solid #2a3242;
  background: #1b222e;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  line-height: 1.15;
  color: #94a3b8;
  transition: background 0.15s, box-shadow 0.15s, color 0.15s;
}

.led-cell strong {
  font-size: 0.75rem;
}

.led-cell.lit {
  color: #090d14;
  font-weight: 700;
  border-color: rgba(255, 255, 255, 0.7);
}

pre.json-box {
  margin: 0;
  padding: 12px;
  background: #0d1016;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #cbd5e1;
  font-size: 0.8rem;
  overflow: auto;
  max-height: 480px;
}

@media (max-width: 960px) {
  .layout,
  .debug-layout,
  .arcade-layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }
}

.arcade-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 420px);
  gap: 18px;
  padding: 18px 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.arcade-matrix {
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.arcade-controls-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.arcade-hud {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.score-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.score-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.score-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
}

.arcade-status {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #dbeafe;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: center;
}

.arcade-status.game-over {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.flap-btn {
  width: 100%;
  min-height: 112px;
  border-radius: 14px;
  border: 2px solid #facc15;
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.28), rgba(234, 179, 8, 0.16));
  color: #fef08a;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform 0.06s ease, background 0.1s ease;
}

.flap-btn:active {
  transform: scale(0.97);
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.45), rgba(234, 179, 8, 0.3));
}

.arcade-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 11px 4px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s;
}

.user-pill:hover {
  border-color: var(--primary);
}

.user-pill-guest {
  padding: 6px 12px;
}

.user-avatar-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.route-author {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #cbd5e1;
}

.auth-wrap {
  max-width: 480px;
  margin: 28px auto;
  padding: 0 16px;
}

.tab-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.tab-btn {
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(300px, 460px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px 20px;
  max-width: 1180px;
  margin: 0 auto;
}

.avatar-studio {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.avatar-preview-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.avatar-preview-box {
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--border);
  background: #0d1118;
  display: inline-flex;
}

.style-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.avatar-presets {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.avatar-preset-btn {
  padding: 4px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, transform 0.1s;
}

.avatar-preset-btn:hover {
  border-color: #60a5fa;
  transform: translateY(-1px);
}

.avatar-preset-btn.active {
  border-color: var(--primary);
}

.profile-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

@media (max-width: 960px) {
  .profile-layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }
}

/* Zero-scroll desktop & mobile-first app layout for main wall editor */
body.page-main {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.page-main .topbar {
  padding: 8px 16px;
  gap: 10px;
  flex-shrink: 0;
}

body.page-main .layout {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  padding: 10px 14px;
}

body.page-main .wall-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 10px 12px;
  gap: 8px;
}

body.page-main .wall-toolbar {
  margin-bottom: 0;
  gap: 6px;
  flex-shrink: 0;
}

body.page-main .brush-group {
  gap: 5px;
}

body.page-main .brush-btn {
  padding: 5px 9px;
  font-size: 0.8rem;
}

.wall-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.counter-pill {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 9px;
  white-space: nowrap;
}

.btn-compact {
  padding: 5px 10px;
  font-size: 0.8rem;
}

body.page-main .wall-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px;
}

body.page-main #wall-svg {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1000 / 1080;
  display: block;
}

body.page-main .sidebar {
  min-height: 0;
  overflow: hidden;
  gap: 0;
}

.sidebar-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px;
  gap: 10px;
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 6px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar-tab-btn:hover {
  color: var(--text);
}

.sidebar-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.tab-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 18, 24, 0.38);
  color: inherit;
}

.sidebar-panel {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.sidebar-panel.active {
  display: flex;
}

body.page-main .routes-list {
  flex: 1;
  min-height: 0;
  max-height: none;
  margin-top: 0;
  overflow-y: auto;
}

.lights-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ambient-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.mobile-nav {
  display: none;
}

.mobile-nav-btn {
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mobile-nav-btn.active {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.45);
}

.routes-top-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  flex-shrink: 0;
}

.filters-drawer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.filter-pills .brush-btn {
  padding: 4px 8px;
  font-size: 0.76rem;
}

.filter-pills .brush-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.filter-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.filter-grid-2 select,
.filter-grid-2 input {
  padding: 6px 8px;
  font-size: 0.82rem;
}

.filter-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-checks .toggle-chip {
  font-size: 0.78rem;
  padding: 4px 8px;
}

.route-item.sent-flash {
  border-left: 3px solid #f59e0b;
}

.route-item.sent-redpoint {
  border-left: 3px solid #22c55e;
}

.route-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ascent-btn {
  padding: 4px 7px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.ascent-btn:hover {
  color: var(--text);
  border-color: #64748b;
}

.ascent-btn.flash-active {
  background: rgba(245, 158, 11, 0.22);
  border-color: #f59e0b;
  color: #fde68a;
}

.ascent-btn.redpoint-active {
  background: rgba(34, 197, 94, 0.22);
  border-color: #22c55e;
  color: #bbf7d0;
}

.send-count-pill {
  color: #86efac;
  font-weight: 600;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stat-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-chip span {
  font-size: 0.74rem;
  color: var(--muted);
}

.stat-chip strong {
  font-size: 1.2rem;
  color: var(--text);
}

@media (max-width: 960px) {
  body.page-main .topbar {
    padding: 6px 10px;
    gap: 6px;
  }

  body.page-main .topbar .subtitle,
  body.page-main .hide-mobile {
    display: none;
  }

  body.page-main .topbar-controls {
    gap: 6px;
  }

  body.page-main .layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 8px;
    padding-bottom: 64px;
    gap: 0;
  }

  body.page-main.mobile-view-wall .wall-card {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  body.page-main.mobile-view-wall .sidebar {
    display: none;
  }

  body.page-main.mobile-view-panel .wall-card {
    display: none;
  }

  body.page-main.mobile-view-panel .sidebar {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  body.page-main .sidebar-tabs {
    display: none;
  }

  body.page-main .wall-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  body.page-main .wall-toolbar::-webkit-scrollbar {
    display: none;
  }

  body.page-main .brush-group {
    flex-wrap: nowrap;
    flex-shrink: 0;
  }

  body.page-main .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 56px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 20;
    padding: 4px;
    gap: 4px;
  }
}

.project-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.grade-pill.has-votes {
  border: 1px dashed rgba(56, 189, 248, 0.55);
}

.bookmark-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  padding: 0;
  transition: all 0.15s ease;
}

.bookmark-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.bookmark-btn.saved {
  background: rgba(56, 189, 248, 0.18);
  border-color: #38bdf8;
  color: #7dd3fc;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.modal-title {
  font-weight: 700;
  font-size: 1rem;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
}

.modal-field select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.list-modal-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.list-check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.88rem;
}

.list-check-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex: 1;
}

.inline-create-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-create-form input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.list-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.list-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  cursor: pointer;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.35;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.toast.ok {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(20, 42, 30, 0.96);
  color: #86efac;
}

.toast.err {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(45, 20, 24, 0.96);
  color: #fca5a5;
}

@media (max-width: 960px) {
  .toast-container {
    bottom: 66px;
    left: 12px;
    right: 12px;
    max-width: none;
  }
}

.stat-chip-link {
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease;
}

.stat-chip-link:hover {
  border-color: var(--accent);
}

.leaderboard-layout {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lb-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

.lb-rules-hint {
  font-size: 0.8rem;
  margin-top: 10px;
  line-height: 1.4;
}

.lb-me-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-color: rgba(56, 189, 248, 0.45);
}

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

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.lb-row.is-me {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

.lb-rank {
  min-width: 34px;
  text-align: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--muted);
}

.lb-rank.medal {
  font-size: 1.2rem;
}

.lb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

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

.lb-display-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-stats-line {
  font-size: 0.78rem;
  margin-top: 2px;
}

.lb-points {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}

.lb-points strong {
  font-size: 1.05rem;
  color: #38bdf8;
}

.lb-points span {
  font-size: 0.72rem;
  color: var(--muted);
}

.pyramid-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.76rem;
  color: var(--muted);
}

.legend-dot-flash::before,
.legend-dot-rp::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

.legend-dot-flash::before {
  background: #f59e0b;
}

.legend-dot-rp::before {
  background: #22c55e;
}

.pyramid-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.pyramid-row {
  display: grid;
  grid-template-columns: 46px 1fr 28px;
  align-items: center;
  gap: 8px;
}

.pyramid-bar {
  height: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  display: flex;
}

.pyramid-fill-flash {
  background: #f59e0b;
  height: 100%;
}

.pyramid-fill-redpoint {
  background: #22c55e;
  height: 100%;
}

.pyramid-count {
  font-size: 0.78rem;
  text-align: right;
}

.heatmap-wrap {
  overflow-x: auto;
  padding-bottom: 4px;
}

.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 3px;
  width: max-content;
}

.heatmap-cell {
  width: 11px;
  height: 11px;
  padding: 0;
  border-radius: 2.5px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: #0f172a;
  cursor: pointer;
}

.heatmap-cell.level-0 {
  background: #0f172a;
}

.heatmap-cell.level-1 {
  background: #14532d;
}

.heatmap-cell.level-2 {
  background: #15803d;
}

.heatmap-cell.level-3 {
  background: #22c55e;
}

.heatmap-cell.level-4 {
  background: #86efac;
}

.heatmap-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  min-height: 18px;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
}

/* Admin boards page */
.admin-layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 20px 32px;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.admin-col-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.admin-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.admin-boards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-board-card {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-board-card.is-active {
  border-color: rgba(59, 130, 246, 0.55);
}

.admin-board-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-board-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 700;
}

.admin-board-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
}

.admin-board-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-badge-active {
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(59, 130, 246, 0.45);
  color: #93c5fd;
}

.admin-board-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-board-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.token-banner {
  border-color: rgba(245, 158, 11, 0.5);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08), transparent);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.token-warn {
  color: #fbbf24;
  font-size: 0.86rem;
  margin: 0;
}

.token-code {
  display: block;
  padding: 9px 11px;
  border-radius: 8px;
  background: #0b1220;
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  word-break: break-all;
  color: #e2e8f0;
}

.token-snippet {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #0b1220;
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  overflow-x: auto;
  color: #cbd5e1;
}

.admin-denied-wrap {
  max-width: 520px;
  margin: 48px auto;
  padding: 0 16px;
}

@media (max-width: 900px) {
  .admin-layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }
}
