:root {
  --ink: #fff8ef;
  --muted: rgba(255, 248, 239, .72);
  --line: rgba(255, 248, 239, .16);
  --panel: rgba(24, 24, 22, .72);
  --panel-strong: rgba(21, 19, 18, .9);
  --red: #d33134;
  --gold: #d7a752;
  --green: #4c8a65;
  --blue: #5884b9;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: #090b0b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

.immersive-shell { position: relative; width: 100vw; height: 100vh; background: #090b0b; }
.immersive-scene { position: absolute; inset: 0; }
.immersive-scene canvas { display: block; width: 100%; height: 100%; }

.portrait-cloud-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  overflow: hidden;
  pointer-events: none;
}
.portrait-cloud-overlay.active { display: block; }
.floating-portrait {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  margin: 0;
  aspect-ratio: 1 / 1.22;
  overflow: hidden;
  border: 1px solid rgba(255, 248, 239, .42);
  background: rgba(15, 18, 17, .78);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .46), 0 0 30px rgba(215, 167, 82, .16);
  opacity: .86;
  transform: translate(-50%, -50%) rotate(var(--rot));
  animation: portrait-drift var(--duration) ease-in-out infinite alternate;
  animation-delay: var(--delay);
}
.floating-portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center 28%;
  background: #0c0f0e;
  filter: grayscale(.08) contrast(1.05) saturate(.9);
}
.floating-portrait strong {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--ink);
  font-size: clamp(28px, 6vw, 64px);
  background: radial-gradient(circle at 50% 35%, rgba(215, 167, 82, .32), rgba(11, 13, 12, .9) 62%);
}
.floating-portrait figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 7px 6px 6px;
  color: var(--ink);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .82));
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .8);
}
.martyr-cloud .floating-portrait {
  border-color: rgba(211, 49, 52, .56);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .48), 0 0 34px rgba(211, 49, 52, .18);
}
@keyframes portrait-drift {
  from { transform: translate(calc(-50% - var(--dx)), calc(-50% - var(--dy))) rotate(calc(var(--rot) - 2deg)); }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(calc(var(--rot) + 2deg)); }
}

.immersive-topbar {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 18px;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  pointer-events: none;
}
.immersive-topbar > * { pointer-events: auto; }
.immersive-brand, .immersive-link {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  background: rgba(10, 12, 12, .58);
  backdrop-filter: blur(18px);
}
.immersive-brand {
  display: grid;
  gap: 2px;
  min-width: 148px;
  padding: 10px 12px;
}
.immersive-brand span { color: var(--gold); font-size: 12px; font-weight: 900; letter-spacing: .12em; }
.immersive-brand strong { font-size: 18px; line-height: 1.1; }
.immersive-link {
  padding: 10px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
}
.immersive-modes {
  justify-self: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 12, 12, .58);
  backdrop-filter: blur(18px);
}
.immersive-modes button {
  min-width: 58px;
  border: 0;
  color: rgba(255, 248, 239, .78);
  background: transparent;
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}
.immersive-modes button.active {
  color: #151312;
  background: var(--gold);
}

.focus-panel {
  position: absolute;
  left: 24px;
  bottom: 26px;
  z-index: 4;
  width: min(420px, calc(100vw - 48px));
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 26px 80px rgba(0, 0, 0, .42);
  backdrop-filter: blur(20px);
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .18em;
}
.focus-panel h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.02;
  letter-spacing: 0;
}
.focus-panel p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 14px;
}
.focus-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}
.focus-meta span {
  border: 1px solid rgba(255, 248, 239, .18);
  background: rgba(255, 248, 239, .08);
  border-radius: 999px;
  padding: 5px 8px;
  color: rgba(255, 248, 239, .82);
  font-size: 11px;
  font-weight: 800;
}
.focus-action {
  display: inline-flex;
  margin-top: 16px;
  color: #151312;
  background: var(--gold);
  border-radius: 999px;
  padding: 9px 12px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
}

.index-strip {
  position: absolute;
  right: 24px;
  bottom: 26px;
  z-index: 4;
  width: min(340px, calc(100vw - 48px));
  max-height: 42vh;
  overflow: auto;
  display: none;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(10, 12, 12, .55);
  backdrop-filter: blur(18px);
}
.index-strip button {
  width: 100%;
  border: 1px solid rgba(255, 248, 239, .12);
  color: var(--ink);
  background: rgba(255, 248, 239, .07);
  padding: 10px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.index-strip button strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}
.index-strip button span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.index-strip button.active {
  border-color: rgba(215, 167, 82, .72);
  background: rgba(215, 167, 82, .16);
}

.walk-controls {
  position: absolute;
  left: 50%;
  bottom: 26px;
  z-index: 4;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 12, 12, .58);
  backdrop-filter: blur(18px);
}
.walk-controls button {
  border: 0;
  color: #151312;
  background: var(--gold);
  border-radius: 999px;
  padding: 9px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}
.walk-controls strong {
  min-width: 66px;
  text-align: center;
  color: var(--ink);
  font-size: 13px;
}
.walk-controls span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  padding-right: 6px;
}

.immersive-loading {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #090b0b;
  font-weight: 900;
}
.immersive-loading.hidden { display: none; }

@media (max-width: 760px) {
  .immersive-topbar {
    left: 12px;
    right: 12px;
    top: 10px;
    grid-template-columns: 1fr auto;
  }
  .immersive-brand { min-width: 0; }
  .immersive-link { display: none; }
  .immersive-modes {
    grid-column: 1 / -1;
    justify-self: stretch;
    justify-content: space-between;
    border-radius: 16px;
  }
  .immersive-modes button { min-width: auto; flex: 1; padding: 8px 6px; }
  .focus-panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    padding: 16px;
    max-height: 28vh;
    overflow: auto;
  }
  .focus-panel h1 { font-size: 25px; }
  .focus-panel p { font-size: 13px; }
  .focus-meta { gap: 6px; }
  .focus-action { padding: 9px 12px; }
  .index-strip {
    display: none;
  }
  .walk-controls {
    left: 12px;
    right: 12px;
    bottom: calc(28vh + 34px);
    transform: none;
    justify-content: center;
  }
  .walk-controls span { display: none; }
}
