/* ==========================================================================
   hoangtrung.dev — Unified 3-World Portfolio (Ethereal · Swiss · Editorial)
   Ultra-smooth 60/120fps GPU-composited transitions
   ========================================================================== */

:root {
  --font-ed-serif: 'Instrument Serif', Georgia, serif;
  --font-ed-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sw-display: 'Space Grotesk', -apple-system, sans-serif;
  --font-et-serif: 'Cormorant Garamond', Georgia, serif;
  --font-et-sans: 'Outfit', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  /* Default initial tokens: Ethereal Dark (Night) — prevents any flash on load */
  --page-bg: #07080c;
  --dock-bg: rgba(16, 18, 26, 0.72);
  --dock-border: rgba(255, 255, 255, 0.12);
  --dock-text: #f3f1ec;
  --dock-muted: rgba(243, 241, 236, 0.56);
  --dock-pill-bg: #e5c694;
  --dock-pill-text: #090a0e;
  --dock-accent: #e5c694;
  --dock-hover: rgba(255, 255, 255, 0.08);
  --dock-shadow: 0 16px 40px -14px rgba(0, 0, 0, 0.72);

  /* Editorial Light (Paper) */
  --ed-bg: #f5f1e8;
  --ed-elevated: #ece6da;
  --ed-ink: #171614;
  --ed-muted: #656057;
  --ed-faint: #928b80;
  --ed-rule: rgba(23, 22, 20, 0.13);
  --ed-rule-strong: rgba(23, 22, 20, 0.28);
  --ed-accent: #c44128;
  --ed-accent-soft: rgba(196, 65, 40, 0.09);
  --ed-hover: rgba(23, 22, 20, 0.035);

  /* Swiss Dark (Matte) */
  --sw-bg: #0b0c0e;
  --sw-panel: #101215;
  --sw-panel-alt: #0d0f12;
  --sw-ink: #f3f3ee;
  --sw-muted: #90949e;
  --sw-dim: #5d616b;
  --sw-line: rgba(243, 243, 238, 0.13);
  --sw-line-strong: rgba(243, 243, 238, 0.28);
  --sw-signal: #ff4d00;
  --sw-signal-soft: rgba(255, 77, 0, 0.13);
  --sw-led: #22c55e;
  --sw-invert-bg: #f3f3ee;
  --sw-invert-ink: #0b0c0e;

  /* Ethereal Dark (Night) */
  --et-bg: #07080c;
  --et-text: #f3f1ec;
  --et-soft: rgba(243, 241, 236, 0.74);
  --et-muted: rgba(243, 241, 236, 0.48);
  --et-accent: #e5c694;
  --et-dock-bg: rgba(16, 18, 26, 0.66);
  --et-dock-border: rgba(255, 255, 255, 0.12);
  --et-dock-hover: rgba(255, 255, 255, 0.08);
  --et-veil: radial-gradient(circle at 50% 48%, rgba(7, 8, 12, 0.14) 0%, rgba(7, 8, 12, 0.7) 100%);
}

/* Ethereal Light (Pearl) */
html[data-theme="ethereal"][data-polarity="light"] {
  --page-bg: #f7f6f2;
  --dock-bg: rgba(255, 255, 255, 0.78);
  --dock-border: rgba(20, 21, 26, 0.11);
  --dock-text: #14151a;
  --dock-muted: rgba(20, 21, 26, 0.55);
  --dock-pill-bg: #14151a;
  --dock-pill-text: #f7f6f2;
  --dock-accent: #8f6532;
  --dock-hover: rgba(20, 21, 26, 0.06);
  --dock-shadow: 0 14px 36px -14px rgba(20, 21, 26, 0.16);

  --et-bg: #f7f6f2;
  --et-text: #14151a;
  --et-soft: rgba(20, 21, 26, 0.72);
  --et-muted: rgba(20, 21, 26, 0.48);
  --et-accent: #8f6532;
  --et-dock-bg: rgba(255, 255, 255, 0.76);
  --et-dock-border: rgba(20, 21, 26, 0.11);
  --et-dock-hover: rgba(20, 21, 26, 0.06);
  --et-veil: radial-gradient(circle at 50% 48%, rgba(247, 246, 242, 0.1) 0%, rgba(247, 246, 242, 0.62) 100%);
}

/* Editorial Light (Paper) */
html[data-theme="editorial"][data-polarity="light"] {
  --page-bg: #f5f1e8;
  --dock-bg: rgba(245, 241, 232, 0.8);
  --dock-border: rgba(23, 22, 20, 0.13);
  --dock-text: #171614;
  --dock-muted: #6c665d;
  --dock-pill-bg: #171614;
  --dock-pill-text: #f5f1e8;
  --dock-accent: #c44128;
  --dock-hover: rgba(23, 22, 20, 0.06);
  --dock-shadow: 0 12px 34px -14px rgba(23, 22, 20, 0.18);
}

/* Editorial Dark (Ink) */
html[data-theme="editorial"][data-polarity="dark"] {
  --page-bg: #11100f;
  --dock-bg: rgba(22, 21, 19, 0.8);
  --dock-border: rgba(241, 237, 228, 0.13);
  --dock-text: #f1ede4;
  --dock-muted: #9c968b;
  --dock-pill-bg: #f1ede4;
  --dock-pill-text: #11100f;
  --dock-accent: #e56448;
  --dock-hover: rgba(241, 237, 228, 0.07);
  --dock-shadow: 0 14px 36px -14px rgba(0, 0, 0, 0.65);

  --ed-bg: #11100f;
  --ed-elevated: #1a1816;
  --ed-ink: #f1ede4;
  --ed-muted: #9e988e;
  --ed-faint: #6c675f;
  --ed-rule: rgba(241, 237, 228, 0.12);
  --ed-rule-strong: rgba(241, 237, 228, 0.28);
  --ed-accent: #e56448;
  --ed-accent-soft: rgba(229, 100, 72, 0.12);
  --ed-hover: rgba(241, 237, 228, 0.04);
}

/* Swiss Dark (Matte) */
html[data-theme="swiss"][data-polarity="dark"] {
  --page-bg: #0b0c0e;
  --dock-bg: rgba(16, 18, 21, 0.84);
  --dock-border: rgba(243, 243, 238, 0.16);
  --dock-text: #f3f3ee;
  --dock-muted: #90949e;
  --dock-pill-bg: #ff4d00;
  --dock-pill-text: #ffffff;
  --dock-accent: #ff4d00;
  --dock-hover: rgba(243, 243, 238, 0.07);
  --dock-shadow: 0 14px 36px -14px rgba(0, 0, 0, 0.7);
}

/* Swiss Light (Stone) */
html[data-theme="swiss"][data-polarity="light"] {
  --page-bg: #e8e7e1;
  --dock-bg: rgba(241, 240, 234, 0.86);
  --dock-border: rgba(18, 19, 22, 0.18);
  --dock-text: #121316;
  --dock-muted: #56585f;
  --dock-pill-bg: #e64200;
  --dock-pill-text: #ffffff;
  --dock-accent: #e64200;
  --dock-hover: rgba(18, 19, 22, 0.06);
  --dock-shadow: 0 12px 30px -14px rgba(18, 19, 22, 0.2);

  --sw-bg: #e8e7e1;
  --sw-panel: #f1f0ea;
  --sw-panel-alt: #e4e3dc;
  --sw-ink: #121316;
  --sw-muted: #56585f;
  --sw-dim: #7f828a;
  --sw-line: rgba(18, 19, 22, 0.15);
  --sw-line-strong: rgba(18, 19, 22, 0.34);
  --sw-signal: #e64200;
  --sw-signal-soft: rgba(230, 66, 0, 0.1);
  --sw-led: #16a34a;
  --sw-invert-bg: #121316;
  --sw-invert-ink: #f1f0ea;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  background-color: var(--page-bg);
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* ==========================================================================
   View Transitions API (Manual Click Liquid Radial Reveal — Zero Blur Lag)
   ========================================================================== */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(root) {
  z-index: 1;
}

::view-transition-new(root) {
  z-index: 2;
}

.theme-dock-wrap {
  view-transition-name: theme-dock;
}

::view-transition-group(theme-dock) {
  z-index: 100;
  animation-duration: 0.42s;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

::view-transition-old(theme-dock) {
  animation: none;
  opacity: 0;
}

::view-transition-new(theme-dock) {
  animation: none;
  opacity: 1;
}

/* ==========================================================================
   Ambient Background Layers (Pure GPU Opacity Crossfade)
   ========================================================================== */
.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 0;
  will-change: opacity;
  transition:
    opacity 0.92s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0.92s;
}

html[data-theme="editorial"] .bg-editorial,
html[data-theme="swiss"] .bg-swiss,
html[data-theme="ethereal"] .bg-ethereal {
  opacity: 1;
  visibility: visible;
  transition:
    opacity 0.92s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0s;
}

/* Instant swap when inside radial View Transition so clip-path reveals immediately */
html.is-vt-radial .bg-layer {
  transition: none !important;
}

.bg-editorial {
  background: var(--ed-bg);
}

.paper-grain {
  position: absolute;
  inset: 0;
  opacity: 0.036;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.editorial-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 50% at 82% 16%, var(--ed-accent-soft), transparent 70%),
    radial-gradient(48% 44% at 15% 88%, rgba(180, 155, 118, 0.075), transparent 72%);
}

.bg-swiss {
  background-color: var(--sw-bg);
  background-image:
    linear-gradient(to right, var(--sw-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--sw-line) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
}

.bg-ethereal {
  background: var(--et-bg);
}

#silk-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ethereal-veil {
  position: absolute;
  inset: 0;
  background: var(--et-veil);
}

/* ==========================================================================
   Unified Floating Theme Switcher Pill
   ========================================================================== */
.theme-dock-wrap {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100vw - 24px);
}

.theme-dock {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px;
  border-radius: 999px;
  background: var(--dock-bg);
  border: 1px solid var(--dock-border);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--dock-shadow);
  transition:
    background-color 0.65s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.65s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.theme-segments {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 999px;
}

.segment-indicator {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--dock-pill-bg);
  will-change: transform, width;
  transition:
    transform 0.56s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.56s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  z-index: 0;
}

.seg-btn {
  position: relative;
  z-index: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--dock-muted);
  font-family: var(--font-mono);
  font-size: 0.71rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.seg-btn:hover {
  color: var(--dock-text);
}

.seg-btn.is-active {
  color: var(--dock-pill-text);
}

.dock-sep {
  width: 1px;
  height: 16px;
  background: var(--dock-border);
  margin: 0 2px;
  flex-shrink: 0;
  transition: background-color 0.55s ease;
}

.dock-ctrl {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--dock-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.25s ease, color 0.35s ease, transform 0.16s ease;
}

.dock-ctrl:hover {
  background: var(--dock-hover);
  color: var(--dock-text);
}

.dock-ctrl:active {
  transform: scale(0.96);
}

.icon-sun,
.icon-moon {
  display: none;
  flex-shrink: 0;
}

html[data-polarity="light"] .icon-sun {
  display: block;
}

html[data-polarity="dark"] .icon-moon {
  display: block;
}

.auto-ring-wrap {
  width: 15px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auto-ring {
  transform: rotate(-90deg);
}

.ring-track {
  stroke: var(--dock-border);
  transition: stroke 0.55s ease;
}

.ring-fill {
  stroke: var(--dock-accent);
  stroke-dasharray: 47.12;
  stroke-dashoffset: 47.12;
  transition: stroke 0.55s ease;
}

.dock-ctrl.is-auto-on {
  color: var(--dock-text);
}

.dock-ctrl:not(.is-auto-on) .ring-fill {
  stroke: var(--dock-muted);
  opacity: 0.38;
}

/* ==========================================================================
   Live GPU-Composited World Stage (Zero Freeze, 120fps Silk Crossfade)
   ========================================================================== */
.worlds-stage {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  width: 100%;
}

.world {
  width: 100%;
  min-height: 100dvh;
  transform-origin: center center;
}

.world.is-active {
  position: relative;
  z-index: 3;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, 0, 0) scale(1);
}

.world.is-inactive {
  position: fixed;
  inset: 0;
  z-index: 1;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
}

/* Live crossfade states (Auto-cycle & non-VT fallback) */
.world.is-leaving {
  position: fixed;
  inset: 0;
  z-index: 2;
  visibility: visible;
  pointer-events: none;
  overflow: hidden;
  will-change: opacity, transform;
  animation: world-silk-out 0.72s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.world.is-entering {
  position: relative;
  z-index: 3;
  visibility: visible;
  pointer-events: auto;
  will-change: opacity, transform;
  animation: world-silk-in 0.88s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.world.is-entering .stagger {
  will-change: opacity, transform;
  animation: stagger-rise 0.84s cubic-bezier(0.16, 1, 0.3, 1) calc(var(--stagger, 0) * 58ms + 60ms) both;
}

/* Subtle choreographed stagger on initial boot as well */
.world.is-boot .stagger {
  animation: stagger-rise 0.9s cubic-bezier(0.16, 1, 0.3, 1) calc(var(--stagger, 0) * 75ms) both;
}

@keyframes world-silk-out {
  from {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    opacity: 0;
    transform: translate3d(0, -10px, 0) scale(0.988);
  }
}

@keyframes world-silk-in {
  from {
    opacity: 0;
    transform: translate3d(0, 10px, 0) scale(1.008);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes stagger-rise {
  from {
    opacity: 0;
    transform: translate3d(0, 14px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* ==========================================================================
   WORLD 1 — ETHEREAL (Generative Silk & Zen)
   ========================================================================== */
.world-ethereal {
  color: var(--et-text);
  font-family: var(--font-et-sans);
}

.world-ethereal ::selection {
  background: var(--et-accent);
  color: #0b0b0d;
}

.et-shell {
  min-height: 100dvh;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 96px clamp(20px, 4vw, 40px) clamp(28px, 4.5vh, 44px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  gap: 32px;
}

.et-spacer {
  height: 1px;
}

.et-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 2.8vh, 24px);
  max-width: 780px;
}

.et-kicker {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.26em;
  color: var(--et-accent);
}

.et-title {
  font-family: var(--font-et-serif);
  font-weight: 300;
  font-size: clamp(3.3rem, 8.8vw, 6.6rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
  color: var(--et-text);
  text-wrap: balance;
}

.et-italic {
  font-style: italic;
  font-weight: 300;
  color: var(--et-accent);
  display: inline-block;
  margin-top: 4px;
}

.et-roles {
  font-size: clamp(0.92rem, 1.55vw, 1.04rem);
  font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--et-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.et-dock-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.et-dock {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  border-radius: 999px;
  background: var(--et-dock-bg);
  border: 1px solid var(--et-dock-border);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow:
    0 20px 55px -20px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.et-item {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--et-soft);
  text-decoration: none;
  font-family: var(--font-et-sans);
  font-size: 0.85rem;
  font-weight: 400;
  padding: 9px 15px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.et-item:hover {
  background: var(--et-dock-hover);
  color: var(--et-text);
  transform: translateY(-1px);
}

.et-handle {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--et-text);
}

.et-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--et-accent);
}

.et-divider {
  width: 1px;
  height: 18px;
  background: var(--et-dock-border);
  margin: 0 3px;
}

/* ==========================================================================
   WORLD 2 — SWISS CLI (Industrial Grid & Terminal)
   ========================================================================== */
.world-swiss {
  color: var(--sw-ink);
  font-family: var(--font-sw-display);
}

.world-swiss ::selection {
  background: var(--sw-signal);
  color: #fff;
}

.sw-wrapper {
  min-height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 84px clamp(16px, 3.5vw, 44px) clamp(24px, 4vw, 44px);
}

.sw-frame {
  width: 100%;
  max-width: 960px;
  background: var(--sw-panel);
  border: 1px solid var(--sw-line-strong);
  box-shadow: 0 32px 90px -28px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  position: relative;
}

.sw-frame::before,
.sw-frame::after {
  content: '+';
  position: absolute;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1;
  color: var(--sw-signal);
  pointer-events: none;
}

.sw-frame::before {
  top: -18px;
  left: -4px;
}

.sw-frame::after {
  bottom: -18px;
  right: -4px;
}

.sw-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--sw-line);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
}

.sw-top-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
}

.sw-signal {
  width: 9px;
  height: 9px;
  background: var(--sw-signal);
  flex-shrink: 0;
}

.sw-mono-strong {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--sw-ink);
}

.sw-mono-dim {
  font-family: var(--font-mono);
  color: var(--sw-muted);
  font-variant-numeric: tabular-nums;
}

.sw-core {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  border-bottom: 1px solid var(--sw-line);
}

.sw-identity {
  padding: clamp(22px, 3vw, 34px);
  border-right: 1px solid var(--sw-line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 30px;
  min-height: 345px;
}

.sw-panel-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--sw-dim);
}

.sw-tag {
  padding: 3px 8px;
  border: 1px solid var(--sw-signal);
  color: var(--sw-signal);
  background: var(--sw-signal-soft);
  font-weight: 600;
  font-size: 0.64rem;
}

.sw-id-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sw-title {
  font-size: clamp(3.1rem, 6.2vw, 4.85rem);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.045em;
  color: var(--sw-ink);
}

.sw-accent {
  color: var(--sw-signal);
}

.sw-role {
  font-size: clamp(0.98rem, 1.45vw, 1.08rem);
  line-height: 1.55;
  color: var(--sw-muted);
  max-width: 38ch;
  cursor: default;
}

.sw-id-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 15px;
  border-top: 1px dashed var(--sw-line);
  font-size: 0.74rem;
}

.sw-terminal {
  background: var(--sw-panel-alt);
  padding: clamp(22px, 3vw, 34px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  min-height: 345px;
}

.sw-term-ready {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--sw-muted);
}

.sw-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sw-led);
  box-shadow: 0 0 8px var(--sw-led);
}

.sw-screen {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.65;
  overflow-y: auto;
  max-height: 215px;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sw-line {
  margin-top: 6px;
}

.sw-line:first-child {
  margin-top: 0;
}

.sw-prompt {
  color: var(--sw-signal);
  font-weight: 600;
  margin-right: 6px;
}

.sw-cmd {
  color: var(--sw-ink);
  font-weight: 500;
}

.sw-res {
  color: var(--sw-muted);
  padding-left: 16px;
}

.sw-highlight {
  color: var(--sw-ink);
  border-left: 2px solid var(--sw-signal);
  padding-left: 12px;
  margin-left: 4px;
  margin-top: 2px;
}

.sw-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--sw-line);
}

.sw-form {
  display: flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.sw-form input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--sw-ink);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  caret-color: var(--sw-signal);
}

.sw-form input::placeholder {
  color: var(--sw-dim);
}

.sw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sw-chip {
  appearance: none;
  border: 1px solid var(--sw-line);
  background: transparent;
  color: var(--sw-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 4px 9px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.sw-chip:hover {
  border-color: var(--sw-signal);
  color: var(--sw-signal);
  background: var(--sw-signal-soft);
}

.sw-bottom {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sw-cell {
  appearance: none;
  background: transparent;
  border: none;
  border-right: 1px solid var(--sw-line);
  padding: 18px 20px 20px;
  text-align: left;
  text-decoration: none;
  color: var(--sw-ink);
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.22s ease, color 0.22s ease;
}

.sw-cell:last-child {
  border-right: none;
}

.sw-cell-kicker {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  color: var(--sw-dim);
  transition: color 0.22s ease;
}

.sw-cell-main {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.sw-arrow {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.sw-cell-sub {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--sw-muted);
  transition: color 0.22s ease;
}

.sw-link:hover {
  background: var(--sw-invert-bg);
  color: var(--sw-invert-ink);
}

.sw-link:hover .sw-cell-kicker,
.sw-link:hover .sw-cell-sub {
  color: var(--sw-invert-ink);
  opacity: 0.72;
}

.sw-link:hover .sw-arrow {
  transform: translate(3px, -3px);
}

.sw-copy:hover,
.sw-copy.is-copied {
  background: var(--sw-signal);
  color: #fff;
}

.sw-copy:hover .sw-cell-kicker,
.sw-copy:hover .sw-cell-sub,
.sw-copy.is-copied .sw-cell-kicker,
.sw-copy.is-copied .sw-cell-sub {
  color: rgba(255, 255, 255, 0.88);
}

/* ==========================================================================
   WORLD 3 — EDITORIAL (Paper & Ink)
   ========================================================================== */
.world-editorial {
  color: var(--ed-ink);
  font-family: var(--font-ed-sans);
}

.world-editorial ::selection {
  background: var(--ed-accent);
  color: #fff;
}

.ed-shell {
  width: 100%;
  max-width: 900px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 84px clamp(22px, 5vw, 52px) clamp(24px, 3.6vh, 40px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(22px, 3.5vh, 38px);
}

.ed-masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ed-rule);
}

.ed-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}

.ed-seal {
  width: 8px;
  height: 8px;
  border-radius: 1.5px;
  background-color: var(--ed-accent);
  flex-shrink: 0;
}

.ed-brand-name {
  font-weight: 500;
  color: var(--ed-ink);
}

.ed-sep {
  color: var(--ed-faint);
}

.ed-domain {
  color: var(--ed-muted);
}

.ed-clock {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ed-muted);
  font-variant-numeric: tabular-nums;
}

.ed-spread {
  display: flex;
  flex-direction: column;
  gap: clamp(22px, 3.2vh, 34px);
}

.ed-kicker {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--ed-muted);
}

.ed-kicker-num {
  color: var(--ed-accent);
  font-weight: 500;
}

.ed-kicker-rule {
  height: 1px;
  width: 44px;
  background: var(--ed-rule-strong);
}

.ed-headline {
  font-family: var(--font-ed-serif);
  font-weight: 400;
  font-size: clamp(3.15rem, 7.2vw, 5.45rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
  color: var(--ed-ink);
}

.ed-headline em {
  font-style: italic;
  font-weight: 400;
}

.ed-notes {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 48px);
  padding-top: 22px;
  border-top: 1px solid var(--ed-rule);
  align-items: start;
}

.ed-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--ed-faint);
  margin-bottom: 10px;
}

.ed-copy {
  font-size: clamp(1rem, 1.45vw, 1.1rem);
  line-height: 1.65;
  color: var(--ed-muted);
  max-width: 36ch;
}

.ed-focus {
  padding-left: 20px;
  border-left: 2px solid var(--ed-accent);
}

.ed-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ed-tags li {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--ed-ink);
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--ed-elevated);
  border: 1px solid var(--ed-rule);
}

.ed-ledger {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ed-ledger-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ed-rule);
}

.ed-ledger-head .ed-label {
  margin-bottom: 0;
}

.ed-copy-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--ed-rule);
  border-radius: 999px;
  padding: 5px 12px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--ed-ink);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  transition: border-color 0.25s ease, background-color 0.25s ease;
}

.ed-copy-btn:hover {
  border-color: var(--ed-accent);
  background: var(--ed-accent-soft);
}

.ed-copy-status {
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ed-accent);
  font-weight: 500;
}

.ed-index {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--ed-rule);
}

.ed-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "num arrow arrow"
    "name name name"
    "handle handle handle";
  row-gap: 3px;
  padding: 15px 16px 17px 0;
  text-decoration: none;
  color: var(--ed-ink);
  border-right: 1px solid var(--ed-rule);
  transition: background-color 0.28s ease, padding-left 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.ed-row:not(:first-child) {
  padding-left: 20px;
}

.ed-row:last-child {
  border-right: none;
}

.ed-row:hover {
  background: var(--ed-hover);
}

.ed-row:first-child:hover {
  padding-left: 12px;
}

.ed-row:not(:first-child):hover {
  padding-left: 26px;
}

.ed-num {
  grid-area: num;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ed-faint);
  transition: color 0.25s ease;
}

.ed-arrow {
  grid-area: arrow;
  justify-self: end;
  font-size: 0.95rem;
  color: var(--ed-muted);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), color 0.25s ease;
}

.ed-name {
  grid-area: name;
  font-family: var(--font-ed-serif);
  font-size: 1.68rem;
  line-height: 1.15;
  margin-top: 6px;
}

.ed-handle {
  grid-area: handle;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ed-muted);
}

.ed-row:hover .ed-num,
.ed-row:hover .ed-arrow {
  color: var(--ed-accent);
}

.ed-row:hover .ed-arrow {
  transform: translate(3px, -3px);
}

/* ==========================================================================
   Toast Feedback
   ========================================================================== */
.copy-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(14px);
  z-index: 80;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--dock-pill-bg);
  color: var(--dock-pill-text);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.copy-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Responsive Polish
   ========================================================================== */
@media (max-width: 820px) {
  .sw-core {
    grid-template-columns: 1fr;
  }

  .sw-identity {
    border-right: none;
    border-bottom: 1px solid var(--sw-line);
    min-height: auto;
  }

  .sw-terminal {
    min-height: 280px;
  }

  .sw-bottom {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sw-cell:nth-child(2) {
    border-right: none;
  }

  .sw-cell:nth-child(1),
  .sw-cell:nth-child(2) {
    border-bottom: 1px solid var(--sw-line);
  }
}

@media (max-width: 720px) {
  .ctrl-label {
    display: none;
  }

  .seg-btn {
    padding: 6px 10px;
    font-size: 0.68rem;
  }

  .dock-ctrl {
    padding: 6px 8px;
  }

  .ed-sep,
  .ed-domain {
    display: none;
  }

  .ed-notes {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .ed-index {
    grid-template-columns: 1fr;
  }

  .ed-row,
  .ed-row:not(:first-child) {
    border-right: none;
    border-bottom: 1px solid var(--ed-rule);
    padding: 14px 4px;
    grid-template-columns: 30px 1fr auto auto;
    grid-template-areas: "num name handle arrow";
    align-items: baseline;
    column-gap: 12px;
  }

  .ed-row:last-child {
    border-bottom: none;
  }

  .ed-row:first-child:hover,
  .ed-row:not(:first-child):hover {
    padding-left: 10px;
  }

  .ed-name {
    margin-top: 0;
    font-size: 1.35rem;
  }
}

@media (max-width: 560px) {
  .sw-bar-top {
    flex-direction: column;
    align-items: stretch;
  }

  .sw-top-cell:first-child {
    border-bottom: 1px solid var(--sw-line);
  }

  .sw-bottom {
    grid-template-columns: 1fr;
  }

  .sw-cell {
    border-right: none;
    border-bottom: 1px solid var(--sw-line);
  }

  .sw-cell:last-child {
    border-bottom: none;
  }

  .et-dock {
    border-radius: 22px;
    padding: 8px;
    max-width: 340px;
  }

  .et-divider {
    display: none;
  }

  .et-item {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-layer,
  .segment-indicator,
  .theme-dock,
  body {
    transition-duration: 0.01ms !important;
  }

  .world.is-leaving,
  .world.is-entering,
  .world.is-entering .stagger,
  .world.is-boot .stagger {
    animation: none !important;
  }
}
