/* ═══════════════════════════════════════════════════════════
   NIRMĀNA — Practice Architecture
   Visual Identity: Dark Rajasthani maroon, spatial, rigorous
   WCAG AA compliant contrast ratios throughout
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg-primary: #12100e;
  --bg-secondary: #1a1613;
  --bg-card: #1e1a17;
  --bg-card-elevated: #252019;
  --bg-chaya: #0c0a08;
  --bg-dock: #181410;

  --fg-primary: #e6dfd6;
  --fg-secondary: #cfc3b4;
  --fg-tertiary: #a89888;
  --fg-muted: #958578;

  --border: #3d332d;
  --border-subtle: #2e2824;
  --accent: #d4a574;
  --accent-dim: #b8926a;
  --accent-glow: rgba(212, 165, 116, 0.12);
  --error: #e88888;

  --territory-chaya: #c9a88a;
  --territory-nirmiti: #86b89a;
  --territory-artha: #c9a882;
  --territory-maya: #9aadc4;
  --territory-parampara: #b092cc;

  --dock-radius: 20px;

  --font-sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Libre Baskerville', 'Georgia', serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --deck-progress: 0;
  --deck-hue: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--fg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-tertiary); }

::selection {
  background: rgba(212, 165, 116, 0.28);
  color: var(--fg-primary);
}

[hidden] { display: none !important; }

.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;
}

/* ═══════════════════════════════════════════════════════════
   ANIMATED BACKGROUND
   Layered gradients that shift with deck progress
   ═══════════════════════════════════════════════════════════ */

.nirmana-gradient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 85% 65% at 18% 82%, rgba(72, 38, 32, 0.22) 0%, transparent 58%),
    radial-gradient(ellipse 75% 55% at 82% 18%, rgba(58, 42, 36, 0.18) 0%, transparent 52%),
    radial-gradient(ellipse 95% 75% at 50% 48%, rgba(42, 32, 28, 0.28) 0%, transparent 68%),
    linear-gradient(168deg, #0b0908 0%, #14110f 35%, #181412 65%, #12100e 100%);
  overflow: hidden;
}

/* Slow fluid “breath” — low contrast so WebGL stays the hero layer */
.nirmana-gradient-bg::before {
  content: "";
  position: absolute;
  inset: -14%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 44% 40% at 30% 30%, rgba(212, 165, 116, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 44% at 70% 70%, rgba(88, 48, 42, 0.14) 0%, transparent 58%),
    radial-gradient(ellipse 58% 52% at 50% 50%, rgba(36, 28, 24, 0.12) 0%, transparent 64%);
  mix-blend-mode: soft-light;
  opacity: 0.55;
  animation: nirmana-bg-breathe 28s ease-in-out infinite alternate;
}

@keyframes nirmana-bg-breathe {
  0%   { transform: translate(-2.5%, 1.5%) scale(1.02); }
  50%  { transform: translate(0.5%, -1%) scale(1.05); }
  100% { transform: translate(2.2%, -2.2%) scale(1.08); }
}

.gradient-layer-drift {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2s ease;
  background:
    radial-gradient(ellipse 60% 50% at 20% 80%, rgba(180, 140, 118, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 20%, rgba(110, 150, 130, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse 70% 60% at 50% 50%, rgba(120, 132, 160, 0.035) 0%, transparent 55%);
  animation: drift-slow 40s ease-in-out infinite alternate;
}

@keyframes drift-slow {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(2%, -1%) scale(1.02); }
  66%  { transform: translate(-1%, 2%) scale(0.98); }
  100% { transform: translate(1%, -2%) scale(1.01); }
}

.nirmana-grain::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.028;
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMDAiIGhlaWdodD0iMzAwIj48ZmlsdGVyIGlkPSJuIj48ZmVUdXJidWxlbmNlIGJhc2VGcmVxdWVuY3k9Ii43NSIgbnVtT2N0YXZlcz0iNCIgc3RpdGNoVGlsZXM9InN0aXRjaCIvPjwvZmlsdGVyPjxyZWN0IHdpZHRoPSIzMDAiIGhlaWdodD0iMzAwIiBmaWx0ZXI9InVybCgjbikiIG9wYWNpdHk9IjEiLz48L3N2Zz4=");
}

#app {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ═══════════════════════════════════════════════════════════
   MOBILE SPLASH — polite redirect for small screens
   ═══════════════════════════════════════════════════════════ */

.mobile-splash {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 60%, rgba(92, 26, 26, 0.3) 0%, rgba(18, 16, 14, 0.98) 70%),
    var(--bg-primary);
}

.mobile-splash-content {
  max-width: 22rem;
}

.mobile-splash-content .mono-label {
  display: block;
  margin-bottom: 1.5rem;
  color: var(--accent);
}

.mobile-splash-content h1 {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  color: var(--fg-primary);
}

.mobile-splash-content p {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--fg-secondary);
  margin-bottom: 2rem;
}

.mobile-splash-content .btn-accent {
  display: inline-block;
  text-decoration: none;
}

@media (max-width: 768px), (max-width: 1280px) and (orientation: landscape) and (max-height: 560px) {
  .mobile-splash { display: flex; }
  body:not(.splash-dismissed) #app { display: none !important; }
}

body.splash-dismissed .mobile-splash {
  display: none !important;
}

.mobile-splash-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
  margin-top: 1rem;
}

.three-bg-host {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.three-bg-host canvas {
  display: block;
}

body.reduce-motion .gradient-layer-drift {
  animation: none !important;
}

body.reduce-motion .nirmana-gradient-bg::before {
  animation: none !important;
  opacity: 0.5;
  transform: none;
}

body.reduce-motion .card-view--abyss .card-shell {
  animation: none !important;
}

body.reduce-motion #death-overlay:not([hidden]) .death-content {
  animation: none !important;
}

body.reduce-motion .breathe {
  animation: none !important;
}

body.reduce-motion .card-grid-container,
body.reduce-motion .card-grid-territory {
  animation: none !important;
}

body.reduce-motion .card-view {
  animation: none !important;
}

body.reduce-motion .card-grid-tile {
  transition: none !important;
}

body.reduce-motion .card-grid-tile:hover:not(:disabled) {
  transform: none !important;
}

body.reduce-motion .card-grid-tile:active:not(:disabled) {
  transform: none !important;
}

body.reduce-motion .card-grid-progress-fill,
body.reduce-motion .progress-ring-fill {
  transition: none !important;
}

body.reduce-motion .toast {
  animation: none !important;
}

body.reduce-motion .scroll-hint {
  animation: none !important;
}

body.reduce-motion .scroll-arrow {
  animation: none !important;
}

body.reduce-motion .card-flow-hint {
  animation: none !important;
}

body.reduce-motion .dock-shell,
body.reduce-motion .dock-tab,
body.reduce-motion .dock-panel-area {
  transition: none !important;
}

.settings-panel .settings-toggle-row {
  padding: 0.5rem 0;
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--fg-secondary);
}

.settings-advanced {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.settings-advanced-summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--fg-tertiary);
}

.settings-advanced-body {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--fg-secondary);
}

.depth-md-preview {
  margin-top: 0.5rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--fg-secondary);
}

.depth-md-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.depth-md-stack .depth-md-preview {
  margin-top: 0;
  min-height: 2.75rem;
}

.depth-md-stack--source .depth-md-preview {
  display: none;
}

.depth-md-empty {
  font-style: italic;
  color: var(--fg-muted);
  margin: 0;
}

.depth-md-preview p { margin-bottom: 0.5rem; }
.depth-md-preview strong { color: var(--fg-primary); }

.card-chaya-gate {
  padding: 0.75rem 1.5rem 0;
}

@media (min-width: 640px) {
  .card-chaya-gate {
    padding: 0.75rem 2rem 0;
  }
}

.card-chaya-gate-text {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--territory-chaya);
  border-left: 2px solid rgba(201, 168, 138, 0.45);
  padding-left: 0.75rem;
  margin: 0;
}

.card-grid-chaya-hint {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--territory-chaya);
  margin: 0.35rem 0 0.5rem;
  padding: 0 0.15rem;
  line-height: 1.45;
}

.reversal-link--chaya {
  color: var(--territory-chaya);
}

.reversal-link--chaya:hover {
  color: var(--fg-primary);
}

body.layout-mobile .card-grid-container {
  display: none !important;
}

#carousel-wrap {
  padding: 1rem 1rem 5rem;
  max-width: 100%;
}

.carousel-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.carousel-organism {
  font-size: 0.7rem;
  margin-bottom: 1rem;
  color: var(--fg-tertiary);
}

.carousel-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.carousel-dot {
  flex: 0 0 auto;
  min-width: 4.25rem;
  min-height: 4.25rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: transform 0.15s var(--ease-spring);
}

.carousel-dot:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.carousel-dot.done {
  border-color: var(--cd, var(--accent));
}

.carousel-dot-id {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--cd, var(--accent));
}

.carousel-dot-tag {
  font-size: 0.55rem;
  color: var(--fg-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-right: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg-primary);
  font-size: 1.25rem;
  cursor: pointer;
}

body.layout-mobile .mobile-menu-btn {
  display: flex;
}

body.layout-mobile #carousel-wrap {
  display: block;
}

body:not(.layout-mobile) #carousel-wrap {
  display: none !important;
}

.mobile-desktop-link {
  position: fixed;
  top: 0.75rem;
  right: 4rem;
  z-index: 40;
  font-family: var(--font-mono);
  font-size: 0.65rem;
}

.mobile-desktop-link a {
  color: var(--fg-tertiary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--fg-primary);
  background: var(--bg-card-elevated);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.35s var(--ease-out-expo), toast-out 0.3s ease 2.7s forwards;
  max-width: 20rem;
  text-align: center;
}

.toast.toast-error {
  border-color: var(--error);
  color: var(--error);
}

.toast.toast-success {
  border-color: var(--accent);
  color: var(--accent);
}

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

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

/* ═══════════════════════════════════════════════════════════
   NOSCRIPT FALLBACK
   ═══════════════════════════════════════════════════════════ */

.noscript-msg {
  padding: 4rem 2rem;
  text-align: center;
  max-width: 28rem;
  margin: 0 auto;
}

.noscript-msg h1 {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--fg-tertiary);
  margin-bottom: 1rem;
}

.noscript-msg p {
  font-size: 0.9375rem;
  color: var(--fg-secondary);
  line-height: 1.7;
}

/* ═══════════════════════════════════════════════════════════
   TYPOGRAPHY UTILITIES — AA minimum contrast on all bgs
   ═══════════════════════════════════════════════════════════ */

.mono-label {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-tertiary);
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-tertiary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.section-hint {
  font-size: 0.9375rem;
  color: var(--fg-tertiary);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS — with micro-interactions
   ═══════════════════════════════════════════════════════════ */

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:disabled {
  pointer-events: none;
}

.btn-accent {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 1px solid rgba(212, 165, 116, 0.3);
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  color: var(--fg-primary);
  background: transparent;
  transition: all 0.3s var(--ease-spring), transform 0.15s var(--ease-spring);
}

.btn-accent:hover {
  background: rgba(212, 165, 116, 0.1);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(212, 165, 116, 0.05);
}

.btn-accent:active {
  transform: scale(0.97) translateY(0);
}

.btn-ghost {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-tertiary);
  padding: 0.5rem 0;
  background: transparent;
  transition: color 0.3s var(--ease-spring), transform 0.15s var(--ease-spring);
}

.btn-ghost:hover {
  color: var(--fg-primary);
  transform: translateY(-1px);
}

.btn-ghost:active {
  transform: scale(0.97) translateY(0);
}

.btn-outline {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-secondary);
  padding: 0.625rem 1.25rem;
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  background: transparent;
  transition: all 0.3s var(--ease-spring), transform 0.15s var(--ease-spring);
}

.btn-outline:hover {
  color: var(--fg-primary);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-outline:active {
  transform: scale(0.97) translateY(0);
}

/* ═══════════════════════════════════════════════════════════
   OVERLAYS — shared foundation
   ═══════════════════════════════════════════════════════════ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.3s var(--ease-out-expo);
}

.overlay-content {
  animation: scaleIn 0.3s var(--ease-out-expo);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

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

@keyframes depthReveal {
  from { opacity: 0; transform: translateY(8px); max-height: 0; }
  to { opacity: 1; transform: translateY(0); max-height: 60rem; }
}

/* Death Overlay — high-stakes gravity (Chāyā pool / corpse-run threshold) */
#death-overlay {
  background: radial-gradient(ellipse at 50% 60%, rgba(92, 26, 26, 0.3) 0%, rgba(8, 4, 4, 0.97) 70%);
}

#death-overlay:not([hidden]) {
  animation: death-overlay-settle 0.55s var(--ease-out-expo) forwards;
}

#death-overlay:not([hidden]) .death-content {
  animation: death-content-weight 7s ease-in-out infinite;
}

@keyframes death-overlay-settle {
  from {
    filter: brightness(0.88) saturate(0.95);
  }
  to {
    filter: brightness(1) saturate(1);
  }
}

@keyframes death-content-weight {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(2px); }
}

.death-content { max-width: 28rem; text-align: center; padding: 2rem; }
.death-content .mono-label { margin-bottom: 1.5rem; }
.death-title { font-family: var(--font-serif); font-size: 1.25rem; font-weight: 500; line-height: 1.6; margin-bottom: 0.5rem; }
.death-body { font-family: var(--font-serif); font-size: 1.0625rem; color: var(--fg-secondary); font-style: italic; line-height: 1.65; margin-bottom: 0.75rem; }
.death-instruction { font-family: var(--font-serif); font-size: 1rem; color: var(--fg-tertiary); line-height: 1.65; margin-bottom: 2rem; }

/* Parampara Gate */
#parampara-gate {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
}

.gate-content {
  max-width: 28rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.gate-content .mono-label { margin-bottom: 1rem; }
.gate-title { font-family: var(--font-serif); font-size: 1.125rem; font-weight: 500; line-height: 1.6; margin-bottom: 0.5rem; }
.gate-body { font-family: var(--font-serif); font-size: 1.0625rem; color: var(--fg-secondary); font-style: italic; line-height: 1.65; margin-bottom: 1.5rem; }
.gate-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

/* Tutorial */
#tutorial-overlay {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.tutorial-content {
  width: 100%;
  max-width: 32rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
}

.tutorial-header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.tutorial-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.tutorial-title {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tutorial-subtitle {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  color: var(--fg-secondary);
  font-style: italic;
  margin-top: 0.25rem;
}

.tutorial-body {
  padding: 1.25rem 1.5rem;
  min-height: 12rem;
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--fg-secondary);
}

.tutorial-body p { margin-bottom: 0.75rem; }
.tutorial-body p:last-child { margin-bottom: 0; }
.tutorial-body strong { color: var(--fg-primary); font-weight: 500; }

.tutorial-body .depth-example {
  border-left: 2px solid;
  padding-left: 0.75rem;
  margin-bottom: 0.75rem;
}

.tutorial-body .depth-example .mono-label { margin-bottom: 0.125rem; }

.tutorial-body .territory-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}

.tutorial-body .territory-num {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.1em;
  width: 2rem;
  flex-shrink: 0;
}

.tutorial-body .territory-name { font-weight: 500; }

.tutorial-body ol {
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.tutorial-body ol li {
  margin-bottom: 0.375rem;
}

.tutorial-body .action-callout {
  background: rgba(212, 165, 116, 0.06);
  border: 1px solid rgba(212, 165, 116, 0.15);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.tutorial-footer {
  padding: 1rem 1.5rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tutorial-dots {
  display: flex;
  gap: 0.375rem;
}

.tutorial-dot {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s var(--ease-spring);
}

.tutorial-dot:hover { transform: scale(1.3); }
.tutorial-dot.active { background: var(--accent); }

.tutorial-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ═══════════════════════════════════════════════════════════
   HEADER — sticky with progress bar
   ═══════════════════════════════════════════════════════════ */

.main-header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(18, 16, 14, 0.78);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: 48rem;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-brand {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-tertiary);
}

button.header-brand,
button.header-brand-btn {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

button.header-brand:hover,
button.header-brand:focus-visible {
  color: var(--accent);
  outline: none;
}

.header-back {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
}

.header-back:hover { color: var(--accent); }
.header-back:hover .back-arrow { transform: translateX(-2px); }

.back-arrow {
  display: inline-block;
  transition: transform 0.2s ease;
}

.header-context {
  font-size: 0.9375rem;
  color: var(--fg-tertiary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Progress Indicator */
.progress-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.progress-ring-container {
  position: relative;
  width: 1.75rem;
  height: 1.75rem;
}

.progress-ring {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.progress-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 2;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s var(--ease-out-expo);
}

.progress-label {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--fg-tertiary);
  letter-spacing: 0.05em;
  min-width: 2rem;
}

/* ═══════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════ */

.main-content {
  position: relative;
  z-index: 10;
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1.5rem 6rem;
}

/* ── Card Grid (Idle State) ── */

.card-grid-container {
  max-width: 48rem;
  min-width: 0;
  margin: 0 auto;
  animation: slideUp 0.4s var(--ease-out-expo);
}

.card-grid-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-top: 1rem;
}

.card-grid-title {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-secondary);
  margin-bottom: 0.5rem;
}

.card-grid-subtitle {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  color: var(--fg-tertiary);
  line-height: 1.65;
  max-width: 28rem;
  margin: 0 auto;
}

.card-grid-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card-grid-territory {
  min-width: 0;
  animation: slideUp 0.4s var(--ease-out-expo);
  animation-fill-mode: both;
}

.card-grid-territory:nth-child(2) { animation-delay: 0.05s; }
.card-grid-territory:nth-child(3) { animation-delay: 0.10s; }
.card-grid-territory:nth-child(4) { animation-delay: 0.15s; }
.card-grid-territory:nth-child(5) { animation-delay: 0.20s; }

.card-grid-territory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding: 0 0.25rem;
}

.card-grid-territory-label {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card-grid-territory-progress {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--fg-tertiary);
}

.card-grid-progress-bar {
  height: 2px;
  background: var(--border-subtle);
  border-radius: 1px;
  margin: 0 0.25rem 0.75rem;
  overflow: hidden;
}

.card-grid-progress-fill {
  height: 100%;
  border-radius: 1px;
  transition: width 0.6s var(--ease-out-expo);
}

.card-grid-cards {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.5rem;
}

.card-grid-tile {
  position: relative;
  min-width: 0;
  container-type: inline-size;
  container-name: card-tile;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  padding: 0.75rem 0.625rem;
  border-radius: 0.5rem;
  background: rgba(22, 20, 18, 0.45);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.2s ease, transform 0.15s var(--ease-spring);
  text-align: left;
  overflow: hidden;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.card-grid-tile:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(30, 26, 24, 0.55);
  transform: translateY(-2px);
}

.card-grid-tile:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.card-grid-tile:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.card-grid-tile-id {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.card-grid-tile-title {
  font-family: var(--font-serif);
  font-size: clamp(0.62rem, 0.48rem + 2.75cqi, 0.78rem);
  font-weight: 500;
  color: var(--fg-primary);
  line-height: 1.28;
  max-width: 100%;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
}

.card-grid-tile-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  margin-top: 0.1rem;
}

@supports not (font-size: 1cqi) {
  .card-grid-tile-title {
    font-size: 0.72rem;
  }
}

.card-grid-tile-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  border: 1px solid var(--border-subtle);
  color: var(--fg-tertiary);
}

.card-grid-tile-tag.done {
  border-color: currentColor;
  color: var(--accent);
}

.card-grid-tile-tag.chaya {
  color: var(--fg-muted);
}

.card-grid-tile-tag.boss {
  color: var(--accent);
}

.card-grid-tile-tag.locked {
  color: var(--fg-muted);
}

.card-grid-footer {
  text-align: center;
  margin-top: 2rem;
  padding: 1rem;
}

.card-grid-footer .mono-label {
  color: var(--fg-tertiary);
}

/* Scroll hint — fixed nudge, never blocks clicks (children stay pointer-events: none) */
.scroll-hint,
.scroll-hint * {
  pointer-events: none !important;
}

.scroll-hint {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 5.25rem;
  transform: translateX(-50%);
  width: auto;
  max-width: min(18rem, 92vw);
  text-align: center;
  z-index: 15;
  animation: hintPulse 4s ease-in-out infinite;
}

.scroll-hint-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-tertiary);
  opacity: 0.72;
  background: rgba(18, 16, 14, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 0.25rem 0.5rem;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.scroll-arrow {
  display: inline-block;
  animation: scrollBounce 2s ease-in-out infinite;
}

@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(2px); }
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.85; }
}

/* ═══════════════════════════════════════════════════════════
   CARD VIEW — the primary interaction surface
   ═══════════════════════════════════════════════════════════ */

.card-view {
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  animation: cardEnter 0.4s var(--ease-out-expo);
}

@keyframes cardEnter {
  from { opacity: 0; transform: translateY(16px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.card-shell {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  overflow: hidden;
  transition: box-shadow 0.3s ease;
}

/* Abyss depth: the card surface carries extra “pull” */
.card-view--abyss .card-shell {
  box-shadow:
    0 0 0 1px rgba(212, 165, 116, 0.07),
    0 12px 40px rgba(0, 0, 0, 0.45),
    inset 0 0 48px rgba(8, 2, 4, 0.35);
  animation: card-abyss-pull 8s ease-in-out infinite alternate;
}

@keyframes card-abyss-pull {
  0%   { box-shadow: 0 0 0 1px rgba(212, 165, 116, 0.06), 0 10px 36px rgba(0, 0, 0, 0.42), inset 0 0 44px rgba(8, 2, 4, 0.32); }
  100% { box-shadow: 0 0 0 1px rgba(212, 165, 116, 0.1), 0 16px 48px rgba(0, 0, 0, 0.52), inset 0 0 56px rgba(8, 2, 4, 0.42); }
}

.card-header {
  padding: 1.5rem 1.5rem 0.5rem;
}

@media (min-width: 640px) { .card-header { padding: 2rem 2rem 0.5rem; } }

.card-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.card-territory-label {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card-id-label {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg-tertiary);
  letter-spacing: 0.1em;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  line-height: 1.35;
}

@media (min-width: 640px) { .card-title { font-size: 1.75rem; } }

.card-boss-badge {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 0.5rem;
  display: inline-block;
}

/* Frame */
.card-frame {
  padding: 1.25rem 1.5rem;
}

@media (min-width: 640px) { .card-frame { padding: 1.25rem 2rem; } }

.card-frame-text {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.75;
  color: var(--fg-secondary);
}

.card-frame-text.markdown-body p {
  margin-bottom: 0.75rem;
}

.card-frame-text.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body strong {
  color: var(--fg-primary);
  font-weight: 600;
}

.markdown-body em {
  font-style: italic;
}

.depth-prompt.markdown-body {
  font-family: var(--font-serif);
}

.depth-prompt.markdown-body p {
  margin-bottom: 0.65rem;
}

.depth-prompt.markdown-body p:last-child {
  margin-bottom: 0;
}

/* Card Hint */
.card-flow-hint {
  padding: 0.5rem 1.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent-dim);
  letter-spacing: 0.08em;
  animation: slideDown 0.4s var(--ease-out-expo);
  transition: opacity 0.3s ease;
}

@media (min-width: 640px) { .card-flow-hint { padding: 0.5rem 2rem 0; } }

.card-flow-hint-icon {
  font-size: 1rem;
  animation: hintPulse 2s ease-in-out infinite;
}

/* Reversals */
.card-reversals {
  padding: 1rem 1.5rem;
}

@media (min-width: 640px) { .card-reversals { padding: 1rem 2rem; } }
.card-reversals .section-label { color: var(--accent); }

.reversals-list { display: flex; flex-direction: column; gap: 0.75rem; }

.reversal-item {
  border-left: 2px solid var(--accent);
  padding-left: 0.75rem;
}

.reversal-condition {
  font-size: 1.0625rem;
  color: var(--fg-secondary);
  font-style: italic;
  line-height: 1.6;
  margin-bottom: 0.375rem;
}

.reversal-link {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.15s var(--ease-spring);
  padding: 0.25rem 0;
}

.reversal-link:hover { color: var(--fg-primary); }
.reversal-link:active { transform: scale(0.97); }

.reversal-link:disabled {
  color: var(--fg-tertiary);
  cursor: not-allowed;
  opacity: 0.65;
}
.reversal-link:disabled:hover { color: var(--fg-tertiary); }

/* Depths */
.card-depths {
  padding: 1.5rem;
}

@media (min-width: 640px) { .card-depths { padding: 1.5rem 2rem; } }

.depths-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.depth-item {
  border-left: 2px solid var(--border);
  padding-left: 1rem;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  animation: depthReveal 0.5s var(--ease-out-expo);
}

.depth-item.current { border-left-color: var(--accent); }
.depth-item.completed { border-left-color: rgba(212, 165, 116, 0.4); }

.depth-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
  transition: opacity 0.2s ease;
}

.depth-item.completed .depth-header {
  cursor: pointer;
  user-select: none;
}

.depth-item.completed .depth-header:hover {
  opacity: 0.8;
}

.depth-level {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-tertiary);
}

.depth-check {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--accent);
}

.depth-toggle-icon {
  font-size: 0.625rem;
  color: var(--fg-tertiary);
  transition: transform 0.3s var(--ease-spring);
  display: inline-block;
}

.depth-item.collapsed .depth-toggle-icon {
  transform: rotate(-90deg);
}

.depth-content-wrapper {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.3s var(--ease-out-expo), opacity 0.3s ease;
  opacity: 1;
}

.depth-item.collapsed .depth-content-wrapper {
  grid-template-rows: 0fr;
  opacity: 0.3;
}

.depth-content-inner {
  overflow: hidden;
}

.depth-hint {
  font-size: 0.9375rem;
  color: var(--fg-tertiary);
  font-style: italic;
}

.depth-prompt {
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--fg-primary);
}

.depth-item.completed .depth-prompt { color: var(--fg-secondary); }
.depth-item[data-level="abyss"] .depth-prompt {
  font-style: italic;
  color: var(--fg-tertiary);
}

.depth-item.depth-item--abyss-active {
  border-left-width: 3px;
  border-left-color: color-mix(in srgb, var(--accent) 75%, var(--border-subtle));
  padding-left: calc(1rem - 1px);
  box-shadow: -6px 0 18px rgba(212, 165, 116, 0.05);
}

/* Writing Space */
.depth-writing-space {
  margin-top: 1rem;
  position: relative;
}

.depth-textarea {
  width: 100%;
  min-height: 7rem;
  padding: 1rem;
  background: rgba(18, 16, 14, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  color: var(--fg-primary);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.7;
  resize: vertical;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.depth-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(212, 165, 116, 0.15), inset 0 0 20px rgba(212, 165, 116, 0.03);
}

.depth-textarea::placeholder {
  color: var(--fg-muted);
  font-style: italic;
}

/* Abyss: input friction — Hick’s Law / deliberate cost; escape: Settings “Calm Abyss” or reduced motion */
.depth-abyss-writing {
  --abyss-chars: 0;
}

.abyss-oblique {
  position: relative;
  z-index: 2;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--fg-muted);
  font-style: italic;
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
  opacity: 0.9;
}

body:not(.abyss-soft) .depth-abyss-writing::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 0.5rem;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(ellipse 70% 65% at 50% 45%, transparent 25%, rgba(4, 2, 3, 0.22) 100%);
  opacity: clamp(0, calc(var(--abyss-chars) * 0.0011), 0.72);
  transition: opacity 0.12s ease;
}

.depth-abyss-writing .depth-writing-footer,
.depth-abyss-writing .depth-md-toggle,
.depth-abyss-writing .depth-md-preview {
  position: relative;
  z-index: 3;
}

body:not(.abyss-soft) .depth-textarea--abyss {
  position: relative;
  z-index: 2;
  letter-spacing: min(0.11em, calc(0.01em + var(--abyss-chars) * 0.000095em));
  text-shadow:
    0 0 calc(0.5px + var(--abyss-chars) * 0.004px) rgba(0, 0, 0, 0.35),
    0 0 calc(2px + var(--abyss-chars) * 0.012px) rgba(20, 8, 8, 0.25);
  caret-color: color-mix(in srgb, var(--accent) 55%, var(--fg-muted));
  transition: letter-spacing 0.08s ease, text-shadow 0.12s ease;
}

body:not(.abyss-soft) .depth-abyss-writing.abyss-kick {
  animation: abyss-kick 95ms ease-out;
}

@keyframes abyss-kick {
  0%   { transform: translate(0, 0); }
  22%  { transform: translate(-1px, 1px); }
  55%  { transform: translate(1px, -1px); }
  100% { transform: translate(0, 0); }
}

body.abyss-soft .depth-abyss-writing::after {
  display: none;
}

body.abyss-soft .depth-textarea--abyss {
  letter-spacing: normal;
  text-shadow: none;
  caret-color: var(--accent);
}

.depth-writing-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
}

.depth-char-count {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--fg-tertiary);
  letter-spacing: 0.05em;
}

.depth-saved-indicator {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
  opacity: 0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: opacity 0.3s ease;
}

.depth-saved-indicator.visible { opacity: 1; }

.depth-action {
  margin-top: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.15s var(--ease-spring);
  padding: 0.375rem 0;
}

.depth-action:hover { color: var(--fg-primary); }
.depth-action:active { transform: scale(0.97); }

/* Fitts: larger, clearer target for the irreversible Abyss acknowledge */
.depth-action.depth-action--heavy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  min-width: min(100%, 13rem);
  padding: 0.65rem 1.25rem;
  margin-top: 1rem;
  border: 1px solid rgba(212, 165, 116, 0.35);
  border-radius: 0.5rem;
  background: rgba(212, 165, 116, 0.07);
  letter-spacing: 0.14em;
}

.depth-action.depth-action--heavy:hover {
  background: rgba(212, 165, 116, 0.12);
  border-color: rgba(212, 165, 116, 0.5);
}

.depths-counter {
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--fg-tertiary);
  font-style: italic;
}

/* Threads */
.card-threads {
  padding: 1rem 1.5rem;
  animation: slideUp 0.4s var(--ease-out-expo);
}

@media (min-width: 640px) { .card-threads { padding: 1rem 2rem; } }

.threads-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.thread-btn {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease, transform 0.15s var(--ease-spring);
}

.thread-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--bg-primary);
  box-shadow: 0 0 20px rgba(212, 165, 116, 0.08), 0 4px 12px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

.thread-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.thread-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.thread-id {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
}

.thread-title {
  font-size: 0.875rem;
  margin-left: 0.5rem;
  color: var(--fg-primary);
}

.thread-done {
  font-size: 0.75rem;
  color: var(--accent);
  margin-left: 0.25rem;
}

.card-threads-locked {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border);
}

@media (min-width: 640px) { .card-threads-locked { padding: 0.75rem 2rem; } }

.locked-hint {
  font-size: 0.8125rem;
  color: var(--fg-tertiary);
  font-style: italic;
}

/* Artifact */
.card-artifact {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid rgba(212, 165, 116, 0.3);
  background: rgba(212, 165, 116, 0.02);
  animation: slideUp 0.4s var(--ease-out-expo);
}

@media (min-width: 640px) { .card-artifact { padding: 1.25rem 2rem; } }

.artifact-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.artifact-text {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--fg-secondary);
  font-style: italic;
  margin-bottom: 0.75rem;
}

.artifact-done-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
}

/* Footer */
.card-footer {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

@media (min-width: 640px) { .card-footer { padding: 1.25rem 2rem; } }

.card-footer-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.card-footer-hint {
  font-size: 0.8125rem;
  color: var(--fg-tertiary);
}

/* ═══════════════════════════════════════════════════════════
   DOCK NAVIGATION
   ═══════════════════════════════════════════════════════════ */

.dock-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1rem 1rem;
  pointer-events: none;
}

.dock-shell {
  pointer-events: auto;
  width: 100%;
  max-width: 28rem;
  background: linear-gradient(180deg, rgba(26, 22, 19, 0.9) 0%, rgba(18, 16, 14, 0.96) 100%);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(61, 36, 32, 0.5);
  border-radius: var(--dock-radius);
  overflow: hidden;
  box-shadow:
    0 -4px 30px rgba(0, 0, 0, 0.4),
    0 0 60px rgba(92, 26, 26, 0.08),
    inset 0 1px 0 rgba(212, 165, 116, 0.06);
}

.dock-panel-area {
  overflow: hidden;
  animation: panelOpen 0.3s var(--ease-out-expo);
}

@keyframes panelOpen {
  from { max-height: 0; opacity: 0; }
  to { max-height: 60vh; opacity: 1; }
}

.dock-panel-content {
  padding: 0.75rem;
  max-height: 50vh;
  overflow-y: auto;
}

.dock-divider {
  height: 1px;
  margin: 0 0.75rem;
  background: linear-gradient(90deg, transparent 0%, var(--border) 30%, var(--border) 70%, transparent 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.dock-divider.visible { opacity: 1; }

.dock-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
  padding: 0.375rem;
  position: relative;
}

.dock-pill {
  position: absolute;
  background: var(--accent);
  border-radius: calc(var(--dock-radius) - 4px);
  box-shadow: 0 0 16px rgba(212, 165, 116, 0.2);
  transition: all 0.3s var(--ease-spring);
  z-index: 0;
  pointer-events: none;
  opacity: 0;
}

.dock-pill.active { opacity: 1; }

.dock-tab {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.5rem 0.35rem;
  color: var(--fg-tertiary);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: calc(var(--dock-radius) - 4px);
  transition: color 0.2s ease, transform 0.15s var(--ease-spring);
  white-space: nowrap;
}

.dock-tab:hover { color: var(--fg-secondary); }
.dock-tab.active { color: var(--bg-primary); }
.dock-tab:active { transform: scale(0.96); }

.dock-tab-icon {
  width: 1rem;
  height: 1rem;
  opacity: 0.8;
}

.chaya-badge {
  margin-left: 0.25rem;
  font-weight: 700;
}

.chaya-badge.warning {
  color: var(--accent);
  animation: chaya-gravity-pulse 2.4s ease-in-out infinite;
}

@keyframes chaya-gravity-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

body.reduce-motion .chaya-badge.warning {
  animation: none;
}

/* Dock Panel Items */
.dock-panel-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s var(--ease-spring);
  border: 1px solid transparent;
  width: 100%;
  text-align: left;
  background: transparent;
}

.dock-panel-item:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(61, 36, 32, 0.3);
}

.dock-panel-item:active:not(:disabled) {
  transform: scale(0.98);
}

.dock-panel-item:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.dock-item-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
  transition: transform 0.2s var(--ease-out-quart);
}

.dock-panel-item:hover:not(:disabled) .dock-item-icon { transform: translateX(3px); }

.dock-item-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg-primary);
  transition: transform 0.2s var(--ease-out-quart);
}

.dock-panel-item:hover:not(:disabled) .dock-item-title { transform: translateX(3px); }

.dock-item-subtitle {
  font-size: 0.8125rem;
  color: var(--fg-tertiary);
}

.dock-item-tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.125rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  color: var(--fg-tertiary);
  transition: transform 0.2s var(--ease-out-quart);
  white-space: nowrap;
}

.dock-panel-item:hover:not(:disabled) .dock-item-tag { transform: translateX(-3px); }

/* Territory progress bar */
.territory-progress-bar {
  height: 1px;
  background: var(--border-subtle);
  border-radius: 1px;
  margin: 0 0.25rem 0.5rem;
  overflow: hidden;
}

.territory-progress-fill {
  height: 100%;
  border-radius: 1px;
  transition: width 0.5s var(--ease-out-expo);
}

.territory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.375rem;
  padding: 0 0.25rem;
}

.territory-label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.territory-count {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--fg-tertiary);
}

/* Cards panel */
.cards-panel-header {
  text-align: center;
  padding-bottom: 0.25rem;
}

/* Guide panel */
.guide-quick-ref {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.75rem;
}

.guide-ref-item {
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  padding: 0.625rem;
  font-size: 0.8125rem;
  color: var(--fg-secondary);
}

.guide-ref-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.guide-reset-btn {
  display: block;
  width: 100%;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--error);
  padding: 0.625rem 1rem;
  border: 1px solid rgba(224, 96, 96, 0.2);
  border-radius: 0.5rem;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease, transform 0.15s var(--ease-spring);
  margin-top: 0.25rem;
}

.guide-reset-btn:hover {
  background: rgba(224, 96, 96, 0.06);
  border-color: var(--error);
}

.guide-reset-btn:active {
  transform: scale(0.97);
}

.guide-export-btn {
  display: block;
  width: 100%;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0.625rem 1rem;
  border: 1px solid rgba(212, 165, 116, 0.2);
  border-radius: 0.5rem;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease, transform 0.15s var(--ease-spring);
  margin-top: 0.25rem;
}

.guide-export-btn:hover {
  background: rgba(212, 165, 116, 0.06);
  border-color: var(--accent);
}

.guide-export-btn:active {
  transform: scale(0.97);
}

.guide-designer-note {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.6875rem;
  line-height: 1.55;
  letter-spacing: 0.02em;
  color: var(--fg-muted);
  font-style: italic;
}

.organism-footer {
  text-align: center;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
}

/* ═══════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════ */

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(212, 165, 116, 0.1); }
  50% { box-shadow: 0 0 20px rgba(212, 165, 116, 0.25); }
}

.pulse-glow { animation: pulse-glow 2.5s ease-in-out infinite; }

@keyframes breathe {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}

.breathe { animation: breathe 4s ease-in-out infinite; }

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.btn-accent:focus-visible,
.btn-ghost:focus-visible,
.dock-tab:focus-visible,
.dock-panel-item:focus-visible,
.card-grid-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Transition lock visual indicator */
.app-transitioning .card-shell {
  opacity: 0.95;
  transition: opacity 0.15s ease;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  .card-footer { flex-direction: column; align-items: flex-start; }
  .gate-actions { flex-direction: column; }
  .gate-actions .btn-accent { width: 100%; }
  .card-grid-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 481px) and (max-width: 768px) {
  .card-grid-cards { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 769px) {
  .card-grid-cards { grid-template-columns: repeat(5, 1fr); }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .gradient-layer-drift { animation: none; }
  .nirmana-gradient-bg::before { animation: none !important; }
  .card-view--abyss .card-shell { animation: none !important; }
  #death-overlay:not([hidden]) .death-content { animation: none !important; }
}

/* Print Styles for PDF Export */
@media print {
  body * { visibility: hidden; }
  #print-journal, #print-journal * { visibility: visible; }
  #print-journal { position: absolute; left: 0; top: 0; width: 100%; color: #000; background: #fff; padding: 2rem; font-family: 'Libre Baskerville', Georgia, serif; }
  #print-journal .print-title { font-size: 2rem; margin-bottom: 1rem; }
  #print-journal .print-date { font-family: var(--font-mono); font-size: 0.8rem; margin-bottom: 2rem; color: #666; }
  #print-journal .print-intro { font-style: italic; margin-bottom: 3rem; }
  #print-journal .print-card { margin-bottom: 3rem; page-break-inside: avoid; }
  #print-journal .print-card-title { font-size: 1.5rem; margin-bottom: 0.5rem; font-weight: 600; }
  #print-journal .print-card-meta { font-family: var(--font-mono); font-size: 0.8rem; color: #666; margin-bottom: 1rem; }
  #print-journal .print-card-frame { font-style: italic; margin-bottom: 1.5rem; padding-left: 1rem; border-left: 2px solid #ccc; }
  #print-journal .print-depth { margin-bottom: 1.5rem; }
  #print-journal .print-depth-level { font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; color: #666; margin-bottom: 0.25rem; }
  #print-journal .print-depth-prompt { font-weight: 600; margin-bottom: 0.5rem; }
  #print-journal .print-depth-response { white-space: pre-wrap; font-family: 'Libre Baskerville', Georgia, serif; }
}
