:root {
  --bg-0: #1c243d;
  --bg-1: #3f4c89;
  --bg-2: #f38f73;
  --panel: rgba(18, 21, 35, 0.16);
  --panel-strong: rgba(11, 14, 24, 0.24);
  --surface: rgba(255, 255, 255, 0.06);
  --field: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f5f7;
  --text-muted: #d5d8e3;
  --good: #62d66f;
  --indicator-green: var(--good);
  --warn: #ffd166;
  --danger: #ff5f73;
  --shadow: 0 24px 80px rgba(10, 8, 22, 0.24);
  --glow-blue: rgba(136, 179, 255, 0.22);
  --glow-white: rgba(255, 255, 255, 0.1);
  --glow-sunset: rgba(255, 167, 125, 0.24);
  --console-bg: rgba(7, 14, 13, 0.76);
  --console-text: #baf7c0;
  --glass-top: rgba(255, 255, 255, 0.055);
  --glass-bottom: rgba(255, 255, 255, 0.018);
  --glass-edge: rgba(255, 255, 255, 0.11);
  --glass-edge-soft: rgba(255, 255, 255, 0.07);
  --glass-sheen: rgba(255, 255, 255, 0.08);
  --glass-caustic: rgba(255, 218, 190, 0.08);
  --glass-warp: rgba(148, 198, 255, 0.06);
  --glass-shadow: 0 18px 48px rgba(10, 8, 22, 0.14);
  --radius: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --ease: cubic-bezier(.22,.61,.36,1);
  --radius-card: 22px;
  --radius-btn: 14px;
  --radius-pill: 999px;
  --transition-fast: 0.18s cubic-bezier(.22,.61,.36,1);
  --transition-base: 0.24s cubic-bezier(.22,.61,.36,1);
  --transition-long: 0.58s cubic-bezier(.16,.84,.28,1);
  /* iOS-style motion system — spring easing + duration ramp */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-instant: 120ms;
  --dur-fast: 180ms;
  --dur-base: 240ms;
  --dur-slow: 380ms;
  --dur-modal: 340ms;
  --scale-press: 0.96;
  --good-glow: rgba(98, 214, 111, 0.55);
  --indicator-green-glow: var(--good-glow);
  --warn-glow: rgba(255, 209, 102, 0.5);
  --danger-glow: rgba(255, 95, 115, 0.5);
  --backdrop-blur: 26px;
  --backdrop-blur-strong: 28px;
  --backdrop-sat: 145%;
  --player-tile-size: clamp(164px, 42vw, 186px);
  --font-size-xs: 0.72rem;
  --font-size-sm: 0.82rem;
  --font-size-md: 0.92rem;
  --font-size-lg: 1rem;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

body {
  color: var(--text);
  font-family: "SF Pro Display", "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: var(--font-size-md);
  line-height: 1.45;
  letter-spacing: 0.01em;
  background: #0f1324;
  overflow-x: hidden;
  overflow-y: auto;
  transition: color 0.4s var(--ease);
}

body.modal-open {
  overflow: hidden;
}

/* ── Global iOS-style tap + motion reset ─────────────────────────── */
* {
  -webkit-tap-highlight-color: transparent;
}

button,
[role="button"],
.tab-btn,
.action-pill-btn,
.action-btn,
.villager-card,
.inventory-slot,
.modal-close,
.deploy-button {
  touch-action: manipulation;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Global iOS-style press-scale feedback ───────────────────────
   Applied to interactive controls via one grouped selector. Uses
   short instant duration so the squish is snappy, not laggy. */
.action-pill-btn,
.action-btn,
.tab-btn,
.deploy-button,
.villager-card,
.inventory-slot,
.modal-close,
.vmod-edit-tab-btn,
.backup-restore-btn,
.backup-delete-btn {
  transform-origin: center;
}

.action-pill-btn:active,
.action-btn:active,
.tab-btn:active,
.deploy-button:active,
.villager-card:active,
.inventory-slot:active,
.modal-close:active,
.vmod-edit-tab-btn:active,
.backup-restore-btn:active,
.backup-delete-btn:active {
  transform: scale(var(--scale-press));
  transition: transform var(--dur-instant) var(--ease-out);
}

.touch-feedback-burst {
  position: fixed;
  z-index: 10000;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(214, 224, 255, 0.38);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.35);
  background:
    radial-gradient(circle, rgba(255, 238, 220, 0.48) 0%, rgba(164, 181, 255, 0.24) 30%, transparent 68%);
  box-shadow: 0 0 14px rgba(181, 193, 255, 0.34);
  animation: touch-feedback-burst 420ms var(--ease-out) forwards;
}

.touch-feedback-burst::after {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  content: '';
  transform: translate(-65%, -45%) scale(0.2);
  background: radial-gradient(circle, rgba(255, 246, 231, 0.38) 0%, rgba(145, 174, 255, 0.18) 42%, transparent 70%);
  filter: blur(1px);
  animation: touch-feedback-trail 460ms 70ms var(--ease-out) forwards;
}

@keyframes touch-feedback-burst {
  0% { opacity: 0.9; transform: translate(-50%, -50%) scale(0.35); }
  65% { opacity: 0.32; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(5.2); }
}

@keyframes touch-feedback-trail {
  0% { opacity: 0; transform: translate(-65%, -45%) scale(0.2); }
  24% { opacity: 0.6; }
  100% { opacity: 0; transform: translate(20%, 40%) scale(4.4); }
}

/* ── Backdrop-filter compositor perf ─────────────────────────────
   Visual look preserved. `contain: paint` limits repaint area to each
   surface so the browser doesn't recompute blur over the entire page
   whenever anything below changes. Isolation ensures a fresh stacking
   context which many surfaces already had. Big win on Steam Deck GPU. */
.shell-card,
.modal-card,
.selected-item-sticky,
.music-ribbon-drawer,
.inv-quick-search-results,
.villager-card,
.villager-house-lock,
.deploy-toast {
  contain: paint;
  isolation: isolate;
}

/* Only promote the modal to its own compositor layer while it's visible.
   `will-change` at rest is a memory cost — keeping it gated by state. */
.modal.is-visible .modal-card {
  will-change: transform, opacity;
}

/* ── Global panel fade-in on first paint ─────────────────────────
   Every shell-card and tab-panel softly fades + settles when the app
   shell reveals itself. Staggered to feel like content arriving in
   sequence rather than all-at-once. Runs once per page load. */
@keyframes panel-fade-in {
  0%   { opacity: 0; transform: translateY(6px) scale(0.995); }
  100% { opacity: 1; transform: translateY(0)  scale(1);      }
}
.app-shell:not(.app-hidden) .shell-card {
  animation: panel-fade-in var(--dur-slow) var(--ease-spring) both;
}
.app-shell:not(.app-hidden) .shell-card:nth-child(1) { animation-delay: 0ms; }
.app-shell:not(.app-hidden) .shell-card:nth-child(2) { animation-delay: 40ms; }
.app-shell:not(.app-hidden) .shell-card:nth-child(3) { animation-delay: 80ms; }
.app-shell:not(.app-hidden) .shell-card:nth-child(4) { animation-delay: 120ms; }
.app-shell:not(.app-hidden) .shell-card:nth-child(5) { animation-delay: 160ms; }
.app-shell:not(.app-hidden) .shell-card:nth-child(n+6) { animation-delay: 200ms; }

/* Generic skeleton row + tile for reuse across panels */
.skeleton-row {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(255,255,255,0.11) 40%,
    rgba(255,255,255,0.04) 80%
  );
  background-size: 200% auto;
  animation: shimmer 1.5s linear infinite;
}

/* ── Global input focus ring ─────────────────────────────────────
   Consistent focus indicator for all text/number inputs, matching the
   iOS "soft glow" style. Uses --glow-blue for parity with theme. */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px var(--glow-blue),
    0 0 0 1px rgba(255,255,255,0.18) inset;
  transition:
    box-shadow var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

body.is-drag-scrolling,
body.is-drag-scrolling * {
  cursor: grabbing !important;
  user-select: none !important;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* Hide all scrollbars globally except .code-block custom ones */
*:not(.code-block)::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }
.code-block { scrollbar-width: thin; }

.sky-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

.aurora-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px) scale(1.02);
  transition: opacity 1s var(--ease), transform 1s var(--ease);
}

.moon-layer {
  position: fixed;
  top: clamp(112px, 18vh, 186px);
  right: clamp(-4px, 2vw, 40px);
  width: clamp(68px, 8vw, 112px);
  aspect-ratio: 1 / 1;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transform: translateY(-8px) scale(0.92);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

.moon-body {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 253, 247, 0.98) 0 18%, rgba(244, 241, 236, 0.98) 22%, rgba(227, 226, 236, 0.94) 54%, rgba(197, 199, 221, 0.92) 78%, rgba(142, 147, 178, 0.88) 100%);
  box-shadow:
    0 0 16px rgba(255,255,255,0.24),
    0 0 42px rgba(205, 200, 255, 0.16),
    0 0 84px rgba(161, 157, 218, 0.12);
  overflow: hidden;
}

.moon-body::before {
  content: "";
  position: absolute;
  inset: -26%;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(241, 235, 255, 0.12) 0%, rgba(204, 194, 244, 0.06) 34%, transparent 68%);
  z-index: -1;
}

.moon-body::after {
  content: "";
  position: absolute;
  top: 4%;
  right: -10%;
  width: 86%;
  height: 90%;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 50%, rgba(19, 23, 48, 0.96), rgba(33, 39, 77, 0.88));
  box-shadow: inset 0 0 28px rgba(8, 10, 20, 0.24);
}

.moon-crater {
  position: absolute;
  border-radius: 999px;
  background: rgba(186, 188, 211, 0.28);
  box-shadow: inset 0 1px 3px rgba(110, 116, 144, 0.18);
}

.crater-a {
  top: 26%;
  left: 18%;
  width: 16%;
  height: 12%;
}

.crater-b {
  top: 46%;
  left: 28%;
  width: 12%;
  height: 10%;
}

.crater-c {
  top: 58%;
  left: 18%;
  width: 10%;
  height: 8%;
}

.sky-layer-sunrise {
  opacity: 1;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 214, 168, 0.42), transparent 18%),
    radial-gradient(circle at 50% 20%, rgba(255, 165, 134, 0.36), transparent 28%),
    radial-gradient(circle at 78% 18%, rgba(147, 171, 255, 0.24), transparent 20%),
    linear-gradient(180deg, #5367b2 0%, #7f6fb6 24%, #d77d81 62%, #f6b084 82%, #fff0bf 100%);
}

.sky-layer-night {
  background:
    radial-gradient(circle at 70% 16%, rgba(228, 229, 255, 0.12), transparent 9%),
    radial-gradient(circle at 20% 26%, rgba(121, 111, 184, 0.14), transparent 18%),
    radial-gradient(circle at 56% 40%, rgba(86, 76, 142, 0.18), transparent 28%),
    radial-gradient(circle at 52% 78%, rgba(112, 126, 174, 0.14), transparent 18%),
    linear-gradient(180deg, #0d1330 0%, #171d43 28%, #232550 52%, #2b345e 76%, #1b2745 100%);
}

body[data-theme='night'] {
  --panel: rgba(18, 19, 33, 0.14);
  --panel-strong: rgba(13, 15, 29, 0.22);
  --surface: rgba(255, 255, 255, 0.0);
  --field: rgba(255, 255, 255, 0.04);
  --line: rgba(220, 218, 246, 0.09);
  --line-strong: rgba(236, 233, 255, 0.16);
  --text: #f6f5ff;
  --text-muted: #cfcde4;
  --shadow: 0 24px 80px rgba(8, 9, 20, 0.34);
  --glow-blue: rgba(156, 146, 228, 0.18);
  --glow-sunset: rgba(194, 160, 226, 0.12);
  --console-bg: rgba(10, 12, 24, 0.7);
  --glass-top: rgba(246, 242, 255, 0.045);
  --glass-bottom: rgba(255, 255, 255, 0.016);
  --glass-edge: rgba(232, 227, 255, 0.1);
  --glass-edge-soft: rgba(222, 216, 250, 0.065);
  --glass-sheen: rgba(244, 240, 255, 0.075);
  --glass-caustic: rgba(195, 185, 236, 0.07);
  --glass-warp: rgba(170, 160, 230, 0.05);
  --glass-shadow: 0 18px 50px rgba(8, 9, 20, 0.18);
}

body[data-theme='night'] .sky-layer-sunrise {
  opacity: 0;
  transform: scale(1.015);
}

body[data-theme='night'] .sky-layer-night {
  opacity: 1;
  transform: scale(1);
}

body[data-theme='night'] .moon-layer {
  opacity: 0.88;
  transform: translateY(0) scale(1);
}

body[data-theme='night'] .aurora-layer {
  opacity: 0.92;
  transform: translateY(0) scale(1);
}

button,
input {
  font: inherit;
}

button,
input,
select,
textarea {
  font-size: var(--font-size-md);
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.panel-label,
.inventory-sidebar-label,
.music-field > span,
.status-pill,
.quick-cheat-label,
.inv-qsr-cat,
.tab-category-summary,
.item-modal-payload-label,
.meta-key {
  font-size: var(--font-size-sm);
  letter-spacing: 0.02em;
}

/* Universal skeleton state overlays for first-load and explicit async sections */
.player-panel.is-loading .avatar-box,
.inventory-card.is-loading,
.inv-qsr-row.is-skeleton {
  position: relative;
  overflow: hidden;
}

.player-panel.is-loading .avatar-box::after,
.inventory-card.is-loading::after,
.inv-qsr-row.is-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 0%, rgba(255,255,255,0.22) 44%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.22s cubic-bezier(.22,.61,.36,1) infinite;
  pointer-events: none;
}

.inventory-card.is-loading::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 22, 0.32);
  pointer-events: none;
  z-index: 2;
}

.inventory-card.is-loading #inventory-grid {
  filter: saturate(0.78) opacity(0.72);
}

.player-panel.is-loading .artbox-name-overlay,
.player-panel.is-loading .avatar-edit-chip,
.player-panel.is-loading .avatar-mailbox-btn {
  opacity: 0.55;
}

.inv-qsr-row.is-skeleton {
  cursor: default;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.inv-qsr-row.is-skeleton .inv-qsr-img {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.inv-qsr-row.is-skeleton .inv-qsr-name {
  display: block;
  height: 12px;
  width: 68%;
  max-width: 68%;
}

.inv-qsr-row.is-skeleton .inv-qsr-cat {
  display: block;
  width: 42px;
  height: 10px;
  border-radius: 5px;
}

button {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

:where(button, [role='tab']):focus-visible {
  outline: none;
  border-color: var(--line-strong);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08),
    0 0 0 4px rgba(122,175,255,0.12);
}

body[data-theme='night'] :where(button, [role='tab']):focus-visible {
  box-shadow:
    0 0 0 1px rgba(230,224,255,0.08),
    0 0 0 4px rgba(156, 140, 222, 0.14);
}

.background-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 26%),
    radial-gradient(circle at 14% 12%, rgba(255,255,255,0.16), transparent 12%),
    radial-gradient(circle at 50% 70%, rgba(255, 177, 125, 0.16), transparent 22%),
    radial-gradient(circle at 86% 16%, rgba(120,170,255,0.14), transparent 16%);
  opacity: 0.72;
  z-index: 0;
}

body[data-theme='night'] .background-noise {
  background:
    radial-gradient(circle at 16% 10%, rgba(174, 166, 231, 0.1), transparent 16%),
    radial-gradient(circle at 76% 18%, rgba(255,255,255,0.06), transparent 13%),
    radial-gradient(circle at 52% 76%, rgba(104, 100, 164, 0.16), transparent 24%);
  opacity: 0.58;
}

.clouds-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

body[data-theme='night'] .clouds-layer {
  opacity: 0.98;
  mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.12) 18%, rgba(0, 0, 0, 0.94) 30%, rgba(0, 0, 0, 0.98) 84%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.12) 18%, rgba(0, 0, 0, 0.94) 30%, rgba(0, 0, 0, 0.98) 84%, transparent 100%);
}

.aurora-ribbon {
  position: absolute;
  opacity: var(--aurora-opacity, 0.3);
  filter: blur(var(--aurora-blur, 56px)) saturate(1.02);
  transform: rotate(var(--aurora-rotate, -2deg)) translate3d(0, 0, 0);
  transform-origin: 50% 0%;
  border-radius: 999px 999px 52% 48% / 18% 18% 82% 82%;
  mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.28) 14%, rgba(0, 0, 0, 0.86) 44%, rgba(0, 0, 0, 0.74) 76%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.28) 14%, rgba(0, 0, 0, 0.86) 44%, rgba(0, 0, 0, 0.74) 76%, transparent 100%);
  mix-blend-mode: screen;
  background:
    linear-gradient(
      180deg,
      rgba(245, 255, 249, 0.12) 0%,
      rgba(188, 255, 221, 0.24) 24%,
      rgba(134, 241, 202, 0.18) 58%,
      rgba(181, 216, 255, 0.08) 100%
    ),
    radial-gradient(
      ellipse at 50% 0%,
      rgba(255, 255, 255, 0.16) 0%,
      rgba(176, 255, 219, 0.08) 38%,
      transparent 74%
    );
  box-shadow:
    0 0 96px rgba(118, 244, 190, 0.1),
    0 0 188px rgba(116, 226, 214, 0.06);
  animation:
    auroraDrift var(--aurora-duration, 36s) ease-in-out infinite,
    auroraPulse calc(var(--aurora-duration, 36s) * 0.78) ease-in-out infinite;
  animation-delay:
    var(--aurora-delay, 0s),
    calc(var(--aurora-delay, 0s) * 0.6);
}

.aurora-ribbon::before,
.aurora-ribbon::after {
  content: none;
}

.aurora-ribbon.is-secondary {
  opacity: calc(var(--aurora-opacity, 0.3) * 0.82);
  filter: blur(calc(var(--aurora-blur, 56px) + 10px)) saturate(0.98);
}

.aurora-ribbon.is-far {
  opacity: calc(var(--aurora-opacity, 0.3) * 0.64);
  filter: blur(calc(var(--aurora-blur, 56px) + 20px)) saturate(0.94);
  transform: rotate(calc(var(--aurora-rotate, -2deg) * 0.7)) translate3d(0, 0, 0) scaleY(0.94);
}

.cloud {
  position: absolute;
  opacity: var(--cloud-opacity, 0.18);
  filter: blur(var(--cloud-blur, 2.2px));
  transform: translate3d(0, 0, 0) scaleY(var(--cloud-scale-y, 1)) skewX(var(--cloud-skew, 0deg));
  transform-origin: center center;
  animation: cloudFloat var(--cloud-duration, 52s) linear infinite;
  will-change: transform, opacity;
}

body:not([data-theme='night']) .cloud {
  border-radius: 999px;
  filter: blur(var(--cloud-blur, 1.8px)) saturate(0.98);
  mix-blend-mode: screen;
}

body:not([data-theme='night']) .cloud.cloud--day-round {
  background:
    radial-gradient(22% 34% at 42% 24%, rgba(255, 255, 255, 0.94) 0 58%, transparent 64%),
    radial-gradient(20% 30% at 61% 22%, rgba(255, 248, 251, 0.9) 0 56%, transparent 62%),
    radial-gradient(34% 58% at 17% 72%, rgba(255, 236, 244, 0.78) 0 66%, transparent 72%),
    radial-gradient(40% 68% at 50% 64%, rgba(255, 245, 249, 0.88) 0 68%, transparent 74%),
    radial-gradient(32% 56% at 83% 71%, rgba(255, 226, 238, 0.74) 0 66%, transparent 72%);
  background-repeat: no-repeat;
  box-shadow:
    0 10px 22px rgba(255, 199, 220, 0.08),
    0 0 18px rgba(255, 247, 251, 0.08);
}

body:not([data-theme='night']) .cloud.cloud--day-round {
  border-radius: 999px;
}

body[data-theme='night'] .cloud {
  border-radius: 999px;
  filter: blur(var(--cloud-blur, 2.2px)) saturate(0.88);
  mix-blend-mode: screen;
}

body[data-theme='night'] .cloud.cloud--wispy {
  background:
    linear-gradient(90deg, transparent 0%, rgba(191, 210, 255, 0.08) 10%, rgba(226, 234, 255, 0.28) 42%, rgba(181, 194, 244, 0.18) 72%, transparent 100%);
  box-shadow:
    0 0 26px rgba(205, 220, 255, 0.08),
    0 0 54px rgba(130, 155, 255, 0.06);
}

body[data-theme='night'] .cloud.cloud--puff {
  background:
    radial-gradient(46% 88% at 20% 74%, rgba(219, 228, 255, 0.36) 0 70%, transparent 74%),
    radial-gradient(30% 78% at 48% 36%, rgba(235, 241, 255, 0.38) 0 72%, transparent 76%),
    radial-gradient(44% 82% at 80% 74%, rgba(190, 203, 248, 0.28) 0 70%, transparent 74%),
    linear-gradient(180deg, rgba(216, 226, 255, 0.2), rgba(110, 125, 206, 0.1));
  box-shadow:
    0 8px 24px rgba(132, 142, 208, 0.09),
    0 0 38px rgba(215, 226, 255, 0.08);
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: inherit;
  box-shadow: inherit;
  opacity: 0.96;
}

body:not([data-theme='night']) .cloud.cloud--day-round::before {
  width: 42%;
  height: 86%;
  left: 16%;
  top: -16%;
  background:
    radial-gradient(60% 66% at 50% 58%, rgba(255, 250, 252, 0.94) 0 62%, transparent 68%);
  box-shadow: none;
  opacity: 0.98;
}

body:not([data-theme='night']) .cloud.cloud--day-round::after {
  width: 28%;
  height: 64%;
  right: 16%;
  top: -8%;
  background:
    radial-gradient(60% 66% at 50% 58%, rgba(255, 240, 247, 0.88) 0 62%, transparent 68%);
  box-shadow: none;
  opacity: 0.94;
}

body[data-theme='night'] .cloud.cloud--wispy::before {
  width: 58%;
  height: 36%;
  left: 12%;
  top: -16%;
  opacity: 0.82;
}

body[data-theme='night'] .cloud.cloud--wispy::after {
  width: 42%;
  height: 28%;
  right: 8%;
  bottom: -4%;
  opacity: 0.66;
}

body[data-theme='night'] .cloud.cloud--puff::before {
  width: 42%;
  height: 78%;
  left: 10%;
  top: -18%;
}

body[data-theme='night'] .cloud.cloud--puff::after {
  width: 30%;
  height: 60%;
  right: 12%;
  top: -8%;
}

.stars-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.shooting-stars-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star {
  position: absolute;
  width: var(--star-size, 2px);
  height: var(--star-size, 2px);
  border-radius: 999px;
  background: rgba(255,252,246,0.98);
  box-shadow:
    0 0 11px rgba(255,255,255,0.72),
    0 0 26px rgba(164, 203, 255, 0.3);
  opacity: var(--star-opacity, 0.84);
  animation:
    twinkle var(--star-duration, 4.2s) ease-in-out infinite,
    drift var(--star-drift-duration, 18s) ease-in-out infinite;
}

.star--tiny {
  box-shadow:
    0 0 4px rgba(255,255,255,0.42),
    0 0 10px rgba(164, 203, 255, 0.12);
}

.star--soft {
  box-shadow:
    0 0 8px rgba(255,255,255,0.58),
    0 0 18px rgba(164, 203, 255, 0.18);
}

.star--bright {
  box-shadow:
    0 0 12px rgba(255,255,255,0.8),
    0 0 28px rgba(172, 205, 255, 0.34);
}

body[data-theme='night'] .star {
  background: rgba(247, 244, 246, 0.98);
  box-shadow:
    0 0 7px rgba(255,255,255,0.56),
    0 0 16px rgba(176, 166, 224, 0.14);
}

body[data-theme='night'] .star--tiny {
  background: rgba(238, 236, 242, 0.92);
  box-shadow:
    0 0 3px rgba(255,255,255,0.26),
    0 0 7px rgba(178, 168, 218, 0.06);
}

body[data-theme='night'] .star--soft {
  background: rgba(244, 242, 248, 0.96);
  box-shadow:
    0 0 6px rgba(255,255,255,0.5),
    0 0 14px rgba(184, 174, 226, 0.12);
}

body[data-theme='night'] .star--bright {
  background: rgba(255, 248, 239, 1);
  box-shadow:
    0 0 10px rgba(255,255,255,0.84),
    0 0 20px rgba(226, 208, 255, 0.16);
}

.shooting-star {
  position: absolute;
  height: 2px;
  border-radius: 999px;
  opacity: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(182, 209, 255, calc(var(--shoot-tail-opacity, 0.58) * 0.4)) 38%, rgba(231, 239, 255, var(--shoot-tail-opacity, 0.58)) 74%, rgba(255,255,255,0.98) 100%);
  box-shadow:
    0 0 8px rgba(255,255,255, calc(var(--shoot-glow, 0.28) * 0.9)),
    0 0 18px rgba(168, 206, 255, calc(var(--shoot-glow, 0.28) * 0.8));
  transform: rotate(var(--shoot-angle, -22deg));
  transform-origin: left center;
  filter: blur(0.15px);
  animation: shootingStar var(--shoot-duration, 1.15s) ease-out forwards;
}

@keyframes twinkle {
  0%, 100% { opacity: calc(var(--star-opacity, 0.72) * 0.4); transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1.42); }
}

@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(var(--star-drift-x, 6px), var(--star-drift-y, -10px), 0); }
}

@keyframes cloudFloat {
  0% {
    transform: translate3d(-12vw, 0, 0) scaleY(var(--cloud-scale-y, 1)) skewX(var(--cloud-skew, 0deg));
  }
  50% {
    transform: translate3d(4vw, var(--cloud-drift-y, 0), 0) scaleY(var(--cloud-scale-y, 1)) skewX(var(--cloud-skew, 0deg));
  }
  100% {
    transform: translate3d(112vw, 0, 0) scaleY(var(--cloud-scale-y, 1)) skewX(var(--cloud-skew, 0deg));
  }
}

@keyframes auroraDrift {
  0% {
    transform: rotate(var(--aurora-rotate, -2deg)) translate3d(calc(var(--aurora-drift-x, 12vw) * -0.34), 0, 0) scaleX(1) scaleY(0.96);
  }
  50% {
    transform: rotate(calc(var(--aurora-rotate, -2deg) + 1deg)) translate3d(calc(var(--aurora-drift-x, 12vw) * 0.4), var(--aurora-rise, 14px), 0) scaleX(1.03) scaleY(1.04);
  }
  100% {
    transform: rotate(var(--aurora-rotate, -2deg)) translate3d(calc(var(--aurora-drift-x, 12vw) * -0.34), 0, 0) scaleX(1) scaleY(0.96);
  }
}

@keyframes auroraPulse {
  0%, 100% {
    opacity: calc(var(--aurora-opacity, 0.3) * 0.86);
  }
  50% {
    opacity: calc(var(--aurora-opacity, 0.3) * 1.08);
  }
}

@keyframes shootingStar {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(var(--shoot-angle, -22deg)) scaleX(0.7);
  }
  14% {
    opacity: 0.96;
  }
  82% {
    opacity: 0.74;
    transform: translate3d(var(--shoot-travel-x, 210px), var(--shoot-travel-y, 72px), 0) rotate(var(--shoot-angle, -22deg)) scaleX(1);
  }
  100% {
    opacity: 0;
    transform: translate3d(calc(var(--shoot-travel-x, 210px) + 18px), calc(var(--shoot-travel-y, 72px) + 8px), 0) rotate(var(--shoot-angle, -22deg)) scaleX(0.94);
  }
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  opacity: 1;
  transition: opacity 0.35s var(--ease);
}

.loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.shell-card.is-updating {
  animation: fade-update 0.18s var(--ease);
}

@keyframes fade-update {
  0% { opacity: 0.88; }
  50% { opacity: 0.92; }
  100% { opacity: 1; }
}

.loading-center {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.loading-ring {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.12);
  border-top-color: rgba(255,255,255,0.95);
  animation: spin 0.8s linear infinite;
}

.loading-center-icon {
  position: absolute;
  width: 24px;
  height: 24px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
}

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

/* ── Shimmer skeleton animation ─────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

.skeleton-line,
.skeleton-block {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(255,255,255,0.11) 40%,
    rgba(255,255,255,0.04) 80%
  );
  background-size: 200% auto;
  animation: shimmer 1.5s linear infinite;
  border-radius: 6px;
}

.skeleton-block {
  border-radius: 12px;
}

/* Villager modal skeleton layout */
.vmod-skeleton {
  display: flex;
  gap: 20px;
  padding: 0 20px;
  flex: 1;
}

.vmod-skeleton-aside {
  flex-shrink: 0;
  width: clamp(110px, 18vw, 150px);
}

.vmod-skeleton-art {
  width: 100%;
  height: clamp(160px, 26vh, 220px);
}

.vmod-skeleton-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
}

.vmod-skeleton-name {
  height: 28px;
  width: 50%;
}

.vmod-skeleton-btns {
  display: flex;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.vmod-skeleton-btn {
  height: 28px;
  width: 60px;
  border-radius: 8px;
}

.vmod-skeleton-row {
  height: 34px;
  width: 100%;
  border-radius: 0;
}

/* Villager card list skeleton (first-load shimmer) */
.villager-card-skeleton {
  pointer-events: none;
}

.villager-skel-avatar {
  width: 68px;
  height: 68px;
  flex-shrink: 0;
  border-radius: 50%;
}

.villager-skel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.villager-skel-name {
  height: 18px;
  width: 42%;
  border-radius: 8px;
}

.villager-skel-line {
  height: 12px;
  width: 70%;
  border-radius: 6px;
}

.villager-skel-line:last-child {
  width: 55%;
}

/* Inventory slot image fade-in shimmer */
.vedit-inv-img {
  width: 72%;
  height: 72%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.22s var(--ease);
}

.vedit-inv-img.is-loaded {
  opacity: 1;
}

.vedit-inv-slot.is-selected .vedit-inv-img { opacity: 0.72; }

/* Inventory slot image shimmer — pseudo-element so slot background/transition are unaffected */
.vedit-inv-slot:has(img:not(.is-loaded)):not(.is-empty-slot)::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.12) 50%, transparent 100%);
  animation: shimmer 1.6s ease-in-out infinite;
  will-change: transform;
  pointer-events: none;
}

/* Preview panel image fade-in */
.vedit-inv-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity 0.22s var(--ease);
}

.vedit-inv-preview-img.is-loaded {
  opacity: 1;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: calc(100% - 32px);
  max-width: 1110px;
  margin: 0 auto;
  padding: calc(max(16px, 2.5vw) + 2.5vw) 0 calc(56px + 2.5vw);
  opacity: 1;
  transform: translateY(0);
  filter: none;
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

/* Bootstrap-style static breakpoint widths. The shell only resizes when a
   breakpoint boundary is crossed, not continuously with every pixel of
   viewport width change — this keeps the 40-box inventory grid (and every
   other descendant) from recomputing/redrawing on every resize tick. */
@media (min-width: 560px) {
  .app-shell { width: 540px; }
}
@media (min-width: 720px) {
  .app-shell { width: 700px; }
}
@media (min-width: 860px) {
  .app-shell { width: 840px; }
}
@media (min-width: 1200px) {
  .app-shell { width: 1110px; }
}

/* Steam Deck-sized landscape screens (1280x800 native). Narrow the shell so
   the UI has generous side margins instead of stretching edge-to-edge. */
@media (min-width: 1200px) and (max-width: 1366px) and (max-height: 900px) {
  .app-shell {
    width: 920px;
  }
}

.app-hidden {
  opacity: 0;
  transform: translateY(10px);
}

/* When a modal is open, keep the app-shell fully rendered underneath.
   The dim overlay comes from `.modal` itself (rgba background that fades
   with the modal opacity), and the modal-card's own backdrop-filter
   applies blur to whatever is behind it. No filter/opacity animation
   on the app-shell = no jank, no transparent glitch. */
body.modal-open .app-shell {
  pointer-events: none;
}

.shell-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(180deg, var(--glass-top), var(--glass-bottom)),
    var(--panel);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  box-shadow:
    var(--glass-shadow),
    inset 0 1px 0 rgba(255,255,255,0.1),
    inset 0 -1px 0 rgba(255,255,255,0.015);
  backdrop-filter: blur(var(--backdrop-blur)) saturate(var(--backdrop-sat)) contrast(1.02);
  -webkit-backdrop-filter: blur(var(--backdrop-blur)) saturate(var(--backdrop-sat)) contrast(1.02);
  transition:
    border-color var(--transition-long),
    background var(--transition-long),
    transform var(--transition-long),
    opacity var(--transition-long),
    box-shadow var(--transition-long);
}

.shell-card:hover {
  box-shadow:
    0 20px 58px rgba(16, 12, 28, 0.16),
    0 0 0 1px rgba(255,255,255,0.03),
    inset 0 1px 0 rgba(255,255,255,0.12);
}

.shell-card > *,
.meta-value > *,
.inventory-card > *,
.tab-panel > *,
.tab-card > *,
.footer-mark > *,
.modal-card > *,
.item-modal-artbox > * {
  position: relative;
  z-index: 1;
}

.topbar,
.log-panel,
.player-panel,
.tabs-panel {
  margin-bottom: var(--space-4);
}

.topbar {
  overflow: visible;
  z-index: 4;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: clamp(12px, 2vw, 18px) clamp(14px, 2.5vw, 22px);
}

/* Compact iOS-style top bar row: identity left, clock center, trigger right */
.topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.topbar-identity {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  flex-shrink: 0;
}

.brand-title {
  font-size: clamp(1.35rem, 1.6vw, 1.75rem);
  line-height: 1;
  letter-spacing: -0.03em;
  font-weight: 700;
  color: var(--text);
}

.brand-version {
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.7;
  letter-spacing: 0.02em;
  font-weight: 500;
  margin-top: 2px;
}

.topbar-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  opacity: 0.72;
}

.topbar-clock .console-date {
  font-size: 0.72rem;
  font-weight: 500;
}
.topbar-clock .console-time {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  opacity: 0.85;
}

.topbar-trigger-wrap {
  flex-shrink: 0;
  position: relative;
}

/* Single hamburger/kebab trigger that opens the controls panel.
   iOS-large tap target (44x44), soft glass surface. */
.utility-panel-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02)),
    rgba(255,255,255,0.05);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  position: relative;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.utility-panel-trigger:hover {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03)),
    rgba(255,255,255,0.08);
  border-color: var(--line-strong);
}

.utility-panel-trigger:active {
  transform: scale(var(--scale-press));
}

.utility-panel-trigger[aria-expanded="true"] {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.04)),
    rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.28);
}

/* Small dot on the trigger to reflect overall bridge status at a glance */
.utility-trigger-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 6px rgba(255, 209, 102, 0.55);
  transition: background var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.utility-trigger-dot.is-ok {
  background: var(--good);
  box-shadow: 0 0 6px rgba(98, 214, 111, 0.6);
}
.utility-trigger-dot.is-error {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(255, 95, 115, 0.6);
}

.topbar-actions-legacy {
  display: none !important;
}

/* Legacy status pill row — hidden in top bar (status now lives in the
   utility panel). Kept in DOM so panel can read the state classes. */
.brand-subline[hidden] {
  display: none !important;
}

.brand-subline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: hidden;
  justify-content: flex-start;
}

/* ── Console-style date/time (no border, monospace) ─────────────────────── */
.console-date,
.console-time {
  font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
}

/* ── Uniform status pills ───────────────────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  font-weight: 500;
  color: var(--text-muted);
  transition: border-color 0.3s ease;
}

.status-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--warn);
  transition: background 0.35s ease, box-shadow 0.35s ease;
}

.status-pill-label {
  white-space: nowrap;
}

.status-pill-value {
  font-size: 0.65rem;
  opacity: 0.65;
  margin-left: 2px;
}

/* Pill state: parent carries the class, dot gets the color */
.status-pill.is-ok { border-color: rgba(98, 214, 111, 0.3); }
.status-pill.is-ok .status-pill-dot {
  background: var(--good);
  box-shadow: 0 0 5px rgba(98, 214, 111, 0.55);
}
.status-pill.is-bad { border-color: rgba(255, 95, 115, 0.3); }
.status-pill.is-bad .status-pill-dot { background: var(--danger); }
.status-pill.is-warn { border-color: rgba(255, 209, 102, 0.2); }
.status-pill.is-warn .status-pill-dot { background: var(--warn); }

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-weight: 600;
}
.status-chip.is-ok { color: var(--good); border-color: rgba(142, 244, 183, 0.42); }
.status-chip.is-bad { color: var(--danger); border-color: rgba(255, 131, 131, 0.42); }
.status-chip.is-warn { color: var(--warn); border-color: rgba(247, 188, 114, 0.42); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
}

/* ── Connect Bridge button ───────────────────────────────────────────────── */
.deploy-button {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--ease), opacity var(--ease), box-shadow var(--ease);
  white-space: nowrap;
}
.deploy-button:hover { background: rgba(255,255,255,0.12); box-shadow: 0 0 0 1px rgba(255,255,255,0.1); }
.deploy-button:disabled,
.deploy-button.is-busy { opacity: 0.55; cursor: not-allowed; }

/* ── Uniform action-pill button (settings, etc.) ────────────────────────── */
.action-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
  transition: background var(--ease), box-shadow var(--ease), color var(--ease);
}
.action-pill-btn:hover { background: rgba(255,255,255,0.11); box-shadow: 0 0 0 1px rgba(255,255,255,0.1); }
.action-pill-btn .icon-img { width: 16px; height: 16px; }

/* Force header reload SVG to match gear icon sizing (16x16). Icon inherits
   button color via currentColor, keeping parity with gear/theme icons. */
.action-pill-btn .reload-icon {
  width: 16px;
  height: 16px;
  display: block;
  opacity: 1;
  filter: none;
  color: currentColor;
}

/* Day theme adjustments */
body:not([data-theme='night']) .action-pill-btn {
  background: rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.12);
  color: #2c2c2e;
}
body:not([data-theme='night']) .action-pill-btn:hover {
  background: rgba(0,0,0,0.12);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

/* ── Reload button with spinning animation ────────────────────────────── */
.reload-button:disabled,
.reload-button.is-reloading { opacity: 0.55; cursor: not-allowed; }
.reload-icon { display: block; }
.reload-button.is-reloading .reload-icon {
  animation: spin-reload 0.8s linear infinite;
}
@keyframes spin-reload {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}


/* ── Bridge status dot ───────────────────────────────────────────────────── */
.bridge-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger, #ff8383);
  flex-shrink: 0;
  transition: background 0.4s ease;
}
.bridge-dot.is-on {
  background: var(--good, #8ef4b7);
  box-shadow: 0 0 5px rgba(142, 244, 183, 0.6);
}

/* ── Deploy toast ────────────────────────────────────────────────────────── */
.deploy-toast {
  display: none;
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  min-width: 160px;
  max-width: min(340px, 80vw);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02)),
    rgba(15, 17, 26, 0.94);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.78rem;
  font-family: inherit;
  color: rgba(245, 245, 247, 0.94);
  line-height: 1.45;
  white-space: normal;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 18px 40px rgba(8, 8, 20, 0.22);
}
.deploy-toast.is-visible {
  display: block;
  opacity: 1;
  transform: translateY(0);
}
body[data-theme='night'] .deploy-toast {
  border-color: rgba(210, 202, 240, 0.12);
  background:
    linear-gradient(180deg, rgba(240, 236, 255, 0.1), rgba(255,255,255,0.018)),
    rgba(17, 17, 32, 0.96);
  color: rgba(241, 238, 248, 0.96);
}

.music-ribbon {
  --music-ribbon-width: min(466px, calc(100vw - 40px));
  --music-tab-size: 56px;
  position: fixed;
  top: 56vh;
  left: calc(-1 * (var(--music-ribbon-width) - var(--music-tab-size)));
  z-index: 12;
  width: var(--music-ribbon-width);
  transform: translateY(-50%);
  pointer-events: none;
  overflow: visible;
  transition: left 0.32s cubic-bezier(.2,.82,.2,1);
}

.music-ribbon > * {
  pointer-events: auto;
}

.music-ribbon.is-open {
  left: 0;
}

.music-ribbon-drawer {
  position: relative;
  width: calc(100% - 38px);
  box-sizing: border-box;
  margin-right: 38px;
  padding: 16px 18px 14px;
  border: 1px solid var(--glass-edge);
  border-radius: 28px;
  background:
    linear-gradient(180deg, var(--glass-top), var(--glass-bottom)),
    var(--panel);
  box-shadow:
    var(--glass-shadow),
    inset 0 1px 0 rgba(255,255,255,0.1),
    inset 0 -1px 0 rgba(255,255,255,0.015);
  backdrop-filter: blur(var(--backdrop-blur)) saturate(var(--backdrop-sat)) contrast(1.02);
  -webkit-backdrop-filter: blur(var(--backdrop-blur)) saturate(var(--backdrop-sat)) contrast(1.02);
  contain: paint;
  isolation: isolate;
  transition:
    border-color var(--transition-base),
    box-shadow var(--transition-base),
    background var(--transition-base);
}

.music-ribbon:hover .music-ribbon-drawer {
  box-shadow:
    0 20px 58px rgba(16, 12, 28, 0.16),
    inset 0 1px 0 rgba(255,255,255,0.12),
    inset 0 -1px 0 rgba(255,255,255,0.015);
}

.music-ribbon-tab {
  position: absolute;
  top: 50%;
  right: 0;
  width: var(--music-tab-size);
  height: var(--music-tab-size);
  padding: 0;
  transform: translateY(-50%);
  border: 1px solid rgba(255,255,255,0.13);
  /* Left edge flush against viewport; right edge rounded for tab shape */
  border-radius: 0 18px 18px 0;
  border-left: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03)),
    linear-gradient(135deg, rgba(64, 81, 166, 0.48), rgba(88, 64, 166, 0.38) 65%, rgba(43, 48, 110, 0.36)),
    rgba(26, 29, 62, 0.56);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 16px 34px rgba(16, 14, 34, 0.22),
    inset 0 1px 0 rgba(255,255,255,0.12);
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition:
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    background 0.18s var(--ease);
}

.music-ribbon-tab:hover {
  transform: translateY(calc(-50% - 1px));
  border-color: rgba(255,255,255,0.18);
  box-shadow:
    0 18px 40px rgba(16, 14, 34, 0.24),
    inset 0 1px 0 rgba(255,255,255,0.14);
}

.music-ribbon-tab::before,
.music-ribbon-tab::after,
.music-ribbon-tab-rail {
  display: none !important;
}

.music-ribbon-tab-icon {
  color: var(--warn);
  font-size: 1.6rem;
  line-height: 1;
  text-shadow: 0 0 18px rgba(255, 209, 102, 0.42);
  pointer-events: none;
  user-select: none;
}

.music-ribbon.is-dragging .music-ribbon-tab,
.music-ribbon.is-dragging .music-ribbon-tab:hover,
.cheats-ribbon.is-dragging .cheats-ribbon-tab,
.cheats-ribbon.is-dragging .cheats-ribbon-tab:hover {
  cursor: grabbing;
  transform: translateY(-50%);
  transition: none;
  box-shadow:
    0 24px 48px rgba(16, 14, 34, 0.34),
    inset 0 1px 0 rgba(255,255,255,0.16);
}

.music-ribbon.is-dragging .music-ribbon-drawer {
  transition: none;
}

body:not([data-theme='night']) .music-ribbon-tab {
  border-color: rgba(255,255,255,0.14);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03)),
    linear-gradient(135deg, rgba(88, 120, 215, 0.42), rgba(146, 106, 217, 0.38) 65%, rgba(111, 94, 205, 0.32)),
    rgba(255,255,255,0.06);
  box-shadow:
    0 16px 34px rgba(77, 90, 170, 0.18),
    inset 0 1px 0 rgba(255,255,255,0.16);
}

body:not([data-theme='night']) .music-ribbon-tab:hover {
  box-shadow:
    0 18px 38px rgba(77, 90, 170, 0.2),
    inset 0 1px 0 rgba(255,255,255,0.18);
}

.music-player-shell {
  display: grid;
  gap: 12px;
}

.music-player-top {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.music-artbox {
  width: 46px;
  height: 46px;
  padding: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.024)),
    rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 8px 18px rgba(22, 18, 38, 0.18);
}

.music-artbox img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.music-player-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.music-source-badge {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.music-player-copy strong {
  font-size: 1.08rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.music-track-meta {
  color: var(--text-muted);
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.music-progress {
  position: relative;
  width: min(184px, 100%);
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(195, 208, 255, 0.12);
  box-shadow: inset 0 1px 2px rgba(28, 26, 48, 0.22);
}

.music-progress-bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(168, 244, 219, 0.96), rgba(144, 197, 255, 0.92));
  transition: width 0.16s linear;
}

.music-progress.is-ambient .music-progress-bar {
  width: 100%;
  transform-origin: 0 50%;
  animation: musicAmbientSweep 4.8s ease-in-out infinite;
}

.music-player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.music-control-btn {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.03)),
    rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.music-control-btn:hover:not(:disabled) {
  border-color: var(--line-strong);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.04)),
    rgba(255,255,255,0.06);
}

.music-control-btn:active:not(:disabled) {
  transform: scale(var(--scale-press));
  transition: transform var(--dur-instant) var(--ease-out);
}

.music-control-btn:disabled {
  cursor: default;
  opacity: 0.38;
}

.music-control-btn-primary {
  width: 40px;
  min-width: 40px;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.04)),
    rgba(255,255,255,0.08);
}

.music-control-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  pointer-events: none;
}

.music-control-btn-primary .music-control-icon {
  width: 18px;
  height: 18px;
}

.music-browser-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 16px;
  align-items: end;
}

.music-field {
  display: grid;
  gap: 7px;
}

.music-field > span {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.music-library-field select {
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  padding: 0 36px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02)),
    rgba(18, 21, 35, 0.42);
  color: var(--text);
  outline: none;
  appearance: none;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05);
  cursor: pointer;
  font-size: var(--font-size-md);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.music-library-field select:hover {
  border-color: var(--line-strong);
}

.music-library-field {
  position: relative;
}

.music-library-field::after {
  content: "⌄";
  position: absolute;
  right: 14px;
  bottom: 8px;
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}

.music-volume-field input {
  width: 100%;
  height: 20px;
  appearance: none;
  background: rgba(255,255,255,0);
  accent-color: #cfe7ff;
}

.music-volume-field {
  align-self: end;
}

.music-volume-field input::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: var(--line-strong);
}

.music-volume-field input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 19px;
  height: 19px;
  margin-top: -7px;
  border: 2px solid rgba(255,255,255,0.95);
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.32), rgba(255,255,255,0.08)), var(--bg-1);
  box-shadow: 0 4px 10px rgba(24, 18, 38, 0.24);
}

.music-volume-field input::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: var(--line-strong);
}

.music-volume-field input::-moz-range-thumb {
  width: 19px;
  height: 19px;
  border: 2px solid rgba(255,255,255,0.95);
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.32), rgba(255,255,255,0.08)), var(--bg-1);
  box-shadow: 0 4px 10px rgba(24, 18, 38, 0.24);
}

@keyframes musicAmbientSweep {
  0%, 100% {
    transform: scaleX(0.34);
    opacity: 0.7;
  }
  50% {
    transform: scaleX(1);
    opacity: 1;
  }
}

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

.theme-toggle-btn.is-night {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02)),
    rgba(24, 22, 41, 0.36);
  border-color: var(--glass-edge);
}

.icon-button,
.corner-icon-button,
.trash-button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
  color: var(--text);
  cursor: pointer;
  transition:
    transform 0.18s var(--ease),
    border-color 0.18s var(--ease),
    background 0.18s var(--ease),
    opacity 0.18s var(--ease);
}

.icon-button:hover,
.corner-icon-button:hover,
.trash-button:hover,
.action-btn:hover,
.shortcut-btn:hover,
.tab-btn:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(255,255,255,0.05);
}

.icon-button {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-button {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  border: 0;
  box-shadow: none;
}

.icon-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.icon-white {
  filter: brightness(0) invert(1);
}

.log-panel {
  --log-console-height: 13vh;
  position: relative;
  padding: 18px;
}

body:not([data-theme='night']) .log-panel {
  background:
    linear-gradient(180deg, var(--glass-top), var(--glass-bottom)),
    linear-gradient(180deg, rgba(100, 200, 210, 0.14), rgba(140, 160, 240, 0.08)),
    linear-gradient(180deg, rgba(14, 20, 34, 0.28), rgba(14, 20, 34, 0.28)),
    var(--panel);
}

body[data-theme='night'] .log-panel {
  background:
    linear-gradient(180deg, var(--glass-top), var(--glass-bottom)),
    linear-gradient(180deg, rgba(130, 120, 210, 0.14), rgba(80, 70, 160, 0.08)),
    linear-gradient(180deg, rgba(10, 10, 22, 0.38), rgba(10, 10, 22, 0.38)),
    var(--panel);
}

.log-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  opacity: 0.25;
}

.log-panel-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

#ip-display {
  color: var(--text-muted);
}

.log-console-wrap {
  position: relative;
}

.cmd-log-notifications {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 2;
  pointer-events: auto;
}

.cmd-log-notifications[hidden] {
  display: none;
}

.cmd-log-notice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(8, 18, 15, 0.92);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.24);
}

.cmd-log-notice.is-new {
  animation: cmd-notification-fade-up 0.46s cubic-bezier(0.2, 1.2, 0.3, 1) both;
}

.cmd-log-notice.is-dismissing {
  pointer-events: none;
  animation: cmd-notification-dismiss 0.3s ease-in both;
}

@keyframes cmd-notification-fade-up {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  72% { opacity: 1; transform: translateY(-2px) scale(1.01); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cmd-notification-dismiss {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-16px) scale(0.97); }
}

.cmd-log-notice-time {
  font-size: 0.64rem;
  line-height: 1;
  letter-spacing: 0.04em;
  color: rgba(212, 208, 233, 0.82);
  white-space: nowrap;
}

.cmd-log-notice-text {
  font-size: 0.72rem;
  color: rgba(241, 238, 248, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-log-notice-close {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
}

.cmd-log-notice-close:hover,
.cmd-log-notice-close:focus-visible {
  background: rgba(255, 255, 255, 0.12);
}

.cmd-log-notice.is-error {
  border-color: rgba(255, 124, 124, 0.4);
  background: rgba(188, 38, 38, 0.22);
  box-shadow: 0 0 0 1px rgba(255, 84, 84, 0.12) inset;
}

.cmd-log-notice.is-error .cmd-log-notice-time,
.cmd-log-notice.is-error .cmd-log-notice-text {
  color: #ff7070;
}

body:not([data-theme='night']) .cmd-log-notice {
  border-color: rgba(0,0,0,0.09);
  background: rgba(0,0,0,0.04);
}

body:not([data-theme='night']) .cmd-log-notice-time {
  color: rgba(82, 72, 96, 0.86);
}

body:not([data-theme='night']) .cmd-log-notice-text {
  color: rgba(44, 40, 55, 0.92);
}

body:not([data-theme='night']) .cmd-log-notice.is-error {
  border-color: rgba(192, 42, 58, 0.38);
  background: rgba(216, 78, 96, 0.16);
}

body:not([data-theme='night']) .cmd-log-notice.is-error .cmd-log-notice-time,
body:not([data-theme='night']) .cmd-log-notice.is-error .cmd-log-notice-text {
  color: rgba(122, 24, 36, 0.95);
}

.log-panel-resize-handle {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 4px;
  height: 16px;
  border: 0;
  padding: 0;
  background: rgba(255,255,255,0.0);
  cursor: ns-resize;
  touch-action: none;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
}

.log-panel-resize-grip {
  width: 72px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.08),
    0 6px 18px rgba(0, 0, 0, 0.08);
  transition:
    background 0.18s var(--ease),
    transform 0.18s var(--ease);
}

.log-panel-resize-handle:hover .log-panel-resize-grip,
.log-panel-resize-handle:focus-visible .log-panel-resize-grip {
  background: rgba(255,255,255,0.28);
  transform: scaleX(1.04);
}

.console-corner-actions {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.code-block {
  margin: 0;
  min-height: 116px;
  max-height: 220px;
  overflow-x: clip;
  overflow-y: auto;
  padding: 16px 18px;
  border: 1px solid rgba(186, 247, 192, 0.16);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), transparent 38%),
    var(--console-bg);
  color: var(--console-text);
  font-size: 13px;
  line-height: 1.6;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, Menlo, monospace;
  text-shadow: 0 0 10px rgba(186, 247, 192, 0.1);
  white-space: pre-wrap;
  scrollbar-width: none;
  transform: translateZ(0);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.code-block::-webkit-scrollbar {
  display: none;
}

#bridge-status {
  height: clamp(52px, var(--log-console-height), 42vh);
  min-height: 52px;
  max-height: none;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: height 0.46s cubic-bezier(0.2, 1.7, 0.34, 1);
}

#bridge-status:focus,
#bridge-status:focus-visible {
  outline: none;
  box-shadow: none;
}

#bridge-status.is-expanding {
  animation: cmd-log-open-bounce 0.54s cubic-bezier(0.2, 1.7, 0.34, 1);
}

#bridge-status.is-collapsing {
  animation: cmd-log-close-bounce 0.48s cubic-bezier(0.42, 0, 0.64, 1.7);
}

@keyframes cmd-log-open-bounce {
  0% { transform: translateZ(0) scaleY(0.96); }
  58% { transform: translateZ(0) scaleY(1.05); }
  78% { transform: translateZ(0) scaleY(0.985); }
  100% { transform: translateZ(0) scaleY(1); }
}

@keyframes cmd-log-close-bounce {
  0% { transform: translateZ(0) scaleY(1); }
  55% { transform: translateZ(0) scaleY(0.94); }
  78% { transform: translateZ(0) scaleY(1.018); }
  100% { transform: translateZ(0) scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  #bridge-status {
    transition: none;
  }

  #bridge-status.is-expanding,
  #bridge-status.is-collapsing,
  .cmd-log-notice.is-new,
  .cmd-log-notice.is-dismissing {
    animation: none;
  }
}

.corner-icon-button {
  position: relative;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#log-copy-button.is-copied::after {
  content: "Copied";
  position: absolute;
  right: 0;
  bottom: calc(100% + 7px);
  padding: 4px 7px;
  border: 1px solid rgba(186, 247, 192, 0.28);
  border-radius: 4px;
  background: rgba(8, 18, 15, 0.96);
  color: var(--console-text);
  font-size: 0.66rem;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  animation: cmd-copy-toast 0.9s ease-out both;
}

@keyframes cmd-copy-toast {
  0% { opacity: 0; transform: translateY(5px) scale(0.94); }
  20%, 72% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-4px) scale(0.98); }
}

.player-panel {
  padding: 14px 16px 16px;
}

.player-panel-head {
  margin-bottom: 12px;
  padding: 0 0 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* Single row: Player title | Cheats Menu | Load/Save */
.player-panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
}

.panel-label {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ── Cheats sidebar ribbon (left, upper) — pull-tab pattern ─────────
   Drawer body is fully covered by the visible tab strip when closed;
   only the pull-tab + icon peek onto the viewport. */
.cheats-ribbon {
  --cheats-ribbon-width: min(466px, calc(100vw - 40px));
  --cheats-tab-size: 56px;
  position: fixed;
  top: 32vh;
  left: calc(-1 * (var(--cheats-ribbon-width) - var(--cheats-tab-size)));
  z-index: 12;
  width: var(--cheats-ribbon-width);
  transform: translateY(-50%);
  pointer-events: none;
  overflow: visible;
  transition: left var(--dur-base) var(--ease-standard);
}

.cheats-ribbon > * {
  pointer-events: auto;
}

.cheats-ribbon.is-open {
  left: 0;
}

.music-ribbon:not(.is-open):not(.is-detached) .music-ribbon-drawer,
.cheats-ribbon:not(.is-open):not(.is-detached) .cheats-ribbon-drawer {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.018)),
    rgba(26, 31, 65, 0.96);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.cheats-ribbon-drawer {
  position: relative;
  /* Drawer stops exactly where the tab starts — no body-strip peek. */
  width: calc(100% - 38px);
  box-sizing: border-box;
  margin-right: 38px;
  min-height: 176px;
  padding: 16px 18px 14px;
  border: 1px solid rgba(98,214,111,0.22);
  border-radius: 28px;
  background:
    linear-gradient(180deg, var(--glass-top), var(--glass-bottom)),
    var(--panel);
  box-shadow:
    var(--glass-shadow),
    inset 0 1px 0 rgba(255,255,255,0.1),
    inset 0 -1px 0 rgba(255,255,255,0.015);
  backdrop-filter: blur(var(--backdrop-blur)) saturate(var(--backdrop-sat)) contrast(1.02);
  -webkit-backdrop-filter: blur(var(--backdrop-blur)) saturate(var(--backdrop-sat)) contrast(1.02);
  contain: paint;
  isolation: isolate;
}

.cheats-ribbon-tab {
  position: absolute;
  top: 50%;
  right: 0;
  width: var(--cheats-tab-size);
  height: var(--cheats-tab-size);
  padding: 0;
  transform: translateY(-50%);
  border: 1px solid rgba(98,214,111,0.35);
  /* Left edge flush against viewport; right edge rounded for tab shape */
  border-radius: 0 18px 18px 0;
  border-left: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03)),
    linear-gradient(135deg, rgba(60, 140, 90, 0.48), rgba(48, 120, 90, 0.38) 65%, rgba(38, 90, 68, 0.36)),
    rgba(26, 46, 34, 0.56);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 16px 34px rgba(20, 40, 26, 0.22),
    inset 0 1px 0 rgba(255,255,255,0.12);
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.cheats-ribbon-tab:hover {
  transform: translateY(calc(-50% - 1px));
  border-color: rgba(98,214,111,0.55);
  box-shadow:
    0 18px 40px rgba(20, 40, 26, 0.24),
    inset 0 1px 0 rgba(255,255,255,0.14);
}

.cheats-ribbon-tab:active {
  transform: translateY(-50%) scale(var(--scale-press));
}

/* Grabber rails removed — square left edge is enough visual affordance
   that the tab is grabbable. Explicitly hide any legacy rail pseudos. */
.cheats-ribbon-tab::before,
.cheats-ribbon-tab::after,
.cheats-ribbon-tab-rail {
  display: none !important;
}

.cheats-ribbon-tab-icon {
  color: var(--good);
  font-size: 1.5rem;
  line-height: 1;
  text-shadow: 0 0 18px rgba(98, 214, 111, 0.5);
  pointer-events: none;
  user-select: none;
}

body:not([data-theme='night']) .cheats-ribbon-tab {
  border-color: rgba(98,214,111,0.32);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03)),
    linear-gradient(135deg, rgba(88, 175, 108, 0.42), rgba(76, 156, 98, 0.38) 65%, rgba(66, 140, 90, 0.32)),
    rgba(255,255,255,0.06);
  box-shadow:
    0 16px 34px rgba(60, 130, 88, 0.16),
    inset 0 1px 0 rgba(255,255,255,0.16);
}

/* Detached ribbons retain their tab as a compact button and reveal the drawer
   beneath it as a small floating card when opened. */
.music-ribbon.is-detached,
.cheats-ribbon.is-detached {
  width: min(330px, calc(100vw - 24px));
  transform: none;
  z-index: 70;
  transition: left 0.3s cubic-bezier(0.2, 1.45, 0.36, 1), top 0.3s cubic-bezier(0.2, 1.45, 0.36, 1);
}

.music-ribbon.is-detached .music-ribbon-tab,
.cheats-ribbon.is-detached .cheats-ribbon-tab {
  position: relative;
  top: auto;
  right: auto;
  left: auto;
  transform: none;
  border-radius: 14px;
}

.music-ribbon.is-detached .music-ribbon-tab:hover,
.cheats-ribbon.is-detached .cheats-ribbon-tab:hover {
  transform: translateY(-1px);
}

.music-ribbon.is-detached .music-ribbon-drawer,
.cheats-ribbon.is-detached .cheats-ribbon-drawer {
  position: absolute;
  top: calc(100% + 9px);
  left: 0;
  width: 100%;
  box-sizing: border-box;
  max-height: calc(100vh - 81px);
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top left;
  transition:
    opacity 0.2s ease,
    transform 0.34s cubic-bezier(0.2, 1.45, 0.36, 1),
    visibility 0s linear 0.34s;
}

.music-ribbon.is-detached.is-open .music-ribbon-drawer,
.cheats-ribbon.is-detached.is-open .cheats-ribbon-drawer {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition-delay: 0s;
}

.music-ribbon.is-docked-right:not(.is-detached),
.cheats-ribbon.is-docked-right:not(.is-detached) {
  left: auto;
  right: calc(-1 * (var(--music-ribbon-width) - var(--music-tab-size)));
}

.cheats-ribbon.is-docked-right:not(.is-detached) {
  right: calc(-1 * (var(--cheats-ribbon-width) - var(--cheats-tab-size)));
}

.music-ribbon.is-docked-right:not(.is-detached).is-open,
.cheats-ribbon.is-docked-right:not(.is-detached).is-open {
  right: 0;
}

.music-ribbon.is-docked-right:not(.is-detached) .music-ribbon-tab,
.cheats-ribbon.is-docked-right:not(.is-detached) .cheats-ribbon-tab {
  right: auto;
  left: 0;
  border-right: none;
  border-left: 1px solid rgba(255,255,255,0.13);
  border-radius: 18px 0 0 18px;
}

.cheats-ribbon.is-docked-right:not(.is-detached) .cheats-ribbon-tab {
  border-left-color: rgba(98,214,111,0.35);
}

.music-ribbon.is-docked-right:not(.is-detached) .music-ribbon-drawer,
.cheats-ribbon.is-docked-right:not(.is-detached) .cheats-ribbon-drawer {
  margin-right: 0;
  margin-left: 38px;
}

.music-ribbon.is-snapping,
.cheats-ribbon.is-snapping {
  animation: ribbon-dock-bounce 0.46s cubic-bezier(0.2, 1.55, 0.36, 1);
}

@keyframes ribbon-dock-bounce {
  0% { transform: translateY(-50%) scale(1); }
  58% { transform: translateY(-50%) scale(1.08); }
  100% { transform: translateY(-50%) scale(1); }
}

.cheats-drawer-shell {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cheats-drawer-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: rgba(98,214,111,0.75);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cheats-drawer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Ensure hidden attribute always wins regardless of media query display rules */
.selected-item-sticky[hidden] { display: none !important; }



/* Sticky selected-item bar — position:fixed so overflow:hidden doesn't trap it */
/* Visibility is controlled by the [hidden] attribute — not display:none here */
.selected-item-sticky {
  display: flex;
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 10px;
  border-radius: 14px;
  background: rgba(14,10,30,0.82);
  border: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
  max-width: calc(100vw - 32px);
  pointer-events: auto;
  cursor: pointer;
  white-space: nowrap;
}
.selected-item-sticky-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.05);
}
.selected-item-sticky-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.quick-cheat-btn {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.02);
  color: var(--text);
  cursor: pointer;
  position: relative;
  opacity: 0.5;
  transition:
    transform var(--transition-fast),
    border-color var(--transition-fast),
    background var(--transition-fast),
    opacity var(--transition-fast),
    box-shadow var(--transition-fast);
}

.quick-cheat-label {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: var(--text);
}

.quick-cheat-btn:hover,
.quick-cheat-btn:focus-visible {
  opacity: 0.88;
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(255,255,255,0.05);
}

.quick-cheat-btn.is-active {
  opacity: 1;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03)),
    rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.28);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    0 0 24px rgba(122,175,255,0.18),
    0 14px 30px rgba(122,175,255,0.12);
}

body:not([data-theme='night']) .quick-cheat-btn.is-active {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.05),
    0 0 24px rgba(255, 181, 123, 0.18),
    0 14px 30px rgba(255, 181, 123, 0.12);
}

body[data-theme='night'] .quick-cheat-btn.is-active {
  box-shadow:
    0 0 0 1px rgba(230,224,255,0.05),
    0 0 24px rgba(156, 140, 222, 0.2),
    0 14px 30px rgba(88, 82, 142, 0.14);
}

.player-card {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "avatar"
    "meta";
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}

.player-left {
  display: contents;
}

.player-meta {
  grid-area: meta;
  display: none;
  gap: 11px;
  min-width: 0;
  width: 100%;
  align-content: start;
  padding-top: 12px;
}

.meta-row {
  display: grid;
  grid-template-columns: 122px minmax(188px, 264px);
  gap: 12px;
  align-items: center;
  width: auto;
}

.meta-inject-row { align-items: flex-start; padding-top: 2px; }
.meta-inject-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.inject-btn {
  font-size: 0.72rem;
  padding: 5px 9px;
  line-height: 1.2;
  opacity: 0.88;
}
.inject-btn:hover { opacity: 1; }
.player-inject-row { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; }

.meta-key {
  white-space: nowrap;
  line-height: 1.2;
}

.meta-value {
  min-height: 42px;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding: 0 16px;
  border: 1px solid var(--glass-edge-soft);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.015)),
    var(--field);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 -1px 0 rgba(255,255,255,0.012);
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
  width: 100%;
  min-width: 0;
  justify-self: stretch;
}

.meta-input {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: var(--text);
  outline: none;
}

.meta-input::placeholder {
  color: rgba(255, 255, 255, 0.36);
}

.meta-input:focus {
  border-color: rgba(255,255,255,0.28);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.11), rgba(255,255,255,0.035)),
    var(--field);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 0 0 3px rgba(122,175,255,0.08),
    0 12px 28px rgba(122,175,255,0.08);
}

.meta-reload-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.meta-reload-wrap .meta-input {
  flex: 1;
  min-width: 0;
  background: rgba(255,255,255,0.5);
  border: none;
  padding: 0;
  height: 100%;
}

.reload-required-hint {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.25;
  transition: opacity 0.2s ease;
}

.reload-required-hint.has-pending {
  opacity: 1;
}

/* Scoped to hint/field usages only so header reload button SVG is unaffected. */
.reload-required-hint .reload-icon,
.field-reload-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: middle;
  opacity: 0.7;
}

body:not([data-theme='night']) .reload-required-hint .reload-icon,
body:not([data-theme='night']) .field-reload-icon {
  filter: invert(1);
}

body[data-theme='night'] .reload-required-hint .reload-icon,
body[data-theme='night'] .field-reload-icon {
  filter: none;
}

.field-reload-icon {
  width: 13px;
  height: 13px;
  margin-left: 4px;
  opacity: 0.55;
}

/* Preset buttons — compact chips with category color tint */
.preset-btn {
  min-width: unset;
  min-height: 20px;
  height: 20px;
  padding: 0 5px;
  font-size: 0.67rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.82);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--ease), opacity var(--ease);
}
.preset-btn:hover { background: rgba(255,255,255,0.13); }
.preset-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Inventory sidebar — hanging tabs off the right edge of inventory-card */
.inventory-sidebar {
  display: flex;
  flex-direction: column;
  margin-left: -1px;
  align-self: flex-start;
  overflow: visible;
}

.inventory-sidebar-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 10px 4px;
  opacity: 0.55;
  white-space: nowrap;
}

.inventory-sidebar .preset-btn {
  min-height: 22px;
  height: auto;
  padding: 5px 10px 5px 8px;
  font-size: 0.68rem;
  border-radius: 6px;
  border-left: 2px solid;
  text-align: left;
  width: 100%;
  white-space: nowrap;
  margin-bottom: 2px;
}

/* Per-category color tints */
/* Sidebar tabs — left accent border uses border-color from the preset specifics */
.inventory-sidebar .preset-btn[data-preset="tools"]     { background: rgba(255, 180,  60, 0.16); border-color: rgba(255, 180,  60, 0.50); color: rgba(255,210,140,0.95); }
.inventory-sidebar .preset-btn[data-preset="tools"]:hover { background: rgba(255, 180, 60, 0.26); }
.inventory-sidebar .preset-btn[data-preset="gold"]      { background: rgba(255, 215,   0, 0.14); border-color: rgba(255, 215,   0, 0.50); color: rgba(255,230,120,0.95); }
.inventory-sidebar .preset-btn[data-preset="gold"]:hover  { background: rgba(255, 215,  0, 0.26); }
.inventory-sidebar .preset-btn[data-preset="materials"] { background: rgba( 98, 214, 111, 0.14); border-color: rgba( 98, 214, 111, 0.50); color: rgba(160,240,180,0.95); }
.inventory-sidebar .preset-btn[data-preset="materials"]:hover { background: rgba(98, 214, 111, 0.26); }
.inventory-sidebar .preset-btn[data-preset="dye"]       { background: rgba(200,  90, 220, 0.14); border-color: rgba(200,  90, 220, 0.50); color: rgba(230,160,255,0.95); }
.inventory-sidebar .preset-btn[data-preset="dye"]:hover { background: rgba(200, 90, 220, 0.26); }
.inventory-sidebar .preset-btn[data-preset="trees"]     { background: rgba( 80, 180,  80, 0.14); border-color: rgba( 80, 180,  80, 0.50); color: rgba(160,230,160,0.95); }
.inventory-sidebar .preset-btn[data-preset="trees"]:hover { background: rgba(80, 180,  80, 0.26); }
.inventory-sidebar .preset-btn[data-preset="bushes"]    { background: rgba( 60, 160, 100, 0.14); border-color: rgba( 60, 160, 100, 0.50); color: rgba(130,220,170,0.95); }
.inventory-sidebar .preset-btn[data-preset="bushes"]:hover { background: rgba(60, 160, 100, 0.26); }
.inventory-sidebar .preset-btn[data-preset="roses"]     { background: rgba(220,  60,  80, 0.14); border-color: rgba(220,  60,  80, 0.50); color: rgba(255,140,150,0.95); }
.inventory-sidebar .preset-btn[data-preset="roses"]:hover { background: rgba(220, 60,  80, 0.26); }
.inventory-sidebar .preset-btn[data-preset="tulips"]    { background: rgba(255, 120, 160, 0.14); border-color: rgba(255, 120, 160, 0.50); color: rgba(255,180,210,0.95); }
.inventory-sidebar .preset-btn[data-preset="tulips"]:hover { background: rgba(255, 120, 160, 0.26); }

/* Non-sidebar preset buttons keep original colors */
.preset-btn[data-preset="tools"]     { background: rgba(255, 180,  60, 0.12); border-color: rgba(255, 180,  60, 0.22); }
.preset-btn[data-preset="tools"]:hover { background: rgba(255, 180, 60, 0.22); }
.preset-btn[data-preset="gold"]      { background: rgba(255, 215,   0, 0.12); border-color: rgba(255, 215,   0, 0.22); }
.preset-btn[data-preset="gold"]:hover  { background: rgba(255, 215,  0, 0.22); }
.preset-btn[data-preset="materials"] { background: rgba( 98, 214, 111, 0.10); border-color: rgba( 98, 214, 111, 0.20); }
.preset-btn[data-preset="materials"]:hover { background: rgba(98, 214, 111, 0.20); }
.preset-btn[data-preset="dye"]       { background: rgba(200,  90, 220, 0.10); border-color: rgba(200,  90, 220, 0.22); }
.preset-btn[data-preset="dye"]:hover { background: rgba(200, 90, 220, 0.20); }
.preset-btn[data-preset="trees"]     { background: rgba( 80, 180,  80, 0.10); border-color: rgba( 80, 180,  80, 0.20); }
.preset-btn[data-preset="trees"]:hover { background: rgba(80, 180,  80, 0.20); }
.preset-btn[data-preset="bushes"]    { background: rgba( 60, 160, 100, 0.10); border-color: rgba( 60, 160, 100, 0.20); }
.preset-btn[data-preset="bushes"]:hover { background: rgba(60, 160, 100, 0.20); }
.preset-btn[data-preset="roses"]     { background: rgba(220,  60,  80, 0.10); border-color: rgba(220,  60,  80, 0.22); }
.preset-btn[data-preset="roses"]:hover { background: rgba(220, 60,  80, 0.20); }
.preset-btn[data-preset="tulips"]    { background: rgba(255, 120, 160, 0.10); border-color: rgba(255, 120, 160, 0.22); }
.preset-btn[data-preset="tulips"]:hover { background: rgba(255, 120, 160, 0.20); }

.preset-btn-add {
  min-width: 20px;
  width: 20px;
  padding: 0;
  font-size: 0.8rem;
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
}
.preset-btn-add:hover { background: rgba(255,255,255,0.16); }

/* Hidden preset (unpinned from shortcut bar) */
.preset-btn-hidden { display: none !important; }

/* Long-hold visual feedback */
@keyframes preset-hold-pulse {
  0%   { transform: scale(1); }
  60%  { transform: scale(0.88); }
  100% { transform: scale(0.88); }
}
.preset-btn.is-holding {
  animation: preset-hold-pulse 0.65s ease forwards;
  outline: 2px solid rgba(255,255,255,0.35);
  outline-offset: 2px;
}

/* ── Preset Manager Modal ─────────────────────────── */
.modal-card-preset-manager {
  width: min(560px, 100%);
}
.pm-body {
  padding: 18px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  max-height: calc(80vh - 60px);
}
.pm-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pm-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.pm-hint-inline {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.65;
}
.pm-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  align-items: center;
}
.pm-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.82);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--ease);
}
.pm-chip:hover { background: rgba(255,255,255,0.14); }
.pm-chip-pinned { border-color: rgba(255,255,255,0.26); background: rgba(255,255,255,0.10); }
.pm-chip-pinned .pm-chip-x { opacity: 0.55; font-size: 0.65rem; }
.pm-chip-pinned:hover .pm-chip-x { opacity: 1; }
.pm-chip-available .pm-chip-plus { opacity: 0.7; font-size: 0.8rem; color: var(--good); }
.pm-empty { font-size: 0.74rem; color: var(--text-muted); opacity: 0.6; font-style: italic; }

/* Create form */
.pm-create-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pm-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pm-row-col {
  flex-direction: column;
  align-items: flex-start;
}
.pm-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 48px;
  white-space: nowrap;
}
.pm-input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: rgba(255,255,255,0.9);
  font-size: 0.8rem;
  padding: 5px 9px;
  outline: none;
  min-width: 0;
  flex: 1;
}
.pm-input:focus { border-color: rgba(255,255,255,0.32); }

/* Color swatches */
.pm-swatches {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.pm-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  background-color: var(--sw-color);
  cursor: pointer;
  transition: transform var(--ease), border-color var(--ease);
}
.pm-swatch:hover { transform: scale(1.15); }
.pm-swatch.is-selected {
  border-color: rgba(255,255,255,0.9);
  transform: scale(1.2);
}

/* Item list */
.pm-item-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  max-height: 140px;
  overflow-y: auto;
}
.pm-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  font-size: 0.76rem;
}
.pm-item-name { flex: 1; color: rgba(255,255,255,0.85); }
.pm-item-qty  { color: var(--text-muted); font-size: 0.72rem; }
.pm-item-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0 2px;
  opacity: 0.6;
}
.pm-item-remove:hover { opacity: 1; }

/* Add item row */
.pm-item-add-row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  margin-top: 6px;
}
.pm-item-search-wrap {
  position: relative;
  flex: 1;
}
.pm-item-query { width: 100%; }
.pm-item-qty { width: 58px; flex: none; }

/* Autocomplete suggestions — fixed to viewport to escape overflow:hidden parents */
.pm-suggestions {
  position: fixed;
  z-index: 9999;
  background: rgba(18, 22, 32, 0.97);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  overflow-y: auto;
  max-height: 220px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
  display: none;
}
.pm-suggestions:not(:empty) { display: block; }
.pm-suggestion-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  font-size: 0.76rem;
  color: rgba(255,255,255,0.82);
  cursor: pointer;
}
.pm-suggestion-item:hover { background: rgba(255,255,255,0.09); }
.pm-suggestion-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}
.pm-suggestion-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.action-btn {
  min-width: 92px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.02);
  color: var(--text);
  cursor: pointer;
  transition:
    transform 0.18s var(--ease),
    border-color 0.18s var(--ease),
    background 0.18s var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 500;
}

.action-btn-solid {
  background: rgba(255,255,255,0.92);
  color: #0a0a0b;
  border-color: rgba(255,255,255,0.92);
}

.action-btn-solid.vmod-save-ok {
  background: rgba(100, 220, 130, 0.85);
  border-color: rgba(100, 220, 130, 0.85);
  color: #0a0a0b;
  transition: background 0.25s, border-color 0.25s;
}

.action-btn-solid.vmod-save-error {
  background: rgba(255, 100, 80, 0.85);
  border-color: rgba(255, 100, 80, 0.85);
  color: #fff;
  transition: background 0.25s, border-color 0.25s;
}

/* Save button: keep text + add circle dot to the right */
.vmod-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.vmod-save-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.22s;
}

.vmod-save-dot--saving {
  background: var(--warn);
  box-shadow: 0 0 6px rgba(245, 197, 66, 0.7);
  animation: vmod-dot-pulse 0.9s ease-in-out infinite;
}

.vmod-save-dot--ok {
  background: var(--good);
  box-shadow: 0 0 6px rgba(92, 216, 122, 0.7);
}

.vmod-save-dot--error {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(245, 108, 80, 0.7);
}

@keyframes vmod-dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.action-btn.is-active {
  border-color: rgba(122, 175, 255, 0.4);
  background: rgba(122, 175, 255, 0.1);
  box-shadow: 0 4px 16px rgba(122, 175, 255, 0.08);
}

.action-btn.is-loading {
  opacity: 0.7;
  cursor: wait;
}

.action-btn[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
}

.player-avatar-wrap {
  grid-area: avatar;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  width: min(100%, var(--player-tile-size));
  height: auto;
  margin-inline: auto;
}

.player-mailbox-status {
  width: fit-content;
  min-height: 32px;
  margin: 0 0 12px;
  padding: 0 10px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02)),
    rgba(8, 14, 24, 0.78);
  display: flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255,255,255,0.08);
}

.player-mailbox-status .icon-img {
  width: 16px;
  height: 16px;
}

.player-mailbox-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.35);
  box-shadow: 0 0 8px rgba(255,255,255,0.12);
}

.avatar-box {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(circle at top, rgba(255, 191, 145, 0.14), transparent 54%),
    radial-gradient(circle at 50% 100%, rgba(120,170,255,0.1), transparent 56%),
    rgba(255,255,255,0.02);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 18px 40px rgba(0,0,0,0.2);
}

body[data-theme='night'] .avatar-box {
  background:
    radial-gradient(circle at top, rgba(174, 160, 240, 0.1), transparent 54%),
    radial-gradient(circle at 50% 100%, rgba(108, 100, 182, 0.1), transparent 56%),
    rgba(255,255,255,0.015);
}

.avatar-button {
  color: inherit;
  cursor: pointer;
  transition:
    transform 0.18s var(--ease),
    border-color 0.18s var(--ease),
    background 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.avatar-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(255,255,255,0.04);
}

.avatar-button:focus-visible {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.05);
}

.avatar-edit-chip {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 36px;
  height: 36px;
  border: 1px solid color-mix(in srgb, var(--indicator-green) 34%, var(--line));
  border-radius: 999px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--indicator-green) 20%, transparent), color-mix(in srgb, var(--indicator-green) 5%, transparent)),
    var(--panel-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

.avatar-edit-chip .icon-img {
  width: 18px;
  height: 18px;
}

.avatar-button:hover .avatar-edit-chip,
.avatar-button:focus-visible .avatar-edit-chip {
  border-color: color-mix(in srgb, var(--indicator-green) 60%, var(--line));
}

body:not([data-theme='night']) .avatar-edit-chip .icon-img {
  filter: none;
}

.player-avatar {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Silhouette placeholder fills less space and centers cleanly */
.player-avatar[src*="player-silhouette"] {
  width: 64px;
  height: 64px;
  opacity: 0.3;
  margin: auto;
}

/* inventory-search-bar — quick assign search input */
.inventory-search-bar {
  display: flex;
  margin-bottom: 8px;
  position: relative;
  z-index: 10;
}

.inv-quick-search-wrap {
  position: relative;
  width: 100%;
}

.inv-quick-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 14px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  font-size: 0.80rem;
  outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.inv-quick-search-input:focus {
  border-color: rgba(255,255,255,0.32);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.05);
}
.inv-quick-search-input::placeholder {
  color: var(--text-muted);
  opacity: 0.78;
}
.inv-quick-search-input::-webkit-search-cancel-button { display: none; }

body:not([data-theme='night']) .inv-quick-search-input {
  color: var(--text);
}

.inv-quick-search-results,
.modal-results-list {
  border-radius: 12px;
  border: 1px solid var(--glass-edge-soft);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015)), var(--surface);
  backdrop-filter: blur(16px) saturate(1.35);
  -webkit-backdrop-filter: blur(16px) saturate(1.35);
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}

.inv-quick-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 5px);
  z-index: 200;
  max-height: 260px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

body[data-theme='night'] .inv-quick-search-results,
body[data-theme='night'] .modal-results-list {
  background: linear-gradient(180deg, rgba(14, 16, 28, 0.96), rgba(10, 12, 22, 0.94)), rgba(12, 14, 26, 0.88);
  border-color: rgba(222, 216, 250, 0.08);
}

body:not([data-theme='night']) .inv-quick-search-results,
body:not([data-theme='night']) .modal-results-list {
  background: linear-gradient(180deg, rgba(255, 248, 242, 0.95), rgba(255, 246, 238, 0.84)), rgba(255,255,255,0.92);
  border-color: rgba(255, 220, 191, 0.18);
}
.inv-quick-search-results,
.modal-results-list {
  transition:
    opacity 0.24s var(--ease),
    transform 0.24s var(--ease),
    max-height 0.28s var(--ease),
    border-color 0.24s var(--ease),
    box-shadow 0.24s var(--ease);
  transform-origin: top center;
}

.inv-quick-search-results.is-collapsed,
.modal-results-list.is-collapsed {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  border-color: transparent;
  transform: translateY(-8px) scaleY(0.96);
  pointer-events: none;
  box-shadow: none;
}

.inv-qsr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.80rem;
  transition: background 0.1s;
}
.inv-qsr-row:hover,
.inv-qsr-row.is-focused {
  background: rgba(255,255,255,0.06);
}
.inv-qsr-row.is-skeleton:hover,
.inv-qsr-row.is-skeleton.is-focused {
  background: transparent;
}

body[data-theme='night'] .inv-qsr-row {
  border-bottom-color: rgba(255,255,255,0.05);
}

body[data-theme='night'] .inv-qsr-row:hover,
body[data-theme='night'] .inv-qsr-row.is-focused {
  background: rgba(255,255,255,0.06);
}

body:not([data-theme='night']) .inv-qsr-row {
  border-bottom-color: rgba(70, 35, 28, 0.08);
}

body:not([data-theme='night']) .inv-qsr-row:hover,
body:not([data-theme='night']) .inv-qsr-row.is-focused {
  background: rgba(255, 202, 169, 0.12);
}
.inv-qsr-row:last-child { border-bottom: none; }

.inv-qsr-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
}

.inv-qsr-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-qsr-cat {
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0.65;
  flex-shrink: 0;
  white-space: nowrap;
}

.inv-qsr-empty {
  padding: 12px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.6;
}

.inventory-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
  gap: 0;
  align-items: start;
}

/* Theme toggle — dual icon approach (no src-swap flash) */
.theme-toggle-btn .theme-icon-night { display: none; }
.theme-toggle-btn.is-night .theme-icon-day { display: none; }
.theme-toggle-btn.is-night .theme-icon-night { display: block; }

.inventory-card {
  min-height: 208px;
  overflow: hidden;
  padding: 14px;
  border: 1px solid var(--glass-edge-soft);
  border-radius: 18px;
  background: var(--surface);
  contain: layout;
  transition:
    border-color 0.82s cubic-bezier(.16,.84,.28,1);
  position: relative;
  z-index: 1;
}

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

.inventory-slot {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.015);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.18s var(--ease),
    border-color 0.18s var(--ease),
    background 0.18s var(--ease),
    opacity 0.18s var(--ease);
}

.inventory-slot.is-selected {
  border-color: rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.03);
}

.inventory-slot.is-clipboard-source {
  border-color: rgba(142, 244, 183, 0.62);
  background: rgba(142, 244, 183, 0.08);
  box-shadow:
    inset 0 0 0 1px rgba(142, 244, 183, 0.2),
    0 0 0 1px rgba(142, 244, 183, 0.14);
}

.inventory-slot.is-paste-armed-1 {
  border-color: rgba(255, 95, 115, 0.52);
  background: rgba(255, 95, 115, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 95, 115, 0.14);
}

.inventory-slot.is-paste-armed-2 {
  border-color: rgba(255, 95, 115, 0.68);
  background: rgba(255, 95, 115, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 95, 115, 0.22);
}

.inventory-slot.is-paste-armed-3 {
  border-color: rgba(255, 95, 115, 0.62);
  background: rgba(255, 95, 115, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 95, 115, 0.2);
}

.inventory-slot.is-pending-write {
  border-color: rgba(123, 212, 255, 0.58);
  background: rgba(123, 212, 255, 0.05);
}

/* Batch 2 — copy/move visual feedback */
.inventory-slot.is-clipboard-move img {
  filter: grayscale(1);
  opacity: 0.38 !important;
}
.inventory-slot.is-clipboard-move .inventory-slot-stack-count {
  opacity: 0.38;
}
.inventory-slot.is-clipboard-copy::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background-image: url('/assets/icons/copy.svg');
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
  pointer-events: none;
  z-index: 2;
}

.inventory-slot img {
  width: 72%;
  height: 72%;
  object-fit: contain;
  opacity: 1;
  transition: opacity 0.18s var(--ease), filter 0.18s var(--ease);
}

.inventory-slot.is-selected img,
.inventory-slot.is-clipboard-source img,
.inventory-slot.is-paste-armed-1 img,
.inventory-slot.is-paste-armed-2 img,
.inventory-slot.is-paste-armed-3 img,
.inventory-slot.is-pending-write img {
  opacity: 0.72;
}

.inventory-slot-pending-indicator {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(123, 212, 255, 0.04) 0%, rgba(123, 212, 255, 0.16) 100%);
  pointer-events: none;
}

.inventory-slot-pending-ring {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 3px solid rgba(255,255,255,0.16);
  border-top-color: rgba(123, 212, 255, 0.95);
  border-right-color: rgba(123, 212, 255, 0.72);
  box-shadow: 0 0 18px rgba(123, 212, 255, 0.22);
  animation: inventory-slot-spinner 0.9s linear infinite;
}

@keyframes inventory-slot-spinner {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.slot-index {
  position: absolute;
  top: 5px;
  left: 7px;
  color: rgba(255,255,255,0.42);
  font-size: 0.67rem;
}

.inventory-slot-stack-count {
  position: absolute;
  bottom: 7%;
  right: 7%;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
  color: #fff;
  text-shadow:
    0 1px 4px rgba(0,0,0,0.95),
    0 0 8px rgba(0,0,0,0.8),
    1px 1px 0 rgba(0,0,0,0.7);
  pointer-events: none;
  z-index: 2;
}

body:not([data-theme='night']) .inventory-slot-stack-count {
  text-shadow:
    0 1px 3px rgba(0,0,0,0.4),
    0 0 5px rgba(0,0,0,0.2);
}

.shortcut-column {
  display: grid;
  gap: 10px;
  align-content: start;
  padding-top: 16px;
  margin-left: -1px;
}

.shortcut-btn {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 14px 14px 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.015)),
    rgba(255,255,255,0.02);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition:
    transform 0.22s var(--ease),
    border-color 0.42s var(--ease),
    background 0.42s var(--ease),
    box-shadow 0.52s cubic-bezier(.16,.84,.28,1),
    color 0.32s var(--ease),
    filter 0.42s var(--ease);
}

.shortcut-btn.is-active {
  background:
    linear-gradient(180deg, rgba(122,175,255,0.24), rgba(122,175,255,0.08)),
    rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.3);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.06),
    0 0 28px rgba(122,175,255,0.2),
    0 0 64px rgba(122,175,255,0.14),
    0 18px 36px rgba(122,175,255,0.18);
  filter: saturate(1.08);
}

.tabs-panel {
  padding: 12px;
}

.tab-bar {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 0;
  border: 1px solid var(--glass-edge-soft);
  border-radius: 14px;
  background: rgba(8, 12, 26, 0.22);
}

.tab-btn {
  min-width: 0;
  min-height: 40px;
  flex: 1 1 0;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition:
    color 0.28s var(--ease),
    border-color 0.42s var(--ease),
    background 0.42s var(--ease),
    box-shadow 0.58s cubic-bezier(.16,.84,.28,1),
    transform 0.24s var(--ease),
    text-shadow 0.36s var(--ease);
}

.tab-btn.is-active {
  color: var(--text);
  border-color: rgba(255,255,255,0.14);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.035)),
    rgba(255,255,255,0.055);
  box-shadow:
    0 5px 16px rgba(6, 8, 20, 0.2),
    inset 0 1px 0 rgba(255,255,255,0.12);
  text-shadow: none;
}

body:not([data-theme='night']) .shortcut-btn.is-active,
body:not([data-theme='night']) .tab-btn.is-active {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.06),
    0 0 30px rgba(255, 185, 128, 0.18),
    0 0 78px rgba(122,175,255,0.12),
    0 18px 40px rgba(255, 185, 128, 0.12);
}

body[data-theme='night'] .shortcut-btn.is-active,
body[data-theme='night'] .tab-btn.is-active {
  box-shadow:
    0 0 0 1px rgba(230,224,255,0.05),
    0 0 30px rgba(156, 140, 222, 0.18),
    0 0 72px rgba(120, 110, 182, 0.12),
    0 18px 38px rgba(88, 82, 142, 0.14);
}

.tab-panel {
  min-height: 0;
  position: relative;
  overflow: clip;
  padding: 16px 4px 4px;
  border: 1px solid var(--glass-edge-soft);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  background: rgba(10, 14, 30, 0.16);
  transition:
    opacity 0.82s cubic-bezier(.16,.84,.28,1),
    transform 0.82s cubic-bezier(.16,.84,.28,1),
    border-color 0.82s cubic-bezier(.16,.84,.28,1);
}

/* ── Tab compact bar (Village tab) ─────────────────────────────────────── */
.tab-compact-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  border: 0;
}

.tab-compact-field {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--glass-edge-soft);
  border-radius: 12px;
  background: rgba(255,255,255,0.035);
  font-size: 0.78rem;
}

.tcf-label {
  color: var(--text-muted);
  opacity: 0.7;
  white-space: nowrap;
}

.tab-compact-field strong {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: baseline;
}

.tab-hidden-source { display: none !important; }

/* ── Tab category details/summary ───────────────────────────────────────── */
.tab-category-details {
  border: 1px solid var(--glass-edge-soft);
  border-radius: 12px;
  overflow: hidden;
}

.tab-category-summary {
  padding: 9px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.tab-category-summary::-webkit-details-marker { display: none; }
.tab-category-details[open] .tab-category-summary {
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.tab-category-details .tab-list {
  padding: 10px 14px;
}

/* ── Tab status dot (Villagers / future tabs) ───────────────────────────── */
.tab-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  margin-left: 5px;
  vertical-align: middle;
  flex-shrink: 0;
  transition: background 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
}
.tab-status-dot.is-busy {
  background: #f5c842;
  box-shadow: 0 0 5px rgba(245, 200, 66, 0.65);
  animation: dot-pulse 1.1s ease-in-out infinite;
}
.tab-status-dot.is-ok {
  background: var(--good, #8ef4b7);
  box-shadow: 0 0 5px rgba(142, 244, 183, 0.6);
  animation: none;
}
.tab-status-dot.is-error {
  background: var(--danger, #ff8383);
  box-shadow: 0 0 5px rgba(255, 131, 131, 0.6);
  animation: none;
}
@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.tab-panel-copy h3 {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: 0;
}

.tab-panel-copy p {
  margin: 4px 0 0;
  max-width: 56ch;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.tab-layout {
  display: grid;
  gap: 12px;
}

.tab-dual-grid {
  display: grid;
  gap: 14px;
}

.tab-dual-grid {
  grid-template-columns: 1fr;
}

.tab-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--glass-edge-soft);
  border-radius: 16px;
  background: var(--surface);
  transition:
    border-color 0.82s cubic-bezier(.16,.84,.28,1),
    transform 0.82s cubic-bezier(.16,.84,.28,1);
}

.tab-card h4 {
  color: var(--text-muted);
}

.tab-card {
  padding: 14px;
}

.tab-card h4 {
  margin: 0 0 10px;
  font-size: var(--font-size-sm);
  font-weight: 650;
}

.tab-list,
.tab-kv-list {
  display: grid;
  gap: 10px;
}

.tab-list-row,
.tab-kv-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.tab-list-row,
.tab-kv-row {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.tab-list-row:last-child,
.tab-kv-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.tab-list-row span,
.tab-kv-row span,
.tab-empty-state {
  color: var(--text-muted);
}

.tab-list-row strong,
.tab-kv-row strong {
  text-align: right;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.18);
  flex: 0 0 auto;
}

.status-dot.is-live {
  background: var(--good);
  border-color: rgba(98, 214, 111, 0.6);
}

.mini-code-block {
  margin: 0;
  min-height: 190px;
  padding: 14px;
  border: 1px solid rgba(186, 247, 192, 0.14);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), transparent 38%),
    var(--console-bg);
  color: var(--console-text);
  font-size: 12px;
  line-height: 1.6;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, Menlo, monospace;
  text-shadow: 0 0 10px rgba(186, 247, 192, 0.1);
  white-space: pre-wrap;
}

.footer-mark {
  width: 100%;
  margin-top: 26px;
  padding: var(--space-4) var(--space-1) 0;
  border-top: 1px solid var(--line);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-muted);
  opacity: 0.92;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.footer-label {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.footer-mark img {
  max-height: 24px;
  width: auto;
  opacity: 0.82;
}

.footer-watermark {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--font-size-md);
  letter-spacing: 0.02em;
  transition: color 0.18s var(--ease), opacity 0.18s var(--ease);
}

.footer-watermark:hover,
.footer-watermark:focus-visible {
  color: var(--text);
}

body[data-theme='night'] .footer-mark {
  border-color: var(--line);
}

body[data-theme='night'] .footer-watermark {
  color: var(--text-muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(12px, 2.2vw, 20px);
  /* Safe-area insets for iPhone notch / home indicator */
  padding-top: max(clamp(12px, 2.2vw, 20px), env(safe-area-inset-top, 0px));
  padding-bottom: max(clamp(12px, 2.2vw, 20px), env(safe-area-inset-bottom, 0px));
  padding-left: max(clamp(12px, 2.2vw, 20px), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(12px, 2.2vw, 20px), env(safe-area-inset-right, 0px));
  /* Dim overlay behind the card — fades with the modal's own opacity.
     No filter animation needed; the modal-card's backdrop-filter blurs
     the app-shell + this dim tint for the proper iOS depth cue. */
  background: rgba(6, 8, 16, 0.42);
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--dur-base) var(--ease-standard),
    visibility 0s linear var(--dur-base);
}

body:not([data-theme='night']) .modal {
  background: rgba(48, 36, 30, 0.28);
}

.modal.hidden {
  display: none;
}

.modal.is-visible,
.modal.is-closing {
  visibility: visible;
  transition:
    opacity var(--dur-base) var(--ease-standard),
    visibility 0s linear 0s;
}

.modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.modal.is-closing {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  width: min(900px, 100%);
  margin: auto;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  max-height: min(92vh, calc(100dvh - 24px));
  border: 1px solid var(--glass-edge);
  border-radius: 24px;
  background:
    linear-gradient(180deg, var(--glass-top), var(--glass-bottom)),
    var(--panel);
  box-shadow:
    0 18px 58px rgba(0,0,0,0.18),
    inset 0 1px 0 rgba(255,255,255,0.1),
    inset 0 -1px 0 rgba(255,255,255,0.015);
  backdrop-filter: blur(var(--backdrop-blur-strong)) saturate(var(--backdrop-sat)) contrast(1.02);
  -webkit-backdrop-filter: blur(var(--backdrop-blur-strong)) saturate(var(--backdrop-sat)) contrast(1.02);
  /* Only animate opacity + transform — never animate backdrop-filter or background
     as they force expensive composite layer rebuilds that cause jank. Spring
     easing (peak 1.56) gives a clearly iOS-like pop-in. */
  transition:
    opacity var(--dur-modal) var(--ease-spring),
    transform var(--dur-modal) var(--ease-spring);
  overflow-y: auto;
  scrollbar-width: none;
  opacity: 0;
  transform: translateY(24px) scale(0.94);
}

body:not([data-theme='night']) .modal-card {
  background:
    linear-gradient(180deg, var(--glass-top), var(--glass-bottom)),
    var(--panel);
  box-shadow:
    0 18px 58px rgba(40, 18, 18, 0.12),
    inset 0 1px 0 rgba(255,255,255,0.11),
    inset 0 -1px 0 rgba(255,255,255,0.015);
}

body[data-theme='night'] .modal-card {
  background:
    linear-gradient(180deg, var(--glass-top), var(--glass-bottom)),
    var(--panel);
  box-shadow:
    0 18px 58px rgba(8, 8, 20, 0.16),
    inset 0 1px 0 rgba(255,255,255,0.1),
    inset 0 -1px 0 rgba(255,255,255,0.015);
}

body:not([data-theme='night']) .settings-debug-box,
body:not([data-theme='night']) .mini-code-block {
  border-color: rgba(255, 211, 182, 0.14);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 38%),
    rgba(24, 16, 15, 0.52);
}

body:not([data-theme='night']) #settings-debug-output,
body:not([data-theme='night']) .mini-code-block,
body:not([data-theme='night']) .modal-filter-btn {
  color: rgba(255, 231, 212, 0.84);
  text-shadow: 0 0 10px rgba(255, 174, 120, 0.08);
}

.modal.is-visible .modal-card {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal.is-closing .modal-card {
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  /* Faster exit with ease-in — feels snappier than reversing the spring. */
  transition:
    opacity var(--dur-fast) var(--ease-in),
    transform var(--dur-fast) var(--ease-in);
}

.modal-card-settings {
  width: min(310px, 100%);
  min-height: 360px;
}

.modal-card-backups {
  width: min(680px, 100%);
}

/* ── Villager edit modal ───────────────────────────── */
.modal-card-villager {
  width: min(720px, 100%);
  overflow-x: hidden;
  height: min(92vh, calc(100svh - 24px));
  max-height: min(92vh, calc(100svh - 24px));
  --vmod-inset: 16px;
}

/* Compact modal-head for villager modal ONLY (does not affect other modals) */
.modal-card-villager .modal-head {
  padding: 10px var(--vmod-inset);
}

.modal-card-villager .modal-head h2 {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.modal-card-villager .modal-close {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  font-size: 1.4rem;
}

/* React body mount fills the card below the modal-head */
#villager-modal-body,
.villager-modal-body-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.villager-modal-shell {
  display: flex;
  flex: 1;
  gap: 16px;
  padding: 12px var(--vmod-inset) 0;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}

/* Full-width sub-views (house/flags/edit) — no art aside; children self-inset via --vmod-inset */
.villager-modal-shell.vmod-fullwidth {
  padding: 8px 0 0;
}

.villager-modal-aside {
  flex-shrink: 0;
  width: clamp(180px, 26vw, 240px);
  display: flex;
  flex-direction: column;
  align-self: flex-start;
}

/* iOS hero art: aspect-ratio-locked frame so the frame height matches the
   image aspect — zero letterbox. Anchored flush to the bottom edge. */
.villager-modal-art-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 320px;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 78%, rgba(144, 168, 224, 0.14), rgba(255,255,255,0) 65%),
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.008));
  border: 1px solid rgba(255,255,255,0.08);
  display: block;
  padding: 0;
}

.villager-modal-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center 100%;
  transition: opacity 0.24s ease;
  filter: drop-shadow(0 8px 22px rgba(0,0,0,0.32));
}

.villager-modal-art.art-pending {
  opacity: 0;
}

.villager-modal-art-shimmer {
  position: absolute;
  inset: 0;
  border-radius: 0;
  /* Don't tint the art — only the ::after sweep should be visible */
  background: rgba(255,255,255,0.5);
}

.villager-modal-art-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  opacity: 0.4;
}

.villager-modal-info {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 0;
  overflow: hidden;
}

/* Hero: name + inline meta chips. iOS Music/Contact "large-title header". */
.vmod-hero {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 4px 4px;
}

.villager-modal-name-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.villager-modal-name {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.022em;
  color: var(--text);
  line-height: 1.05;
}

.villager-modal-gender-label {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.55);
  font-weight: 500;
}

.vmod-hero-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.vmod-hero-sep {
  color: rgba(255,255,255,0.28);
  font-weight: 600;
}

.vmod-hero-species {
  color: rgba(255,255,255,0.78);
  font-weight: 500;
}

/* iOS Settings-style section title: small, uppercase, muted, above each group */
.vmod-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.5);
  padding: 8px 6px 2px;
  margin-top: 2px;
}

/* iOS grouped-list card: rounded, subtle inset bg, hairline row separators. */
.vmod-fields {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
}

.vmod-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  min-height: 44px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

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

.vmod-label {
  flex-shrink: 0;
  min-width: 100px;
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.vmod-value {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: rgba(255,255,255,0.62);
  font-size: 0.9rem;
}

.vmod-id-pair {
  gap: 10px;
}

.vmod-num {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.42);
  font-variant-numeric: tabular-nums;
  min-width: 22px;
  text-align: right;
}

.vmod-name {
  font-size: 0.92rem;
  color: rgba(255,255,255,0.88);
}

/* Catchphrase row: input fills the row, no label column */
.vmod-field-catchphrase {
  padding: 8px 10px;
}

.vmod-catchphrase-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 0;
  justify-content: stretch;
}

.vmod-input {
  flex: 1;
  min-width: 0;
  background: rgba(0,0,0,0.24);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: rgba(255,255,255,0.92);
  font-size: 0.92rem;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}

.vmod-input::placeholder {
  color: rgba(255,255,255,0.32);
}

.vmod-input:focus {
  border-color: rgba(122, 175, 255, 0.55);
}

.vmod-btn-sm {
  min-height: 30px;
  min-width: unset;
  padding: 4px 12px;
  font-size: 0.78rem;
  flex-shrink: 0;
}

/* iOS toggle switch */
.vmod-checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 8px;
  user-select: none;
}

.vmod-checkbox-label input[type="checkbox"] {
  width: 46px;
  height: 26px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.22s ease, border-color 0.22s ease;
  flex-shrink: 0;
  touch-action: manipulation;
}

.vmod-checkbox-label input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.28), 0 0 1px rgba(0,0,0,0.16);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.vmod-checkbox-label input[type="checkbox"]:checked {
  background: rgba(52, 199, 89, 0.92);
  border-color: rgba(52, 199, 89, 1);
}

.vmod-checkbox-label input[type="checkbox"]:checked::after {
  transform: translateX(20px);
  background: #fff;
}

/* Friendship — its own iOS card. Nested selectors keep home page untouched. */
.villager-modal-friendship {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  margin-top: 2px;
}

.villager-modal-friendship-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.villager-modal-friendship .villager-friendship-bar-track {
  height: 6px;
  border-radius: 999px;
}

.villager-modal-friendship .villager-friendship-bar-fill {
  border-radius: 999px;
}

.villager-modal-friendship .villager-friendship-tier {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
  font-weight: 500;
}

.vmod-friendship-value {
  font-variant-numeric: tabular-nums;
  color: rgba(255,255,255,0.82);
  margin-left: auto;
  font-size: 0.82rem;
}

.villager-modal-slot {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.32);
  padding: 8px 6px 0;
  text-align: center;
}

/* Main view wrapper — scrollable content */
.vmod-main-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 4px;
}

/* Footer — iOS action bar, larger primary Save pill */
.villager-modal-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 12px var(--vmod-inset) max(14px, env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-shrink: 0;
  gap: 8px;
}

.villager-modal-footer .action-btn-solid {
  min-height: 40px;
  padding: 0 20px;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: 999px;
}

/* Sub-view footer: left cluster + right Save */
.vmod-subview-footer {
  justify-content: space-between;
  padding: 12px var(--vmod-inset) max(14px, env(safe-area-inset-bottom, 0px));
}

.vmod-footer-left {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Sub-view shared layout */
.vmod-house-view,
.vmod-flags-view,
.vmod-edit-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 8px;
}

.vmod-subview-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  padding: 12px var(--vmod-inset) 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

/* House fields */
.vmod-house-fields {
  flex: 1;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  margin: 0 var(--vmod-inset);
}

.vmod-house-input {
  width: 100%;
  min-width: 0;
}

/* House labels are longer than generic vmod-label — let them size to content */
.vmod-house-fields .vmod-label {
  width: auto;
  min-width: 88px;
  max-width: 148px;
}

/* Flags view */
.vmod-flags-shell {
  display: flex;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0 var(--vmod-inset);
}

.vmod-flags-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: monospace;
}

.vmod-flag-item {
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255,255,255,0.65);
  user-select: none;
  transition: background 0.1s;
}

.vmod-flag-item:last-child {
  border-bottom: none;
}

.vmod-flag-item:hover {
  background: rgba(255,255,255,0.05);
}

.vmod-flag-item.is-selected {
  background: rgba(80, 100, 220, 0.3);
  color: rgba(255,255,255,0.95);
  font-weight: 600;
}

.vmod-flags-editor {
  width: 120px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  align-self: flex-start;
}

.vmod-flags-selected-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  word-break: break-all;
  min-height: 1.6em;
}

.vmod-flags-value-label {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
  display: block;
  margin-top: 4px;
}

.vmod-flags-value-input {
  width: 100%;
  min-width: 0;
}

/* Edit view */
.vmod-edit-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  overflow: hidden;
  margin: 0 var(--vmod-inset);
  background: rgba(255,255,255,0.015);
}

.vmod-edit-tabs {
  flex-shrink: 0;
  display: flex;
  gap: 2px;
  padding: 14px 4px 0;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
  background: transparent;
  border-bottom: 1px solid rgba(255,255,255,0.09);
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}

.vmod-edit-tabs::-webkit-scrollbar { display: none; }

/* Modal edit tabs inherit the global .tab-btn styling (pill top + active glow).
   Only smaller sizing so all 6 tabs fit inside the modal without excess scroll. */
.vmod-edit-tab-btn {
  min-width: 72px;
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Save Manager panel */
.vmod-save-manager {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 4px 0;
}

.vmod-save-manager-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vmod-save-manager-heading {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.vmod-save-manager-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
}

.vmod-save-manager-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.vmod-save-manager-filename {
  font-size: 0.72rem;
  color: var(--text-muted);
  word-break: break-all;
  opacity: 0.75;
}

.vmod-save-manager-loading,
.vmod-save-manager-empty,
.vmod-save-manager-error {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 8px 0;
}

.vmod-save-manager-error { color: var(--danger); }

.vmod-backup-list {
  display: flex;
  flex-direction: column;
  max-height: 160px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.vmod-backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.vmod-backup-row:last-child { border-bottom: 0; }

.vmod-backup-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.vmod-backup-row-date {
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
}

.vmod-backup-row-size {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Edit subview title with icon */
.vmod-edit-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vmod-edit-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  flex-shrink: 0;
}

.vmod-edit-panel {
  flex: 1;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
}

/* vedit-panel overrides the default centered flex of vmod-edit-panel */
.vmod-edit-panel.vedit-panel {
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  overflow: hidden;
}

/* ── Inventory panel ─────────────────────────────────────────────────── */
.vedit-inv-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.vedit-inv-left {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  padding: 10px;
  gap: 8px;
}

.vedit-inv-grid {
  display: grid;
  gap: 8px;
  flex: 1;
  align-content: start;
}

/* matches home page .inventory-slot exactly */
.vedit-inv-slot {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.015);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.18s var(--ease),
    border-color 0.18s var(--ease),
    background 0.18s var(--ease),
    opacity 0.18s var(--ease);
}

.vedit-inv-slot:hover {
  border-color: rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.03);
}

.vedit-inv-slot.is-selected {
  border-color: rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.05);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}

.vedit-inv-count {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  line-height: 1;
  pointer-events: none;
}

.vedit-inv-slot.is-empty-slot {
  opacity: 0.35;
}

.vedit-inv-slot-label {
  font-size: 0.52rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  text-align: center;
  line-height: 1.2;
  padding: 2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  pointer-events: none;
}

.vedit-inv-left-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.vedit-inv-detail {
  width: 148px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.vedit-inv-preview {
  width: 100%;
  aspect-ratio: 1;
  background: rgba(255,255,255,0.015);
  border: 1px solid var(--line);
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.vedit-inv-empty-state {
  padding: 16px;
  color: rgba(255,255,255,0.4);
  font-size: 0.75rem;
  line-height: 1.5;
  text-align: center;
}

.vedit-inv-name-row {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.vedit-inv-name-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vedit-inv-field-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.vedit-inv-field-label {
  flex-shrink: 0;
  min-width: 42px;
  text-align: right;
  font-size: 0.72rem;
}

.vedit-inv-field-input {
  flex: 1;
  min-width: 0;
}

/* ── Room panel ──────────────────────────────────────────────────────── */
.vedit-room-shell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 20px;
  flex: 1;
  overflow-y: auto;
}

.vedit-room-table {
  display: grid;
  grid-template-columns: 110px 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.vedit-room-thead {
  display: contents;
}

.vedit-room-th {
  padding: 6px 10px;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.vedit-room-th-label {
  border-right: 1px solid var(--line);
}

.vedit-room-row {
  display: contents;
}

.vedit-room-row:not(:last-child) .vedit-room-cell {
  border-bottom: 1px solid var(--line);
}

.vedit-room-cell {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.vedit-room-cell-label {
  border-right: 1px solid var(--line);
}

.vedit-room-cell-extra {
  gap: 6px;
}

.vedit-room-extra-label {
  white-space: nowrap;
  font-size: 0.72rem;
}

.vedit-room-label-btn {
  width: 100%;
  font-size: 0.75rem;
}

.vedit-room-input {
  flex: 1;
  min-width: 0;
}

/* ── DIY Timer panel ─────────────────────────────────────────────────── */
.vedit-diy-shell {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.vedit-diy-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 24px;
  background: rgba(255,255,255,0.02);
}

.vedit-diy-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.vedit-diy-label {
  min-width: 110px;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.75);
  flex-shrink: 0;
}

.vedit-diy-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent, rgba(80,180,120,1));
}

.vedit-diy-time {
  flex: 1;
  min-width: 0;
}

.vedit-diy-select {
  flex: 1;
  min-width: 0;
}

/* ── Designs panel ───────────────────────────────────────────────────── */
.vedit-designs-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 10px;
  gap: 10px;
}

.vedit-designs-list {
  width: 120px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  overflow-y: auto;
  font-size: 0.78rem;
}

.vedit-designs-item {
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.65);
  user-select: none;
}

.vedit-designs-item:hover { background: rgba(255,255,255,0.05); }
.vedit-designs-item.is-selected { background: rgba(80,100,220,0.3); color: rgba(255,255,255,0.95); }

.vedit-designs-empty {
  padding: 10px;
  color: rgba(255,255,255,0.25);
  font-size: 0.78rem;
}

.vedit-designs-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.vedit-designs-canvas {
  flex: 1;
  width: 100%;
  background: #000;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.08);
}

.vedit-designs-dump {
  align-self: flex-start;
}

/* ── Player panel ────────────────────────────────────────────────────── */
.vedit-player-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.vedit-player-left {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
}

.vedit-player-list {
  flex: 1;
  overflow-y: auto;
  font-size: 0.78rem;
  font-family: monospace;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.vedit-player-item {
  padding: 5px 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

.vedit-player-item:hover { background: rgba(255,255,255,0.05); }
.vedit-player-item.is-selected { background: rgba(80,100,220,0.3); color: rgba(255,255,255,0.95); }

.vedit-player-left-actions {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.vedit-player-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  flex-shrink: 0;
}

.vedit-player-meta-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
}

.vedit-player-meta-row .vmod-label {
  flex-shrink: 0;
  min-width: 46px;
  text-align: right;
}

.vedit-player-meta-row .vmod-input {
  flex: 1;
  min-width: 0;
}

.vedit-player-right {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.vedit-player-flags-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 8px 10px;
  gap: 6px;
}

.vedit-player-value-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.vedit-player-value-input {
  width: 80px;
}

.vedit-player-misc-panel,
.vedit-player-greet-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}

.vedit-player-greet-date {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.5);
  padding: 4px 0;
}

@media (max-width: 480px) {
  .modal-card-villager {
    --vmod-inset: 16px;
  }

  /* Shell: stack art above info */
  .villager-modal-shell {
    flex-direction: column;
    align-items: center;
    padding: 0 16px 0;
  }
  .villager-modal-aside {
    width: clamp(90px, 36vw, 120px);
  }
  .villager-modal-art-frame {
    width: clamp(90px, 36vw, 120px);
    height: clamp(130px, 22vh, 190px);
    max-height: 180px;
  }

  /* House: stack label above input on narrow screens */
  .vmod-house-fields .vmod-field-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 8px 12px;
  }
  .vmod-house-fields .vmod-label {
    width: auto;
    max-width: 100%;
    min-width: unset;
  }
  .vmod-house-fields .vmod-value {
    width: 100%;
  }

  /* Flags: stack list + editor vertically on narrow screens */
  .vmod-flags-shell {
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
  }
  .vmod-flags-list {
    flex: none;
    min-height: 160px;
    max-height: clamp(180px, 40vh, 320px);
  }
  .vmod-flags-editor {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    align-self: stretch;
    gap: 6px 10px;
  }
  .vmod-flags-selected-name {
    flex: 1 1 100%;
  }
  .vmod-flags-value-label {
    flex-shrink: 0;
    margin-top: 0;
  }
  .vmod-flags-value-input {
    flex: 1;
    min-width: 0;
  }

  /* Edit tabs: comfortable touch targets */
  .vmod-edit-tab-btn {
    padding: 10px 12px 8px;
    font-size: 0.78rem;
  }

  /* Footer: wrap buttons on small screens */
  .vmod-subview-footer {
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px max(14px, env(safe-area-inset-bottom, 0px));
  }
  .vmod-footer-left {
    flex-wrap: wrap;
    gap: 6px;
  }
  .villager-modal-footer {
    padding: 10px var(--vmod-inset) max(14px, env(safe-area-inset-bottom, 0px));
  }

  /* EditView panels: stack detail below grid on narrow screens */
  .vedit-inv-shell {
    flex-direction: column;
    overflow-y: auto;
  }
  .vedit-inv-detail {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--line);
    padding: 10px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  .vedit-inv-preview {
    width: 72px;
    aspect-ratio: 1;
    flex-shrink: 0;
  }
  .vedit-inv-name-row {
    flex: 1 1 100%;
  }
  .vedit-inv-field-row {
    flex: 1 1 calc(50% - 4px);
  }

  /* Room: collapse to single column on narrow screens */
  .vedit-room-table {
    grid-template-columns: 1fr;
  }
  .vedit-room-th:not(.vedit-room-th-label),
  .vedit-room-thead { display: none; }
  .vedit-room-cell-label {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .vedit-room-cell {
    flex-wrap: wrap;
  }

  /* DIY form: full width on narrow */
  .vedit-diy-form {
    max-width: 100%;
    padding: 16px;
  }
  .vedit-diy-label {
    min-width: 90px;
  }

  /* Player panel: stack left + right */
  .vedit-player-shell {
    flex-direction: column;
  }
  .vedit-player-left {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 160px;
  }
}

@media (max-height: 600px) {
  .villager-modal-art-frame {
    height: clamp(100px, 22vh, 170px);
    max-height: 160px;
  }
}



.backups-shell {
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.backups-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.backups-status-msg {
  font-size: 0.78rem;
  opacity: 0.7;
  flex: 1;
}

.backups-force-close-btn {
  min-height: 34px;
  padding: 0 12px;
  border-color: rgba(255, 118, 132, 0.4);
  background: rgba(170, 44, 56, 0.2);
  color: rgba(255, 223, 226, 0.98);
  white-space: nowrap;
}

.backups-force-close-btn:hover,
.backups-force-close-btn:focus-visible {
  border-color: rgba(255, 156, 168, 0.56);
  background: rgba(206, 62, 80, 0.28);
}

body:not([data-theme='night']) .backups-force-close-btn {
  border-color: rgba(170, 40, 56, 0.35);
  background: rgba(206, 74, 88, 0.14);
  color: rgba(118, 18, 32, 0.95);
}

.backups-col-head {
  display: grid;
  grid-template-columns: 1fr 130px 130px 70px 120px;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.55;
  padding: 0 4px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.backups-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 380px;
  overflow-y: auto;
}

.backups-row {
  display: grid;
  grid-template-columns: 1fr 130px 130px 70px 120px;
  gap: 6px;
  align-items: start;
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  overflow: hidden;
}

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

.backup-path-hint {
  display: block;
  font-size: 0.66rem;
  opacity: 0.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  cursor: default;
  user-select: none;
  position: relative;
}

.backup-path-hint.long-press-active {
  opacity: 0.6;
}

.backup-copied-tip {
  position: absolute;
  left: 0;
  top: -1.4rem;
  font-size: 0.65rem;
  font-family: inherit;
  background: rgba(98, 214, 111, 0.18);
  color: rgba(98, 214, 111, 0.95);
  border: 1px solid rgba(98, 214, 111, 0.3);
  border-radius: 4px;
  padding: 1px 7px;
  pointer-events: none;
  white-space: nowrap;
  animation: copied-tip-fade 1.4s ease forwards;
  z-index: 10;
}

@keyframes copied-tip-fade {
  0%   { opacity: 1; transform: translateY(0); }
  60%  { opacity: 0.9; transform: translateY(-3px); }
  100% { opacity: 0; transform: translateY(-6px); }
}

@keyframes backup-label-flash {
  0%   { border-bottom-color: rgba(98, 214, 111, 0.7); }
  60%  { border-bottom-color: rgba(98, 214, 111, 0.3); }
  100% { border-bottom-color: transparent; }
}

.backup-label-saved {
  animation: backup-label-flash 1.2s var(--ease) forwards;
}

.backup-label-input {
  background: rgba(255,255,255,0.5);
  border: none;
  border-bottom: 1px solid transparent;
  color: inherit;
  font: inherit;
  font-size: 0.82rem;
  width: 100%;
  padding: 2px 4px;
  border-radius: 3px;
  transition: border-color 0.15s;
}

.backups-col-label {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.backup-label-input:hover,
.backup-label-input:focus {
  border-bottom-color: rgba(255,255,255,0.3);
  outline: none;
}

.backups-col-date,
.backups-col-created,
.backups-col-size {
  font-size: 0.78rem;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.backups-col-actions {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}

.backup-restore-btn {
  font-size: 0.72rem;
  min-height: 28px;
  padding: 3px 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.backup-restore-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}

.backup-delete-btn {
  font-size: 0.85rem;
  opacity: 0.45;
  padding: 2px 6px;
  background: rgba(255,255,255,0.5);
  border: 1px solid transparent;
  color: var(--text);
  cursor: pointer;
  transition: opacity 0.15s;
}

.backup-delete-btn:hover {
  opacity: 1;
}

.backups-empty,
.backups-loading,
.backups-error {
  text-align: center;
  padding: 28px 16px;
  opacity: 0.55;
  font-size: 0.85rem;
}

.backups-error {
  color: var(--danger);
  opacity: 1;
}

.village-actions {
  padding: 10px 0 4px;
  display: flex;
  gap: 10px;
}



.modal-card-form {
  width: min(900px, 100%);
}

.modal-card-item {
  width: min(640px, 100%);
}

.player-modal-shell {
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  gap: 22px;
  padding: 22px 22px 14px;
  align-items: start;
  min-height: 0;
}

.player-modal-aside,
.player-modal-main,
.player-modal-view,
.player-flags-shell {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.player-modal-main,
.player-modal-view,
.player-flags-shell {
  align-content: start;
  min-height: 0;
}

.player-modal-main {
  padding-top: 2px;
}

.player-modal-view[hidden],
.player-flags-panel[hidden],
.player-modal-footer[hidden] {
  display: none !important;
}

.player-modal-bust-card,
.player-modal-placeholder {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--glass-edge-soft);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.012)),
    rgba(255,255,255,0.014);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 -1px 0 rgba(255,255,255,0.012);
}

.player-modal-bust-card {
  padding: 14px;
}

.player-modal-bust-frame {
  min-height: 268px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 207, 162, 0.12), transparent 44%),
    radial-gradient(circle at 50% 100%, rgba(122,175,255,0.1), transparent 58%),
    var(--field);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 -1px 0 rgba(255,255,255,0.012);
}

.player-modal-bust-image {
  max-width: 100%;
  max-height: 236px;
  object-fit: contain;
}

.player-modal-bust-copy {
  display: grid;
  gap: 4px;
  padding: 12px 4px 2px;
}

.player-modal-bust-copy strong {
  font-size: 1.02rem;
  font-weight: 600;
}

.player-modal-bust-copy span {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.player-modal-nav {
  display: grid;
  gap: 10px;
}

.player-modal-section-btn {
  width: 100%;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.012)),
    var(--field);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 -1px 0 rgba(255,255,255,0.012);
}

.player-modal-section-btn.is-active {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.025)),
    rgba(255,255,255,0.045);
  border-color: rgba(255,255,255,0.26);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.05),
    0 0 26px rgba(122,175,255,0.12);
}

body:not([data-theme='night']) .player-modal-section-btn.is-active {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.06),
    0 0 26px rgba(255, 185, 128, 0.15);
}

body[data-theme='night'] .player-modal-section-btn.is-active {
  box-shadow:
    0 0 0 1px rgba(230,224,255,0.05),
    0 0 26px rgba(156, 140, 222, 0.14);
}

.player-modal-form-grid {
  padding: 0;
}

.player-modal-form-panel {
  min-height: 100%;
  border-radius: 18px;
}

.player-modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  padding: 12px 22px 18px;
  border-top: 0;
  background: var(--surface);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.player-modal-footer #player-modal-save {
  min-width: 120px;
}

.player-modal-placeholder {
  min-height: clamp(240px, 48vh, 402px);
  padding: 18px;
  align-content: start;
}

.player-modal-placeholder h4 {
  margin: 0 0 6px;
}

.player-modal-placeholder p {
  margin: 0;
  color: var(--text-muted);
}

.player-modal-console {
  min-height: 176px;
  max-height: min(240px, 32vh);
  overflow: auto;
  margin-top: 4px;
}

.player-flags-bar {
  display: flex;
  gap: 2px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  margin-bottom: -1px;
  padding: 0 2px;
  scrollbar-width: none;
}

.player-flags-bar::-webkit-scrollbar {
  display: none;
}

.player-flags-tab-btn {
  flex: 0 0 auto;
  min-width: max-content;
  margin-bottom: 0;
}

.player-flags-tab-btn.is-active {
  z-index: 1;
}

.player-flags-panel {
  min-height: clamp(240px, 38vh, 320px);
  border-radius: 0 16px 16px 16px;
}

.player-flags-panel h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 500;
}

.player-flags-panel p {
  margin: 0;
  color: var(--text-muted);
}

.player-flags-panel .player-modal-console {
  margin-top: 10px;
}

body[data-theme='night'] .player-modal-bust-card,
body[data-theme='night'] .player-modal-placeholder,
body[data-theme='night'] .player-flags-panel {
  background:
    linear-gradient(180deg, rgba(244,240,255,0.05), rgba(255,255,255,0.014)),
    rgba(18, 18, 32, 0.14);
}

body[data-theme='night'] .player-modal-bust-frame {
  background:
    radial-gradient(circle at 24% 12%, rgba(209, 197, 240, 0.12), transparent 28%),
    radial-gradient(circle at 50% 100%, rgba(126, 118, 186, 0.12), transparent 58%),
    rgba(18, 18, 34, 0.28);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: var(--space-4);
  border-bottom: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.modal-head {
  background: var(--surface);
}

.modal-head h2 {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 500;
}

.modal-close {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 16px;
  font-size: 1.9rem;
  line-height: 1;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.modal-save-button {
  height: 40px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--indicator-green) 48%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--indicator-green) 31%, transparent), color-mix(in srgb, var(--indicator-green) 12%, transparent));
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 0.18s var(--ease),
    border-color 0.18s var(--ease),
    background 0.18s var(--ease);
}

.modal-save-button:hover {
  border-color: color-mix(in srgb, var(--indicator-green) 70%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--indicator-green) 42%, transparent), color-mix(in srgb, var(--indicator-green) 18%, transparent));
  box-shadow: 0 0 16px color-mix(in srgb, var(--indicator-green-glow) 38%, transparent);
}

.modal-save-button:active {
  transform: scale(0.96);
}

.modal-close,
.settings-debug-action,
.settings-github-btn,
.trash-button {
  transition:
    transform 0.18s var(--ease),
    background 0.18s var(--ease),
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

body:not([data-theme='night']) .modal-close,
body:not([data-theme='night']) .settings-debug-action,
body:not([data-theme='night']) .settings-github-btn,
body:not([data-theme='night']) .trash-button {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255, 220, 191, 0.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

body[data-theme='night'] .modal-close,
body[data-theme='night'] .settings-debug-action,
body[data-theme='night'] .settings-github-btn,
body[data-theme='night'] .trash-button {
  background: rgba(11, 19, 38, 0.7);
  border: 1px solid rgba(170, 198, 255, 0.1);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 12px 24px rgba(4, 8, 18, 0.14);
}

.settings-greeting {
  padding: var(--space-1) var(--space-5) var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  opacity: 0.4;
}

.settings-debug-box {
  position: relative;
  height: auto;
  margin: 10px 18px 0;
  border: 1px solid rgba(186, 247, 192, 0.1);
  border-radius: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 12px 14px;
  background: var(--console-bg);
}

.settings-debug-box-secondary {
  height: auto;
  min-height: unset;
  margin-top: 8px;
  align-items: stretch;
}

.settings-debug-stack {
  width: 100%;
  display: grid;
  gap: 8px;
}

.settings-debug-title {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  opacity: 0.6;
}

.settings-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-field-label {
  font-size: var(--font-size-sm);
  color: var(--text);
  opacity: 0.75;
  white-space: nowrap;
  flex: 1;
}

.settings-select {
  flex: 1;
  min-width: 120px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--font-size-sm);
  padding: var(--space-1) var(--space-3);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color 0.18s;
}

.settings-select:focus {
  border-color: rgba(255, 255, 255, 0.3);
}

.settings-select option {
  background: #1a1c2a;
  color: var(--text);
}

body:not([data-theme='night']) .settings-select option {
  background: rgba(255, 246, 238, 0.96);
  color: rgba(30, 20, 38, 0.92);
}

body[data-theme='night'] .settings-debug-box,
body[data-theme='night'] .mini-code-block {
  border-color: rgba(198, 190, 234, 0.14);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), transparent 38%),
    rgba(12, 12, 24, 0.72);
}

body[data-theme='night'] #settings-debug-output,
body[data-theme='night'] .mini-code-block,
body[data-theme='night'] .modal-filter-btn {
  color: rgba(223, 219, 239, 0.86);
  text-shadow: 0 0 10px rgba(161, 145, 215, 0.1);
}

#settings-debug-output {
  max-width: calc(100% - 34px);
  color: rgba(186, 247, 192, 0.76);
  line-height: 1.6;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, Menlo, monospace;
  text-shadow: 0 0 8px rgba(186, 247, 192, 0.08);
}

.settings-debug-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: rgba(186, 247, 192, 0.76);
  line-height: 1.55;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, Menlo, monospace;
  text-shadow: 0 0 8px rgba(186, 247, 192, 0.08);
}

.settings-debug-action {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 8px;
  background: rgba(255,255,255,0.5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s;
}
.settings-debug-action:hover { opacity: 1; }

.settings-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4) var(--space-4);
}

.settings-github-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,0.5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s;
}
.settings-github-btn:hover { opacity: 1; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.field-wrap {
  display: grid;
  gap: 8px;
}

.field-wrap span {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.compact-field span {
  font-size: 0.82rem;
}

.field-wrap input,
.search-input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02)),
    rgba(255,255,255,0.02);
  color: var(--text);
  outline: none;
  transition:
    border-color 0.18s var(--ease),
    background 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

body:not([data-theme='night']) .field-wrap input,
body:not([data-theme='night']) .search-input {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.026)),
    rgba(255,255,255,0.03);
  color: var(--text);
}

body[data-theme='night'] .field-wrap input,
body[data-theme='night'] .search-input {
  background:
    linear-gradient(180deg, rgba(236,232,248,0.05), rgba(255,255,255,0.015)),
    rgba(18, 18, 34, 0.36);
  border-color: rgba(198, 190, 234, 0.12);
}

.field-wrap input[type='number'],
.meta-input[inputmode='numeric'] {
  appearance: textfield;
  -moz-appearance: textfield;
}

body:not([data-theme='night']) .field-wrap input[type='number'],
body:not([data-theme='night']) .meta-input[inputmode='numeric'] {
  color-scheme: light;
}

body[data-theme='night'] .field-wrap input[type='number'],
body[data-theme='night'] .meta-input[inputmode='numeric'] {
  color-scheme: dark;
}

/* ── Utility panel (top-bar controls popover) ───────────────────
   VS Code / GitHub-style slide-in from the right edge. Groups
   status + all app actions into a single organized surface. */
.utility-panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 88;
  background: rgba(6, 8, 16, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-standard);
}
.utility-panel-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.utility-panel-backdrop[hidden] { display: none !important; }

.utility-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 89;
  width: min(360px, calc(100vw - 32px));
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--glass-edge);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.015)),
    rgba(10, 12, 20, 0.94);
  /* No saturate() here — the global --backdrop-sat boost turns faint
     decorative glows behind the panel (e.g. the avatar ambient glow) into
     a distracting saturated purple blob instead of a neutral blur. */
  backdrop-filter: blur(var(--backdrop-blur-strong));
  -webkit-backdrop-filter: blur(var(--backdrop-blur-strong));
  box-shadow: -18px 0 48px rgba(0,0,0,0.32);
  transform: translateX(100%);
  transition: transform var(--dur-modal) var(--ease-spring);
  contain: paint;
  isolation: isolate;
}
.utility-panel[hidden] { display: none !important; }
.utility-panel.is-visible {
  transform: translateX(0);
}

.utility-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-edge-soft);
  padding-top: max(14px, env(safe-area-inset-top, 0px));
}
.utility-panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.utility-panel-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.utility-panel-close:hover { background: rgba(255,255,255,0.08); }
.utility-panel-close:active { transform: scale(var(--scale-press)); }

.utility-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.utility-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.utility-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 4px;
}

/* Status mirror grid — 3 pill rows */
.utility-status-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--glass-edge-soft);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  padding: 8px;
}
.utility-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text);
}
.utility-status-row-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  flex-shrink: 0;
  box-shadow: 0 0 4px rgba(255, 209, 102, 0.5);
}
.utility-status-row-dot.is-ok { background: var(--good); box-shadow: 0 0 4px rgba(98, 214, 111, 0.55); }
.utility-status-row-dot.is-error { background: var(--danger); box-shadow: 0 0 4px rgba(255, 95, 115, 0.55); }
.utility-status-row-label {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}
.utility-status-row-value {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

/* Actions grid — iOS Control Center tile style */
.utility-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.utility-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 12px 12px 14px;
  min-height: 74px;
  border: 1px solid var(--glass-edge-soft);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  text-align: left;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.utility-action:hover {
  background: rgba(255,255,255,0.07);
  border-color: var(--line-strong);
}
.utility-action:active {
  transform: scale(var(--scale-press));
}
.utility-action.is-busy {
  opacity: 0.55;
  pointer-events: none;
}
.utility-action.is-active {
  background: rgba(122, 175, 255, 0.14);
  border-color: rgba(122, 175, 255, 0.35);
  color: var(--text);
  box-shadow: 0 0 22px rgba(122, 175, 255, 0.12);
}

.utility-action svg {
  color: rgba(255,255,255,0.86);
}
.utility-action-label {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.utility-action-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.75;
}

/* iOS-style pill status inside an action tile (e.g. Test Mode ON/OFF) */
.utility-action-pill {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.12);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.utility-action.is-active .utility-action-pill {
  background: rgba(52, 199, 89, 0.85);
  color: #08110a;
  border-color: rgba(52, 199, 89, 1);
}
.utility-action-toggle { position: relative; }

/* Small status dot in the top-right of the Download Assets tile */
.utility-action-dot {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  transition: background var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.utility-action-dot.is-ok {
  background: var(--good);
  box-shadow: 0 0 6px rgba(98, 214, 111, 0.6);
}

/* Theme action: swap between animated day/night icons based on body theme */
.utility-theme-icons {
  position: relative;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.utility-theme-icon {
  position: absolute;
  inset: 0;
  width: 20px;
  height: 20px;
  filter: brightness(0) invert(1);
  transition: opacity var(--dur-fast) var(--ease-out);
}
.utility-action-theme .utility-theme-icon-night { opacity: 0; }
.utility-action-theme.is-night .utility-theme-icon-day { opacity: 0; }
.utility-action-theme.is-night .utility-theme-icon-night { opacity: 1; }

.utility-panel-foot {
  padding: 10px 16px max(14px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--glass-edge-soft);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  opacity: 0.7;
}
.utility-foot-version {
  font-variant-numeric: tabular-nums;
}

/* Light theme adjustments */
body:not([data-theme='night']) .utility-panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.7), rgba(255,255,255,0.55)),
    rgba(240, 236, 232, 0.5);
  border-left-color: rgba(0,0,0,0.08);
  color: #2c2c2e;
}
body:not([data-theme='night']) .utility-panel-title,
body:not([data-theme='night']) .utility-section-title,
body:not([data-theme='night']) .utility-status-row,
body:not([data-theme='night']) .utility-status-row-value,
body:not([data-theme='night']) .utility-action-hint,
body:not([data-theme='night']) .utility-panel-foot {
  color: rgba(48, 41, 60, 0.74);
}
body:not([data-theme='night']) .utility-panel-title,
body:not([data-theme='night']) .utility-status-row {
  color: #2c2c2e;
}
body:not([data-theme='night']) .utility-panel-close {
  border-color: rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.045);
  color: #2c2c2e;
}
body:not([data-theme='night']) .utility-panel-close:hover {
  background: rgba(0,0,0,0.08);
}
body:not([data-theme='night']) .utility-status-grid {
  border-color: rgba(0,0,0,0.08);
  background: rgba(0,0,0,0.025);
}
body:not([data-theme='night']) .utility-action {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
  color: #2c2c2e;
}
body:not([data-theme='night']) .utility-action svg {
  color: rgba(48, 41, 60, 0.86);
}
body:not([data-theme='night']) .utility-action-pill {
  background: rgba(0,0,0,0.08);
  color: rgba(36,33,45,0.72);
  border-color: rgba(0,0,0,0.14);
}
body:not([data-theme='night']) .utility-theme-icon {
  filter: none;
}
body:not([data-theme='night']) .utility-action:hover {
  background: rgba(0,0,0,0.06);
}


.field-wrap input[type='number']::-webkit-inner-spin-button,
.field-wrap input[type='number']::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.field-wrap input:focus,
.search-input:focus {
  border-color: var(--line-strong);
  background: rgba(255,255,255,0.04);
  box-shadow:
    0 0 0 3px rgba(122,175,255,0.08),
    0 12px 24px rgba(122,175,255,0.08);
}

body[data-theme='night'] .field-wrap input:focus,
body[data-theme='night'] .search-input:focus {
  background:
    linear-gradient(180deg, rgba(236,232,248,0.08), rgba(255,255,255,0.02)),
    rgba(22, 22, 40, 0.44);
  box-shadow:
    0 0 0 3px rgba(156,146,228,0.12),
    0 12px 28px rgba(104, 93, 172, 0.14);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 18px 18px;
}

.item-modal-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: clamp(12px, 2vw, 18px);
  align-items: start;
}

.item-modal-preview-wrap {
  display: grid;
  gap: 14px;
}

.item-modal-artbox {
  min-height: 212px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--glass-edge-soft);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 207, 162, 0.12), transparent 44%),
    radial-gradient(circle at 50% 100%, rgba(122,175,255,0.1), transparent 58%),
    var(--field);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 -1px 0 rgba(255,255,255,0.012);
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}

body:not([data-theme='night']) .item-modal-artbox {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 207, 162, 0.14), transparent 44%),
    radial-gradient(circle at 50% 100%, rgba(122,175,255,0.12), transparent 58%),
    rgba(255,255,255,0.08);
}

body[data-theme='night'] .item-modal-artbox {
  background:
    radial-gradient(circle at 24% 12%, rgba(209, 197, 240, 0.12), transparent 28%),
    radial-gradient(circle at 50% 100%, rgba(126, 118, 186, 0.12), transparent 56%),
    rgba(18, 18, 34, 0.28);
  border-color: rgba(198, 190, 234, 0.12);
}

.item-modal-artbox img {
  max-width: 160px;
  max-height: 160px;
  object-fit: contain;
}

.item-modal-main {
  display: grid;
  gap: 14px;
}

.item-modal-summary {
  display: grid;
  gap: 0;
}

.item-modal-name {
  margin-bottom: 0;
  font-size: 1.02rem;
  font-weight: 500;
}

.modal-payload-console {
  margin: 0;
  height: clamp(52px, 13vh, 96px);
  overflow: auto;
  padding: 10px 12px;
  font-size: 13px;
  white-space: pre-wrap;
  tab-size: 2;
}

.item-modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.item-modal-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 12px;
  align-items: center;
}

.item-modal-search-row .trash-button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 122, 136, 0.28);
  border-radius: 12px;
  background: rgba(176, 48, 62, 0.2);
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: rgba(255, 214, 220, 0.95);
}

.item-modal-search-row .trash-button {
  background: rgba(176, 48, 62, 0.2);
  border-color: rgba(255, 122, 136, 0.28);
}

body:not([data-theme='night']) .item-modal-search-row .trash-button {
  background: rgba(196, 52, 66, 0.14);
  border-color: rgba(162, 34, 52, 0.22);
  color: rgba(108, 20, 30, 0.94);
}

.item-modal-search-stack {
  display: grid;
  gap: 10px;
}

.item-modal-search-row .trash-button:hover,
.item-modal-search-row .trash-button:focus-visible {
  background: rgba(224, 76, 96, 0.22);
  border-color: rgba(255, 148, 162, 0.5);
  box-shadow: 0 0 0 2px rgba(255, 112, 134, 0.16);
  color: #fff;
}

.item-modal-search-row .trash-button .icon-img {
  opacity: 0.9;
}

.modal-results-list {
  max-height: 172px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.modal-result-row {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.modal-result-row.is-selected {
  color: var(--danger);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.qsr-cat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--dot-color, rgba(255,255,255,0.32));
  box-shadow: 0 0 6px var(--dot-color, transparent);
}

.modal-result-row.is-selected .qsr-cat-dot {
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--dot-color, rgba(255,255,255,0.32)) 46%, transparent),
    0 0 10px var(--dot-color, transparent);
  animation: modal-dot-pulse 1.4s ease-in-out infinite;
}

.modal-search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  max-height: 96px;
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  transform-origin: top center;
  transition:
    opacity 0.24s var(--ease),
    transform 0.24s var(--ease),
    max-height 0.28s var(--ease);
}

.modal-search-filters.is-collapsed {
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.modal-filter-btn {
  --filter-accent: rgba(255,255,255,0.22);
  min-height: 20px;
  padding: 0 7px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.016)),
    color-mix(in srgb, var(--filter-accent) 22%, rgba(34, 27, 24, 0.4));
  color: rgba(255,255,255,0.82);
  font-size: 0.64rem;
  cursor: pointer;
  transition:
    transform 0.18s var(--ease),
    border-color 0.18s var(--ease),
    background 0.18s var(--ease),
    color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.modal-filter-btn[data-modal-filter='Tool'] { --filter-accent: rgba(255, 193, 145, 0.5); }
.modal-filter-btn[data-modal-filter='Material'] { --filter-accent: rgba(255, 165, 134, 0.48); }
.modal-filter-btn[data-modal-filter='Sea creature'] { --filter-accent: rgba(130, 170, 255, 0.52); }
.modal-filter-btn[data-modal-filter='Bug'] { --filter-accent: rgba(134, 241, 202, 0.5); }
.modal-filter-btn[data-modal-filter='Fossil'] { --filter-accent: rgba(205, 170, 130, 0.52); }
.modal-filter-btn[data-modal-filter='Flora'] { --filter-accent: rgba(108, 200, 160, 0.5); }
.modal-filter-btn[data-modal-filter='Furniture'] { --filter-accent: rgba(174, 160, 240, 0.52); }
.modal-filter-btn[data-modal-filter='Clothing'] { --filter-accent: rgba(214, 150, 200, 0.5); }

body[data-theme='night'] .modal-filter-btn {
  border-color: rgba(198, 190, 234, 0.14);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.014)),
    rgba(18, 18, 34, 0.58);
}

.modal-filter-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.18);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02)),
    rgba(45, 32, 28, 0.5);
}

body[data-theme='night'] .modal-filter-btn:hover {
  border-color: rgba(198, 190, 234, 0.22);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.018)),
    rgba(24, 22, 42, 0.72);
}

.modal-filter-btn.is-active {
  border-color: color-mix(in srgb, var(--filter-accent) 70%, rgba(255,255,255,0.22));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--filter-accent) 34%, rgba(255,255,255,0.09)), rgba(255,255,255,0.04)),
    color-mix(in srgb, var(--filter-accent) 44%, rgba(42, 32, 30, 0.72));
  color: rgba(255, 247, 239, 0.98);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--filter-accent) 40%, transparent),
    0 10px 24px color-mix(in srgb, var(--filter-accent) 42%, transparent);
  animation: modal-filter-pulse 1.7s ease-in-out infinite;
}

body[data-theme='night'] .modal-filter-btn.is-active {
  border-color: rgba(210, 202, 240, 0.24);
  background:
    linear-gradient(180deg, rgba(178,166,228,0.14), rgba(178,166,228,0.03)),
    rgba(26, 24, 44, 0.94);
  color: rgba(239, 236, 248, 0.98);
  box-shadow: 0 10px 24px var(--glow-blue);
}

@keyframes modal-filter-pulse {
  0%, 100% { box-shadow: 0 0 0 1px color-mix(in srgb, var(--filter-accent) 40%, transparent), 0 8px 18px color-mix(in srgb, var(--filter-accent) 32%, transparent); }
  50% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--filter-accent) 58%, transparent), 0 12px 26px color-mix(in srgb, var(--filter-accent) 44%, transparent); }
}

@keyframes modal-dot-pulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.16); opacity: 1; }
}

body[data-theme='night'] .action-btn-solid {
  background: rgba(238, 235, 245, 0.94);
  border-color: rgba(238, 235, 245, 0.94);
  color: #1d1a2b;
  box-shadow: 0 10px 24px rgba(154, 140, 212, 0.12);
}

body:not([data-theme='night']) .backup-restore-btn {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.12);
  color: var(--text);
}

body:not([data-theme='night']) .backup-restore-btn:hover {
  background: rgba(0,0,0,0.1);
  border-color: rgba(0,0,0,0.18);
}

body:not([data-theme='night']) .action-btn-solid {
  background:
    linear-gradient(180deg, rgba(255, 248, 242, 0.98), rgba(255, 234, 218, 0.94));
  border-color: rgba(255, 241, 231, 0.96);
  color: #3a241e;
  box-shadow:
    0 10px 24px rgba(255, 182, 126, 0.14),
    inset 0 1px 0 rgba(255,255,255,0.35);
}

@media (max-width: 860px) {
  .inventory-area,
  .item-modal-layout,
  .tab-dual-grid {
    grid-template-columns: 1fr;
  }

  .player-modal-shell {
    grid-template-columns: 1fr;
    padding: 14px 16px 10px;
    gap: 14px;
  }

  .player-modal-bust-frame {
    min-height: 160px;
  }

  .player-modal-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .player-modal-section-btn {
    min-width: 0;
  }

  .shortcut-column {
    margin-left: 0;
    padding-top: 10px;
  }

  .shortcut-btn {
    border-left: 1px solid var(--line);
    border-radius: 12px;
  }

  .music-ribbon {
    --music-ribbon-width: min(430px, calc(100vw - 28px));
  }
}

@media (max-width: 720px) {
  .footer-mark,
  .footer-brand {
    justify-content: center;
  }

  .footer-mark {
    text-align: center;
  }

  .music-ribbon {
    --music-ribbon-width: calc(100vw - 22px);
  }

  /* topbar stays column on mobile — title row handles the inline layout */

  .log-panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Sticky pill already flex at base; no override needed */

  .music-player-top {
    grid-template-columns: 46px 1fr;
  }

  .music-player-controls {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

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

  .inventory-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .meta-row,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .player-modal-nav {
    grid-template-columns: 1fr;
    display: grid;
  }

  .player-flags-tab-btn {
    border-radius: 12px;
    border-bottom: 1px solid transparent;
    min-width: 0;
  }

  .player-flags-panel {
    border-radius: 16px;
  }

  .modal {
    align-items: flex-start;
  }

  .modal-card {
    max-height: calc(100dvh - 16px);
  }

  .player-meta {
    width: 100%;
  }

  /* Mobile touch targets — 44px minimum height */
  .field-wrap input,
  .search-input {
    min-height: 44px;
  }

  .action-btn {
    min-height: 44px;
  }

  /* Player modal mobile improvements */
  .player-modal-footer {
    justify-content: stretch;
    padding: 10px 14px 16px;
  }

  .player-modal-footer #player-modal-save {
    width: 100%;
    min-width: 0;
  }

  .form-grid {
    padding: 14px;
    gap: 12px;
  }

  .player-modal-shell {
    padding: 12px 12px 8px;
  }
}

@supports (-webkit-touch-callout: none) {
  @media (max-width: 720px) {
    body.modal-open .aurora-ribbon,
    body.modal-open .cloud,
    body.modal-open .shooting-star {
      animation-play-state: paused;
    }

    #item-modal .modal-card {
      transform: translateY(16px);
    }

    #item-modal.is-visible .modal-card {
      transform: translateY(0);
    }

    #item-modal.is-closing .modal-card {
      transform: translateY(8px);
    }

  }
}

@media (max-width: 720px) {
  input,
  textarea,
  select {
    font-size: 16px;
  }

  #item-modal .modal-card {
    margin: 0 auto auto;
  }

  #item-modal .modal-close {
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }

  #item-modal .item-modal-layout {
    gap: 12px;
    padding: 10px 12px 14px;
  }

  #item-modal .item-modal-preview-wrap {
    gap: 10px;
  }

  #item-modal .item-modal-artbox {
    min-height: 148px;
  }

  #item-modal .item-modal-artbox img {
    max-width: 112px;
    max-height: 112px;
  }

  #item-modal .item-modal-main {
    gap: 9px;
  }

  #item-modal .item-modal-name {
    margin-bottom: 6px;
  }

  #item-modal .item-modal-stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: 4px;
  }

  #item-modal .field-wrap input,
  #item-modal .search-input {
    min-height: 38px;
    padding: 7px 10px;
  }

  #item-modal .field-wrap {
    gap: 4px;
  }

  #item-modal .item-modal-search-row {
    gap: 8px;
  }

  #item-modal .item-modal-search-stack {
    gap: 7px;
  }

  #item-modal .modal-search-filters {
    gap: 6px;
  }

  #item-modal .modal-payload-console {
    height: clamp(52px, 13vh, 96px);
    padding: 10px 12px;
    font-size: 12px;
  }
}

@media (max-width: 560px) {
  /* Collapse bust frame on small phones — show only name + nav */
  .player-modal-bust-frame {
    display: none;
  }

  .player-modal-bust-copy {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 4px 2px;
  }

  .player-modal-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

}

@media (min-width: 721px) {
  .player-card {
    grid-template-columns: minmax(0, 1fr) minmax(0, var(--player-tile-size));
    grid-template-areas:
      "avatar avatar"
      "meta meta";
    gap: 20px;
  }

  .player-avatar-wrap {
    width: var(--player-tile-size);
    margin-inline: 0;
    justify-content: flex-end;
  }
}

@media (min-width: 861px) {
  .player-card {
    gap: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html,
  body {
    scroll-behavior: auto;
  }

  .aurora-ribbon,
  .aurora-ribbon::before,
  .aurora-ribbon::after,
  .cloud,
  .shooting-star,
  .loading-ring,
  .modal-fade,
  .skeleton-line::after,
  .skeleton-block::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .sky-layer,
  .aurora-layer,
  .moon-layer,
  .shell-card,
  .icon-button,
  .corner-icon-button,
  .trash-button,
  .action-btn,
  .shortcut-btn,
  .tab-btn,
  .modal,
  .modal-card {
    transition-duration: 0.01ms !important;
  }
}

/* ─── Villager Roster ─────────────────────────────────────────────────────── */

.villager-count-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15em 0.65em;
  vertical-align: middle;
  color: rgba(255,255,255,0.7);
}

.villager-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.villager-placeholder {
  color: rgba(255,255,255,0.4);
  font-size: 0.9rem;
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 0;
}

.villager-card {
  background:
    linear-gradient(180deg, var(--glass-top), var(--glass-bottom)),
    var(--panel);
  border: 1px solid var(--glass-edge-soft);
  border-radius: var(--radius-md);
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 10px;
  text-align: center;
  position: relative;
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(16px) saturate(125%);
  -webkit-backdrop-filter: blur(16px) saturate(125%);
  transition: border-color var(--transition-fast), background var(--transition-fast);
  cursor: pointer;
}

.villager-card:hover {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.028)),
    var(--panel);
  border-color: var(--line);
}

.villager-card.is-moving-out {
  border-color: rgba(255, 120, 80, 0.5);
  background: rgba(255, 100, 60, 0.07);
}

.villager-card.is-empty {
  opacity: 0.9;
  border-style: solid;
  align-items: center;
  justify-content: center;
}

.villager-card.is-empty.is-editable {
  min-height: 154px;
  opacity: 0.62;
  justify-content: center;
  gap: 8px;
}

.villager-card.is-house-locked {
  border-color: rgba(255, 214, 158, 0.18);
}

.villager-house-lock {
  position: static;
  order: 3;
  max-width: 100%;
  font-size: 0.64rem;
  border-radius: 999px;
  padding: 0.14rem 0.42rem;
  letter-spacing: 0.015em;
  font-weight: 600;
  color: rgba(252, 242, 226, 0.78);
  background: rgba(51, 45, 37, 0.38);
  border: 1px solid rgba(255, 224, 178, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.villager-empty-copy {
  justify-content: center;
}

.villager-empty-title {
  font-size: 0.92rem;
  font-weight: 560;
  color: rgba(245,245,247,0.82);
}

.villager-empty-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.68;
}

.villager-avatar {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.12);
}

.villager-avatar-neutral {
  object-fit: contain;
  padding: 0.48rem;
  background: rgba(255,255,255,0.07);
  border-style: solid;
  border-color: rgba(255,255,255,0.16);
  opacity: 0.54;
}

.villager-avatar-placeholder {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: 2px dashed rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  color: rgba(255,255,255,0.3);
}

.villager-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 4px;
}

.villager-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.villager-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.villager-gender {
  font-size: 0.85rem;
  opacity: 0.55;
}

.villager-species {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}

.villager-personality-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.14em 0.45em;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #000;
}

.villager-catchphrase {
  min-height: 1.2em;
  overflow: hidden;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255,255,255,0.55);
  font-style: italic;
}

.villager-friendship-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.villager-friendship-bar-track {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.12);
  overflow: hidden;
}

.villager-friendship-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #63c6a0, #9be0c1);
  transition: width 0.4s ease;
}

.villager-friendship-tier {
  display: none;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
}

.villager-moving-out-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 0.7rem;
  background: rgba(255,80,40,0.85);
  color: #fff;
  border-radius: 6px;
  padding: 0.1em 0.45em;
  font-weight: 700;
  letter-spacing: 0.04em;
}

@media (min-width: 560px) {
  .tabs-panel { padding: 16px; }
  .tab-panel { padding: 18px 2px 2px; }
  .tab-compact-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .villager-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .villager-card {
    flex-direction: row;
    align-items: center;
    padding: 14px;
    text-align: left;
  }
  .villager-card.is-empty.is-editable { min-height: 0; justify-content: flex-start; }
  .villager-house-lock { position: absolute; top: 8px; right: 8px; }
  .villager-avatar, .villager-avatar-placeholder { width: 62px; height: 62px; }
  .villager-body { gap: 5px; }
  .villager-name-row { justify-content: flex-start; flex-wrap: wrap; gap: 5px; }
  .villager-name { font-size: 1rem; }
  .villager-species { font-size: 0.78rem; }
  .villager-catchphrase { font-size: 0.78rem; }
  .villager-friendship-tier { display: inline; font-size: 0.68rem; }
}

@media (min-width: 860px) {
  .tab-compact-bar { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tab-dual-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .villager-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}


/* ── Villager modal head icon buttons + aside actions/friendship ─── */
.vmod-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.vmod-head-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.vmod-head-icon-btn:hover { background: rgba(255,255,255,0.09); border-color: var(--line-strong); }
.vmod-head-icon-btn:active { transform: scale(var(--scale-press)); }

/* Compact friendship heart strip under the villager art */
.vmod-aside-friendship {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 0 4px;
}
.vmod-aside-heart {
  color: #ff5f73;
  font-size: 1.05rem;
  line-height: 1;
  text-shadow: 0 0 8px rgba(255, 95, 115, 0.35);
}
.vmod-aside-friendship-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  overflow: hidden;
}
.vmod-aside-friendship-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff8a95, #ff5f73);
  transition: width var(--dur-slow) var(--ease-out);
}
.vmod-aside-friendship-value {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 26px;
  text-align: right;
}

/* Action row: Save / Flags / House under the villager art */
.vmod-aside-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}
.vmod-aside-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.vmod-aside-btn:hover { background: rgba(255,255,255,0.09); border-color: var(--line-strong); }
.vmod-aside-btn:active { transform: scale(var(--scale-press)); }
.vmod-aside-btn:disabled { opacity: 0.55; cursor: default; }
.vmod-aside-btn svg { flex-shrink: 0; opacity: 0.85; }
.vmod-aside-btn-label { white-space: nowrap; }
.vmod-aside-btn-primary {
  background: linear-gradient(180deg, rgba(90, 155, 255, 0.32), rgba(90, 155, 255, 0.18));
  border-color: rgba(122, 175, 255, 0.55);
  color: #f5f5f7;
}
.vmod-aside-btn-primary:hover {
  background: linear-gradient(180deg, rgba(90, 155, 255, 0.42), rgba(90, 155, 255, 0.24));
}
