:root {
  color-scheme: light;
  --page: #ffffff;
  --ink: #111111;
  --muted: #6f6f6f;
  --line: #dedede;
  --panel: #ffffff;
  --soft: #f7f7f7;
  --accent: #111111;
  --accent-2: #5e5e5e;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.06);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font-ui: "Noto Sans KR", "Pretendard Variable", Pretendard, SUIT, "IBM Plex Sans KR",
    "Apple SD Gothic Neo", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Neue Haas Grotesk Text Pro", "Helvetica Neue", Inter, var(--font-ui);
  --font-title: "Space Grotesk", "Neue Haas Grotesk Text Pro", "Helvetica Neue", var(--font-ui);

  /* ---- Design system tokens (v7 normalization) ---- */
  /* Spacing scale (4px base) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  /* Type scale */
  --fs-label: 11px;   /* uppercase micro-labels, eyebrows, kickers */
  --fs-meta: 12px;    /* chips, meta, secondary */
  --fs-body: 14px;    /* default body / inputs */
  --fs-md: 16px;
  --fs-lg: 18px;      /* card sub-headings (h4/h5) */
  --fs-xl: 22px;      /* row / section titles */
  --fs-2xl: 28px;

  /* Font weights — three steps only */
  --fw-regular: 400;
  --fw-medium: 520;
  --fw-bold: 600;

  /* Line heights */
  --lh-tight: 1.15;   /* display headings */
  --lh-snug: 1.35;    /* sub-heads, controls */
  --lh-normal: 1.6;   /* UI body */
  --lh-reading: 1.85; /* long-form reading bodies */

  /* Letter spacing for uppercase labels */
  --ls-label: 0.06em;

  /* Radii */
  --radius: 0;
  --radius-pill: 999px;

  /* Shared reading-column width so stacked sections align */
  --content-max: 960px;

  /* Character screen: content window caps here and centers; theme bg stays full-bleed */
  --shell-max: 1240px;

  font-family: var(--font-ui);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(17, 17, 17, 0.3) transparent;
}

/* Custom scrollbars everywhere — a quiet hairline thumb, no track box */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(17, 17, 17, 0.22);
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(17, 17, 17, 0.42);
}

/* Themed rooms tint the thumb with their ink */
.character-shell ::-webkit-scrollbar-thumb,
.character-shell::-webkit-scrollbar-thumb {
  background-color: color-mix(in srgb, var(--theme-ink, #111111) 30%, transparent);
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-feature-settings: "tnum";
  text-rendering: geometricPrecision;
  min-height: 100%;
  overflow: visible;
}

button {
  appearance: none;
  font: inherit;
  border-radius: 0;
}

.app-frame {
  min-height: 100vh;
  overflow: visible;
}


[hidden] {
  display: none !important;
}

/* A custom room is composed while hidden so the shared character shell never
   flashes before its registered JS and CSS have settled. */
html[data-archive-custom-paint] #character-view {
  visibility: hidden !important;
  pointer-events: none !important;
}

.view-enter {
  animation: viewEnter 440ms var(--ease-out) both;
}

.view-exit {
  pointer-events: none;
  animation: viewExit 180ms ease both;
}

.section-enter {
  animation: sectionEnter 300ms var(--ease-out) both;
}

/* Tab transition variants — selected per character in Customize》Effects */
.section-enter-slide {
  animation: sectionEnterSlide 360ms var(--ease-out) both;
}

.section-enter-rise {
  animation: sectionEnterRise 460ms var(--ease-out) both;
}

.section-enter-blur {
  animation: sectionEnterBlur 480ms var(--ease-out) both;
}

.section-enter-wipe {
  animation: sectionEnterWipe 440ms var(--ease-out) both;
}

.section-enter-glitch {
  animation: sectionEnterGlitch 320ms var(--ease-out) both;
}

@keyframes sectionEnterSlide {
  from {
    opacity: 0;
    transform: translateX(18px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes sectionEnterRise {
  from {
    opacity: 0;
    transform: translateY(22px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sectionEnterBlur {
  from {
    opacity: 0;
    filter: blur(7px);
  }

  to {
    opacity: 1;
    filter: blur(0);
  }
}

@keyframes sectionEnterWipe {
  from {
    clip-path: inset(0 100% 0 0);
  }

  to {
    clip-path: inset(0 0 0 0);
  }
}

/* Glitch entrance: a clip-path reveal with a 1px chromatic split and a
   touch of blur that resolves as the content settles. No shaking. */
@keyframes sectionEnterGlitch {
  0% {
    opacity: 0;
    clip-path: inset(0 0 96% 0);
    filter: blur(2px) drop-shadow(1px 0 rgba(255, 80, 80, 0.3)) drop-shadow(-1px 0 rgba(100, 150, 255, 0.3));
  }
  40% {
    opacity: 1;
    clip-path: inset(0 0 34% 0);
    transform: translateX(1px);
    filter: blur(1px) drop-shadow(1px 0 rgba(255, 80, 80, 0.24)) drop-shadow(-1px 0 rgba(100, 150, 255, 0.24));
  }
  70% {
    clip-path: inset(0 0 6% 0);
    transform: translateX(-1px);
    filter: blur(0.4px) drop-shadow(0.5px 0 rgba(255, 80, 80, 0.16)) drop-shadow(-0.5px 0 rgba(100, 150, 255, 0.16));
  }
  100% {
    opacity: 1;
    clip-path: inset(0 0 0 0);
    transform: translateX(0);
    filter: none;
  }
}

/* ---- Room effects layer ---- */
.character-shell {
  position: relative;
}

.effects-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Broken glass: a real photographic crack texture, blended over the room.
   The center is masked out so the reading column stays clean; a slow
   glint breathes through the fissures. */
.glass-overlay {
  --glass-opacity-low: 0.42;
  --glass-opacity-high: 0.58;
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: none;
  mix-blend-mode: screen;
  opacity: 0.5;
  -webkit-mask-image: radial-gradient(ellipse 60% 56% at 50% 46%, transparent 34%, #000 78%);
  mask-image: radial-gradient(ellipse 60% 56% at 50% 46%, transparent 34%, #000 78%);
  animation: glassGlint 9s ease-in-out infinite;
}

/* Light rooms use a pale texture multiplied in, so cracks read as
   fine dark fissures instead of glare. */
.glass-overlay.glass-light {
  background-image: none;
  mix-blend-mode: multiply;
  opacity: 0.45;
}

@keyframes glassGlint {
  0%,
  100% {
    opacity: var(--glass-opacity-low);
  }
  50% {
    opacity: var(--glass-opacity-high);
  }
}

/* TV: hairline scanlines + a barely-there brightness flicker. The
   actual static noise is drawn on the effects canvas (ImageData). */
.tv-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.14) 0 1px, transparent 1px 3px);
  animation: tvFlicker 0.6s steps(2) infinite;
}

@keyframes tvFlicker {
  0%,
  100% {
    opacity: 0.85;
  }
  50% {
    opacity: 1;
  }
}

/* VHS: a real tape-noise loop blended over the room, plus a constant
   sub-pixel chroma fringe on the content. */
.vhs-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.14;
}

.vhs-overlay.vhs-light {
  mix-blend-mode: soft-light;
  opacity: 0.3;
}

.character-shell.is-vhs .character-shell-grid {
  filter: drop-shadow(0.5px 0 rgba(255, 70, 70, 0.12)) drop-shadow(-0.5px 0 rgba(90, 140, 255, 0.12));
}

@media (prefers-reduced-motion: reduce) {
  .glass-overlay,
  .tv-overlay {
    animation: none;
  }
}

/* Backdrop layer: inherits the theme's full background stack so the
   parallax can move the atmosphere without touching the content. */
.room-backdrop {
  position: absolute;
  inset: -36px;
  z-index: 0;
  background: inherit;
  pointer-events: none;
}

.character-shell-grid {
  position: relative;
  z-index: 1;
}

.character-shell.has-parallax .room-backdrop {
  transform: translate3d(calc(var(--pointer-x, 0) * -16px), calc(var(--pointer-y, 0) * -12px), 0);
  transition: transform 800ms var(--ease-out);
  will-change: transform;
}

/* Particles drift slightly with the pointer too — same depth plane */
.character-shell.has-parallax .effects-canvas {
  transform: translate3d(calc(var(--pointer-x, 0) * -8px), calc(var(--pointer-y, 0) * -6px), 0);
  transition: transform 800ms var(--ease-out);
}

/* Signal tear: during a brief burst, two thin slices of the BACKGROUND
   shift sideways (clip-path on backdrop copies). Content never moves —
   it only catches a 1px chromatic split for the duration. */
.room-backdrop::before,
.room-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: inherit;
  opacity: 0;
  pointer-events: none;
}

.character-shell.is-glitching .room-backdrop::before {
  opacity: 1;
  clip-path: inset(var(--tear1-top, 20%) 0 var(--tear1-bottom, 76%) 0);
  transform: translateX(var(--tear1-x, 7px));
}

.character-shell.is-glitching .room-backdrop::after {
  opacity: 1;
  clip-path: inset(var(--tear2-top, 58%) 0 var(--tear2-bottom, 38%) 0);
  transform: translateX(var(--tear2-x, -5px));
}

.character-shell.is-glitching .character-shell-grid {
  filter: drop-shadow(1px 0 rgba(255, 255, 255, 0.12)) drop-shadow(-1px 0 rgba(255, 255, 255, 0.08));
}

.character-shell.is-glitching.is-glitching-rgb .character-shell-grid {
  filter: drop-shadow(1px 0 rgba(255, 70, 70, 0.16)) drop-shadow(-1px 0 rgba(90, 140, 255, 0.16));
}

@media (prefers-reduced-motion: reduce) {
  .character-shell.is-glitching .room-backdrop::before,
  .character-shell.is-glitching .room-backdrop::after {
    opacity: 0;
  }

  .character-shell.is-glitching .character-shell-grid {
    filter: none;
  }
}

/* ---- Writing effects (body markers) ---- */
.fx-typing.is-typing::after {
  content: "▌";
  margin-left: 1px;
  color: var(--theme-accent, var(--theme-ink, var(--ink)));
  animation: fxCaret 0.9s steps(2, start) infinite;
}

@keyframes fxCaret {
  50% {
    opacity: 0;
  }
}

.fx-glitch {
  animation: fxGlitch 2.4s steps(1) infinite;
}

@keyframes fxGlitch {
  0%,
  100% {
    text-shadow:
      1px 0 rgba(120, 160, 255, 0.45),
      -1px 0 rgba(255, 90, 90, 0.4);
  }
  18% {
    text-shadow:
      -2px 0 rgba(120, 160, 255, 0.5),
      2px 0 rgba(255, 90, 90, 0.42);
  }
  21% {
    text-shadow: none;
  }
  52% {
    text-shadow:
      2px 0 rgba(120, 160, 255, 0.4),
      -1px 0 rgba(255, 90, 90, 0.46);
  }
  55% {
    text-shadow:
      1px 0 rgba(120, 160, 255, 0.45),
      -1px 0 rgba(255, 90, 90, 0.4);
  }
}

.fx-shake {
  display: inline-block;
  animation: fxShake 0.42s linear infinite;
}

@keyframes fxShake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(0.6px, -0.6px); }
  50% { transform: translate(-0.6px, 0.4px); }
  75% { transform: translate(0.4px, 0.6px); }
}

.fx-fade-line {
  display: block;
  opacity: 0;
}

.fx-fade-seq.is-on .fx-fade-line {
  animation: fxFadeLine 700ms var(--ease-out) both;
  animation-delay: calc(var(--fx-i, 0) * 520ms);
}

@keyframes fxFadeLine {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fx-glitch,
  .fx-shake,
  .structure-tab-panel {
    animation: none;
  }

  .fx-fade-line {
    opacity: 1;
  }
}

.character-toolbar h2,
.character-sidebar h2 {
  margin: 0;
  letter-spacing: 0;
}

.eyebrow,
.card-kicker,
.character-kicker {
  margin: 0 0 var(--s-2);
  color: var(--muted);
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.home-view {
  padding: clamp(20px, 2.6vw, 44px) clamp(20px, 3vw, 52px) clamp(42px, 6vw, 80px);
}

/* Swiss split: a fixed informational rail on the left, the gallery
   taking the rest of the viewport. Ratio ≈ 1 : 4 on wide screens. */
.home-shell {
  display: grid;
  grid-template-columns: clamp(200px, 19vw, 280px) minmax(0, 1fr);
  gap: clamp(32px, 5vw, 88px);
  align-items: start;
}

.home-rail {
  position: sticky;
  top: clamp(20px, 2.6vw, 44px);
  display: grid;
  gap: clamp(18px, 2.4vw, 30px);
  border-top: 2px solid #111111;
  padding-top: 16px;
  color: #111111;
}

.home-rail p {
  margin: 0;
}

.rail-brand {
  margin: 0;
  font-family: var(--font-title);
  font-size: clamp(22px, 1.9vw, 30px);
  font-weight: var(--fw-bold);
  line-height: 1.04;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.rail-sub {
  margin-top: 10px !important;
  color: #8a8a8a;
  font-size: var(--fs-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rail-lead {
  max-width: 30ch;
  color: #4a4a4a;
  font-size: 13px;
  line-height: 1.75;
}

.home-meta {
  color: #111111;
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-main {
  min-width: 0;
}

.home-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  max-width: none;
  margin: clamp(56px, 7vw, 110px) 0 0;
  padding-top: clamp(16px, 2vw, 24px);
  border-top: 1px solid var(--line);
}

.home-footer p {
  margin: 0;
}

.home-footer-mark {
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #111111;
}

.home-footer-note {
  color: #8a8a8a;
  font-size: var(--fs-meta);
}

.controls-sentinel {
  height: 1px;
}

.home-controls {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: clamp(12px, 2vw, 22px);
  align-items: center;
  max-width: none;
  margin: 0 0 clamp(20px, 2.4vw, 32px);
  padding: clamp(12px, 1.5vw, 16px) 0;
  background: var(--page);
  transition: border-color 200ms var(--ease-out);
}

.home-controls.is-stuck {
  border-bottom: 1px solid var(--line);
}

.sort-control-row {
  display: grid;
  grid-template-columns: minmax(128px, auto) auto;
  gap: clamp(10px, 1.5vw, 16px);
  align-items: end;
}

.home-control-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: end;
  align-self: end;
  white-space: nowrap;
}

/* ---- Gallery wall — image first. Every module is identical, so no
   character outranks another; the portraits are the only color on the
   page. Details surface in a glass veil over the image on hover. ---- */
.character-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: clamp(32px, 3.4vw, 48px) clamp(16px, 1.8vw, 24px);
  max-width: none;
  margin: 0;
}

.gallery-card {
  position: relative;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  background: transparent;
  transition: transform 480ms var(--ease-out);
}

/* Hover: the piece itself answers — a quiet lift and the veil.
   No sibling dimming, no layout shift. */
.gallery-card:hover {
  transform: translate3d(0, -6px, 0);
}

.gallery-card .card-media {
  position: relative;
  overflow: hidden;
  background: #ededed;
  /* 스크롤 패럴랙스 제거에 맞춰 여유 줌(1.12)도 제거 —
     홈 카드가 편집 모달의 크롭 미리보기와 동일하게 보인다. */
}

.gallery-card .card-media .image-crop-art {
  transition:
    transform 700ms var(--ease-out),
    opacity 900ms var(--ease-out);
}

.gallery-card:hover .card-media .image-crop-art {
  --art-hover: 1.045;
}

/* Glass veil: summary, tags and date over the portrait */
.card-veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--s-2);
  padding: clamp(14px, 1.8vw, 22px);
  background: rgba(16, 16, 20, 0.34);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #ffffff;
  opacity: 0;
  transition: opacity 340ms var(--ease-out);
}

.gallery-card:hover .card-veil,
.gallery-card:focus-within .card-veil {
  opacity: 1;
}

.card-veil > * {
  transform: translateY(8px);
  transition: transform 480ms var(--ease-out);
}

.gallery-card:hover .card-veil > *,
.gallery-card:focus-within .card-veil > * {
  transform: translateY(0);
}

.card-veil-summary {
  margin: 0;
  font-size: var(--fs-body);
  line-height: 1.6;
}

.card-veil-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-2) var(--s-3);
  min-width: 0;
}

.card-veil-date {
  color: rgba(255, 255, 255, 0.72);
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  font-variant-numeric: tabular-nums;
}

.card-veil .chip-row span {
  color: rgba(255, 255, 255, 0.85);
}

.card-edit-button {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 3;
  min-height: 0;
  border: 0;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  padding: 0;
  font-size: var(--fs-meta);
  line-height: 1.2;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 200ms ease;
}

.gallery-card:hover .card-edit-button,
.card-edit-button:focus-visible {
  opacity: 1;
}

.card-edit-button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Caption: a quiet two-line label — worldline above, name below.
   The portrait carries the weight; the caption only identifies it. */
.card-caption {
  padding-top: 12px;
  min-width: 0;
}

.card-caption .card-kicker {
  margin-bottom: var(--s-1);
}

.card-name {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: var(--fw-bold);
  line-height: 1.35;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

/* Touch devices: no hover, so the veil rests as a bottom gradient */
@media (hover: none) {
  .card-veil {
    opacity: 1;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.66), rgba(0, 0, 0, 0) 62%);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .card-veil > * {
    transform: none;
  }

  .card-edit-button {
    opacity: 1;
  }
}

.image-crop-frame.char-image-frame {
  width: 100%;
  aspect-ratio: 832 / 1216;
  background: transparent;
}

.char-image-frame::after {
  display: none;
}

/* Sidebar image: two stacked layers cross-fade for random rotation */
.char-sidebar-frame .image-crop-art {
  transition:
    transform 700ms var(--ease-out),
    opacity 900ms var(--ease-out);
}

.char-sidebar-frame [data-sidebar-art="b"] {
  opacity: 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-row.vertical {
  margin-top: 18px;
}

.filter-chip {
  border: 1px solid currentColor;
  color: var(--accent-2);
  padding: 5px 9px;
  border-radius: var(--radius);
  font-size: var(--fs-meta);
  line-height: 1;
  white-space: nowrap;
}

/* Display tags: borderless text with a middot separator (no boxes) */
.chip-row span {
  border: 0;
  padding: 0;
  color: var(--theme-muted, var(--accent-2));
  font-size: var(--fs-meta);
  line-height: 1.3;
  white-space: nowrap;
}

.chip-row span:not(:last-of-type)::after {
  content: "·";
  margin-left: var(--s-2);
  opacity: 0.5;
}

.pin-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 1px solid currentColor;
  color: var(--theme-ink, var(--ink));
  padding: 4px 7px;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.solid-button,
.ghost-button,
.icon-button,
.tab-button,
.filter-chip {
  min-height: 36px;
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
  padding: 8px 12px;
  cursor: pointer;
  transition:
    background 160ms ease,
    color 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

select,
input,
textarea {
  border-radius: 0;
}

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--theme-line, var(--line));
  background: #ffffff;
  cursor: pointer;
  vertical-align: middle;
  transition:
    background 140ms ease,
    border-color 140ms ease;
}

input[type="checkbox"]:checked {
  background: var(--theme-ink, var(--ink));
  border-color: var(--theme-ink, var(--ink));
}

input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #ffffff;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

input[type="checkbox"]:focus-visible {
  outline: 1px solid var(--theme-ink, var(--ink));
  outline-offset: 2px;
}

.solid-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.ghost-button:hover,
.icon-button:hover,
.tab-button:hover,
.filter-chip:hover {
  border-color: currentColor;
  transform: translateY(-1px);
}

.character-shell {
  min-height: calc(100vh - 92px);
  padding: clamp(14px, 2vw, 24px);
}

/* Inner content window: caps at --shell-max and centers; the theme background
   on .character-shell stays full-bleed behind it. */
.character-shell-grid {
  display: grid;
  grid-template-columns: minmax(248px, 304px) minmax(0, 1fr);
  align-items: start;
  align-content: start;
  gap: 14px clamp(16px, 1.8vw, 24px);
  max-width: var(--shell-max);
  margin: 0 auto;
}

.character-utility-bar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  min-height: 30px;
}

.utility-actions {
  display: flex;
  gap: 8px;
}

.utility-button {
  border: 0;
  background: transparent;
  color: var(--theme-muted, var(--muted));
  padding: 2px 0;
  min-height: 0;
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  cursor: pointer;
}

.utility-button:hover {
  color: var(--theme-ink, var(--ink));
}

.app-frame[data-view="character"] .character-shell {
  min-height: 100vh;
}

/* Free-layout characters: no sidebar/tabs, full-width canvas */
.character-shell.is-free-layout .character-sidebar {
  display: none;
}

.character-shell.is-free-layout .character-shell-grid {
  grid-template-columns: minmax(0, 1fr);
}

.free-layout-canvas {
  max-width: none;
  padding: clamp(24px, 5vw, 64px) 0;
  color: var(--theme-ink, var(--ink));
  animation: sectionEnter 300ms var(--ease-out) both;
}

/* User-authored canvas: no chrome at all */
.free-layout-user {
  padding: 0;
}

.free-canvas-actions {
  display: flex;
  justify-content: flex-end;
  padding: 10px 0 24px;
}

.free-layout-canvas h3 {
  margin: 0 0 var(--s-3);
  font-size: clamp(26px, 2.8vw, 38px);
  font-weight: var(--fw-medium);
}

.free-layout-canvas p {
  margin: 0;
  max-width: 640px;
  color: var(--theme-muted, var(--muted));
  line-height: var(--lh-reading);
}

.segmented {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
}

.segmented-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-option span {
  display: block;
  padding: 8px 16px;
  color: var(--muted);
  font-size: var(--fs-meta);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 160ms ease,
    color 160ms ease;
}

.segmented-option + .segmented-option span {
  border-left: 1px solid var(--line);
}

.segmented-option input:checked + span {
  background: var(--ink);
  color: #ffffff;
}

.segmented-option input:focus-visible + span {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

.surface-switch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
}

.surface-switch-row .segmented {
  flex: 0 0 auto;
}

.surface-switch-row .filter-chip {
  margin-left: 2px;
}

/* Panels are defined by surface, not by outline — themes can re-add
   borders through the .character-sidebar / .character-main hooks. */
.character-sidebar,
.character-main {
  background: var(--theme-panel, rgba(255, 255, 255, 0.86));
  color: var(--theme-ink, var(--ink));
}

.character-sidebar {
  padding: clamp(16px, 1.6vw, 22px);
  position: sticky;
  top: 58px;
  height: fit-content;
  max-height: calc(100vh - 76px);
  overflow: auto;
}

.character-sidebar h2 {
  margin-top: var(--s-1);
  font-family: var(--font-title);
  font-size: clamp(26px, 2.2vw, 32px);
  font-weight: var(--fw-medium);
  letter-spacing: -0.01em;
  line-height: 1.05;
}

.character-sidebar .character-kicker {
  display: block;
  margin: 16px 0 0;
  color: var(--theme-muted, var(--muted));
}

.character-sidebar .character-summary {
  display: block;
  margin: 10px 0 0;
  color: var(--theme-muted, var(--muted));
  font-size: var(--fs-meta);
  line-height: 1.65;
}

#character-tags {
  display: none;
}

/* Optional BGM player — only visible when enabled in Structure */
.character-bgm {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 7px 0;
  border-top: 1px solid var(--theme-line, var(--line));
  border-bottom: 1px solid var(--theme-line, var(--line));
}

.bgm-button {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--theme-line, var(--line));
  background: transparent;
  color: var(--theme-ink, var(--ink));
  cursor: pointer;
  font-size: 9px;
  line-height: 1;
}

.bgm-button:hover {
  border-color: var(--theme-ink, var(--ink));
}

.bgm-label {
  color: var(--theme-muted, var(--muted));
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.bgm-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--theme-ink, var(--ink));
  font-size: var(--fs-meta);
}

.form-actions .preset-delete-button {
  margin-right: auto;
  color: #a84a50;
}

.form-actions .preset-delete-button:hover {
  color: #7e2f35;
}

.preset-scope-dot {
  margin-left: 5px;
  color: var(--theme-accent, #a84a50);
  font-size: 8px;
  vertical-align: 2px;
}

.structure-bgm-section {
  display: grid;
  gap: 12px;
  max-width: 420px;
}

.structure-tab-body {
  margin: 16px 0 4px;
}

.structure-tab-panel {
  animation: structureTabIn 240ms var(--ease-out) both;
}

@media (prefers-reduced-motion: reduce) {
  .structure-tab-panel {
    animation: none;
  }
}

/* Effects controls: compact columns, never wider than a comfortable hand */
.effects-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 280px));
  gap: 18px 32px;
}

.effect-color-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.structure-tab-body .char-image-help {
  margin-top: 6px;
}

.character-tabs {
  display: grid;
  margin-top: 20px;
  border-top: 1px solid var(--theme-line, var(--line));
}

.tab-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--theme-muted, var(--muted));
  padding: 11px 2px;
  text-align: left;
  font-size: var(--fs-body);
}

.tab-button:hover {
  color: var(--theme-ink, var(--ink));
  background: transparent;
  transform: none;
}

.tab-button:focus-visible {
  outline: none;
  color: var(--theme-ink, var(--ink));
}

.tab-button {
  transition:
    color 180ms ease,
    padding-left 240ms var(--ease-out),
    box-shadow 240ms var(--ease-out);
}

.tab-button.active {
  color: var(--theme-ink, var(--ink));
  font-weight: var(--fw-medium);
  box-shadow: inset 2px 0 0 currentColor;
  padding-left: 10px;
}

.tab-count {
  color: var(--theme-muted, var(--muted));
  font-size: var(--fs-label);
  font-variant-numeric: tabular-nums;
}

.tab-button.active .tab-count {
  color: var(--theme-ink, var(--ink));
}

.character-main {
  min-width: 0;
  overflow: visible;
}

.character-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 50px;
  padding: 12px clamp(18px, 3vw, 34px);
  border-bottom: 1px solid var(--theme-line, var(--line));
}

.character-toolbar[hidden] {
  display: none;
}

.character-toolbar h2 {
  font-size: 13px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--theme-ink, var(--ink));
}

.toolbar-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
  white-space: nowrap;
}

.content-sort-controls {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  padding-right: 2px;
}

.content-sort-controls::after {
  content: "";
  width: 1px;
  height: 14px;
  margin-left: 4px;
  background: var(--theme-line, var(--line));
  opacity: 0.85;
}

.character-toolbar .toolbar-actions .filter-chip,
.character-toolbar .toolbar-actions .solid-button {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--theme-muted, var(--muted));
  padding: 0;
  font-size: var(--fs-meta);
  line-height: 1.2;
}

.character-toolbar .toolbar-actions .solid-button {
  color: var(--theme-muted, var(--muted));
  font-weight: var(--fw-regular);
}

.character-toolbar .toolbar-actions .filter-chip:hover,
.character-toolbar .toolbar-actions .solid-button:hover {
  color: var(--theme-ink, var(--ink));
  transform: none;
}

.character-toolbar .toolbar-actions .filter-chip.active {
  color: var(--theme-ink, var(--ink));
  font-weight: var(--fw-bold);
}

.filter-panel {
  display: grid;
  gap: 0;
  max-width: none;
  margin: 0 auto var(--s-4);
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--theme-line, var(--line));
  background: transparent;
  overflow: clip;
  animation: filterSlide 380ms var(--ease-out);
}

/* Slide open: the panel grows from 0 height so the content below
   glides down with it instead of jumping. */
@keyframes filterSlide {
  from {
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

  to {
    opacity: 1;
    max-height: 480px;
  }
}

/* Slide shut: same motion in reverse before the panel is removed. */
.filter-panel.is-closing {
  animation: filterSlideOut 320ms var(--ease-out) both;
  pointer-events: none;
}

@keyframes filterSlideOut {
  from {
    opacity: 1;
    max-height: 480px;
  }

  to {
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
}

.search-panel {
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
}

.tag-panel {
  grid-template-columns: 1fr;
}

.tag-category {
  display: grid;
  grid-template-columns: minmax(72px, 0.16fr) minmax(0, 1fr);
  gap: var(--s-3);
  align-items: baseline;
  padding: var(--s-3) 0;
}

.tag-panel .tag-category {
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: center;
  padding: var(--s-2) 0;
}

/* No dividers between filter rows — keep an even vertical rhythm */
.tag-panel .tag-category + .tag-category {
  border-top: 0;
}

.tag-category + .tag-category {
  border-top: 1px solid var(--theme-line, var(--line));
}

.tag-category-title {
  margin: 0;
  color: var(--theme-muted, var(--muted));
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.tag-panel .chip-row {
  gap: var(--s-1) var(--s-3);
}

.filter-panel .field {
  grid-template-columns: auto minmax(140px, 1fr);
  gap: 12px;
  align-items: center;
}

.filter-panel .field input {
  min-height: 28px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  padding: 2px 0 5px;
  color: var(--theme-ink, var(--ink));
  transition: border-color 200ms var(--ease-out);
}

.filter-panel .field input:focus,
.filter-panel .field input:focus-visible {
  outline: 0;
  border-bottom-color: var(--theme-ink, var(--ink));
}

.filter-panel .solid-button,
.tag-panel .filter-chip {
  min-height: 0;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--theme-muted, var(--muted));
  font-size: var(--fs-meta);
  font-weight: var(--fw-regular);
}

.filter-panel .solid-button:hover,
.tag-panel .filter-chip:hover {
  color: var(--theme-ink, var(--ink));
  font-weight: 700;
  transform: none;
}

.tag-panel .filter-chip.active {
  color: var(--theme-ink, var(--ink));
  font-weight: 700;
}

.modal-card .structure-tag-section {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.tag-config-section {
  display: grid;
  gap: 8px;
  align-content: start;
}

.tag-config-title {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.tag-config-rows {
  display: grid;
  gap: 4px;
}

.tag-config-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
}

.tag-config-name {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 5px 0;
  font: inherit;
  font-size: var(--fs-meta);
  color: var(--ink);
}

.tag-config-name:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

.tag-config-count {
  flex: none;
  color: var(--muted);
  font-size: var(--fs-label);
  font-variant-numeric: tabular-nums;
}

.tag-config-del {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: var(--fs-meta);
  padding: 0 2px;
}

.tag-config-del:hover {
  color: var(--ink);
}

.tag-config-confirm-text {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
  font-size: var(--fs-meta);
}

.tag-config-confirm-actions {
  display: flex;
  gap: 10px;
  flex: none;
}

.tag-config-confirm-actions .filter-chip {
  border: 0;
  background: transparent;
  padding: 2px;
  min-height: 0;
  color: var(--muted);
  font-size: var(--fs-meta);
}

.tag-config-confirm-actions .filter-chip:hover {
  color: var(--ink);
  transform: none;
}

.config-empty {
  color: var(--muted);
  font-size: var(--fs-meta);
}

.config-category-add {
  display: flex;
  gap: 10px;
  align-items: center;
}

.config-category-add input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 5px 0;
  font: inherit;
  font-size: var(--fs-meta);
}

.config-category-add input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

.preset-guide-list {
  display: grid;
}

.preset-guide-item {
  display: grid;
  grid-template-columns: minmax(120px, 0.32fr) minmax(0, 1fr);
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-top: 1px solid var(--line);
}

.preset-guide-item:first-child {
  border-top: 0;
}

.preset-guide-name {
  margin: 0;
  font-weight: var(--fw-medium);
}

.preset-guide-desc {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-meta);
  line-height: 1.6;
}

.char-image-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.char-image-thumb {
  position: relative;
  flex: none;
  width: 44px;
  height: 56px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.char-image-pick {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.char-image-thumb.is-primary {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.char-image-thumb.is-editing {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.char-primary-row {
  margin-top: 10px;
}

.char-primary-row .filter-chip[disabled] {
  color: var(--ink);
  cursor: default;
}

.char-image-star {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  line-height: 17px;
  cursor: pointer;
}

.char-image-star.is-on,
.char-image-star:hover {
  color: #ffffff;
}

.char-image-help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.char-image-help b {
  color: var(--ink);
  font-weight: var(--fw-medium);
}

.char-image-remove {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #ffffff;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}

.char-image-remove:hover {
  background: rgba(0, 0, 0, 0.8);
}

.name-alias-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 620px) {
  .name-alias-row {
    grid-template-columns: 1fr;
  }
}

.tag-editor-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.char-rotate-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.char-rotate-toggle input {
  flex: none;
  margin-top: 2px;
}

.char-rotate-text {
  display: grid;
  gap: 2px;
  color: var(--ink);
  font-size: 13px;
}

.char-rotate-text em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  line-height: 1.5;
}

.char-image-thumb .portrait-art {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

.char-image-add {
  flex: none;
  width: auto;
  min-width: 92px;
}

.modal-card .structure-tag-section:first-child {
  border-top: 0;
}

.modal-card .structure-tag-section .chip-row span,
.modal-card .structure-tag-section .filter-chip {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 0;
  font-size: 12px;
  font-weight: 400;
}

.modal-card .structure-tag-section .chip-row {
  gap: 7px 14px;
}

.modal-card .structure-tag-section .filter-chip:hover {
  color: var(--ink);
  font-weight: 700;
  transform: none;
}

.match-card {
  grid-column: auto;
}

.content-root {
  padding: 26px clamp(18px, 3vw, 34px) clamp(48px, 6vw, 96px);
  min-height: calc(100vh - 220px);
}

.content-subnav {
  position: relative;
  z-index: 8;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  max-width: none;
  margin: 0 auto 18px;
}

.content-subnav button {
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.subnav-button {
  border: 0;
  background: transparent;
  color: var(--theme-muted, var(--muted));
  min-height: 0;
  padding: 0;
  font: inherit;
  font-size: var(--fs-meta);
  cursor: pointer;
}

.subnav-button:hover {
  color: var(--theme-ink, var(--ink));
}

.profile-document,
.archive-detail,
.editor-view {
  max-width: none;
  margin: 0 auto;
}

.profile-document {
  display: grid;
  grid-template-columns: minmax(220px, 0.36fr) minmax(0, 1fr);
  gap: clamp(20px, 4vw, 52px);
  align-items: start;
}

.profile-document h3,
.archive-detail h3,
.editor-view h3 {
  margin: 0 0 var(--s-4);
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: var(--fw-medium);
}

.profile-document p,
.archive-detail p,
.editor-view p {
  color: var(--theme-muted, #585858);
  line-height: var(--lh-reading);
}

.profile-note {
  min-width: 0;
}

.safe-component-showcase {
  max-width: none;
  margin: clamp(28px, 4vw, 52px) auto 0;
  padding-top: clamp(22px, 3vw, 34px);
  border-top: 1px solid var(--theme-line, var(--line));
}

.safe-demo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 12px;
}

.safe-demo-card {
  position: relative;
  display: grid;
  gap: 12px;
  min-height: 178px;
  border: 1px solid var(--theme-line, var(--line));
  background: rgba(255, 255, 255, 0.5);
  padding: 14px;
}

.compact-demo-card {
  min-height: 0;
  gap: 8px;
  padding: 12px;
}

.compact-demo-card h4 {
  font-size: 16px;
}

.safe-demo-card h4,
.safe-demo-card h5,
.safe-demo-card p {
  margin: 0;
}

.safe-demo-card h4 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
}

.safe-demo-kicker {
  color: var(--theme-muted, var(--muted));
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.safe-text-button,
.safe-tabs button,
.choice-row button,
.safe-close {
  border: 1px solid var(--theme-line, var(--line));
  background: rgba(255, 255, 255, 0.38);
  color: var(--theme-ink, var(--ink));
  cursor: pointer;
}

.safe-text-button {
  justify-self: start;
  min-height: 34px;
  padding: 7px 10px;
}

.safe-toggle-demo {
  display: grid;
  gap: 6px;
  align-content: start;
}

.safe-toggle-button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.safe-reveal-slot {
  min-height: 34px;
}

.safe-reveal-panel,
.choice-output {
  border-left: 1px solid var(--theme-line, var(--line));
  padding-left: 12px;
  color: var(--theme-muted, var(--muted));
  line-height: 1.6;
}

.safe-reveal-panel {
  font-size: 12px;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.safe-reveal-panel.is-hidden {
  visibility: hidden;
  opacity: 0;
  transform: translateY(-2px);
}

.emphasis-preview {
  --emphasis-bg: #fff7e8;
  --emphasis-border: #8a6a42;
  --emphasis-style: solid;
  --emphasis-width: 2px;
  display: grid;
  gap: 7px;
  border: var(--emphasis-width) var(--emphasis-style) var(--emphasis-border);
  background: var(--emphasis-bg);
  color: #2a2119;
  padding: 12px;
  line-height: 1.6;
}

.emphasis-preview p {
  color: inherit;
}

.block-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.block-controls label {
  display: grid;
  gap: 5px;
  color: var(--theme-muted, var(--muted));
  font-size: 11px;
}

.block-controls input,
.block-controls select {
  min-width: 0;
  min-height: 30px;
  border: 1px solid var(--theme-line, var(--line));
  background: rgba(255, 255, 255, 0.58);
  color: inherit;
  padding: 5px;
}

.safe-layer {
  position: absolute;
  inset: 10px;
  z-index: 3;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(8px);
}

.safe-layer-panel {
  display: grid;
  gap: 10px;
  width: min(280px, 100%);
  border: 1px solid var(--theme-ink, var(--ink));
  background: var(--theme-panel, #ffffff);
  padding: 14px;
}

.safe-close {
  justify-self: end;
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--theme-muted, var(--muted));
  padding: 0;
  font-size: 12px;
}

.safe-tabs,
.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.safe-tabs button,
.choice-row button {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

.safe-tabs button.active,
.choice-row button.active {
  background: var(--theme-ink, var(--ink));
  color: var(--theme-panel, #ffffff);
}

.vn-box {
  display: grid;
  gap: 10px;
  border-left: 1px solid var(--theme-ink, var(--ink));
  padding-left: 12px;
}

.vn-box p {
  color: var(--theme-muted, var(--muted));
  font-size: 12px;
}

.chat-sample {
  display: grid;
  gap: 8px;
}

.bubble {
  width: fit-content;
  max-width: 82%;
  padding: 8px 10px;
  border: 1px solid var(--theme-line, var(--line));
  line-height: 1.55;
}

.bubble.mine {
  justify-self: end;
  background: rgba(0, 0, 0, 0.06);
}

.mini-timeline {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mini-timeline li {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px;
  color: var(--theme-muted, var(--muted));
}

.mini-timeline span {
  color: var(--theme-ink, var(--ink));
  font-size: 12px;
}

.image-switcher {
  position: relative;
  display: grid;
  width: 100%;
  border: 1px solid var(--theme-line, var(--line));
  background: transparent;
  color: var(--theme-panel, #ffffff);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
}

.image-switcher .portrait-art {
  display: none;
  aspect-ratio: 16 / 9;
  min-height: 0;
}

.image-switcher .portrait-art.active {
  display: block;
}

.image-switcher > span:last-child {
  position: absolute;
  left: 10px;
  bottom: 9px;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(0, 0, 0, 0.26);
  padding: 4px 8px;
  font-size: 12px;
}

.scroll-demo {
  --scroll-demo-progress: 0;
  position: relative;
  display: grid;
  gap: 18px;
  max-height: 154px;
  overflow-y: auto;
  border: 1px solid var(--theme-line, var(--line));
  padding: 12px 52px 12px 12px;
  scroll-behavior: smooth;
}

.scroll-demo p {
  min-height: 62px;
  color: var(--theme-muted, var(--muted));
  line-height: 1.55;
}

.scroll-orbit {
  position: sticky;
  top: 10px;
  justify-self: end;
  width: 30px;
  height: 112px;
  margin-right: -40px;
  border-left: 1px solid var(--theme-line, var(--line));
}

.scroll-orbit span {
  position: absolute;
  left: -5px;
  top: calc(var(--scroll-demo-progress) * 86px);
  width: 9px;
  height: 9px;
  background: var(--theme-ink, var(--ink));
  transition: top 120ms ease;
}

.scroll-orbit b {
  position: absolute;
  right: 0;
  bottom: 0;
  color: var(--theme-muted, var(--muted));
  font-size: 11px;
  font-weight: 500;
}

.mini-carousel {
  display: grid;
  gap: 8px;
}

.mini-carousel .portrait-art {
  aspect-ratio: 16 / 9;
}

.carousel-controls {
  display: grid;
  grid-template-columns: auto minmax(48px, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.carousel-controls span {
  color: var(--theme-muted, var(--muted));
  text-align: center;
  font-size: 12px;
}

.compare-demo {
  --compare: 52%;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--theme-line, var(--line));
}

.compare-demo .portrait-art {
  position: absolute;
  inset: 0;
  min-height: 0;
}

.compare-after {
  clip-path: inset(0 calc(100% - var(--compare)) 0 0);
}

.compare-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--compare);
  width: 1px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.range-field {
  display: grid;
  gap: 6px;
  color: var(--theme-muted, var(--muted));
  font-size: 12px;
}

.relationship-demo {
  display: grid;
  gap: 10px;
}

.relationship-bar {
  height: 12px;
  border: 1px solid var(--theme-line, var(--line));
  background: rgba(255, 255, 255, 0.42);
}

.relationship-bar span {
  display: block;
  width: 35%;
  height: 100%;
  background: var(--theme-ink, var(--ink));
  transition: width 180ms ease;
}

.relationship-demo strong {
  font-weight: 560;
}

.location-demo {
  display: grid;
  gap: 10px;
}

.room-map {
  position: relative;
  height: 128px;
  border: 1px solid var(--theme-line, var(--line));
  background:
    linear-gradient(90deg, transparent 49%, rgba(0, 0, 0, 0.07) 50%, transparent 51%),
    linear-gradient(0deg, transparent 49%, rgba(0, 0, 0, 0.07) 50%, transparent 51%),
    rgba(255, 255, 255, 0.42);
}

.room-marker {
  position: absolute;
  left: 28%;
  top: 32%;
  width: 12px;
  height: 12px;
  border: 2px solid var(--theme-panel, #ffffff);
  background: var(--theme-ink, var(--ink));
  transform: translate(-50%, -50%);
  transition:
    left 180ms ease,
    top 180ms ease;
}

.safe-tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px solid currentColor;
  cursor: help;
}

.safe-tooltip span {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 4;
  display: none;
  width: 210px;
  border: 1px solid var(--theme-line, var(--line));
  background: var(--theme-panel, #ffffff);
  padding: 9px;
  color: var(--theme-ink, var(--ink));
  font-size: 12px;
  line-height: 1.5;
}

.safe-tooltip:hover span,
.safe-tooltip:focus span {
  display: block;
}

.archive-list {
  display: grid;
  max-width: none;
  margin: 0 auto;
}

.archive-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  padding: 22px 0;
  border-bottom: 1px solid var(--theme-line, var(--line));
  cursor: pointer;
  transition: opacity 300ms var(--ease-out);
}

/* List copy can contain pasted URLs or long unbroken strings. Grid children
   default to min-width:auto, so one such value used to widen Logs, Settings
   and the nested pair log list beyond the reading column. */
.archive-row > *,
.archive-row > * > *,
.row-right,
.archive-preview,
.row-meta {
  min-width: 0;
  max-width: 100%;
}

.archive-row h3,
.archive-preview,
.row-meta span,
.pair-list-title h3,
.gallery-caption,
.gallery-caption h3,
.gallery-caption .chip-row span {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.archive-preview {
  overflow: hidden;
}

/* Same focus-follows-cursor rhythm as the home index */
.archive-list:hover .archive-row {
  opacity: 0.45;
}

.archive-list .archive-row:hover {
  opacity: 1;
}

.archive-row:hover h3 {
  text-decoration: underline;
  text-underline-offset: 5px;
}

.archive-row h3 {
  margin: 0 0 var(--s-2);
  color: var(--theme-ink, var(--ink));
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
}

.archive-row p {
  margin: 0;
  color: var(--theme-muted, var(--muted));
  line-height: 1.65;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
  color: var(--theme-muted, var(--muted));
  font-size: 12px;
}

.row-date {
  color: var(--theme-muted, var(--muted));
  white-space: nowrap;
  font-size: 13px;
}

.character-shell .chip-row span,
.character-shell .row-meta {
  color: var(--theme-muted, var(--muted));
}

.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--theme-line, var(--line));
}

.detail-meta-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.detail-meta-line .eyebrow {
  margin: 0;
}

.archive-detail h3 {
  padding-bottom: 10px;
}

.detail-body {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  padding: clamp(16px, 3vw, 30px) 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--theme-ink, var(--ink));
  line-height: var(--lh-reading);
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-4);
  margin-top: var(--s-5);
}

.detail-section-label {
  margin: 0;
  color: var(--theme-muted, var(--muted));
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.detail-divider {
  height: 1px;
  margin: 28px 0;
  border: 0;
  background: var(--theme-line, var(--line));
}

.detail-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--theme-line, var(--line));
}

.detail-nav .ghost-button {
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--theme-muted, var(--muted));
  padding: 0;
}

.detail-nav .ghost-button:hover {
  color: var(--theme-ink, var(--ink));
  border-color: transparent;
  transform: none;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-width: none;
  margin: 0 auto;
}

/* Theme option (Noct): Cosmos-style masonry — columns aligned, rows staggered.
   See THEME_CUSTOM_OPTIONS.md. Item heights vary via aspect-ratio so the
   horizontal lines break up. */
.theme-noct .gallery-grid {
  display: block;
  column-count: 3;
  column-gap: 16px;
}

.theme-noct .gallery-item {
  width: 100%;
  margin-bottom: 16px;
  break-inside: avoid;
}

.theme-noct .gallery-item:nth-child(4n + 1) .portrait-art {
  aspect-ratio: 4 / 5;
}

.theme-noct .gallery-item:nth-child(4n + 2) .portrait-art {
  aspect-ratio: 4 / 6.8;
}

.theme-noct .gallery-item:nth-child(4n + 3) .portrait-art {
  aspect-ratio: 4 / 3.5;
}

.theme-noct .gallery-item:nth-child(4n) .portrait-art {
  aspect-ratio: 4 / 5.6;
}

@media (max-width: 920px) {
  .theme-noct .gallery-grid {
    column-count: 2;
  }
}

@media (max-width: 620px) {
  .theme-noct .gallery-grid {
    column-count: 1;
  }
}

.pair-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: none;
  margin: 0 auto;
}

.pair-card {
  position: relative;
  display: block;
  min-height: 0;
  aspect-ratio: 4 / 3;
  border: 0;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
  transition:
    transform 180ms ease,
    background 180ms ease;
}

.pair-card:hover {
  transform: translateY(-3px);
}

.pair-list-title {
  display: none;
}

.image-crop-frame {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: #111111;
}

.image-crop-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.portrait-art.image-crop-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  transform: translate3d(0, var(--parallax-y, 0px), 0)
    scale(calc(var(--crop-zoom, 1.18) * var(--art-hover, 1) * var(--parallax-pad, 1)));
  transform-origin: var(--focus-x, 50%) var(--focus-y, 50%);
  /* Focus also drives the internal cover crop, so frames whose aspect
     differs from the image (pair hero 16:9, cards 4:3) can truly reach
     the image's top/bottom — not just the transform window. */
  background-position: var(--focus-x, 50%) var(--focus-y, 50%);
}

.card-media .image-crop-art {
  transition:
    transform 600ms var(--ease-out),
    opacity 900ms var(--ease-out);
}

.card-media [data-card-layer="b"] {
  opacity: 0;
}

.uploaded-art {
  background-image: var(--uploaded-image);
  background-size: cover;
  background-position: center;
}

.uploaded-art::before,
.uploaded-art::after {
  display: none;
}

.pair-transparent-png,
.pair-transparent-png .image-crop-art {
  background-color: transparent !important;
}

.pair-transparent-png .image-crop-art {
  background-size: contain !important;
  background-position: var(--focus-x, 50%) var(--focus-y, 50%) !important;
  filter: none !important;
  clip-path: none;
}

[data-pair-mode="card"].pair-transparent-png::after {
  background: transparent !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

.pair-thumb-frame {
  width: 100%;
  min-height: 0;
  height: 100%;
  aspect-ratio: 4 / 3;
}

.pair-thumb-frame::after {
  background: rgb(var(--card-overlay-rgb, 17 17 17) / var(--card-overlay-opacity, 0.38));
  backdrop-filter: blur(var(--card-glass-blur, 14px));
}

.pair-image-overlay {
  position: absolute;
  z-index: 2;
  color: #ffffff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.42);
}

.pair-card-copy {
  left: 18px;
  right: 18px;
  bottom: 18px;
  padding: 0;
}

.pair-card-copy h3,
.pair-hero-copy h3 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(20px, 2.4vw, 30px);
  font-weight: var(--fw-medium);
}

.pair-card-copy p:not(.eyebrow),
.pair-hero-copy p:not(.eyebrow) {
  margin: 12px 0 14px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.7;
}

.pair-image-overlay .eyebrow,
.pair-image-overlay .chip-row span {
  color: rgba(255, 255, 255, 0.86);
}

.pair-hero-frame::after {
  background: var(--hero-gradient, linear-gradient(to top, rgb(0 0 0 / 0.66), rgb(0 0 0 / 0) 62%));
}

.pair-hero {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  max-width: none;
  margin: 0 auto clamp(26px, 3vw, 38px);
}

.pair-detail-layout,
.pair-detail-posts {
  min-width: 0;
}

.pair-context {
  display: none;
}

.pair-detail-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.pair-hero-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}

.pair-hero-copy {
  left: var(--hero-copy-left, clamp(18px, 3vw, 36px));
  right: var(--hero-copy-right, auto);
  top: var(--hero-copy-top, auto);
  bottom: var(--hero-copy-bottom, clamp(18px, 3vw, 36px));
  max-width: min(560px, calc(100% - 36px));
  padding: 0;
  text-align: var(--hero-copy-text-align, left);
  transform: var(--hero-copy-transform, none);
}

.pair-hero-copy .chip-row {
  justify-content: inherit;
  max-width: min(560px, calc(100% - 36px));
}

.pair-log-list {
  border-top: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  max-width: none;
  margin: 0 auto 10px;
  padding-top: 2px;
}

.section-header h3 {
  margin: 0;
  font-size: clamp(18px, 1.8vw, 24px);
  font-weight: var(--fw-medium);
}

.pair-posts-header {
  display: block;
}

.pair-posts-label {
  margin: 0;
}

.section-count {
  color: var(--theme-muted, var(--muted));
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  white-space: nowrap;
}

.gallery-item {
  min-width: 0;
  max-width: 100%;
  cursor: pointer;
  overflow: hidden;
  transition: transform 200ms var(--ease-out);
}

.gallery-item:hover {
  transform: translateY(-3px);
}

.gallery-caption {
  min-width: 0;
  max-width: 100%;
  padding: 12px 2px 0;
}

.gallery-date {
  display: block;
  margin-bottom: var(--s-2);
  color: var(--theme-muted, var(--muted));
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.gallery-caption h3 {
  margin: 0 0 var(--s-2);
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
}

.gallery-large {
  aspect-ratio: 16 / 10;
  margin-bottom: 22px;
}

.gallery-large-image {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  aspect-ratio: auto;
  object-fit: contain;
  background: transparent;
}

.editor-view form {
  display: grid;
  gap: var(--s-4);
}

.editor-view {
  display: grid;
  gap: var(--s-4);
  animation: panelReveal 300ms var(--ease-out) both;
}

.editor-view h3 {
  margin-bottom: 4px;
}

.editor-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--theme-line, var(--line));
}

.field {
  display: grid;
  gap: var(--s-2);
}

.field span {
  font-size: 13px;
  color: var(--theme-muted, var(--muted));
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--theme-line, var(--line));
  background: rgba(255, 255, 255, 0.6);
  color: inherit;
  padding: 8px 10px;
  font: inherit;
  font-size: var(--fs-body);
}

/* Checkboxes must never inherit the 100%-width text-input sizing */
.field input[type="checkbox"],
.check-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
}

.field input[type="color"] {
  width: 44px;
  height: 28px;
  padding: 2px;
}

.editor-view .field input,
.editor-view .field select {
  min-height: 30px;
  border: 0;
  border-bottom: 1px solid var(--theme-line, var(--line));
  padding: 4px 0 7px;
  background: transparent;
}

.editor-view .field textarea {
  border: 1px solid var(--theme-line, var(--line));
  padding: 12px;
  background: transparent;
}

.editor-view .field textarea {
  background: transparent;
}

.home-controls .field input,
.home-controls .field select {
  min-height: 26px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: #5f5f5f;
  padding: 2px 0 4px;
  font-size: 13px;
  transition:
    border-color 200ms var(--ease-out),
    box-shadow 200ms var(--ease-out);
}

.home-controls .field input:focus,
.home-controls .field select:focus,
.home-controls .field input:focus-visible,
.home-controls .field select:focus-visible {
  outline: none;
  border-bottom-color: var(--ink);
  box-shadow: 0 1px 0 0 var(--ink);
}

/* Kill the browser's yellow autofill / focus highlight on form fields */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--page) inset;
  box-shadow: 0 0 0 1000px var(--page) inset;
  -webkit-text-fill-color: var(--ink);
}

/* Focus indicator inside themed screens follows the active theme's ink,
   so it can be recolored when a character theme is customized. */
.character-shell input:focus-visible,
.character-shell select:focus-visible,
.character-shell textarea:focus-visible {
  outline: none;
  border-color: var(--theme-ink, var(--ink));
}

.home-controls .ghost-button {
  min-height: 0;
  border: 0;
  background: transparent;
  color: #6f6f6f;
  padding: 0 0 4px;
  border-bottom: 1px solid transparent;
  font-size: var(--fs-meta);
  line-height: 1.2;
}

.home-controls .ghost-button:hover {
  border-bottom-color: rgba(17, 17, 17, 0.42);
  color: #111111;
  transform: none;
}

/* The single strong action on the home screen */
.home-control-buttons .solid-button {
  min-height: 34px;
  border: 1px solid #111111;
  background: #111111;
  color: #ffffff;
  padding: 7px 16px;
  font-size: var(--fs-meta);
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.home-control-buttons .solid-button:hover {
  background: #2b2b2b;
  border-color: #2b2b2b;
  transform: none;
}

.home-controls > .field {
  grid-template-columns: auto minmax(150px, 1fr);
  gap: 10px;
  align-items: center;
}

.home-controls .sort-control-row .field {
  grid-template-columns: auto minmax(112px, auto);
  gap: 8px;
  align-items: center;
}

/* Custom animated select (replaces native dropdown for smooth open/close) */
.custom-select {
  position: relative;
  min-width: 132px;
  max-width: 200px;
}

.custom-select-trigger [data-select-label] {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  width: 100%;
  min-height: 26px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: #5f5f5f;
  padding: 2px 0 4px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 200ms var(--ease-out);
}

.custom-select.is-open .custom-select-trigger,
.custom-select-trigger:focus-visible {
  outline: none;
  border-bottom-color: var(--ink);
}

.custom-select-caret {
  flex: none;
  width: 6px;
  height: 6px;
  border-right: 1.4px solid currentColor;
  border-bottom: 1.4px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 220ms var(--ease-out);
  opacity: 0.65;
}

.custom-select.is-open .custom-select-caret {
  transform: translateY(1px) rotate(-135deg);
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  z-index: 40;
  margin: 0;
  padding: var(--s-1) 0;
  min-width: 210px;
  list-style: none;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  transition:
    opacity 200ms var(--ease-out),
    transform 200ms var(--ease-out);
}

.custom-select.is-open .custom-select-menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.custom-select-option {
  padding: 8px 12px;
  color: #555555;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 140ms ease,
    color 140ms ease;
}

.custom-select-option:hover {
  background: var(--soft);
  color: #111111;
}

.custom-select-option.is-selected {
  color: #111111;
  font-weight: var(--fw-medium);
}

.home-controls .field span {
  color: #7a7a7a;
  font-size: 11px;
  text-transform: uppercase;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.editor-mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--theme-line, var(--line));
}

.mode-button {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--theme-muted, var(--muted));
  padding: 0 0 5px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.2;
  border-bottom: 1px solid transparent;
}

.mode-button.active {
  color: var(--theme-ink, var(--ink));
  border-bottom-color: currentColor;
}

.writing-panel {
  --editor-chrome-bg: transparent;
  display: grid;
  gap: 10px;
  animation: panelReveal 320ms var(--ease-out) both;
}

.rich-editor-shell {
  display: grid;
  border: 1px solid var(--theme-line, var(--line));
  background: var(--editor-chrome-bg, transparent);
}

.rich-editor {
  display: grid;
  border: 0;
  background: transparent;
}

.writing-body-field {
  display: block;
  border-top: 1px solid var(--theme-line, var(--line));
}

.writing-body-field > span {
  display: none;
}

.writing-panel .writing-body-field textarea {
  min-height: 320px;
  border: 0;
  background: transparent;
  padding: var(--s-4);
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 8px;
  align-items: center;
  padding: 6px 7px;
}

.rich-tool-group {
  display: flex;
  gap: 2px;
  align-items: center;
  padding-right: 10px;
  border-right: 1px solid var(--theme-line, var(--line));
}

.rich-tool-group:last-child {
  border-right: 0;
}

.rich-tool-group.align-end {
  margin-left: auto;
}

.tool-button,
.mini-tool {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--theme-ink, var(--ink));
  cursor: pointer;
}

.tool-button {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--theme-muted, var(--muted));
  font-size: 14px;
  line-height: 1;
}

.tool-button.italic {
  font-style: italic;
}

.tool-button.underline {
  text-decoration: underline;
}

.tool-button.strike {
  text-decoration: line-through;
}

.tool-button:hover,
.tool-button.active,
.mini-tool:hover {
  background: rgba(0, 0, 0, 0.045);
  color: var(--theme-ink, var(--ink));
}

.rich-tool-panel {
  border-top: 1px solid var(--theme-line, var(--line));
  padding: 7px 8px;
  background: var(--editor-chrome-bg);
  animation: panelReveal 260ms var(--ease-out) both;
}

.rich-tool-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  justify-content: flex-start;
}

.compact-field {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.compact-field.wide {
  flex: 0 1 auto;
  min-width: 0;
}

.compact-field span {
  color: var(--theme-muted, var(--muted));
  font-size: 11px;
}

.compact-field input,
.compact-field select {
  min-height: 24px;
  border: 0;
  border-bottom: 1px solid var(--theme-line, var(--line));
  background: transparent;
  color: inherit;
  padding: 2px 0 4px;
  font: inherit;
  font-size: 12px;
}

.compact-field select {
  max-width: 142px;
}

.compact-field.wide select {
  max-width: 132px;
}

.compact-field option,
.field option {
  background: #ffffff;
  color: #111111;
}

.compact-field input[type="color"] {
  width: 26px;
  height: 20px;
  min-height: 20px;
  border: 1px solid var(--theme-line, var(--line));
  padding: 1px;
}

.media-file-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.file-picker {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 30px;
  border: 0;
  border-bottom: 1px solid var(--theme-line, var(--line));
  padding: 5px 2px 6px;
  color: var(--theme-muted, var(--muted));
  cursor: pointer;
  font-size: 12px;
}

.file-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-picker span,
.file-picker b,
.file-picker em {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.file-picker span {
  color: var(--theme-ink, var(--ink));
}

.file-picker em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
}

.file-picker b {
  color: var(--theme-ink, var(--ink));
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.file-picker:hover {
  border-bottom-color: var(--theme-ink, var(--ink));
}

.editor-media-lead {
  display: grid;
  gap: 10px;
}

.editor-file-picker {
  max-width: min(360px, 100%);
}

.editor-image-preview {
  width: min(360px, 100%);
  min-height: 220px;
  border: 1px solid var(--theme-line, var(--line));
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
  background-color: rgba(255, 255, 255, 0.28);
  overflow: hidden;
}

.editor-image-preview .portrait-art {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.editor-image-preview.has-image .portrait-art {
  display: none;
}

.thumbnail-adjust-button {
  justify-self: start;
  min-height: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--theme-muted, var(--muted));
  padding: 0 0 4px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.thumbnail-adjust-button:hover,
.thumbnail-adjust-button.active {
  color: var(--theme-ink, var(--ink));
  border-bottom-color: currentColor;
}

.editor-thumbnail-popover {
  display: grid;
  gap: 12px;
  width: min(320px, 100%);
  padding: 14px;
  border: 1px solid var(--theme-line, var(--line));
  background: var(--theme-panel, #ffffff);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
  animation: popoverReveal 300ms var(--ease-out) both;
}

.thumbnail-popover-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.thumbnail-popover-top h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 520;
}

.editor-gallery-thumb-preview {
  width: 100%;
  pointer-events: none;
}

.editor-gallery-thumb-preview .uploaded-art {
  background-repeat: no-repeat;
}

.thumbnail-range-grid {
  grid-template-columns: 1fr;
  gap: 9px;
}

.thumbnail-help {
  margin: 0;
  color: var(--theme-muted, var(--muted));
  font-size: 12px;
  line-height: 1.55;
}

.mini-tool {
  min-height: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 3px 0 4px;
  color: var(--theme-muted, var(--muted));
  font-size: 12px;
}

.mini-tool:hover {
  border-bottom-color: currentColor;
  background: transparent;
}

.html-editor-textarea {
  min-height: 340px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.7;
}

.form-actions {
  display: flex;
  gap: 18px;
  justify-content: flex-end;
  margin-top: 12px;
}

.confirm-layer {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(6px);
}

.confirm-card {
  position: relative;
  width: min(360px, 100%);
  border: 1px solid #111111;
  background: #ffffff;
  color: #111111;
  padding: 20px 22px 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.16);
  animation: modalCardIn 320ms var(--ease-out) both;
}

.confirm-card p {
  margin: 0 0 16px;
  font-size: var(--fs-body);
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
}

.confirm-actions .ghost-button {
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--muted);
  font-size: var(--fs-meta);
}

.confirm-actions .confirm-delete {
  color: #a8333b;
  font-weight: var(--fw-bold);
}

.confirm-actions .ghost-button:hover {
  color: #111111;
  transform: none;
}

.confirm-actions .confirm-delete:hover {
  color: #7e2228;
}

.subnav-button.danger {
  color: #a8333b;
}

.subnav-button.danger:hover {
  color: #7e2228;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-root.modal-enter .modal-backdrop {
  animation: modalBackdropIn 380ms ease both;
}

.modal-root.modal-enter .modal-card {
  animation: modalCardIn 520ms var(--ease-out) both;
}

.modal-root.modal-exit .modal-backdrop {
  animation: modalBackdropOut 180ms ease both;
}

.modal-root.modal-exit .modal-card {
  animation: modalCardOut 180ms ease both;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
}

.modal-card {
  position: relative;
  width: min(980px, 100%);
  max-height: min(86vh, 900px);
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid #111111;
  background: #ffffff;
  color: #111111;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.14);
}

.settings-grid > * {
  min-width: 0;
}

.modal-card .ghost-button,
.modal-card .solid-button,
.modal-card .filter-chip,
.modal-card .mini-tool,
.modal-card .preset-button {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 0;
  box-shadow: none;
  font-size: 12px;
  font-weight: 400;
}

.modal-card .solid-button,
.modal-card [data-apply-theme] {
  color: var(--ink);
  font-weight: 560;
}

.modal-card .ghost-button:hover,
.modal-card .solid-button:hover,
.modal-card .filter-chip:hover,
.modal-card .mini-tool:hover,
.modal-card .preset-button:hover {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  transform: none;
}

.modal-card .preview-switch .active {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 16px 26px 13px;
  border-bottom: 1px solid var(--line);
}

/* Modals are tools, not stages: the title is a small functional label. */
.modal-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.modal-header .eyebrow {
  display: none;
}

.modal-mini-title {
  margin: 0;
  font-size: var(--fs-label);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--muted);
}

.modal-body {
  padding: 22px 26px 26px;
}

.modal-help {
  max-width: 720px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: var(--fs-meta);
  line-height: 1.7;
}

.modal-form {
  display: grid;
  gap: var(--s-4);
}

.split-editor {
  display: grid;
  grid-template-columns: minmax(220px, 0.4fr) minmax(0, 1fr);
  gap: 24px;
}

.pair-editor-body {
  grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
  align-items: start;
}

.pair-preview-panel {
  display: grid;
  gap: 12px;
  align-self: start;
}

.preview-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-switch .active {
  border-color: #111111;
  background: #111111;
  color: #ffffff;
}

.pair-preview-pane {
  display: block;
  max-width: 100%;
  margin-inline: auto;
}

.pair-preview-panel.theme-gilgamesh-preview [data-preview-pane="card"] .pair-image-overlay > :not(h3) {
  display: none;
}

.pair-preview-panel.theme-gilgamesh-preview [data-preview-pane="card"] .pair-card-copy {
  right: auto;
  left: 50%;
  width: max-content;
  max-width: 78%;
  text-align: center;
  transform: translateX(-50%);
}

.pair-preview-panel.theme-gilgamesh-preview .pair-image-overlay h3 {
  font-family: Georgia, "Times New Roman", "Noto Serif KR", Batang, serif !important;
  font-weight: 400;
  letter-spacing: .04em;
}

.pair-preview-panel.theme-gilgamesh-preview .pair-preview-pane {
  border-color: rgba(191, 153, 63, .22);
  background: #090b0e;
}

.tag-editor-block,
.settings-grid,
.code-editor-grid {
  display: grid;
  gap: 12px;
}

.settings-grid,
.code-editor-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.order-list {
  display: grid;
  gap: 0;
}

.order-finder {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 1.45fr) minmax(260px, .8fr);
  gap: 12px 34px;
  margin: 0 0 24px;
  padding: 18px 0 20px;
  border: 0;
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: transparent;
}

.order-finder-search {
  position: relative;
  z-index: 9;
  align-self: start;
  height: max-content;
  min-width: 0;
}

.order-finder-field {
  position: relative;
  display: grid;
  gap: 0;
  min-width: 0;
}

.order-finder-field > span {
  width: max-content;
  padding: 3px 6px;
  color: var(--panel);
  background: var(--ink);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.order-finder-field input {
  box-sizing: border-box;
  width: 100%;
  min-height: 46px;
  padding: 4px 2px 1px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: clamp(17px, 2vw, 24px);
  font-weight: 600;
  letter-spacing: -.025em;
}

.order-finder-field input::placeholder {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
  font-weight: 400;
}

.order-finder-results {
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  z-index: 12;
  width: 100%;
  max-height: min(320px, 46vh);
  overflow: auto;
  border: 0;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: var(--panel);
  box-shadow: 0 14px 34px color-mix(in srgb, var(--ink) 18%, transparent);
}

.order-finder-results[hidden] {
  display: none;
}

.order-finder-result {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  padding: 12px 10px 11px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 98%, var(--ink) 2%);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.order-finder-result:is(:hover, :focus-visible) {
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 88%, var(--ink) 12%);
  outline: 1px solid var(--ink);
  outline-offset: -1px;
}

.order-finder-result span,
.order-finder-command output {
  color: var(--muted);
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
}

.order-finder-result:is(:hover, :focus-visible) span {
  color: var(--ink);
}

.order-finder-result span {
  display: grid;
  align-self: stretch;
  place-items: center;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
}

.order-finder-result b {
  align-self: center;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-finder-empty {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.order-finder-command {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  justify-items: stretch;
  align-content: start;
  gap: 11px 16px;
  padding-top: 2px;
}

.order-finder-command > div {
  grid-column: 1 / -1;
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.order-finder-command output {
  grid-column: 1 / -1;
  display: block;
  min-height: 34px;
  padding: 9px 0 7px;
  overflow: hidden;
  border-top: 0;
  border-bottom: 0;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-position-field {
  grid-column: 1 / -1;
  justify-self: end;
  display: grid;
  grid-template-columns: auto 58px auto;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.order-position-field input {
  box-sizing: border-box;
  width: 58px;
  min-height: 29px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: var(--panel);
  font: inherit;
  text-align: center;
}

.order-row.is-order-target {
  position: relative;
  z-index: 1;
  background: color-mix(in srgb, var(--panel) 91%, var(--ink) 9%);
  box-shadow: none;
  outline: 0;
  border-top-color: var(--ink);
  border-bottom-color: var(--ink);
}

.order-row.is-order-target .order-number {
  align-self: center;
  display: block;
  color: var(--ink);
  background: transparent;
  font-weight: 700;
}

.order-row.is-order-target .order-title {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--muted);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.order-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: grab;
}

.order-row:active {
  cursor: grabbing;
}

.order-row.is-dragging {
  opacity: 0.35;
}

@media (max-width: 620px) {
  .order-finder {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .order-finder-command {
    justify-items: start;
  }

  .order-finder-command > div {
    flex-wrap: wrap;
  }
}

.order-number {
  color: var(--muted);
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
}

.order-title {
  margin: 0;
  font-weight: var(--fw-medium);
}

.order-description {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.order-actions {
  display: flex;
  gap: 6px;
}

.modal-section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.modal-section-title p {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.check-field {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

/* 미리보기 프레임 — 크기/축소는 app.js scalePairPreviews() 가 인라인으로
   지정한다(실제 폭으로 렌더 후 transform: scale). 여기서 글자 크기·여백을
   따로 만지면 실제 화면과 달라지므로 미리보기 전용 타이포 오버라이드는 두지
   않는다. 테두리는 축소된 프레임과 함께 줄지 않도록 pane 쪽에 그린다. */
.pair-preview-pane {
  overflow: hidden;
  border: 1px solid var(--line);
  box-sizing: content-box;
}

.pair-preview-geometry-probe {
  position: absolute !important;
  top: 0 !important;
  left: -100000px !important;
  display: block !important;
  visibility: hidden !important;
  pointer-events: none !important;
  contain: layout style paint;
}

.visual-settings-panel {
  display: grid;
  gap: 12px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--line);
}

.range-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.range-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.range-field span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.range-field output {
  color: #111111;
}

/* Custom range slider — thin ink track, round thumb that visually
   reaches both ends instead of the chunky default control. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 16px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: var(--theme-line, var(--line));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5.5px;
  border: 0;
  border-radius: 50%;
  background: var(--theme-ink, var(--ink));
}

input[type="range"]::-moz-range-track {
  height: 1px;
  background: var(--theme-line, var(--line));
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--theme-ink, var(--ink));
}

input[type="range"]:focus-visible {
  outline: 1px solid var(--theme-ink, var(--ink));
  outline-offset: 4px;
}

.range-field input[type="range"] {
  width: 100%;
}

.tag-chip-editor {
  display: grid;
  gap: 10px;
}

.editable-chip-row,
.tag-entry-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.editable-tag {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  border: 1px solid #111111;
  background: #111111;
  color: #ffffff;
  min-height: 0;
  padding: 3px 6px 3px 8px;
  font-size: var(--fs-meta);
  line-height: 1.2;
  cursor: pointer;
}

.tag-entry-row input {
  flex: 1 1 160px;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 6px 0;
  font: inherit;
  font-size: var(--fs-body);
}

.tag-entry-row input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

.tag-entry-row .filter-chip {
  flex: none;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 2px;
}

.tag-entry-row .filter-chip:hover {
  color: var(--ink);
  transform: none;
}

.tag-suggestion-title {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.preset-panel {
  border: 0;
  border-top: 1px solid var(--theme-line, var(--line));
  background: transparent;
}

.preset-panel[open] {
  padding-bottom: 8px;
}

.preset-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 7px 9px;
  color: var(--theme-muted, var(--muted));
  cursor: pointer;
  list-style: none;
  font-size: 12px;
}

.preset-summary::-webkit-details-marker {
  display: none;
}

.preset-summary span:first-child {
  color: var(--theme-ink, var(--ink));
  font-size: 13px;
}

.preset-summary small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 400;
}

.preset-toggle-state::before {
  content: "Open";
}

.preset-panel[open] .preset-toggle-state::before {
  content: "Close";
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 0 8px 7px;
}

.preset-button {
  min-height: 28px;
  border: 1px solid var(--theme-line, var(--line));
  background: transparent;
  color: var(--theme-muted, var(--muted));
  padding: 5px 7px;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
}

.preset-button:hover {
  border-color: var(--theme-ink, var(--ink));
  color: var(--theme-ink, var(--ink));
}

.preset-manage-button {
  margin-left: 8px;
  border: 0;
  background: transparent;
  color: var(--theme-muted, var(--muted));
  padding: 0;
  cursor: pointer;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.detail-body strong {
  color: var(--theme-ink, var(--ink));
  font-weight: 700;
  background: rgba(255, 255, 255, 0.14);
}

.effect-double {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.effect-single {
  opacity: 0.82;
  font-style: italic;
}

.effect-angle {
  border: 1px solid currentColor;
  padding: 0 4px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.94em;
}

.color-field input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 2px;
}

.code-area {
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--line);
  background: #f7f7f7;
  color: #111111;
  padding: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
}

.portrait-art {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  /* background-color(단축 아님) — 단축 background 는 .uploaded-art 의
     background-image(var(--uploaded-image))까지 리셋해 페어 이미지가
     회색으로만 보이는 버그를 만든다 (선언 순서상 이 규칙이 나중). */
  background-color: #d8d8d8;
}

.portrait-art::before,
.portrait-art::after {
  content: "";
  position: absolute;
  inset: auto;
  display: block;
}

.portrait-eiren {
  background:
    radial-gradient(circle at 64% 26%, rgba(204, 205, 214, 0.7) 0 10%, transparent 11%),
    linear-gradient(130deg, transparent 0 38%, rgba(207, 211, 222, 0.5) 39% 40%, transparent 41%),
    linear-gradient(160deg, #09090c 0%, #191921 48%, #626675 100%);
}

.portrait-eiren::before {
  width: 42%;
  height: 58%;
  left: 29%;
  bottom: 0;
  border: 1px solid rgba(235, 235, 242, 0.6);
  border-bottom: 0;
  border-radius: 50% 50% 0 0;
  background: linear-gradient(180deg, rgba(240, 240, 248, 0.12), rgba(4, 4, 6, 0.8));
}

.portrait-eiren::after {
  width: 64%;
  height: 1px;
  left: 18%;
  bottom: 18%;
  background: rgba(230, 230, 240, 0.35);
  box-shadow: 0 -38px 0 rgba(230, 230, 240, 0.2);
}

.portrait-mira {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.85) 0 8%, transparent 9%),
    radial-gradient(circle at 44% 24%, rgba(234, 164, 122, 0.88) 0 9%, transparent 10%),
    linear-gradient(150deg, #f7f1e8 0%, #f1d9c8 52%, #9fb2b5 100%);
}

.portrait-mira::before {
  width: 48%;
  height: 58%;
  left: 25%;
  bottom: 0;
  background: linear-gradient(180deg, rgba(36, 45, 48, 0.9), rgba(180, 102, 80, 0.72));
  clip-path: polygon(50% 0, 88% 100%, 12% 100%);
}

.portrait-mira::after {
  width: 72%;
  height: 58%;
  left: 14%;
  top: 16%;
  border: 1px solid rgba(45, 45, 45, 0.32);
  transform: rotate(-8deg);
}

.portrait-noct {
  background:
    radial-gradient(circle at 52% 29%, rgba(255, 31, 78, 0.75) 0 5%, transparent 6%),
    linear-gradient(45deg, transparent 0 48%, rgba(255, 255, 255, 0.28) 49% 50%, transparent 51%),
    linear-gradient(135deg, #16121a 0%, #2a2430 42%, #af1741 100%);
}

.portrait-noct::before {
  width: 38%;
  height: 62%;
  left: 31%;
  bottom: 4%;
  border-radius: 48% 48% 8% 8%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0 48%, transparent 49%),
    rgba(16, 12, 18, 0.82);
  filter: blur(0.2px);
}

.portrait-noct::after {
  width: 78%;
  height: 78%;
  left: 11%;
  top: 11%;
  border: 1px solid rgba(255, 54, 93, 0.4);
  transform: rotate(12deg);
  box-shadow: inset 0 0 40px rgba(255, 54, 93, 0.18);
}

/* Blank slate for brand-new characters: no image yet */
.portrait-blank {
  background: repeating-linear-gradient(45deg, #f3f3f3 0 14px, #ececec 14px 28px);
}

.portrait-blank::before {
  content: "NO IMAGE";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  width: auto;
  height: auto;
  color: #b3b3b3;
  font-size: 10px;
  letter-spacing: 0.24em;
}

.theme-eiren {
  --theme-panel: rgba(16, 17, 22, 0.9);
  --theme-ink: #ececf2;
  --theme-muted: #a7a8b2;
  --theme-line: rgba(230, 231, 240, 0.22);
  --theme-accent: #c4c8d8;
  background:
    radial-gradient(circle at 82% 16%, rgba(196, 200, 216, 0.22), transparent 28%),
    linear-gradient(135deg, #070709, #181821 58%, #343746);
}

.theme-mira {
  --theme-panel: rgba(255, 250, 243, 0.92);
  --theme-ink: #27231f;
  --theme-muted: #7d6f62;
  --theme-line: rgba(80, 67, 54, 0.22);
  --theme-accent: #bd6f54;
  background:
    linear-gradient(90deg, rgba(39, 35, 31, 0.04) 1px, transparent 1px),
    linear-gradient(135deg, #fbf6ee, #f2d8c8 52%, #dfe8e6);
  background-size: 42px 42px, auto;
}

.theme-noct {
  --theme-panel: rgba(26, 20, 30, 0.91);
  --theme-ink: #f5eef2;
  --theme-muted: #c8aeb9;
  --theme-line: rgba(255, 73, 115, 0.26);
  --theme-accent: #ff496e;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 48, 88, 0.3), transparent 22%),
    repeating-linear-gradient(125deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 18px),
    #151018;
}

.theme-eiren .archive-detail {
  animation: unfold 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.theme-noct .archive-row:hover {
  transform: translateX(3px) skewX(-1deg);
}

.theme-mira .archive-detail {
  background: transparent;
  padding: 0;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes viewEnter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes viewExit {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@keyframes sectionEnter {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalBackdropIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }

  to {
    opacity: 1;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
}

@keyframes modalBackdropOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes modalCardIn {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modalCardOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(5px) scale(0.992);
  }
}

@keyframes panelReveal {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes structureTabIn {
  from {
    opacity: 0;
    transform: translateY(6px);
    filter: blur(2px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes popoverReveal {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes unfold {
  from {
    opacity: 0;
    transform: perspective(900px) rotateX(2deg) translateY(10px);
    transform-origin: top center;
  }

  to {
    opacity: 1;
    transform: perspective(900px) rotateX(0) translateY(0);
  }
}

@media (max-width: 920px) {
  .character-shell-grid,
  .profile-document,
  .home-controls {
    grid-template-columns: 1fr;
  }

  .home-shell {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .home-rail {
    position: static;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px 24px;
  }

  .home-rail .rail-lead {
    display: none;
  }

  .home-rail .home-meta {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .gallery-grid,
  .pair-grid,
  .safe-demo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .home-control-buttons {
    justify-content: flex-start;
  }

  .sort-control-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .pair-thumb-frame {
    aspect-ratio: 4 / 3;
    min-height: 0;
  }

  .pair-hero-frame {
    aspect-ratio: 16 / 9;
  }

  .character-sidebar {
    position: relative;
    top: auto;
    height: auto;
  }

  .character-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tab-button {
    text-align: center;
  }
}

@media (max-width: 620px) {
  .home-view,
  .content-root {
    padding: 16px;
  }

  .rail-brand {
    font-size: 20px;
  }

  .character-gallery {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .pair-image-overlay {
    left: 12px;
    right: 12px;
    bottom: 12px;
    padding: 14px;
  }

  .gallery-grid,
  .pair-grid,
  .safe-demo-grid {
    grid-template-columns: 1fr;
  }

  .character-shell {
    padding: 10px;
  }

  .character-sidebar > .portrait-art {
    aspect-ratio: 16 / 10;
  }

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

  .character-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .split-editor,
  .settings-grid,
  .code-editor-grid,
  .range-grid,
  .preset-grid,
  .media-file-row {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    white-space: normal;
  }

  .content-sort-controls {
    flex-wrap: wrap;
  }

  .character-utility-bar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: 8px;
  }

  .utility-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .archive-row {
    grid-template-columns: 1fr;
  }

  .row-date {
    white-space: normal;
  }

  .section-header,
  .content-subnav,
  .detail-meta-line,
  .detail-top,
  .editor-top {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ====================================================================
   SCREEN LAYERS — asset-backed full-screen "lens" overlays (blood smear,
   light & flare, vintage film, camcorder, TV static, VHS) plus the
   procedural sheets that animate them. All fixed to the viewport and
   pointer-transparent so the room stays fully interactive underneath.
   ==================================================================== */
#screen-stack,
.screen-noise,
.camera-hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

#screen-stack {
  overflow: hidden;
}

.camera-hud {
  z-index: 6;
}

.screen-asset,
.screen-procedural,
.screen-grade-tint,
.screen-grade-vignette,
.screen-grade-bloom,
.screen-grade-guard {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.screen-asset {
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

/* Blood reads as a surface smear: edges hold the colour, the reading
   column in the middle is masked clearer. */
.screen-asset-blood {
  -webkit-mask-image: radial-gradient(ellipse 72% 66% at 50% 45%, transparent 28%, #000 84%);
  mask-image: radial-gradient(ellipse 72% 66% at 50% 45%, transparent 28%, #000 84%);
}

.screen-asset-broken {
  background-size: cover;
  -webkit-mask-image: radial-gradient(ellipse 62% 56% at 50% 46%, transparent 30%, #000 80%);
  mask-image: radial-gradient(ellipse 62% 56% at 50% 46%, transparent 30%, #000 80%);
  animation: glassGlint 10s ease-in-out infinite;
}

.screen-noise {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  mix-blend-mode: screen;
  opacity: 0.85;
}

/* ---- Procedural sheets ---- */
.screen-procedural {
  mix-blend-mode: screen;
}

/* Glitch: thin analog tear lines, low-opacity RGB edge bleed and a few
   animated burst bands. The heavier pixel blocks are drawn on canvas. */
.screen-procedural-glitch {
  --fx-rgb: 108 220 230;
  --fx2-rgb: 255 80 130;
  background:
    linear-gradient(90deg, rgb(var(--fx2-rgb) / 0.12), transparent 18%, transparent 78%, rgb(var(--fx-rgb) / 0.12)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.038) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgb(var(--fx-rgb) / 0.035) 0 1px, transparent 1px 11px);
}

.screen-procedural-glitch::before,
.screen-procedural-glitch::after {
  content: "";
  position: absolute;
  inset: 0;
  mix-blend-mode: screen;
}

.screen-procedural-glitch::before {
  background:
    linear-gradient(180deg, transparent, rgb(var(--fx-rgb) / 0.22) 46%, rgba(255, 255, 255, 0.18) 50%, rgb(var(--fx2-rgb) / 0.2) 56%, transparent),
    linear-gradient(90deg, transparent 0 12%, rgba(255, 255, 255, 0.09) 16%, transparent 22% 100%);
  background-size: 100% 18%, 42% 100%;
  background-repeat: no-repeat;
  animation: glitchSweep 3.8s steps(3, end) infinite;
}

.screen-procedural-glitch::after {
  background:
    linear-gradient(90deg, transparent 18%, rgb(var(--fx2-rgb) / 0.16) 18% 19%, transparent 19% 100%),
    linear-gradient(90deg, transparent 64%, rgb(var(--fx-rgb) / 0.14) 64% 65%, transparent 65% 100%);
  opacity: 0.72;
  animation: glitchEdgeJitter 1.1s steps(2, end) infinite;
}

/* TV: fine scanlines, a soft rolling bright band, vignette and flicker. */
.screen-procedural-tv {
  background:
    radial-gradient(ellipse at center, transparent 0 52%, rgba(0, 0, 0, 0.5) 90%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 3px);
  animation: tvFlickerFx 1.8s steps(3, end) infinite;
}

.screen-procedural-tv::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.16) 48%, rgba(150, 210, 255, 0.12) 54%, transparent);
  background-size: 100% 42%;
  background-repeat: no-repeat;
  animation: screenBandRoll 6.4s linear infinite;
}

.screen-procedural-tv::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 70, 90, 0.16), transparent 22%),
    linear-gradient(270deg, rgba(90, 160, 255, 0.16), transparent 24%);
  mix-blend-mode: screen;
}

/* VHS: softer scanlines, a slow tracking band, chroma bleed at edges.
   --fx-rgb / --fx2-rgb are the primary/secondary tint channels. */
.screen-procedural-vhs {
  --fx-rgb: 108 220 230;
  --fx2-rgb: 255 80 130;
  background:
    radial-gradient(ellipse at center, transparent 0 52%, rgba(0, 0, 0, 0.28) 92%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.052) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(90deg, rgb(var(--fx2-rgb) / 0.04) 0 2px, transparent 2px 9px);
}

.screen-procedural-vhs::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent, rgb(var(--fx-rgb) / 0.12) 38%, rgba(255, 255, 255, 0.16) 50%, rgb(var(--fx2-rgb) / 0.15) 61%, transparent),
    linear-gradient(90deg, rgb(var(--fx2-rgb) / 0.08), transparent 26%, transparent 74%, rgb(var(--fx-rgb) / 0.08));
  background-size: 100% 34%, 100% 100%;
  background-repeat: no-repeat;
  animation: screenBandRoll 5.4s linear infinite;
}

.screen-procedural-vhs::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgb(var(--fx2-rgb) / 0.18), transparent 17%),
    linear-gradient(270deg, rgb(var(--fx-rgb) / 0.2), transparent 22%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.026) 0 1px, transparent 1px 7px);
  mix-blend-mode: screen;
}

/* Vintage: warm halation vignette + barely-there scanlines. Grain comes
   from the noise canvas; the gate-weave drift is applied to content. */
.screen-procedural-vintage {
  --fx-rgb: 255 180 120;
  --fx2-rgb: 150 110 70;
  background:
    radial-gradient(ellipse at center, rgb(var(--fx-rgb) / 0.1), transparent 46%, rgba(0, 0, 0, 0.42) 92%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 4px);
  mix-blend-mode: soft-light;
}

.screen-procedural-vintage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 78% 14%, rgb(var(--fx-rgb) / 0.2), transparent 34%);
  mix-blend-mode: screen;
  animation: filmBreathe 7.5s ease-in-out infinite;
}

/* Camcorder: gentle exposure breathing + a soft centre-weighted focus. */
.screen-procedural-video {
  --fx-rgb: 255 86 96;
  --fx2-rgb: 150 226 244;
  background:
    radial-gradient(circle at var(--hud-focus-x, 50%) var(--hud-focus-y, 46%), transparent 0 12%, rgb(var(--fx2-rgb) / 0.08) 15%, transparent 25%),
    radial-gradient(circle at var(--hud-focus-x, 50%) var(--hud-focus-y, 46%), rgba(255, 255, 255, 0.035) 0 6%, transparent 24%),
    radial-gradient(circle at 50% 46%, transparent 0 32%, rgba(0, 0, 0, 0.24) 92%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 4px);
  animation: videoExposure 4.8s ease-in-out infinite;
}

.screen-procedural-video.is-focus-off {
  background:
    radial-gradient(circle at 50% 46%, transparent 0 34%, rgba(0, 0, 0, 0.2) 92%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 4px);
}

.screen-procedural-video::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.06) 48%, rgb(var(--fx2-rgb) / 0.05) 55%, transparent);
  background-size: 100% 36%;
  background-repeat: no-repeat;
  animation: screenBandRoll 8s linear infinite;
}

.screen-procedural-video::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgb(var(--fx-rgb) / 0.08), transparent 18%),
    linear-gradient(270deg, rgb(var(--fx2-rgb) / 0.1), transparent 22%);
  mix-blend-mode: screen;
}

/* Light & flare: a procedural tint sheet so the secondary colour can
   shape the cool-side bloom independently from the warm primary glow. */
.screen-procedural-flare {
  --fx-rgb: 255 176 102;
  --fx2-rgb: 100 216 255;
  background:
    radial-gradient(circle at 14% 42%, rgb(var(--fx-rgb) / 0.28), transparent 26%),
    radial-gradient(circle at 76% 28%, rgb(var(--fx2-rgb) / 0.16), transparent 30%),
    linear-gradient(105deg, rgb(var(--fx-rgb) / 0.12), transparent 48%, rgb(var(--fx2-rgb) / 0.1));
  mix-blend-mode: screen;
}

/* Blood procedural: edge-pooled red haze + a couple of slow creeping drips. */
.screen-procedural-blood {
  --fx-rgb: 122 6 12;
  --fx2-rgb: 44 2 6;
  background:
    radial-gradient(ellipse 120% 96% at 50% 48%, transparent 34%, rgb(var(--fx2-rgb) / 0.46) 100%),
    radial-gradient(circle at 6% 4%, rgb(var(--fx-rgb) / 0.55), transparent 32%),
    radial-gradient(circle at 95% 97%, rgb(var(--fx2-rgb) / 0.5), transparent 34%);
  mix-blend-mode: multiply;
}

.screen-procedural-blood::before,
.screen-procedural-blood::after {
  content: "";
  position: absolute;
  top: 0;
  width: 9px;
  height: 36%;
  background: linear-gradient(180deg, rgb(var(--fx2-rgb) / 0.72), rgb(var(--fx-rgb) / 0.4) 62%, transparent);
  filter: blur(1.4px);
  border-radius: 0 0 7px 7px;
  transform-origin: top;
}

.screen-procedural-blood::before {
  left: 17%;
  animation: bloodDrip 9s ease-in infinite;
}

.screen-procedural-blood::after {
  left: 71%;
  height: 28%;
  animation: bloodDrip 11s ease-in 2.4s infinite;
}

@keyframes screenBandRoll {
  from { background-position: 0 -45%; }
  to { background-position: 0 145%; }
}

@keyframes glitchSweep {
  0% { opacity: 0; background-position: 0 -28%, 0 0; }
  14% { opacity: 0.78; background-position: 0 16%, 22% 0; }
  22% { opacity: 0.16; background-position: 0 42%, 54% 0; }
  100% { opacity: 0; background-position: 0 145%, 100% 0; }
}

@keyframes glitchEdgeJitter {
  0%, 100% { transform: translate3d(0, 0, 0); }
  45% { transform: translate3d(3px, 0, 0); }
  70% { transform: translate3d(-2px, 0, 0); }
}

@keyframes tvFlickerFx {
  0%, 100% { opacity: 0.86; }
  33% { opacity: 1; }
  66% { opacity: 0.74; }
}

@keyframes filmBreathe {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@keyframes videoExposure {
  0%, 100% { filter: brightness(1) contrast(1); }
  44% { filter: brightness(1.07) contrast(0.98); }
  70% { filter: brightness(0.96) contrast(1.04); }
}

@keyframes bloodDrip {
  0% { transform: scaleY(0.18); opacity: 0; }
  12% { opacity: 1; }
  72% { transform: scaleY(1); opacity: 0.92; }
  100% { transform: scaleY(1.06); opacity: 0; }
}

/* Vintage gate weave — a sub-pixel drift on the content frame. */
.character-shell.is-weave .character-shell-grid {
  animation: gateWeave 6.5s ease-in-out infinite;
}

@keyframes gateWeave {
  0%, 100% { transform: translate3d(0, 0, 0); }
  30% { transform: translate3d(0.5px, -0.8px, 0); }
  60% { transform: translate3d(-0.7px, 0.5px, 0); }
}

/* ---- Camcorder HUD ---- */
.camera-hud {
  --fx-rgb: 255 86 96;
  --fx2-rgb: 150 226 244;
  color: rgb(var(--fx2-rgb) / 0.86);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px rgb(var(--fx2-rgb) / 0.3);
}

.hud-corners {
  position: absolute;
  inset: 26px;
  border: 1px solid rgb(var(--fx2-rgb) / 0.22);
  box-shadow: inset 0 0 42px rgba(0, 0, 0, 0.3);
  clip-path: polygon(
    0 0, 12% 0, 12% 2px, 2px 2px, 2px 12%, 0 12%,
    0 88%, 2px 88%, 2px calc(100% - 2px), 12% calc(100% - 2px), 12% 100%, 0 100%,
    100% 100%, 88% 100%, 88% calc(100% - 2px), calc(100% - 2px) calc(100% - 2px), calc(100% - 2px) 88%, 100% 88%,
    100% 12%, calc(100% - 2px) 12%, calc(100% - 2px) 2px, 88% 2px, 88% 0, 100% 0
  );
}

/* top-left: REC + timecode */
.hud-rec {
  position: absolute;
  top: 34px;
  left: 40px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: rgb(var(--fx-rgb) / 0.96);
  font-weight: 700;
}

.hud-rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgb(var(--fx-rgb));
  box-shadow: 0 0 12px rgb(var(--fx-rgb) / 0.7);
  animation: recPulse 1.2s steps(2, end) infinite;
}

.hud-timecode {
  margin-left: 4px;
  color: rgba(240, 250, 252, 0.85);
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.06em;
}

/* top-right: status chips + battery */
.hud-status {
  position: absolute;
  top: 34px;
  right: 84px;
  display: inline-flex;
  gap: 14px;
  color: rgba(240, 250, 252, 0.72);
}

.hud-status i {
  font-style: normal;
}

.hud-battery {
  position: absolute;
  top: 32px;
  right: 40px;
  width: 34px;
  height: 15px;
  border: 1px solid currentColor;
}

.hud-battery::before {
  content: "";
  position: absolute;
  top: 4px;
  right: -4px;
  width: 3px;
  height: 6px;
  background: currentColor;
}

.hud-battery::after {
  content: "";
  position: absolute;
  inset: 3px 8px 3px 3px;
  background: currentColor;
}

/* bottom-left: zoom / focus mode */
.hud-zoom {
  position: absolute;
  left: 40px;
  bottom: 34px;
  color: rgba(240, 250, 252, 0.7);
}

/* bottom-right: audio meter */
.hud-audio {
  position: absolute;
  right: 40px;
  bottom: 34px;
  display: inline-grid;
  grid-template-columns: repeat(2, 4px);
  align-items: end;
  gap: 4px;
  height: 26px;
}

.hud-audio i {
  width: 4px;
  height: 10px;
  background: linear-gradient(180deg, rgb(var(--fx-rgb) / 0.9), rgb(var(--fx2-rgb) / 0.72));
  transform-origin: bottom;
  animation: hudAudio 0.9s ease-in-out infinite;
}

.hud-audio i:nth-child(2) {
  animation-delay: -0.34s;
}

.hud-focus {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(120px, 14vw, 188px);
  height: clamp(82px, 9.5vw, 126px);
  --focus-line: rgb(var(--fx2-rgb) / 0.86);
  background:
    linear-gradient(var(--focus-line), var(--focus-line)) left top / 30px 2px no-repeat,
    linear-gradient(var(--focus-line), var(--focus-line)) left top / 2px 30px no-repeat,
    linear-gradient(var(--focus-line), var(--focus-line)) right top / 30px 2px no-repeat,
    linear-gradient(var(--focus-line), var(--focus-line)) right top / 2px 30px no-repeat,
    linear-gradient(var(--focus-line), var(--focus-line)) left bottom / 30px 2px no-repeat,
    linear-gradient(var(--focus-line), var(--focus-line)) left bottom / 2px 30px no-repeat,
    linear-gradient(var(--focus-line), var(--focus-line)) right bottom / 30px 2px no-repeat,
    linear-gradient(var(--focus-line), var(--focus-line)) right bottom / 2px 30px no-repeat;
  filter: drop-shadow(0 0 4px rgb(var(--fx2-rgb) / 0.35));
  transform: translate(-50%, -50%);
  transition: filter 200ms ease;
}

.camera-hud.hide-focus .hud-focus {
  display: none;
}

.hud-focus::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.85)) center / 1.6px 16px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.85)) center / 16px 1.6px no-repeat;
}

.hud-focus.is-locked {
  --focus-line: rgba(150, 255, 200, 0.92);
  filter: drop-shadow(0 0 5px rgba(120, 255, 190, 0.45));
}

@keyframes recPulse {
  0%, 48% { opacity: 1; }
  49%, 100% { opacity: 0.22; }
}

@keyframes hudAudio {
  0%, 100% { transform: scaleY(0.4); }
  40% { transform: scaleY(1); }
  70% { transform: scaleY(0.62); }
}

/* ====================================================================
   GRADE & OPTICS — colour grade tint + vignette + soft bloom overlays,
   a backdrop colour filter per preset, and a sub-pixel chromatic split
   on the content. Driven by data-grade / is-soft / is-vignette / is-chroma
   on the character shell. "원본" removes them all.
   ==================================================================== */
.screen-grade-tint { mix-blend-mode: soft-light; }

.character-shell[data-grade="teal-orange"] .room-backdrop {
  filter: saturate(calc(1 + var(--grade-amt, 0.6) * 0.32)) contrast(calc(1 + var(--grade-amt, 0.6) * 0.1));
}
.character-shell[data-grade="teal-orange"] .screen-grade-tint {
  background: linear-gradient(118deg, rgba(255, 150, 70, 0.5), transparent 46%, rgba(36, 150, 172, 0.5));
  opacity: calc(var(--grade-amt, 0.6) * 0.62);
}

.character-shell[data-grade="sepia"] .room-backdrop {
  filter: sepia(calc(var(--grade-amt, 0.6) * 0.55)) saturate(calc(1 - var(--grade-amt, 0.6) * 0.1)) brightness(calc(1 + var(--grade-amt, 0.6) * 0.02));
}
.character-shell[data-grade="sepia"] .screen-grade-tint {
  background: linear-gradient(160deg, rgba(214, 158, 92, 0.6), rgba(150, 96, 48, 0.35));
  opacity: calc(var(--grade-amt, 0.6) * 0.5);
}

.character-shell[data-grade="noir"] .room-backdrop {
  filter: saturate(calc(1 - var(--grade-amt, 0.6) * 0.78)) contrast(calc(1 + var(--grade-amt, 0.6) * 0.18));
}
.character-shell[data-grade="noir"] .screen-grade-tint {
  background: linear-gradient(135deg, rgba(40, 70, 110, 0.5), transparent 60%);
  mix-blend-mode: multiply;
  opacity: calc(var(--grade-amt, 0.6) * 0.42);
}

.character-shell[data-grade="faded"] .room-backdrop {
  filter: contrast(calc(1 - var(--grade-amt, 0.6) * 0.2)) brightness(calc(1 + var(--grade-amt, 0.6) * 0.08)) saturate(calc(1 - var(--grade-amt, 0.6) * 0.2));
}
.character-shell[data-grade="faded"] .screen-grade-tint {
  background: linear-gradient(180deg, rgba(180, 186, 196, 0.4), rgba(150, 140, 150, 0.3));
  mix-blend-mode: screen;
  opacity: calc(var(--grade-amt, 0.6) * 0.4);
}

.character-shell[data-grade="bleach"] .room-backdrop {
  filter: saturate(calc(1 - var(--grade-amt, 0.6) * 0.5)) contrast(calc(1 + var(--grade-amt, 0.6) * 0.34)) brightness(calc(1 + var(--grade-amt, 0.6) * 0.04));
}
.character-shell[data-grade="bleach"] .screen-grade-tint {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 50%, rgba(0, 0, 0, 0.2));
  mix-blend-mode: overlay;
  opacity: calc(var(--grade-amt, 0.6) * 0.5);
}

.screen-grade-vignette {
  background: radial-gradient(ellipse 80% 74% at 50% 46%, transparent 40%, rgba(0, 0, 0, 0.88) 100%);
  mix-blend-mode: multiply;
}

.screen-grade-bloom {
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 250, 240, 0.5), transparent 58%),
    linear-gradient(rgba(255, 252, 246, 0.16), rgba(255, 252, 246, 0.16));
  mix-blend-mode: screen;
}

.screen-grade-guard {
  --guard-amt: 0.45;
  --guard-dark: 0.34;
  --guard-detail: 0.72;
  --guard-edge: 0.74;
  --guard-clear: 42%;
  --guard-feather: 67%;
  background:
    radial-gradient(ellipse 72% 58% at 50% 46%, rgba(255, 255, 255, calc(var(--guard-amt) * 0.08)) 0 var(--guard-clear), transparent var(--guard-feather), rgba(0, 0, 0, calc(var(--guard-dark) * 0.72)) 100%),
    linear-gradient(rgba(12, 13, 18, calc(var(--guard-dark) * 0.26)), rgba(12, 13, 18, calc(var(--guard-dark) * 0.26)));
  mix-blend-mode: multiply;
  backdrop-filter: brightness(calc(1 + var(--guard-amt) * 0.2)) saturate(calc(0.98 + var(--guard-detail) * 0.08)) contrast(0.98);
}

.character-shell.is-chroma .character-shell-grid {
  filter:
    drop-shadow(calc(var(--chroma-amt, 0.8) * 1px) 0 rgba(255, 50, 90, 0.5))
    drop-shadow(calc(var(--chroma-amt, 0.8) * -1px) 0 rgba(60, 150, 255, 0.5));
}

/* ====================================================================
   EFFECTS DOCK — a live customization panel that floats over the room;
   the room stays scrollable / clickable while every control applies
   instantly. Inherits the active room theme so it always matches.
   ==================================================================== */
.effects-dock {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  width: 376px;
  max-width: min(92vw, 376px);
  box-sizing: border-box;
  background: var(--theme-panel, rgba(16, 17, 22, 0.94));
  color: var(--theme-ink, var(--ink));
  border-left: 1px solid var(--theme-line, var(--line));
  box-shadow: -26px 0 64px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(20px) saturate(1.1);
  -webkit-backdrop-filter: blur(20px) saturate(1.1);
  animation: dockSlideIn 300ms var(--ease-out) both;
}

.effects-dock *,
.effects-dock *::before,
.effects-dock *::after {
  box-sizing: border-box;
}

.effects-dock[hidden] {
  display: none;
}

@keyframes dockSlideIn {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

.dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--theme-line, var(--line));
}

.dock-head h3 {
  margin: 0;
  font-family: var(--font-title);
  font-size: var(--fs-lg);
  font-weight: var(--fw-medium);
  letter-spacing: 0.02em;
}

.dock-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 4px 18px 24px;
}

.dock-note {
  margin: 14px 0 4px;
  color: var(--theme-muted, var(--muted));
  font-size: var(--fs-meta);
  line-height: var(--lh-normal);
}

.dock-section {
  padding: 18px 0;
  border-top: 1px solid var(--theme-line, var(--line));
  display: grid;
  gap: 12px;
}

.dock-section:first-of-type {
  border-top: 0;
}

.dock-section-title {
  margin: 0;
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--theme-ink, var(--ink));
  font-weight: var(--fw-bold);
}

.dock-section-hint {
  margin: -6px 0 2px;
  color: var(--theme-muted, var(--muted));
  font-size: 11px;
  line-height: 1.5;
}

.effects-dock .field span {
  color: var(--theme-muted, var(--muted));
}

.effects-dock .field,
.dock-slider {
  min-width: 0;
}

.effects-dock .field input,
.effects-dock .field select {
  width: 100%;
  max-width: 100%;
  background: rgba(127, 127, 127, 0.1);
  border-color: var(--theme-line, var(--line));
  color: var(--theme-ink, var(--ink));
}

.effects-dock .field input[type="range"] {
  width: 100%;
  accent-color: var(--theme-accent, var(--theme-ink, var(--ink)));
  padding: 0;
  background: transparent;
  border: 0;
}

.effects-dock .field input[type="color"] {
  flex: 0 0 44px;
  width: 44px;
  max-width: 44px;
}

.effects-dock .field input[type="checkbox"],
.effects-dock .check-field input[type="checkbox"] {
  flex: 0 0 16px;
  width: 16px;
  max-width: 16px;
}

.effects-dock .check-field {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: var(--fs-body);
  color: var(--theme-ink, var(--ink));
  cursor: pointer;
}

.effects-dock .filter-chip {
  color: var(--theme-ink, var(--ink));
  border-color: var(--theme-line, var(--line));
  background: transparent;
}

.effects-dock .filter-chip.active {
  background: var(--theme-ink, var(--ink));
  border-color: var(--theme-ink, var(--ink));
  color: var(--theme-panel, #fff);
}

.dock-slider span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.dock-slider output {
  font-variant-numeric: tabular-nums;
  color: var(--theme-ink, var(--ink));
}

.dock-layer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

/* Borderless: layer settings flow as a plain list, not boxed cards. */
.dock-layer-card,
.dock-grade {
  display: grid;
  gap: 12px;
  padding: 12px 0 4px;
  border: 0;
  background: transparent;
}

.dock-layer-card + .dock-layer-card {
  border-top: 1px solid var(--theme-line, var(--line));
  padding-top: 16px;
}

.dock-layer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dock-layer-head strong {
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
}

.dock-assets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.dock-asset {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--theme-line, var(--line));
  background: rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.dock-asset:hover {
  border-color: var(--theme-ink, var(--ink));
}

.dock-asset.is-on {
  border-color: var(--theme-accent, var(--theme-ink, var(--ink)));
  background: rgba(127, 127, 127, 0.16);
}

.dock-asset input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.dock-asset.is-on::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--theme-accent, var(--theme-ink, var(--ink)));
  box-shadow: 0 0 0 2px var(--theme-panel, rgba(0, 0, 0, 0.6));
}

.dock-asset-thumb {
  display: block;
  width: 100%;
  height: 46px;
  background-color: #0c0d11;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.dock-asset-thumb-procedural {
  background:
    linear-gradient(90deg, rgba(255, 64, 96, 0.42), transparent 22%, transparent 66%, rgba(88, 190, 255, 0.38)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.18) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 5px, rgba(0, 0, 0, 0.24) 5px 11px),
    #11131a;
}

.dock-asset-name {
  font-size: 11px;
  line-height: 1.3;
  color: var(--theme-muted, var(--muted));
}

.dock-footer {
  display: flex;
  justify-content: flex-end;
  padding: 14px 0 4px;
}

.dock-reset-all {
  color: var(--theme-muted, var(--muted));
  min-height: 30px;
  padding: 5px 12px;
}

.dock-reset-all:hover {
  color: var(--theme-ink, var(--ink));
}

@media (max-width: 620px) {
  .effects-dock {
    width: 100vw;
    max-width: 100vw;
    top: auto;
    height: 76svh;
    border-left: 0;
    border-top: 1px solid var(--theme-line, var(--line));
    animation: dockSlideUp 300ms var(--ease-out) both;
  }

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

@media (prefers-reduced-motion: reduce) {
  .screen-procedural-tv,
  .screen-procedural-tv::before,
  .screen-procedural-glitch::before,
  .screen-procedural-glitch::after,
  .screen-asset-broken,
  .screen-procedural-vhs::before,
  .screen-procedural-vintage::before,
  .screen-procedural-video,
  .screen-procedural-video::before,
  .screen-procedural-blood::before,
  .screen-procedural-blood::after,
  .character-shell.is-weave .character-shell-grid,
  .hud-rec-dot,
  .effects-dock {
    animation: none;
  }
}

/* ── 태그 관리 모달 / 사이드바 링크 ─────────────────────────── */
.tag-manage-note {
  margin: 0 0 14px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted, #888);
}

.tag-manage-row {
  gap: 8px;
}

.tag-manage-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 999px;
  padding: 4px 8px 4px 12px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.65);
}

.tag-manage-chip b {
  font-weight: 500;
}

.tag-manage-chip i {
  font-style: normal;
  font-size: 11px;
  opacity: 0.5;
}

.tag-manage-chip button {
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 2px 3px;
  opacity: 0.55;
}

.tag-manage-chip button:hover {
  opacity: 1;
}

.tag-manage-empty {
  font-size: 12px;
  color: var(--muted, #999);
}

.tag-manage-link {
  margin-top: 10px;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--theme-muted, var(--muted, #888));
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
  text-align: left;
}

.tag-manage-link:hover {
  color: var(--theme-ink, var(--ink, #222));
}

.manage-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* 태그 칩 인라인 편집(이름 변경)·삭제 확인 상태 */
.tag-manage-chip.is-editing,
.tag-manage-chip.is-confirming {
  padding: 3px 7px 3px 11px;
  border-color: rgba(0, 0, 0, 0.32);
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
}

.tag-manage-chip .tag-edit-input {
  width: 108px;
  border: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  padding: 1px 2px;
  outline: none;
}

.tag-manage-chip .tag-edit-input:focus {
  border-bottom-color: rgba(0, 0, 0, 0.75);
}

.tag-manage-chip em {
  font-style: normal;
  font-size: 12px;
  margin-right: 2px;
}

.tag-manage-chip .tag-chip-ok {
  color: #2e7d4f;
  font-weight: 600;
}

.tag-manage-chip .tag-chip-danger {
  color: #b0475a;
  font-weight: 600;
}

.tag-manage-chip.is-confirming button,
.tag-manage-chip.is-editing button {
  opacity: 0.8;
}

.tag-manage-chip.is-confirming button:hover,
.tag-manage-chip.is-editing button:hover {
  opacity: 1;
}

/* ── Marginalia 마스트헤드 — 스위스 에디토리얼 ─────────────────
   큰 그로테스크 워드마크 / 전폭 헤어라인 / 작게 트래킹된 메타.
   크기 대비와 정밀한 간격으로 위계를 만든다. */
.rail-brand-word {
  font-size: clamp(25px, 2.1vw, 33px);
  font-weight: var(--fw-bold);
  letter-spacing: -0.015em;
  line-height: 0.95;
  text-transform: uppercase;
  white-space: nowrap;
}

.rail-head .rail-sub {
  margin-top: 13px !important;
  font-size: 9.5px;
  letter-spacing: 0.32em;
  color: #767676;
}

/* 마스트헤드 아래로 정보들이 한 묶음처럼 이어진다 —
   워드마크 ↔ 카운터 한 단, 카운터 ↔ 유틸리티 반 단.
   (그리드 gap 이 이미 18~30px 을 깔아 주므로 margin 은 미세 조정만) */
.home-rail .home-meta {
  margin-top: 6px;
}

.home-rail #archive-backup {
  margin-top: 0 !important;
}

.footer-ver {
  display: inline-block;
  margin-left: 10px;
  padding: 2px 9px 3px;
  border: 1px solid var(--line, #e2e2e2);
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9a9a9a;
  vertical-align: 1px;
}

/* 형식 없는 프로필 본문 */
.profile-plain {
  max-width: 72ch;
}

.profile-plain > .detail-body {
  overflow-wrap: break-word;
}

/* 클릭 확대 가능한 이미지 표시 */
.archive-detail .gallery-large,
#sidebar-portrait .image-crop-art {
  cursor: zoom-in;
}

/* Pair overview + optional long-form story. These selectors are deliberately
   component-scoped; individual themes can restyle the same generic surface. */
.pair-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(250px, 0.8fr);
  gap: clamp(20px, 3vw, 38px);
  align-items: stretch;
  margin: 0 0 clamp(34px, 5vw, 64px);
}

.pair-overview > * {
  min-width: 0;
}

.pair-overview .pair-hero {
  margin: 0;
}

.pair-overview .pair-hero-frame {
  height: 100%;
  min-height: 280px;
  aspect-ratio: 16 / 10;
}

.pair-intro {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(28px, 5vw, 68px);
  padding: clamp(24px, 3.4vw, 46px);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel, #ffffff) 92%, transparent);
}

.pair-intro-kicker {
  margin: 0 0 18px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.pair-intro h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(25px, 3vw, 42px);
  font-weight: var(--fw-medium);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.pair-intro-summary {
  max-width: 46ch;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.82;
  white-space: pre-line;
}

.pair-intro-summary.pair-intro-empty {
  opacity: 0.72;
  font-style: italic;
}

.pair-story-button {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 0 18px;
  border: 1px solid currentColor;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.14em;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.pair-story-button i {
  font-size: 20px;
  font-style: normal;
  line-height: 1;
}

.pair-story-button:is(:hover, :focus-visible) {
  background: var(--ink);
  color: var(--panel, #ffffff);
  transform: translateY(-2px);
  outline: none;
}

html.pair-story-open,
html.pair-story-open body {
  overflow: hidden;
}

.pair-story-layer {
  --pair-story-panel: var(--panel, #ffffff);
  --pair-story-ink: var(--ink, #171717);
  --pair-story-muted: var(--muted, #747474);
  --pair-story-line: var(--line, #dddddd);
  position: fixed;
  inset: 0;
  z-index: 220;
  color: var(--pair-story-ink);
  font-family: var(--font-body);
}

.pair-story-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(16, 16, 16, 0.42);
  backdrop-filter: blur(7px);
  cursor: default;
  animation: pairStoryFadeIn 220ms ease both;
}

.pair-story-panel {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(560px, calc(100vw - 28px));
  height: 100dvh;
  border-left: 1px solid var(--pair-story-line);
  background: var(--pair-story-panel);
  box-shadow: -28px 0 80px rgba(0, 0, 0, 0.16);
  animation: pairStoryDrawerIn 360ms var(--ease-out) both;
}

.pair-story-layer[data-presentation="modal"] {
  display: grid;
  place-items: center;
  padding: 24px;
}

.pair-story-layer[data-presentation="modal"] .pair-story-panel {
  position: relative;
  top: auto;
  right: auto;
  width: min(760px, 100%);
  height: min(84dvh, 880px);
  border: 1px solid var(--pair-story-line);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.2);
  animation-name: pairStoryModalIn;
}

.pair-story-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
  padding: clamp(24px, 4vw, 44px);
  border-bottom: 1px solid var(--pair-story-line);
}

.pair-story-head p,
.pair-story-section-head > p {
  margin: 0 0 10px;
  color: var(--pair-story-muted);
  font-family: var(--font-ui);
  font-size: 8px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.pair-story-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(27px, 4vw, 46px);
  font-weight: var(--fw-medium);
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.pair-story-head button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--pair-story-muted);
  font: 600 9px/1 var(--font-ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

.pair-story-head button i {
  color: var(--pair-story-ink);
  font-size: 19px;
  font-style: normal;
}

.pair-story-head button:hover {
  color: var(--pair-story-ink);
}

.pair-story-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(28px, 5vw, 54px) clamp(24px, 4vw, 44px) clamp(48px, 7vw, 76px);
}

.pair-story-lead {
  margin: 0 0 36px;
  font-family: var(--font-display);
  font-size: clamp(20px, 2.5vw, 28px);
  line-height: 1.55;
}

.pair-story-prose {
  display: grid;
  gap: 18px;
  color: var(--pair-story-muted);
  font-size: 14px;
  line-height: 1.9;
}

.pair-story-prose p {
  margin: 0;
  white-space: pre-line;
}

.pair-story-empty {
  font-style: italic;
  opacity: 0.75;
}

.pair-story-timeline {
  margin-top: clamp(44px, 8vw, 80px);
  padding-top: 28px;
  border-top: 1px solid var(--pair-story-line);
}

.pair-story-section-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: var(--fw-medium);
}

.pair-story-timeline ol {
  display: grid;
  gap: 0;
  margin: 30px 0 0;
  padding: 0;
  list-style: none;
}

.pair-story-timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 22px;
  padding: 0 0 30px;
}

.pair-story-timeline li::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 98px;
  width: 7px;
  height: 7px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: var(--pair-story-panel);
}

.pair-story-timeline li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 13px;
  bottom: 0;
  left: 101px;
  width: 1px;
  background: var(--pair-story-line);
}

.pair-story-timeline li > span {
  color: var(--pair-story-muted);
  font-family: var(--font-ui);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pair-story-timeline li > div {
  padding-left: 11px;
}

.pair-story-timeline h4 {
  margin: 0 0 7px;
  font-size: 15px;
  font-weight: var(--fw-bold);
}

.pair-story-timeline li p {
  margin: 0;
  color: var(--pair-story-muted);
  font-size: 13px;
  line-height: 1.75;
}

.pair-story-editor {
  display: grid;
  gap: 14px;
  margin: 8px 0 2px;
  padding: 18px 0 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.pair-story-editor-title small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.pair-timeline-editor {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}

.pair-timeline-editor-list {
  display: grid;
  gap: 12px;
}

.pair-timeline-editor-row {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(127, 127, 127, 0.035);
}

.pair-timeline-editor-head,
.pair-timeline-editor-fields {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.pair-timeline-editor-head > span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pair-timeline-editor-head button {
  padding: 0;
  border: 0;
  background: transparent;
  color: #a8333b;
  font: 600 9px/1 var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.pair-timeline-editor-fields > .field {
  flex: 1 1 0;
  min-width: 0;
}

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

@keyframes pairStoryDrawerIn {
  from { opacity: 0; transform: translateX(32px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pairStoryModalIn {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 760px) {
  .pair-overview {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .pair-overview .pair-hero-frame {
    min-height: 0;
    aspect-ratio: 16 / 10;
  }

  .pair-intro {
    gap: 26px;
    padding: 22px;
  }

  .pair-story-layer,
  .pair-story-layer[data-presentation="modal"] {
    display: block;
    padding: 0;
  }

  .pair-story-panel,
  .pair-story-layer[data-presentation="modal"] .pair-story-panel {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100dvh;
    border: 0;
    animation-name: pairStoryDrawerIn;
  }

  .pair-story-head button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .pair-story-timeline li {
    grid-template-columns: 70px minmax(0, 1fr);
    gap: 15px;
  }

  .pair-story-timeline li::before { left: 75px; }
  .pair-story-timeline li:not(:last-child)::after { left: 78px; }
  .pair-timeline-editor-fields { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .pair-story-backdrop,
  .pair-story-panel {
    animation: none;
  }
}
