/* ============================================================
   CC-Workshop Design System
   Vanilla CSS — no build step, themeable via CSS custom properties.
   ============================================================ */

/* --- Custom Properties --- */
:root {
  --primary: #d97757;
  --accent: #6a9bcc;
  --success: #788c5d;
  --dark: #141413;
  --light: #faf9f5;
  --mid-gray: #b0aea5;
  --light-gray: #e8e6dc;
  --primary-soft: rgba(217, 119, 87, 0.12);
  --accent-soft: rgba(106, 155, 204, 0.12);
  --success-soft: rgba(120, 140, 93, 0.12);
  --sidebar-width: 275px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(20, 20, 19, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 20, 19, 0.08);
  --shadow-lg: 0 8px 32px rgba(20, 20, 19, 0.12);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--light);
  color: var(--dark);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--primary-soft); color: var(--dark); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--mid-gray); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--dark); }

/* Grain overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.025;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; }

/* --- Login Screen --- */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dark);
  z-index: 1000;
}

.login-glow {
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  pointer-events: none;
}
.login-glow-1 {
  background: var(--primary);
  animation: loginGlow1 8s ease-in-out infinite;
}
.login-glow-2 {
  background: var(--accent);
  animation: loginGlow2 10s ease-in-out infinite;
}

@keyframes loginGlow1 {
  0%, 100% { top: 20%; left: 25%; }
  50% { top: 40%; left: 60%; }
}
@keyframes loginGlow2 {
  0%, 100% { top: 60%; right: 20%; }
  50% { top: 30%; right: 50%; }
}

.login-card {
  position: relative;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  margin: 1rem;
  z-index: 1;
}

.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo { width: 56px; height: 56px; margin-bottom: 0.5rem; }
.login-header h1 {
  color: var(--light);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.login-subtitle { color: var(--mid-gray); font-size: 0.9rem; }

.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  color: var(--mid-gray);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--light);
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
}
.form-group input::placeholder { color: rgba(255, 255, 255, 0.25); }
.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(217, 119, 87, 0.25);
}

.login-btn {
  width: 100%;
  padding: 0.8rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.login-btn:hover { background: #c4664a; }

.login-btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.login-error {
  color: #e57373;
  font-size: 0.85rem;
  text-align: center;
  margin-top: 1rem;
}

/* --- Admin preview (Workshop/Leaderboard viewed by an admin-only session) --- */
.admin-preview-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  margin-bottom: 1rem;
  background: rgba(217, 119, 87, 0.08);
  border: 1px solid rgba(217, 119, 87, 0.35);
  border-radius: var(--radius-md, 8px);
  font-size: 0.85rem;
  color: var(--text, #2c2a28);
}
.admin-preview-banner .admin-preview-label {
  font-weight: 700;
  color: var(--primary, #d97757);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
}
.admin-preview-banner .admin-preview-scope code {
  font-size: 0.82rem;
}
.admin-preview-banner .admin-preview-note {
  color: var(--text-muted, #7a7875);
  font-size: 0.8rem;
}
.admin-preview-banner a {
  margin-left: auto;
  color: var(--primary, #d97757);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.82rem;
}
.admin-preview-banner a:hover { text-decoration: underline; }

.admin-preview-picker {
  max-width: 640px;
  margin: 2rem auto;
  padding: 1.5rem;
}
.admin-preview-picker h2 {
  margin: 0 0 0.4rem 0;
  font-size: 1.5rem;
}
.admin-preview-picker > p {
  color: var(--text-muted, #7a7875);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.admin-preview-picker-options {
  display: grid;
  gap: 0.65rem;
}
.admin-preview-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.9rem 1.1rem;
  background: var(--bg, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.12));
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.admin-preview-option:hover {
  border-color: var(--primary, #d97757);
  transform: translateY(-1px);
}
.admin-preview-option-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.2rem;
}
.admin-preview-option-alias {
  font-size: 0.8rem;
  color: var(--text-muted, #7a7875);
}

/* --- Sub-link below the primary login button (e.g. "Admin access") --- */
.login-sublink {
  display: block;
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  transition: color 0.15s ease;
}
.login-sublink:hover {
  color: var(--primary);
  text-decoration: none;
}

/* --- OTP Verification --- */
.otp-message {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 1rem;
  line-height: 1.5;
}
.otp-group input {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.5em;
  font-family: 'JetBrains Mono', monospace;
}
.otp-back-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  font-size: 0.85rem;
  margin-top: 0.75rem;
  padding: 0.25rem;
  text-decoration: underline;
  width: 100%;
  text-align: center;
}
.otp-back-btn:hover { color: rgba(255, 255, 255, 0.8); }

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--dark);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo { height: 28px; flex-shrink: 0; }
.sidebar-title {
  color: var(--light);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}
.sidebar-event-id {
  display: block;
  color: rgba(255,255,255,0.5);
  font-size: 0.95rem;
  font-style: italic;
  font-weight: 400;
  margin-top: 0.15rem;
}
.event-lock-label {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 0.4rem;
}
.event-lock-locked { background: rgba(220, 80, 80, 0.12); color: #dc5050; }
.event-lock-unlocked { background: var(--success-soft); color: var(--success); }

.sidebar-nav { flex: 1; padding: 0.75rem 0.5rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.75rem;
  margin-bottom: 0.15rem;
  border-radius: var(--radius-sm);
  color: var(--mid-gray);
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
  text-decoration: none;
}
.nav-item:hover {
  color: var(--light);
  background: rgba(255,255,255,0.05);
  text-decoration: none;
}
.nav-item.active {
  color: var(--light);
  background: var(--primary-soft);
}
.nav-item svg { flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user {
  color: var(--light);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  background: none;
  border: none;
  color: var(--mid-gray);
  font-size: 0.8rem;
  transition: var(--transition);
}
.sidebar-logout:hover { color: var(--light); }

/* --- Mobile --- */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--dark);
  color: var(--light);
  padding: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
}
.mobile-menu-btn {
  background: none;
  border: none;
  color: var(--light);
  padding: 0.25rem;
  display: flex;
}
.mobile-title { font-weight: 600; font-size: 0.9rem; }
.mobile-points { font-size: 0.8rem; color: var(--primary); font-weight: 600; }

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
.mobile-overlay.active { display: block; }

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 2rem 2.5rem 4rem;
  max-width: calc(100vw - var(--sidebar-width));
  overflow-x: hidden;
}

/* --- Progress Section --- */
.progress-section {
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.progress-label { font-weight: 600; font-size: 0.9rem; }
.progress-points { font-size: 0.85rem; color: var(--mid-gray); font-weight: 500; }

.progress-bar {
  height: 10px;
  background: var(--light-gray);
  border-radius: 5px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--success), var(--accent));
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Prerequisites Card --- */
.prerequisites-card {
  background: var(--dark);
  color: var(--light);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
}
.prerequisites-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.prerequisites-card ul {
  list-style: none;
  padding: 0;
}
.prerequisites-card li {
  padding: 0.3rem 0;
  padding-left: 1.25rem;
  position: relative;
  font-size: 0.9rem;
  color: rgba(250,249,245,0.8);
}
.prerequisites-card li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.7rem;
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
}
.prerequisites-card code {
  background: rgba(255,255,255,0.1);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
}
.prerequisites-note {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.85rem;
  color: rgba(250,249,245,0.6);
}

/* --- Mascot Section --- */
.mascot-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.mascot-img {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  object-fit: contain;
}
.mascot-greeting { font-size: 0.9rem; color: var(--dark); line-height: 1.5; }
.mascot-greeting p { margin: 0; }

.mascot-celebration {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mascot-celebration img { width: 100px; height: 100px; object-fit: contain; }
.mascot-bounce-in { animation: clawdBounceIn 0.5s ease-out; }
.mascot-bounce-out { animation: clawdBounceOut 0.4s ease-in forwards; }

@keyframes clawdBounceIn {
  0% { transform: scale(0) translateY(50px); opacity: 0; }
  60% { transform: scale(1.2) translateY(-10px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes clawdBounceOut {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0) translateY(50px); opacity: 0; }
}

/* --- Reference Card --- */
.reference-card {
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.reference-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
  user-select: none;
}
.reference-toggle:hover { background: rgba(0,0,0,0.02); }
.reference-chevron {
  transition: transform var(--transition);
  flex-shrink: 0;
}
.reference-card.expanded .reference-chevron { transform: rotate(180deg); }

.reference-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.reference-card.expanded .reference-body { max-height: 2000px; }
.reference-body > * { padding: 0 1.25rem; }
.reference-body table {
  width: 100%;
  margin: 0 0 1rem;
  padding: 0;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.reference-body th, .reference-body td {
  padding: 0.5rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--light-gray);
}
.reference-body th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mid-gray);
}
.reference-body h4 {
  padding: 0.75rem 1.25rem 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--mid-gray);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.reference-body p {
  padding: 0.25rem 1.25rem 1rem;
  font-size: 0.85rem;
  color: var(--mid-gray);
}
.reference-body a { color: var(--primary); }

/* Code blocks inside reference cards (e.g., one-shot prompts) */
.reference-body pre {
  position: relative;
  background: var(--dark);
  color: var(--light);
  margin: 0.5rem 1.25rem 1rem;
  padding: 1rem 2.75rem 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.reference-body pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* <details>/<summary> inside reference cards for expandable prompt sections */
.reference-body details {
  margin: 0 1.25rem 0.75rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.reference-body details summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  list-style: none;
  background: rgba(0,0,0,0.02);
  transition: background var(--transition);
  user-select: none;
}
.reference-body details summary:hover { background: rgba(0,0,0,0.05); }
.reference-body details summary::-webkit-details-marker { display: none; }
.reference-body details summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.5rem;
  transition: transform 0.2s ease;
  color: var(--mid-gray);
}
.reference-body details[open] summary::before { transform: rotate(90deg); }
.reference-body details > *:not(summary) {
  padding-left: 1rem;
  padding-right: 1rem;
}
.reference-body details > p:first-of-type {
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--dark);
}
.reference-body details pre {
  margin: 0.5rem 0 1rem;
}

/* Intro paragraph(s) and bulleted list directly inside a reference card.
   Overrides the muted greys used by the troubleshooting card so prose is readable. */
.reference-body > p {
  padding: 0.75rem 1.25rem 0.5rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--dark);
}
.reference-body > p:last-of-type {
  padding-bottom: 1rem;
}
.reference-body > ul {
  margin: 0;
  padding: 0 1.25rem 0.25rem 2.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--dark);
  list-style-type: disc;
}
.reference-body > ul li { margin-bottom: 0.35rem; }
.reference-body > ul li:last-child { margin-bottom: 0; }

/* Icon-based copy button — only used in the prompts section */
.copy-icon-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: var(--transition);
}
.copy-icon-btn:hover {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
}
.copy-icon-btn.copied {
  color: var(--success);
  border-color: var(--success);
  background: rgba(120,140,93,0.15);
}

/* --- Task Section --- */
.task-section { margin-bottom: 2rem; }
.task-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--dark);
}
.task-section-hint {
  font-size: 0.85rem;
  color: var(--mid-gray);
  margin-bottom: 1rem;
}

/* --- Task Card --- */
.task-card {
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow-sm);
  animation: taskSlideIn 0.3s ease both;
  transition: var(--transition);
}
.task-card:hover { box-shadow: var(--shadow-md); }

@keyframes taskSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.task-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
}
.task-icon { flex-shrink: 0; display: flex; align-items: center; }
.task-chevron { transition: transform var(--transition); }
.task-card.expanded .task-chevron { transform: rotate(180deg); }

.task-info { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 0.95rem; }
.task-subtitle {
  font-size: 0.8rem;
  color: var(--mid-gray);
  margin-top: 0.15rem;
}
.task-locked-hint { font-style: italic; }

.task-badge {
  flex-shrink: 0;
  padding: 0.25rem 0.65rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-core { background: var(--primary-soft); color: var(--primary); }
.badge-bonus { background: var(--accent-soft); color: var(--accent); }

/* Task body — expand/collapse */
.task-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.task-card.expanded .task-body { max-height: 5000px; }

.task-content {
  padding: 0 1.25rem 1rem;
  font-size: 0.9rem;
  line-height: 1.7;
}
.task-content p { margin-bottom: 0.75rem; }
.task-content ul, .task-content ol { margin: 0.5rem 0 1rem 1.5rem; }
.task-content li { margin-bottom: 0.35rem; }
.task-content strong { font-weight: 600; }

.task-content h3 { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 0.5rem; }
.task-content h4 { font-size: 0.9rem; font-weight: 600; margin: 1rem 0 0.4rem; }

.task-content img {
  border-radius: var(--radius-sm);
  margin: 0.75rem 0;
  box-shadow: var(--shadow-sm);
}

/* Tables inside tasks */
.task-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.85rem;
}
.task-content th, .task-content td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: 1px solid var(--light-gray);
}
.task-content th {
  background: rgba(0,0,0,0.02);
  font-weight: 600;
}

/* Code blocks */
.task-content code {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  background: rgba(0,0,0,0.05);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}
.task-content pre {
  position: relative;
  background: var(--dark);
  color: var(--light);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin: 0.75rem 0;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}
.task-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Copy button on code blocks */
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.3rem 0.6rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  color: var(--mid-gray);
  font-size: 0.7rem;
  font-family: inherit;
  transition: var(--transition);
}
.copy-btn:hover { background: rgba(255,255,255,0.2); color: var(--light); }

/* Callouts */
.task-tip, .task-note, .task-warning {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin: 0.75rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
}
.task-tip { background: var(--accent-soft); border-left: 3px solid var(--accent); }
.task-note { background: var(--primary-soft); border-left: 3px solid var(--primary); }
.task-warning { background: rgba(220, 80, 80, 0.1); border-left: 3px solid #dc5050; }

/* Task completion states */
.task-completed {
  background: var(--success-soft);
  border-color: rgba(120, 140, 93, 0.2);
  opacity: 0.65;
}
.task-completed:hover { opacity: 0.8; }

.task-locked {
  opacity: 0.45;
  cursor: not-allowed;
}
.task-locked .task-header { cursor: not-allowed; }
.task-locked:hover { box-shadow: var(--shadow-sm); }
.task-locked-banner {
  margin: 0.5rem 1.25rem 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--dark);
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Task actions */
.task-actions {
  padding: 0 1.25rem 1.25rem;
  display: flex;
  justify-content: flex-end;
}
.task-complete-btn {
  padding: 0.5rem 1.25rem;
  background: var(--success);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
}
.task-complete-btn:hover { filter: brightness(1.1); }
.task-complete-btn.completed {
  background: var(--light-gray);
  color: var(--mid-gray);
}

/* --- Tabs (Advanced Workflows) --- */
.task-tabs,
.tabs-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--light-gray);
  margin: 1rem 0 0;
  overflow-x: auto;
}
.tab-btn {
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--mid-gray);
  white-space: nowrap;
  transition: var(--transition);
}
.tab-btn:hover { color: var(--dark); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content { display: none; padding: 1rem 0; }
.tab-content.active { display: block; }

/* Try-it sections */
.try-it-section { margin: 0.75rem 0; }
.try-it-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--primary);
}
.try-it-toggle svg { transition: transform var(--transition); }
.try-it-section.expanded .try-it-toggle svg { transform: rotate(90deg); }
.try-it-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.try-it-section.expanded .try-it-body { max-height: 1000px; }

/* --- Leaderboard --- */
.leaderboard-wrapper { max-width: 100%; }
.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.leaderboard-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.leaderboard-title-row h1 { font-size: 1.5rem; font-weight: 700; }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  background: var(--success-soft);
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--success);
}
.live-dot {
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.cast-mode-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  transition: var(--transition);
}
.cast-mode-btn:hover { background: var(--light-gray); }

.leaderboard-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--mid-gray);
  font-size: 0.95rem;
}

.leaderboard-table {
  width: 100%;
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}
.leaderboard-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mid-gray);
  border-bottom: 1px solid var(--light-gray);
  background: rgba(0,0,0,0.01);
}
.leaderboard-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(0,0,0,0.03);
  font-size: 0.9rem;
}
.leaderboard-table tr:last-child td { border-bottom: none; }

.rank-cell { width: 50px; }
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  background: var(--mid-gray);
}
.rank-1 { background: linear-gradient(135deg, #f7d774, #e6b422); color: #7a5c00; }
.rank-2 { background: linear-gradient(135deg, #d0d0d0, #a8a8a8); color: #444; }
.rank-3 { background: linear-gradient(135deg, #e0a87a, #c78547); color: #5a3518; }

.points-cell { white-space: nowrap; }
.steps-cell { white-space: nowrap; color: var(--mid-gray); font-size: 0.85rem; }

.leaderboard-bar {
  height: 8px;
  background: var(--light-gray);
  border-radius: 4px;
  overflow: hidden;
  min-width: 100px;
}
.leaderboard-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width 0.6s ease;
}

/* --- Cast Mode --- */
.cast-stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.08);
  flex-wrap: wrap;
}
.cast-stat { text-align: center; flex: 1; min-width: 100px; }
.cast-stat-value { font-size: 2.5rem; font-weight: 800; color: var(--primary); }
.cast-stat-label { font-size: 0.8rem; font-weight: 500; color: var(--mid-gray); margin-top: 0.25rem; }
.cast-stat-progress { flex: 2; min-width: 200px; }
.cast-progress-bar { margin-top: 0.75rem; }

body.cast-mode {
  background: var(--dark);
  color: var(--light);
}
body.cast-mode .sidebar { display: none; }
body.cast-mode .mobile-header { display: none; }
body.cast-mode .main-content {
  margin-left: 0;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}
body.cast-mode .leaderboard-title-row h1 { color: var(--light); font-size: 2rem; }
body.cast-mode .leaderboard-table { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.08); }
body.cast-mode .leaderboard-table th { color: var(--mid-gray); border-color: rgba(255,255,255,0.08); background: transparent; }
body.cast-mode .leaderboard-table td { color: var(--light); border-color: rgba(255,255,255,0.04); }
body.cast-mode .leaderboard-bar { background: rgba(255,255,255,0.1); }
body.cast-mode .cast-mode-btn { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.15); color: var(--light); }
body.cast-mode .cast-mode-btn:hover { background: rgba(255,255,255,0.15); }
body.cast-mode .steps-cell { color: rgba(255,255,255,0.5); }

/* --- Admin --- */
.admin-login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}
.admin-login-card {
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.admin-login-card h2 { margin-bottom: 0.5rem; font-size: 1.25rem; }
.admin-login-card p { color: var(--mid-gray); font-size: 0.9rem; margin-bottom: 1.5rem; }
.admin-login-card .form-group input {
  background: var(--light);
  color: var(--dark);
  border-color: var(--light-gray);
}
.admin-login-card .form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(217, 119, 87, 0.15);
}
.admin-login-card .login-btn { margin-top: 0.5rem; }

.admin-wrapper {}
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.admin-header h1 { font-size: 1.5rem; font-weight: 700; }
.admin-controls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.admin-workshop-filter {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: white;
  outline: none;
}
.admin-workshop-filter:focus { border-color: var(--primary); }

.admin-export-btn, .admin-logout-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  background: white;
  transition: var(--transition);
}
.admin-export-btn:hover, .admin-logout-btn:hover { background: var(--light-gray); }

/* Admin stat cards */
.admin-stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.admin-stat-card {
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.admin-stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}
.admin-stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--mid-gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* Histogram */
.admin-histogram-section { margin-bottom: 2rem; }
.admin-histogram-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.admin-histogram {
  display: flex;
  align-items: flex-end;
  gap: 0;
  height: 260px;
  padding: 0 0.5rem;
  overflow: hidden;
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.histogram-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
  padding: 0.4rem 0.1rem;
  min-width: 0;
}
.histogram-count {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--mid-gray);
  min-height: 0.9rem;
  line-height: 1;
}
.histogram-bar {
  width: 80%;
  max-width: 40px;
  border-radius: 4px 4px 2px 2px;
  transition: height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.histogram-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--mid-gray);
}

/* Completion bar */
.admin-completion-section { margin-bottom: 2rem; }
.admin-completion-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; }
.admin-progress-bar { height: 12px; }
.admin-completion-label {
  font-size: 0.8rem;
  color: var(--mid-gray);
  margin-top: 0.5rem;
}

/* Participants table */
.admin-participants-section { margin-bottom: 2rem; overflow-x: auto; }
.admin-search-row { margin-bottom: 1rem; }
.admin-search {
  width: 100%;
  max-width: 320px;
  padding: 0.6rem 1rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
  background: white;
}
.admin-search:focus { border-color: var(--primary); }

.admin-participant-table {
  width: 100%;
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.admin-participant-table th {
  padding: 0.7rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mid-gray);
  border-bottom: 1px solid var(--light-gray);
  position: sticky;
  top: 0;
  background: white;
}
.admin-participant-table td {
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(0,0,0,0.03);
}
.admin-participant-table tr:nth-child(even) td { background: rgba(0,0,0,0.01); }
.admin-participant-table tr:last-child td { border-bottom: none; }

.workshop-cell { color: var(--mid-gray); font-size: 0.8rem; }

.admin-mini-bar {
  display: inline-block;
  width: 60px;
  height: 6px;
  background: var(--light-gray);
  border-radius: 3px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 0.4rem;
}
.admin-mini-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--success), var(--accent));
}
.admin-mini-pct { font-size: 0.75rem; color: var(--mid-gray); }

.admin-delete-participant {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; line-height: 1; color: var(--mid-gray);
  padding: 0.15rem 0.4rem; border-radius: var(--radius-sm);
}
.admin-delete-participant:hover { color: #dc5050; background: rgba(220,80,80,0.08); }

/* Sortable table headers */
.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-th:hover { color: var(--primary); }
.sort-active { color: var(--primary); }

/* Admin tabs */
.admin-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--light-gray);
}
.admin-tab {
  padding: 0.65rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--mid-gray);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: var(--transition);
}
.admin-tab:hover { color: var(--dark); }
.admin-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Admin sub-tab content area */
.admin-tab-content { min-height: 200px; }

/* Event cards / table */
.admin-event-table {
  width: 100%;
  min-width: 600px;
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.admin-event-table th {
  padding: 0.7rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mid-gray);
  border-bottom: 1px solid var(--light-gray);
  background: white;
}
.admin-event-table td {
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(0,0,0,0.03);
}
.admin-event-table tr:nth-child(even) td { background: rgba(0,0,0,0.01); }
.admin-event-table tr:last-child td { border-bottom: none; }
.admin-event-table tbody tr { cursor: pointer; transition: var(--transition); }
.admin-event-table tbody tr:hover td { background: var(--primary-soft); }

.event-status {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.event-status-active { background: var(--success-soft); color: var(--success); }
.event-status-archived { background: rgba(0,0,0,0.05); color: var(--mid-gray); }

/* Event create form */
.admin-form-card {
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  max-width: 560px;
  box-shadow: var(--shadow-sm);
}
.admin-form-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}
.admin-form-card .form-group {
  margin-bottom: 1rem;
}
.admin-form-card label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--dark);
}
.admin-form-card input,
.admin-form-card select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--light);
  color: var(--dark);
  outline: none;
  transition: var(--transition);
}
.admin-form-card input:focus,
.admin-form-card select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(217, 119, 87, 0.15);
}
.admin-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.admin-form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.admin-btn-primary {
  padding: 0.55rem 1.25rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.admin-btn-primary:hover { opacity: 0.9; }
.admin-btn-secondary {
  padding: 0.55rem 1.25rem;
  background: white;
  color: var(--dark);
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.admin-btn-secondary:hover { background: var(--light-gray); }

/* Event detail header */
.admin-event-detail-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.admin-event-detail-header h2 { font-size: 1.25rem; font-weight: 700; }
.admin-back-btn {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  background: white;
  cursor: pointer;
  transition: var(--transition);
}
.admin-back-btn:hover { background: var(--light-gray); }

.admin-event-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.admin-event-meta-item {
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}
.admin-event-meta-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mid-gray);
  margin-bottom: 0.25rem;
}
.admin-event-meta-value {
  font-size: 0.95rem;
  font-weight: 600;
}

/* Template browser */
.admin-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.admin-template-card {
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.admin-template-card:hover { box-shadow: var(--shadow-md); }
.admin-template-card h4 { font-size: 1rem; font-weight: 700; margin-bottom: 0.25rem; }
.admin-template-card p { font-size: 0.8rem; color: var(--mid-gray); margin-bottom: 0.75rem; }
.admin-template-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--mid-gray);
}
.admin-template-stat { font-weight: 600; }
.admin-template-stat span { color: var(--primary); }

/* Timer panel */
.admin-timer-panel {
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.admin-timer-display { text-align: center; min-width: 140px; }
.admin-timer-clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
.admin-timer-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--mid-gray);
  margin-top: 0.15rem;
}
.admin-timer-controls {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.admin-timer-progress { flex: 1; min-width: 120px; }

/* Template step editor */
.tpl-step-card {
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.tpl-step-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  flex-wrap: wrap;
}
.tpl-step-number {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--mid-gray);
  min-width: 1.5rem;
}
.tpl-step-title-preview {
  font-size: 0.85rem;
  font-weight: 600;
  flex: 1;
}
.tpl-step-actions {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}
.tpl-step-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--light-gray);
}
.tpl-step-body .form-group { margin-bottom: 0.75rem; }
.tpl-step-body label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--dark);
}
.tpl-step-body input,
.tpl-step-body select,
.tpl-step-body textarea {
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--light);
  color: var(--dark);
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}
.tpl-step-body input:focus,
.tpl-step-body select:focus,
.tpl-step-body textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(217, 119, 87, 0.15);
}
.tpl-content-area {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 120px;
}

/* Content Code/Preview toggle */
.tpl-content-toggle {
  display: flex;
  margin-bottom: 0.5rem;
}
.tpl-toggle-btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--light);
  border: 1px solid var(--light-gray);
  color: var(--mid-gray);
  cursor: pointer;
  transition: var(--transition);
}
.tpl-toggle-btn:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.tpl-toggle-btn:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: none;
}
.tpl-toggle-btn.active {
  background: white;
  color: var(--dark);
  border-color: var(--primary);
  position: relative;
  z-index: 1;
}
.tpl-toggle-btn:hover:not(.active) {
  background: var(--light-gray);
}
.tpl-format-btn {
  margin-left: 0.5rem;
}

/* Content preview (reuses .task-content styles) */
.tpl-content-preview {
  min-height: 120px;
  padding: 0.75rem;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-sm);
  background: white;
}
.tpl-content-preview:empty::before {
  content: 'Nothing to preview';
  color: var(--mid-gray);
  font-style: italic;
}

/* Auto-save status indicator */
.tpl-save-status {
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 0.5rem;
  transition: var(--transition);
}
.tpl-status-dirty { color: var(--primary); }
.tpl-status-saving { color: var(--mid-gray); }
.tpl-status-saved { color: var(--success); }
.tpl-status-error { color: #dc5050; }

/* Admin docs tab */
.admin-docs { font-size: 0.85rem; line-height: 1.6; }
.admin-docs h3 { font-size: 1rem; font-weight: 600; margin: 0 0 0.5rem; border-bottom: 2px solid var(--light-gray); padding-bottom: 0.4rem; }
.admin-docs h4 { font-size: 0.85rem; font-weight: 600; margin: 0.75rem 0 0.3rem; }
.admin-docs p { margin-bottom: 0.4rem; }
.admin-docs code { font-family: 'JetBrains Mono', monospace; font-size: 0.8em; background: rgba(0,0,0,0.05); padding: 0.1rem 0.35rem; border-radius: 3px; }
.admin-docs pre code { background: none; padding: 0; }
.admin-docs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.admin-docs-grid > section { min-width: 0; }
.admin-docs table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-top: 0.3rem; }
.admin-docs th { text-align: left; padding: 0.3rem 0.5rem; border-bottom: 2px solid var(--light-gray); font-weight: 600; }
.admin-docs td { padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--light-gray); }
.admin-docs tr:last-child td { border-bottom: none; }

/* Empty state */
.admin-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--mid-gray);
  font-size: 0.9rem;
}

/* Copy button helper (inline) */
.admin-copy-btn {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  background: var(--light);
  border: 1px solid var(--light-gray);
  border-radius: 3px;
  cursor: pointer;
  transition: var(--transition);
}
.admin-copy-btn:hover { background: var(--light-gray); }

/* --- Toast --- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}
.toast {
  padding: 0.7rem 1.25rem;
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
  font-weight: 500;
  animation: toastIn 0.4s ease;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-undo { border-left: 3px solid var(--mid-gray); }
.toast-error { border-left: 3px solid #dc5050; }
.toast-info { border-left: 3px solid var(--accent); }
.toast-exit { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(20px); }
}

/* --- Spinner --- */
.spinner-container {
  display: flex;
  justify-content: center;
  padding: 3rem;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--light-gray);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Utilities --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.text-center { text-align: center; }
.text-muted { color: var(--mid-gray); }

/* --- Responsive (768px) --- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .mobile-header { display: flex; }
  .main-content {
    margin-left: 0;
    padding: 1rem 1rem 3rem;
    max-width: 100vw;
  }
  .leaderboard-bar-cell { display: none; }
  .admin-stat-cards { grid-template-columns: repeat(2, 1fr); }
  .admin-header { flex-direction: column; align-items: flex-start; }
  .admin-form-row { grid-template-columns: 1fr; }
  .admin-tabs { overflow-x: auto; }
  .admin-event-meta { grid-template-columns: 1fr 1fr; }
  .leaderboard-header { flex-direction: column; align-items: flex-start; }
  .cast-stats { flex-direction: column; gap: 1rem; }
  .cast-stat-value { font-size: 2rem; }

  body.cast-mode .main-content { padding: 1rem; }
  body.cast-mode .leaderboard-title-row h1 { font-size: 1.5rem; }
}
@media (max-width: 1200px) {
  .admin-docs-grid { grid-template-columns: 1fr; }
}

/* ===== Analytics workstream — chart helpers (Phase 11) ===== */

/* Stat card grid */
.chart-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.chart-stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.chart-stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.chart-stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}
.chart-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}
.chart-stat-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.chart-stat-primary  { border-left: 3px solid var(--primary); }
.chart-stat-success  { border-left: 3px solid var(--success); }
.chart-stat-warn     { border-left: 3px solid #e8a87c; }
.chart-stat-danger   { border-left: 3px solid #d97757; }
.chart-stat-neutral  { border-left: 3px solid var(--border); }

/* Vertical histogram */
.chart-histogram {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  padding: 0.5rem 0.25rem 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}
.chart-histogram-col {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  height: 100%;
  min-width: 0;
}
.chart-histogram-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  height: 0.85rem;
  line-height: 0.85rem;
}
.chart-histogram-bar {
  width: 100%;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
  flex-shrink: 0;
  min-height: 0;
  transition: height 0.25s ease;
}
.chart-histogram-col {
  height: calc(100% - 1.6rem);
}
.chart-histogram-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
  height: 0.85rem;
}

/* Horizontal funnel */
.chart-funnel {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
}
.chart-funnel-row {
  display: grid;
  grid-template-columns: 100px 1fr 90px;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.8rem;
}
.chart-funnel-label {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-funnel-bar-wrap {
  background: var(--border);
  height: 14px;
  border-radius: 4px;
  overflow: hidden;
}
.chart-funnel-bar {
  background: var(--primary);
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.chart-funnel-meta {
  font-size: 0.78rem;
  color: var(--text);
  font-weight: 600;
  text-align: right;
}
.chart-funnel-pct {
  color: var(--text-muted);
  font-weight: 500;
}

/* Sparkline */
.chart-sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  height: 32px;
  width: 100%;
  max-width: 200px;
}
.chart-sparkline-bar {
  flex: 1 1 auto;
  background: var(--primary);
  border-radius: 1px;
  min-height: 0;
  opacity: 0.85;
}

/* Empty state */
.chart-empty {
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

/* Stalled participant row highlight */
.participant-row.row-stalled {
  background: rgba(217, 119, 87, 0.06);
  border-left: 3px solid #d97757;
}
.participant-row.row-stalled td:first-child {
  font-weight: 600;
  color: #d97757;
}
.row-stalled-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #d97757;
  background: rgba(217, 119, 87, 0.1);
  border: 1px solid rgba(217, 119, 87, 0.3);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 0.4rem;
}

/* Reporting tab layout */
.reporting-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.reporting-controls select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}
.reporting-section {
  margin-bottom: 1.5rem;
}
.reporting-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  color: var(--text);
}
.reporting-event-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.reporting-event-table th,
.reporting-event-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.reporting-event-table th {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}
.reporting-event-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}
.reporting-event-table tbody tr:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.02));
}

/* Live controls (auto-refresh toggle) */
.live-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.live-controls label {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.live-pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50%      { opacity: 1; transform: scale(1.15); }
}
.live-pulse-off {
  background: var(--border);
  animation: none;
}

/* ===== Template editor conflict modal (Phase A.3 optimistic locking) ===== */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.admin-modal {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.admin-modal h3 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.admin-modal p { margin: 0 0 0.75rem; line-height: 1.5; }
.admin-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}
