/* ============================================================
   Insper AI · MNIST Challenge — design system
   Ethereal Lab vibe: deep OLED, emerald accent, Geist typography
   ============================================================ */

:root {
  /* Color — surfaces */
  --c-bg: #0a0a0c;
  --c-surface-0: #0f1014;
  --c-surface-1: #14151b;
  --c-surface-2: #1a1c24;
  --c-surface-3: #22242e;

  /* Color — ink */
  --c-text: #eceef4;
  --c-text-muted: #9096a6;
  --c-text-dim: #5c6274;

  /* Color — borders (hairlines) */
  --c-hairline: rgba(255, 255, 255, 0.06);
  --c-hairline-strong: rgba(255, 255, 255, 0.10);
  --c-hairline-soft: rgba(255, 255, 255, 0.03);

  /* Color — accent (muted emerald) */
  --c-accent: #5ac4a0;
  --c-accent-soft: rgba(90, 196, 160, 0.16);
  --c-accent-dim: rgba(90, 196, 160, 0.06);
  --c-accent-ink: #0a1813;

  /* Color — semantic */
  --c-danger: #e26d7a;
  --c-danger-soft: rgba(226, 109, 122, 0.14);
  --c-warn: #d9a76b;

  /* Radii */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-2xl: 36px;
  --r-pill: 999px;

  /* Spacing scale (8pt) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;
  --s-24: 96px;
  --s-32: 128px;

  /* Type */
  --f-sans: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --f-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Motion */
  --ease-swift: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-emphasized: cubic-bezier(0.2, 0.8, 0.2, 1);
  --d-fast: 180ms;
  --d-mid: 320ms;
  --d-slow: 640ms;

  /* Elevations — diffused, no harsh darks */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md:
    0 12px 28px -14px rgba(0, 0, 0, 0.6),
    0 2px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg:
    0 40px 80px -40px rgba(0, 0, 0, 0.8),
    0 12px 28px -14px rgba(0, 0, 0, 0.4);

  /* Inner highlight for nested cores */
  --inset-hl: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

* { box-sizing: border-box; }
*::selection { background: var(--c-accent-soft); color: var(--c-text); }

html, body { margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--f-sans);
  font-size: 14.5px;
  line-height: 1.55;
  font-weight: 400;
  letter-spacing: -0.005em;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ---------- Background atmosphere ---------- */
.bg-mesh {
  position: fixed;
  inset: -20vh -20vw;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(40vw 40vw at 78% 12%, rgba(90, 196, 160, 0.12), transparent 60%),
    radial-gradient(38vw 38vw at 12% 88%, rgba(90, 130, 210, 0.09), transparent 60%),
    radial-gradient(60vw 50vw at 50% 50%, rgba(200, 160, 255, 0.03), transparent 70%);
  filter: blur(40px) saturate(1.1);
}
.bg-grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.7 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.page {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--s-10) var(--s-6) var(--s-24);
}

/* ---------- Nav (fluid island) ---------- */
.nav-shell {
  position: sticky;
  top: var(--s-5);
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 0 var(--s-4);
  margin-top: var(--s-5);
  margin-bottom: var(--s-8);
}
.nav-pill {
  display: flex;
  align-items: center;
  gap: var(--s-8);
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-5);
  background: rgba(15, 16, 20, 0.55);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--c-hairline);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-md), var(--inset-hl);
}
.nav-brand {
  display: flex; align-items: center; gap: var(--s-3);
  color: var(--c-text);
  text-decoration: none;
  font-weight: 500;
}
.nav-brand-mark {
  width: 30px; height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-logo {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 0 10px rgba(120, 80, 255, 0.35));
  transition: filter var(--d-mid) var(--ease-swift);
}
.nav-brand:hover .brand-logo {
  filter: drop-shadow(0 0 14px rgba(150, 90, 255, 0.55));
}
.nav-brand-text {
  display: flex; flex-direction: column; line-height: 1.1;
  font-size: 0.875rem;
}
.nav-brand-eyebrow {
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--c-text-dim);
}
.nav-links {
  display: flex; align-items: center; gap: var(--s-1);
  padding-right: var(--s-2);
}
.nav-link {
  color: var(--c-text-muted);
  text-decoration: none;
  font-size: 0.825rem;
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-pill);
  transition: color var(--d-fast) var(--ease-swift), background var(--d-fast) var(--ease-swift);
}
.nav-link:hover { color: var(--c-text); background: rgba(255, 255, 255, 0.04); }
.nav-link.is-active {
  color: var(--c-text);
  background: rgba(255, 255, 255, 0.06);
}
@media (max-width: 640px) {
  .nav-pill { gap: var(--s-3); width: 100%; }
  .nav-brand-eyebrow { display: none; }
}

/* ---------- Typography ---------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--c-accent-dim);
  border: 1px solid rgba(90, 196, 160, 0.18);
  color: var(--c-accent);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.eyebrow::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: var(--r-pill);
  background: var(--c-accent);
  box-shadow: 0 0 8px var(--c-accent);
}

h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.018em; color: var(--c-text); }
.h-display {
  font-size: clamp(2.2rem, 4.6vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: -0.028em;
  font-weight: 500;
}
.h-1 { font-size: 1.65rem; line-height: 1.12; letter-spacing: -0.02em; }
.h-2 { font-size: 1.1rem; line-height: 1.25; letter-spacing: -0.01em; font-weight: 500; }
.h-3 { font-size: 0.875rem; font-weight: 500; letter-spacing: 0; color: var(--c-text); }

.muted { color: var(--c-text-muted); }
.dim { color: var(--c-text-dim); }
.mono { font-family: var(--f-mono); font-feature-settings: 'tnum' 1, 'ss01' 1; }

/* ---------- Section header ---------- */
.section-head {
  display: flex; flex-direction: column; gap: var(--s-3);
  margin-bottom: var(--s-10);
  max-width: 720px;
}
.section-head p { margin: 0; color: var(--c-text-muted); font-size: 0.95rem; }

/* ---------- Double-bezel card ---------- */
.shell {
  background: rgba(255, 255, 255, 0.012);
  border: 1px solid var(--c-hairline-soft);
  border-radius: var(--r-2xl);
  padding: 6px;
  box-shadow: var(--shadow-md);
}
.core {
  background: var(--c-surface-1);
  border: 1px solid var(--c-hairline);
  border-radius: calc(var(--r-2xl) - 8px);
  padding: var(--s-8);
  box-shadow: var(--inset-hl);
}

/* Simpler one-level card for dense contexts */
.card {
  background: var(--c-surface-1);
  border: 1px solid var(--c-hairline);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  box-shadow: var(--inset-hl);
}
.card-sm { padding: var(--s-4); border-radius: var(--r-md); }

/* ---------- Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-4); }
.field-label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--c-text-muted);
}
.field-hint { font-size: 0.75rem; color: var(--c-text-dim); }

input[type="text"], input[type="password"], input[type="number"],
input[type="file"], select, textarea {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  background: var(--c-surface-2);
  color: var(--c-text);
  border: 1px solid var(--c-hairline);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-family: var(--f-sans);
  font-size: 0.875rem;
  line-height: 1.3;
  transition:
    border-color var(--d-fast) var(--ease-swift),
    background var(--d-fast) var(--ease-swift),
    box-shadow var(--d-fast) var(--ease-swift);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(90, 196, 160, 0.45);
  background: var(--c-surface-2);
  box-shadow: 0 0 0 3px var(--c-accent-soft);
}
input[type="file"] {
  padding: 8px 10px;
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  margin-right: 10px;
  background: var(--c-surface-3);
  border: 1px solid var(--c-hairline);
  color: var(--c-text);
  padding: 6px 12px;
  border-radius: var(--r-xs);
  font-family: var(--f-sans);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background var(--d-fast) var(--ease-swift);
}
input[type="file"]::file-selector-button:hover { background: var(--c-surface-0); }

select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='none' stroke='%239096a6' stroke-width='1.2' d='M1 1l4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--c-surface-2);
  --btn-bg-hover: var(--c-surface-3);
  --btn-fg: var(--c-text);
  --btn-ring: var(--c-hairline);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-ring);
  border-radius: var(--r-pill);
  padding: 10px 16px;
  padding-right: 14px;
  font-family: var(--f-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform var(--d-fast) var(--ease-spring),
    background var(--d-fast) var(--ease-swift),
    border-color var(--d-fast) var(--ease-swift);
  box-shadow: var(--inset-hl);
}
.btn:hover { background: var(--btn-bg-hover); }
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

.btn-accent {
  --btn-bg: var(--c-accent);
  --btn-bg-hover: color-mix(in oklab, var(--c-accent) 88%, white);
  --btn-fg: var(--c-accent-ink);
  --btn-ring: transparent;
}
.btn-ghost {
  --btn-bg: transparent;
  --btn-bg-hover: rgba(255, 255, 255, 0.05);
  --btn-ring: transparent;
}
.btn-danger-ghost {
  --btn-bg: transparent;
  --btn-bg-hover: var(--c-danger-soft);
  --btn-fg: var(--c-danger);
  --btn-ring: transparent;
}

/* Button-in-button trailing icon (magnetic) */
.btn .btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, 0.18);
  transition:
    transform var(--d-mid) var(--ease-spring),
    background var(--d-fast) var(--ease-swift);
}
.btn-accent .btn-icon { background: rgba(0, 0, 0, 0.18); }
.btn:hover .btn-icon { transform: translate(2px, -1px) scale(1.05); }
.btn .btn-icon i { font-size: 12px; }

.btn-sm { padding: 6px 12px; font-size: 0.75rem; }
.btn-block { width: 100%; justify-content: center; }

/* Icon-only button */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--c-text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--d-fast) var(--ease-swift);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--c-text); }
.icon-btn.danger:hover { background: var(--c-danger-soft); color: var(--c-danger); }
.icon-btn i { font-size: 15px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: calc(100dvh - 160px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-shell { width: 100%; max-width: 420px; }
.login-core { padding: var(--s-10) var(--s-8); }
.login-head {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--s-3); margin-bottom: var(--s-8);
}
.login-badge {
  width: 56px; height: 56px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 30% 25%, rgba(90, 196, 160, 0.35), transparent 60%),
    var(--c-surface-2);
  border: 1px solid var(--c-hairline);
  color: var(--c-accent);
  font-size: 24px;
  box-shadow: var(--inset-hl), 0 0 28px rgba(90, 196, 160, 0.15);
}
.login-badge-brand {
  background:
    radial-gradient(circle at 30% 25%, rgba(150, 90, 255, 0.28), transparent 65%),
    var(--c-surface-2);
  box-shadow: var(--inset-hl), 0 0 32px rgba(120, 80, 255, 0.18);
  padding: 10px;
}
.login-badge-brand .brand-logo {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 8px rgba(150, 90, 255, 0.45));
}
.login-error {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--c-danger-soft);
  color: var(--c-danger);
  font-size: 0.8125rem;
  margin-bottom: var(--s-4);
}

/* ---------- Dashboard ---------- */
.stat-hero {
  display: grid;
  grid-template-columns: 1.1fr 1.9fr;
  gap: var(--s-6);
  margin-bottom: var(--s-8);
}
@media (max-width: 820px) { .stat-hero { grid-template-columns: 1fr; } }
.stat-big {
  display: flex; flex-direction: column; gap: var(--s-4);
  justify-content: space-between;
  min-height: 240px;
}
.stat-big-value {
  font-family: var(--f-mono);
  font-size: clamp(3rem, 7vw, 4.5rem);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: var(--c-text);
  font-feature-settings: 'tnum' 1;
}
.stat-label { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--c-text-dim); font-weight: 500; }

.digit-chart { display: flex; flex-direction: column; gap: 6px; }
.digit-row {
  display: grid;
  grid-template-columns: 24px 1fr 56px;
  align-items: center;
  gap: var(--s-4);
  padding: 6px 0;
}
.digit-num {
  font-family: var(--f-mono);
  font-size: 0.875rem;
  color: var(--c-text-muted);
  text-align: left;
}
.digit-bar-track {
  position: relative;
  height: 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.digit-bar-fill {
  position: absolute; inset: 0;
  width: var(--pct, 0%);
  background: linear-gradient(90deg, var(--c-accent), color-mix(in oklab, var(--c-accent) 60%, #9ec0ff));
  border-radius: var(--r-pill);
  transform-origin: left center;
  animation: bar-grow var(--d-slow) var(--ease-emphasized) both;
  animation-delay: var(--bar-delay, 0ms);
}
@keyframes bar-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
.digit-count {
  font-family: var(--f-mono);
  font-size: 0.8125rem;
  color: var(--c-text);
  text-align: right;
  font-feature-settings: 'tnum' 1;
}

/* ---------- Validation page layout ---------- */
.val-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: var(--s-6);
  align-items: start;
}
@media (max-width: 980px) { .val-layout { grid-template-columns: 1fr; } }

.sidebar {
  position: sticky;
  top: calc(var(--s-20) + var(--s-4));
  display: flex; flex-direction: column; gap: var(--s-4);
}
@media (max-width: 980px) { .sidebar { position: static; } }

.tab-group {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--c-surface-0);
  border: 1px solid var(--c-hairline-soft);
  border-radius: var(--r-pill);
  margin-bottom: var(--s-5);
}
.tab {
  flex: 1;
  padding: 8px 14px;
  background: transparent;
  color: var(--c-text-muted);
  border: none;
  border-radius: var(--r-pill);
  font-family: var(--f-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--d-fast) var(--ease-swift);
}
.tab:hover { color: var(--c-text); }
.tab.is-active {
  background: var(--c-surface-2);
  color: var(--c-text);
  box-shadow: var(--inset-hl);
}
[data-tab-panel] { display: none; }
[data-tab-panel].is-active { display: block; }

/* ---------- Gallery ---------- */
.gallery-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
}
.gallery-meta {
  display: flex; align-items: baseline; gap: var(--s-3);
}
.gallery-count {
  font-family: var(--f-mono);
  font-size: 0.8125rem;
  color: var(--c-text-muted);
}

.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px;
  background: var(--c-surface-1);
  color: var(--c-text-muted);
  border: 1px solid var(--c-hairline);
  border-radius: var(--r-pill);
  font-family: var(--f-mono);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--d-fast) var(--ease-swift);
}
.chip:hover { color: var(--c-text); border-color: var(--c-hairline-strong); }
.chip.is-active {
  background: var(--c-accent-soft);
  color: var(--c-accent);
  border-color: rgba(90, 196, 160, 0.35);
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.thumb {
  position: relative;
  background: var(--c-surface-1);
  border: 1px solid var(--c-hairline);
  border-radius: var(--r-md);
  padding: 4px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  box-shadow: var(--inset-hl);
  transition:
    transform var(--d-mid) var(--ease-spring),
    border-color var(--d-fast) var(--ease-swift);
  will-change: transform;
}
.thumb:hover {
  transform: translateY(-2px);
  border-color: var(--c-hairline-strong);
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f4f4f6;
  border-radius: calc(var(--r-md) - 5px);
  display: block;
}
.thumb-meta {
  position: absolute;
  inset: auto 8px 8px 8px;
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: none;
}
.thumb-meta > * { pointer-events: auto; }
.thumb-label {
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  background: rgba(10, 10, 12, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--c-text);
  border: 1px solid var(--c-hairline-strong);
}
.thumb-delete {
  width: 22px; height: 22px;
  border-radius: var(--r-pill);
  background: rgba(10, 10, 12, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--c-text-muted);
  border: 1px solid var(--c-hairline-strong);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--d-fast) var(--ease-swift), color var(--d-fast) var(--ease-swift);
  font-size: 11px;
}
.thumb:hover .thumb-delete { opacity: 1; }
.thumb-delete:hover { color: var(--c-danger); }

/* htmx swap animations on thumbs */
.thumb.htmx-swapping {
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 280ms var(--ease-swift), transform 280ms var(--ease-swift);
}

/* ---------- Empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  padding: var(--s-16) var(--s-6);
  text-align: center;
  color: var(--c-text-muted);
  border: 1px dashed var(--c-hairline-strong);
  border-radius: var(--r-lg);
}
.empty i { font-size: 32px; color: var(--c-text-dim); }
.empty-title { color: var(--c-text); font-size: 0.9375rem; font-weight: 500; }
.empty-desc { font-size: 0.8125rem; max-width: 340px; }

/* ---------- Toast ---------- */
.toast-region {
  position: fixed;
  bottom: var(--s-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: var(--s-3);
  padding: 10px 16px 10px 14px;
  background: rgba(20, 21, 27, 0.88);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--c-hairline-strong);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  color: var(--c-text);
  font-size: 0.8125rem;
  min-width: 260px;
  max-width: 480px;
  animation: toast-in var(--d-mid) var(--ease-spring);
}
.toast[data-leaving] {
  animation: toast-out var(--d-mid) var(--ease-swift) forwards;
}
.toast-dot {
  width: 6px; height: 6px; border-radius: var(--r-pill);
  background: var(--c-accent);
  box-shadow: 0 0 8px var(--c-accent);
}
.toast.is-error .toast-dot { background: var(--c-danger); box-shadow: 0 0 8px var(--c-danger); }
.toast.is-error { border-color: rgba(226, 109, 122, 0.35); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-10px) scale(0.96); }
}

/* ---------- Reveal animation ---------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  filter: blur(6px);
  transition:
    opacity 760ms var(--ease-emphasized),
    transform 760ms var(--ease-emphasized),
    filter 760ms var(--ease-emphasized);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: transform, opacity, filter;
}
[data-reveal].is-revealed {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

/* ---------- Loading states (htmx) ---------- */
.htmx-indicator {
  opacity: 0;
  transition: opacity var(--d-fast) var(--ease-swift);
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

.upload-progress {
  display: flex; align-items: center; gap: var(--s-2);
  color: var(--c-text-muted);
  font-size: 0.8125rem;
}
.spinner {
  width: 14px; height: 14px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--c-hairline-strong);
  border-top-color: var(--c-accent);
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Hero (public) ---------- */
.hero {
  padding: var(--s-20) 0 var(--s-16);
  text-align: left;
  max-width: 860px;
}
.hero .h-display { margin-top: var(--s-4); }
.hero p.lead {
  margin-top: var(--s-5);
  font-size: 1.0625rem;
  color: var(--c-text-muted);
  max-width: 600px;
  line-height: 1.55;
}
.hero-actions {
  display: flex; gap: var(--s-3); margin-top: var(--s-8);
  flex-wrap: wrap;
}

.hero-stats {
  margin-top: var(--s-16);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-5);
}
@media (max-width: 720px) { .hero-stats { grid-template-columns: 1fr; } }
.hero-stat { display: flex; flex-direction: column; gap: var(--s-1); padding: var(--s-5) 0; border-top: 1px solid var(--c-hairline); }
.hero-stat-value { font-family: var(--f-mono); font-size: 1.75rem; letter-spacing: -0.02em; }

/* ---------- Utility ---------- */
.row-between { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); flex-wrap: wrap; }
.stack > * + * { margin-top: var(--s-4); }
.stack-lg > * + * { margin-top: var(--s-6); }
.stack-tight > * + * { margin-top: var(--s-2); }
.divider { height: 1px; background: var(--c-hairline); margin: var(--s-5) 0; border: 0; }
.hide-mobile { display: initial; }
@media (max-width: 640px) { .hide-mobile { display: none; } }

/* ---------- Submissions list (trainee dashboard) ---------- */
.sub-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--c-hairline);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--c-surface-0);
}
.sub-head,
.sub-row {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-4) var(--s-5);
}
.sub-head {
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-text-dim);
  background: rgba(255, 255, 255, 0.015);
  border-bottom: 1px solid var(--c-hairline);
  font-weight: 500;
}
.sub-row + .sub-row { border-top: 1px solid var(--c-hairline-soft); }
.sub-row { transition: background var(--d-fast) var(--ease-swift); }
.sub-row:hover { background: rgba(255, 255, 255, 0.015); }

.sub-file {
  display: flex; align-items: center; gap: var(--s-3);
  min-width: 0;
}
.sub-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  border: 1px solid var(--c-hairline);
  color: var(--c-text-muted);
  flex-shrink: 0;
}
.sub-icon i { font-size: 16px; }
.sub-file-meta {
  display: flex; flex-direction: column; min-width: 0; gap: 2px;
}
.sub-name {
  font-size: 0.8125rem;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sub-sub { font-size: 0.6875rem; letter-spacing: 0.08em; }
.sub-size, .sub-time {
  font-size: 0.8125rem;
}

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--c-surface-2);
  border: 1px solid var(--c-hairline);
  color: var(--c-text-muted);
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}
.pill-dot {
  width: 5px; height: 5px;
  border-radius: var(--r-pill);
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}
.pill-pending,
.pill-scored {
  background: var(--c-accent-dim);
  border-color: rgba(90, 196, 160, 0.22);
  color: var(--c-accent);
}
.pill-received {
  background: rgba(146, 158, 255, 0.10);
  border-color: rgba(146, 158, 255, 0.22);
  color: #bfc8ff;
}
.pill-rejected {
  background: rgba(217, 167, 107, 0.10);
  border-color: rgba(217, 167, 107, 0.28);
  color: var(--c-warn);
}
.pill-error {
  background: var(--c-danger-soft);
  border-color: rgba(226, 109, 122, 0.32);
  color: var(--c-danger);
}

/* ---------- Admin attempts list ---------- */
.att-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--c-hairline);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--c-surface-0);
}
.att-head,
.att-row {
  display: grid;
  grid-template-columns:
    minmax(0, 1.1fr)
    minmax(0, 1.7fr)
    minmax(0, 0.8fr)
    minmax(0, 0.9fr)
    minmax(0, 0.9fr)
    32px;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-3) var(--s-5);
}
.att-head {
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-text-dim);
  background: rgba(255, 255, 255, 0.015);
  border-bottom: 1px solid var(--c-hairline);
  font-weight: 500;
}
.att-row + .att-row { border-top: 1px solid var(--c-hairline-soft); }
.att-row { transition: background var(--d-fast) var(--ease-swift); }
.att-row:hover { background: rgba(255, 255, 255, 0.015); }
.att-row.htmx-swapping {
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 240ms var(--ease-swift), transform 240ms var(--ease-swift);
}
.att-actor a {
  color: var(--c-text);
  text-decoration: none;
  border-bottom: 1px dashed var(--c-hairline-strong);
  font-size: 0.875rem;
}
.att-actor a:hover { color: var(--c-accent); border-bottom-color: var(--c-accent); }
.att-repo {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 0.8125rem;
  color: var(--c-text-muted);
  min-width: 0;
}
.att-repo > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-sha { font-size: 0.6875rem; color: var(--c-text-dim); }
.att-num { font-size: 0.8125rem; text-align: right; }
.att-num.accent { color: var(--c-accent); }
.att-num.muted { color: var(--c-text-dim); }
.att-delete {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-text-dim);
  border: 1px solid var(--c-hairline);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition:
    color var(--d-fast) var(--ease-swift),
    border-color var(--d-fast) var(--ease-swift),
    background var(--d-fast) var(--ease-swift);
  font-size: 13px;
}
.att-delete:hover {
  color: var(--c-danger);
  border-color: rgba(226, 109, 122, 0.35);
  background: var(--c-danger-soft);
}

@media (max-width: 820px) {
  .att-head { display: none; }
  .att-row {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    gap: var(--s-2) var(--s-4);
    padding: var(--s-4) var(--s-5);
  }
  .att-actor { grid-column: 1 / 2; grid-row: 1 / 2; }
  .att-repo { grid-column: 1 / 3; grid-row: 2 / 3; }
  .att-num:first-of-type { grid-column: 2 / 3; grid-row: 1 / 2; text-align: right; }
  .att-row > span:nth-of-type(4) { grid-column: 1 / 2; grid-row: 3 / 4; }
  .att-num:last-of-type { grid-column: 2 / 3; grid-row: 3 / 4; text-align: right; }
  .att-delete { grid-column: 2 / 3; grid-row: 1 / 2; justify-self: end; align-self: start; }
}

@media (max-width: 720px) {
  .sub-head { display: none; }
  .sub-row {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: var(--s-2) var(--s-4);
  }
  .sub-file { grid-column: 1 / 2; grid-row: 1 / 3; }
  .sub-size { grid-column: 2 / 3; grid-row: 1 / 2; text-align: right; }
  .sub-time { display: none; }
  .sub-status { grid-column: 2 / 3; grid-row: 2 / 3; text-align: right; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  [data-reveal] { opacity: 1; transform: none; filter: none; }
}
