:root {
  --bg: #0d0e11;
  --surface: #14151a;
  --surface-hover: #1b1d24;
  --border: #252830;
  --text-primary: #f0f1f4;
  --text-secondary: #8a8f9e;
  --text-muted: #50546a;
  /* CAT brand palette */
  --cat-yellow: #FFCD11;
  --cat-yellow-dim: #C9A000;
  --cat-yellow-muted: rgba(255, 205, 17, 0.12);
  /* flow category colors */
  --accent-blue: #4F8EF7;
  --accent-purple: #9B6CF7;
  --accent-red: #F76B4F;
  --accent-yellow: #F7C74F;
  --accent-cyan: #4FC9F7;
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 160ms ease;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  letter-spacing: -0.01em;
}

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

/* ── SELECTION PAGE ─────────────────────────────── */

.selection-page { display: flex; flex-direction: column; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(13, 14, 17, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cat-yellow);
}

.header-meta {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.selection-main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 64px 32px 80px;
  width: 100%;
}

.selection-hero {
  margin-bottom: 48px;
}

.selection-hero h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.selection-hero p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  letter-spacing: 0.01em;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.flow-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.flow-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--cat-yellow));
  opacity: 0;
  transition: opacity var(--transition);
}

.flow-card:hover {
  background: var(--surface-hover);
  border-color: #30333e;
  transform: translateY(-2px);
}

.flow-card:hover::before { opacity: 1; }

.flow-card:active { transform: translateY(0); }

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

.category-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--card-color, var(--cat-yellow)) 14%, transparent);
  color: var(--card-color, var(--cat-yellow));
}

.card-number {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.3;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.card-step-count {
  font-size: 12px;
  color: var(--text-secondary);
}

.card-arrow {
  margin-left: auto;
  color: var(--text-muted);
  transition: transform var(--transition), color var(--transition);
}

.flow-card:hover .card-arrow {
  transform: translateX(3px);
  color: var(--card-color, var(--accent-blue));
}

.card-preview {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #0a0b0d;
  border: 1px solid var(--border);
  margin-bottom: 4px;
}

.card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left;
  display: block;
  transition: transform 300ms ease;
}

.flow-card:hover .card-preview img {
  transform: scale(1.02);
}

/* ── VIEWER PAGE ─────────────────────────────────── */

.viewer-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.viewer-topbar {
  flex-shrink: 0;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}

.back-btn:hover { color: var(--text-primary); background: var(--surface-hover); }

.viewer-flow-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
}

.viewer-step-counter {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.viewer-progress {
  flex-shrink: 0;
  padding: 10px 24px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.viewer-progress-track {
  width: 100%;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.viewer-progress-fill {
  height: 100%;
  background: var(--viewer-color, var(--accent-blue));
  border-radius: 2px;
  transition: width 250ms ease;
}

.viewer-step-dots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.step-dot {
  height: 4px;
  flex: 1;
  max-width: 32px;
  border-radius: 2px;
  background: var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.step-dot.active { background: var(--viewer-color, var(--accent-blue)); }
.step-dot.visited { background: color-mix(in srgb, var(--viewer-color, var(--accent-blue)) 45%, transparent); }
.step-dot:hover { background: var(--viewer-color, var(--accent-blue)); opacity: 0.7; }

.viewer-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 20px;
  padding: 20px 16px;
  overflow: hidden;
  position: relative;
}

.frame-container {
  flex: 1;
  min-width: 0;
  max-width: 1080px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.tablet-frame {
  border: 10px solid #0a0a0a;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  background: #000;
  box-shadow: 0 12px 48px rgba(0,0,0,0.7);
  flex-shrink: 0;
}

.frame-img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 220px);
  width: auto;
  height: auto;
  user-select: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.frame-img.transitioning {
  opacity: 0;
  transform: scale(0.98);
}

.frame-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  letter-spacing: 0.01em;
}

.nav-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.nav-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: #363a47;
}

.nav-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* ── END SCREEN ──────────────────────────────────── */

.viewer-end-screen {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  animation: fadeIn 300ms ease;
}

.viewer-end-screen[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

.end-card {
  text-align: center;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.end-checkmark {
  color: var(--viewer-color, var(--accent-blue));
}

.end-card h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.end-card p {
  font-size: 14px;
  color: var(--text-secondary);
}

.end-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn-primary {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: var(--viewer-color, var(--accent-blue));
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition);
}

.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.btn-secondary:hover { background: var(--surface-hover); color: var(--text-primary); }

/* ── KEYBOARD HINT ───────────────────────────────── */

.keyboard-hint {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 100px;
  pointer-events: none;
  opacity: 0;
  animation: hintFade 4s ease 1s forwards;
}

@keyframes hintFade {
  0%   { opacity: 0; }
  15%  { opacity: 1; }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--border);
  font-family: inherit;
  font-size: 10px;
  color: var(--text-secondary);
}
