:root {
  --bg: #0b1220;
  --surface: #0f172a;
  --surface-elevated: #131d33;
  --border: #22314f;
  --border-subtle: #1a2742;
  --accent: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.22);
  --text: #eef2f8;
  --text-secondary: #a8b6cc;
  --text-muted: #6b7a93;
  --danger: #f87171;
  --radius: 12px;
}

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

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.top-accent {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #38bdf8 0%, #22d3ee 60%, #818cf8 100%);
  z-index: 100;
}

/* Loading & Gate */
.centered-view {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(640px 380px at 50% 18%, rgba(56, 189, 248, 0.09), transparent 70%),
    var(--bg);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.gate-card {
  width: 100%;
  max-width: 440px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 34px 28px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
}

.gate-card.shake {
  animation: shake 0.36s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 14px;
}

.eyebrow-bar {
  width: 26px;
  height: 2.5px;
  background: var(--accent);
  border-radius: 2px;
}

.gate-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}

.gate-subtitle {
  margin-top: 8px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.gate-form {
  margin-top: 26px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-row {
  position: relative;
  display: flex;
  align-items: center;
}

.input-row input {
  width: 100%;
  height: 46px;
  padding: 0 46px 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.icon-btn {
  position: absolute;
  right: 8px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.error-msg {
  min-height: 20px;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--danger);
}

.primary-btn {
  margin-top: 8px;
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
  color: #06101f;
  font-size: 14.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.primary-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.primary-btn:active:not(:disabled) {
  transform: scale(0.99);
}

.primary-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.gate-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 24px 0 16px;
}

.gate-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.gate-footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.gate-footer a:hover {
  color: var(--accent);
}

/* Protected Deck Viewer */
.viewer-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: 3px;
  background: #070d18;
  user-select: none;
  -webkit-user-select: none;
}

.viewer-header {
  height: 50px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  background: rgba(11, 18, 32, 0.96);
  border-bottom: 1px solid var(--border-subtle);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 7px;
  border: 1px solid rgba(56, 189, 248, 0.45);
  background: var(--surface-elevated);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.section-pill {
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.slide-title {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.chapter-select {
  height: 32px;
  max-width: 210px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
  cursor: pointer;
}

.ctrl-btn {
  height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ctrl-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-elevated);
}

.ctrl-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ctrl-btn-muted {
  color: var(--text-secondary);
}

/* 16:9 Stage */
.stage-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 56px;
  overflow: hidden;
}

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  width: min(100%, calc((100dvh - 134px) * 16 / 9));
  max-height: 100%;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.6);
}

.slide-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.live-overlay {
  position: absolute;
  display: block;
  object-fit: fill;
  pointer-events: none;
  -webkit-user-drag: none;
}

.stage-shield {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.stage-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 58px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.72);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.15s ease;
}

.stage-arrow:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(19, 29, 51, 0.95);
}

.stage-arrow:disabled {
  opacity: 0.2;
  cursor: default;
}

.stage-arrow-left {
  left: 10px;
}

.stage-arrow-right {
  right: 10px;
}

/* Footer */
.viewer-footer {
  height: 50px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: rgba(11, 18, 32, 0.96);
  border-top: 1px solid var(--border-subtle);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.slide-counter {
  min-width: 62px;
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-secondary);
}

.progress-track {
  position: relative;
  flex: 1 1 auto;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #22d3ee);
  border-radius: 999px;
  transition: width 0.16s ease;
}

.kbd-hints {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11.5px;
  color: var(--text-muted);
  flex: 0 0 auto;
}

.kbd-hints kbd {
  padding: 1px 5px;
  margin-right: 2px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 10.5px;
}

/* Overview Modal */
.grid-modal {
  position: fixed;
  inset: 3px 0 0 0;
  z-index: 60;
  background: rgba(7, 13, 24, 0.96);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
}

.grid-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border-subtle);
}

.grid-title-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.grid-title-group h2 {
  font-size: 16px;
  font-weight: 700;
}

.grid-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11.5px;
  cursor: pointer;
}

.filter-pill.active,
.filter-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
}

.grid-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 22px 32px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  align-content: start;
}

.thumb-card {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  color: inherit;
  padding: 0;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.thumb-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.thumb-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.thumb-img-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg);
}

.thumb-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.thumb-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(11, 18, 32, 0.85);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.thumb-anim-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.thumb-meta {
  padding: 8px 10px;
}

.thumb-sec {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.thumb-title {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Fullscreen adjustments */
:fullscreen .stage-wrap {
  padding: 10px 44px;
}

/* Responsive */
@media (max-width: 820px) {
  .slide-title,
  .kbd-hints,
  .btn-label,
  .chapter-select {
    display: none;
  }

  .stage-wrap {
    padding: 10px 10px;
  }

  .stage {
    width: min(100%, calc((100dvh - 124px) * 16 / 9));
  }

  .stage-arrow {
    display: none;
  }
}

/* Discourage accidental printing of private portfolio slides */
@media print {
  body:not(.home-page) {
    display: none !important;
  }
}

/* ============================
   Minimalist Landing Page (/)
   ============================ */
body.home-page {
  overflow-y: auto;
  overflow-x: hidden;
  background:
    radial-gradient(840px 420px at 18% 0%, rgba(56, 189, 248, 0.1), transparent 70%),
    radial-gradient(640px 380px at 88% 12%, rgba(129, 140, 248, 0.08), transparent 70%),
    var(--bg);
}

.home-shell {
  max-width: 1080px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 26px 28px 36px;
  display: flex;
  flex-direction: column;
}

.home-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.home-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.home-brand-name {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.home-nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 13.5px;
}

.home-nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.home-nav-links a:hover {
  color: var(--accent);
}

.home-nav-links a.nav-cta {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.42);
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent);
  font-weight: 600;
}

.home-nav-links a.nav-cta:hover {
  background: rgba(56, 189, 248, 0.18);
  color: #e0f2fe;
}

.home-main {
  flex: 1 1 auto;
  padding: 46px 0 36px;
}

.hero {
  max-width: 740px;
}

.hero-title {
  font-size: clamp(36px, 5vw, 52px);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.08;
  color: var(--text);
}

.hero-lead {
  margin-top: 16px;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.hero-actions {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.hero-primary {
  width: auto;
  margin-top: 0;
  padding: 0 20px;
  text-decoration: none;
}

.pill-count {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(6, 16, 31, 0.22);
  color: #06101f;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.pill-count-muted {
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
}

.secondary-btn {
  height: 46px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.78);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.secondary-btn:hover {
  border-color: var(--accent);
  background: var(--surface-elevated);
}

.ghost-btn {
  height: 46px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.ghost-btn:hover {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

/* Segmented Mode Toggle inside Viewer Header */
.mode-toggle {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.mode-btn {
  height: 26px;
  padding: 0 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.mode-btn:hover:not(.active) {
  color: var(--text);
}

.mode-btn.active {
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent);
}

.highlights {
  margin-top: 44px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.highlight-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px 20px 18px;
  transition: border-color 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.highlight-card:hover {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(19, 29, 51, 0.92);
  transform: translateY(-2px);
}

.card-index {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 10px;
}

.highlight-card h2 {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.highlight-card p {
  margin-top: 8px;
  flex: 1 1 auto;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.card-cta {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}

.card-arrow {
  transition: transform 0.15s ease;
}

.highlight-card:hover .card-arrow {
  transform: translateX(4px);
}

.home-footer {
  padding-top: 22px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.home-footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.home-footer a:hover {
  color: var(--accent);
}

.brand-mark-link {
  text-decoration: none;
}

@media (max-width: 900px) {
  .highlights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .home-shell {
    padding: 18px 18px 28px;
  }

  .home-nav-links {
    gap: 12px;
    font-size: 12.5px;
  }

  .highlights {
    grid-template-columns: 1fr;
  }
}
