  :root {
    --bg: #f4ede0;
    --panel: #ffffff;
    --ink: #2a2722;
    --muted: #6f695f;
    --line: #ebe3d2;
    --line-soft: #f3ecdc;
    --accent: #3a72c8;
    --shadow: 0 18px 50px -20px rgba(50, 35, 10, 0.18), 0 2px 6px -2px rgba(50, 35, 10, 0.08);
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
  body {
    background:
      radial-gradient(circle at 86% 15%, rgba(255, 214, 154, min(1, calc(var(--backdrop-strength, 0.78) * 0.58))), transparent 32%),
      radial-gradient(circle at 18% 18%, rgba(var(--sky-blue-strong-rgb, 26, 103, 210), min(1, calc(var(--backdrop-strength, 0.78) * var(--sky-blue-depth, 0.58) * 0.72))), transparent 36%),
      radial-gradient(circle at 70% 86%, rgba(255, 188, 126, min(1, calc(var(--backdrop-strength, 0.78) * 0.22))), transparent 36%),
      linear-gradient(135deg, rgb(var(--sky-blue-base-rgb, 106, 168, 235)) 0%, rgb(var(--sky-blue-low-rgb, 188, 220, 244)) 48%, #fff0d1 100%);
    color: var(--ink);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-user-select: none;
  }
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 7;
    backdrop-filter: blur(var(--tilt-blur, 3.5px)) saturate(1.04);
    -webkit-backdrop-filter: blur(var(--tilt-blur, 3.5px)) saturate(1.04);
    mask-image: linear-gradient(
      to bottom,
      #000 0%,
      #000 var(--tilt-edge-top, 10%),
      rgba(0, 0, 0, 0.82) var(--tilt-soft-top, 18%),
      transparent var(--tilt-clear-top, 34%),
      transparent var(--tilt-clear-bottom, 66%),
      rgba(0, 0, 0, 0.82) var(--tilt-soft-bottom, 82%),
      #000 var(--tilt-edge-bottom, 90%),
      #000 100%
    );
    -webkit-mask-image: linear-gradient(
      to bottom,
      #000 0%,
      #000 var(--tilt-edge-top, 10%),
      rgba(0, 0, 0, 0.82) var(--tilt-soft-top, 18%),
      transparent var(--tilt-clear-top, 34%),
      transparent var(--tilt-clear-bottom, 66%),
      rgba(0, 0, 0, 0.82) var(--tilt-soft-bottom, 82%),
      #000 var(--tilt-edge-bottom, 90%),
      #000 100%
    );
  }
  body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 8;
    opacity: 1;
    background:
      radial-gradient(circle at 14% 18%, rgba(var(--sky-blue-strong-rgb, 28, 99, 205), min(1, calc(var(--backdrop-strength, 0.78) * var(--sky-blue-depth, 0.58) * 0.38))), transparent 34%),
      radial-gradient(circle at 88% 12%, rgba(255, 218, 158, min(1, calc(var(--backdrop-strength, 0.78) * 0.46))), transparent 34%),
      radial-gradient(circle at 72% 88%, rgba(255, 190, 128, min(1, calc(var(--backdrop-strength, 0.78) * 0.16))), transparent 36%),
      radial-gradient(
        ellipse at center,
        rgba(224, 241, 255, 0) 48%,
        rgba(224, 241, 255, min(1, calc(var(--backdrop-strength, 0.78) * 0.24))) 78%,
        rgba(255, 238, 212, min(1, calc(var(--backdrop-strength, 0.78) * 0.58))) 100%
      ),
      radial-gradient(
        ellipse at center,
        rgba(5, 10, 20, 0) 46%,
        rgba(5, 10, 20, min(1, calc(var(--backdrop-vignette, 0.18) * 0.30))) 76%,
        rgba(5, 10, 20, min(1, calc(var(--backdrop-vignette, 0.18) * 0.72))) 100%
      );
  }
  #app {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 100vw;
    height: 100vh;
    z-index: 2;
    overflow: hidden;
  }
  canvas { display: block; cursor: grab; touch-action: none; }
  canvas.placing { cursor: crosshair; }
  canvas.dragging { cursor: grabbing; }

  /* Top-left Tiny World Builder wordmark. */
  .brand {
    position: fixed;
    top: 16px;
    left: 24px;
    pointer-events: none;
    z-index: 10;
  }
  .brand-logo {
    display: block;
    width: 250px;
    height: auto;
    filter: drop-shadow(0 10px 18px rgba(20, 30, 50, 0.18));
  }
  /* World menu trigger — top-center rounded pill; menu opens beneath it. */
  .world-pill {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 13;
    display: flex;
    align-items: center;
    padding: 5px 14px 5px 9px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 10px 30px -14px rgba(40, 50, 80, 0.28);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
  }
  .world-pill .brand-title-btn {
    position: relative;
    height: 30px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 2px 0 0;
    font-family: inherit;
    font-size: 13px;
    font-weight: 750;
    letter-spacing: 0;
    line-height: 1;
    color: var(--ink);
    white-space: nowrap;
  }
  .world-pill .brand-title-btn::before {
    content: '';
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: linear-gradient(135deg, #a6ca53, #75a83a);
    box-shadow: inset 0 -3px 0 rgba(63, 98, 29, 0.2), 0 1px 2px rgba(60, 40, 10, 0.14);
    flex: 0 0 auto;
  }
  .world-pill .brand-title-btn::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 13px;
    width: 10px;
    height: 8px;
    border: 2px solid #fff;
    border-top: 0;
    border-radius: 0 0 2px 2px;
    box-sizing: border-box;
    pointer-events: none;
  }
  .world-pill .brand-title-btn em { display: none; }
  .world-pill .brand-title-btn .brand-chevron {
    width: 11px;
    height: 11px;
    margin-left: 1px;
    color: #8d887d;
  }

  /* Keyboard/mouse tips — discreet pill above the appbar. */
  .tips-panel {
    position: fixed;
    bottom: 72px;
    left: 24px;
    z-index: 14;
    max-width: 360px;
    padding: 8px 10px 8px 12px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 14px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    font-size: 11px;
    color: var(--ink);
    display: flex;
    align-items: flex-start;
    gap: 8px;
  }
  .tips-panel[hidden] { display: none; }
  body.vehicle-demo-active .tips-panel,
  body.showcase .tips-panel,
  body.vehicle-demo-active .tips-show,
  body.showcase .tips-show { display: none; }
  .tips-close {
    order: 2;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 6px;
    align-self: flex-start;
  }
  .tips-close:hover { background: rgba(0, 0, 0, 0.06); color: var(--ink); }
  .tips-grid {
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 14px;
    row-gap: 3px;
    align-items: center;
  }
  .tips-label {
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
  }
  .tips-keys {
    color: var(--muted);
    white-space: nowrap;
  }
  .tips-keys kbd {
    display: inline-block;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 10px;
    padding: 1px 5px;
    margin: 0 1px;
    border: 1px solid rgba(120, 130, 150, 0.25);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--ink);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
    line-height: 1.2;
  }
  .tips-keys .sep {
    margin: 0 4px;
    color: rgba(120, 130, 150, 0.6);
  }
  .tips-show {
    position: fixed;
    bottom: 72px;
    left: 24px;
    z-index: 14;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 1px 2px rgba(20, 30, 50, 0.05);
  }
  .tips-show[hidden] { display: none; }
  .tips-show svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .tips-show:hover { color: var(--ink); background: rgba(255, 255, 255, 0.78); }
  @media (max-width: 700px) {
    .tips-panel, .tips-show { display: none; }
  }

  /* Icon pill — sits bottom-left. */
  .appbar {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 14;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 999px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
  }
  .appbar .btn.icon {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
  }
  .appbar .btn.icon svg { width: 15px; height: 15px; }

  /* Quick language switch — one flag button that opens an upward menu. */
  .appbar-sep {
    width: 1px;
    align-self: stretch;
    margin: 4px 2px;
    background: rgba(120, 130, 150, 0.25);
  }
  .language-picker {
    position: relative;
    display: inline-flex;
    align-items: center;
  }
  .language-trigger {
    position: relative;
    width: 46px;
    height: 30px;
    padding: 2px 5px 2px 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
  }
  .language-current-flag,
  .language-flag-svg {
    width: 25px;
    height: 17px;
    display: inline-flex;
    flex: 0 0 auto;
    overflow: hidden;
    border-radius: 5px;
    box-shadow: 0 0 0 1px rgba(30, 40, 60, 0.22);
  }
  .language-current-flag svg,
  .language-flag-svg svg {
    display: block;
    width: 100%;
    height: 100%;
  }
  .language-chevron {
    width: 10px;
    height: 10px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.12s ease;
  }
  .language-trigger[aria-expanded="true"] .language-chevron { transform: rotate(180deg); }
  .language-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    z-index: 36;
    min-width: 126px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.62);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.86) inset,
      0 12px 28px -14px rgba(20, 30, 50, 0.42);
    backdrop-filter: blur(18px) saturate(170%);
    -webkit-backdrop-filter: blur(18px) saturate(170%);
  }
  .language-menu[hidden] { display: none; }
  .language-option {
    width: 100%;
    min-height: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 5px;
    border: 0;
    border-radius: 8px;
    color: var(--ink);
    background: transparent;
    font: inherit;
    font-size: 12px;
    font-weight: 650;
    line-height: 1;
    text-align: left;
    cursor: pointer;
  }
  .language-option:hover,
  .language-option:focus-visible,
  .language-option.is-active {
    background: rgba(255, 255, 255, 0.72);
  }
  .language-option:focus-visible {
    outline: 2px solid rgba(84, 137, 230, 0.54);
    outline-offset: 1px;
  }
  .language-option.is-active {
    color: #1e428a;
    box-shadow: inset 0 0 0 1px rgba(30, 66, 138, 0.18);
  }
  body.ui-theme-dark .language-menu {
    background: rgba(24, 30, 44, 0.88);
    border-color: rgba(220, 236, 255, 0.22);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.14) inset,
      0 14px 30px -16px rgba(0, 0, 0, 0.72);
  }
  body.ui-theme-dark .language-option {
    color: #eef5ff;
  }
  body.ui-theme-dark .language-option:hover,
  body.ui-theme-dark .language-option:focus-visible,
  body.ui-theme-dark .language-option.is-active {
    background: rgba(220, 236, 255, 0.12);
  }
  body.ui-theme-dark .language-option.is-active {
    color: #9fc1ff;
    box-shadow: inset 0 0 0 1px rgba(159, 193, 255, 0.24);
  }
  .language-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-banner {
    position: fixed;
    top: 28px;
    left: 294px;
    right: auto;
    bottom: auto;
    z-index: 12;
    display: block;
    line-height: 0;
    border-radius: 8px;
    overflow: hidden;
    opacity: 0.92;
    box-shadow: 0 8px 24px -10px rgba(40, 50, 80, 0.35);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  .brand-banner:hover { opacity: 1; transform: translateY(-1px); }
  .brand-banner:focus-visible { outline: 2px solid rgba(90, 140, 255, 0.8); outline-offset: 2px; }
  .brand-banner img { display: block; width: 154px; height: auto; }

  @media (max-width: 1180px) {
    .brand-banner {
      top: 116px;
      left: 24px;
    }
    .brand-banner img { width: 132px; }
  }

  .token-corner {
    position: fixed;
    top: 18px;
    right: 24px;
    z-index: 14;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    line-height: 1;
    color: #2a2722;
    white-space: nowrap;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  }
  .token-corner .token-github-link {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 10px;
  }
  .token-corner .token-github-link svg {
    width: 16px;
    height: 16px;
  }
  .token-corner .token-corner-text {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    min-width: 0;
  }
  .token-corner .ticker { font-weight: 700; color: #2a2722; }
  .token-corner .token-sep { color: rgba(42, 39, 34, 0.48); }
  .token-corner .ca { font-family: ui-monospace, monospace; opacity: 0.72; }
  body.ui-theme-dark .token-corner {
    color: #f4f7ff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.72);
  }
  body.ui-theme-dark .token-corner .ticker { color: #f4f7ff; }
  body.ui-theme-dark .token-corner .token-sep,
  body.ui-theme-dark .token-corner .ca { color: rgba(244, 247, 255, 0.76); }
  .multiplayer-status {
    position: fixed;
    top: 44px;
    right: 24px;
    z-index: 16;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: min(260px, calc(100vw - 32px));
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 8px 24px -14px rgba(40, 50, 80, 0.35);
    color: var(--ink);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
    pointer-events: none;
    backdrop-filter: blur(18px) saturate(170%);
    -webkit-backdrop-filter: blur(18px) saturate(170%);
  }
  .multiplayer-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #a1a7b3;
  }
  .multiplayer-status[data-state="online"]::before { background: #3fb36f; box-shadow: 0 0 0 3px rgba(63, 179, 111, 0.16); }
  .multiplayer-status[data-state="connecting"]::before { background: #d89a2b; box-shadow: 0 0 0 3px rgba(216, 154, 43, 0.16); }
  .multiplayer-status[data-state="offline"]::before { background: #c8564a; box-shadow: 0 0 0 3px rgba(200, 86, 74, 0.16); }

  /* Connected-user roster — top-center glassy pill, matches .multiplayer-status. */
  .multiplayer-roster {
    position: fixed;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 16;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 4px 11px 4px 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 22px rgba(20, 28, 45, 0.14);
    font: 700 12px/1 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: #2b3242;
    pointer-events: none;
  }
  .multiplayer-roster.visible { display: inline-flex; }
  .multiplayer-roster .mp-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(58, 114, 200, 0.16);
    color: #2f5db0;
    font-size: 11px;
    font-weight: 800;
    pointer-events: auto;
  }
  .multiplayer-roster .mp-avatars { display: inline-flex; align-items: center; }
  .multiplayer-roster .mp-avatar {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: -7px;
    color: #fff;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.02em;
    border: 2px solid rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 3px rgba(20, 28, 45, 0.28);
    text-transform: uppercase;
    pointer-events: auto;
  }
  .multiplayer-roster .mp-avatar:first-child { margin-left: 0; }
  .multiplayer-roster .mp-avatar.mp-self { box-shadow: 0 0 0 2px #3a72c8, 0 1px 3px rgba(20, 28, 45, 0.28); }
  .multiplayer-roster .mp-avatar.mp-more { background: rgba(43, 50, 66, 0.62); font-size: 10px; }
  .multiplayer-roster .mp-avatar.mp-clickable { cursor: pointer; }
  .multiplayer-roster .mp-avatar { position: relative; }
  /* Small role badge clipped to the bottom-right of an avatar. */
  .multiplayer-roster .mp-role-badge {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1.5px solid rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 3px rgba(20, 28, 45, 0.3);
    color: #2b2f6b;
  }
  .multiplayer-roster .mp-role-badge svg { width: 10px; height: 10px; }
  .multiplayer-roster .mp-role-host { color: #b07a16; }
  .multiplayer-roster .mp-role-editor { color: #2b2f6b; }
  .multiplayer-roster .mp-role-player { color: #2f7d4a; }
  .multiplayer-roster .mp-role-viewer { color: #5a6172; }

  /* Glassy bottom-center toast (lobby entrance / role changes). */
  .mp-toast {
    position: fixed;
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%) translateY(8px);
    z-index: 60;
    max-width: min(360px, calc(100vw - 32px));
    padding: 9px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 10px 28px -12px rgba(40, 50, 80, 0.4);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    backdrop-filter: blur(12px) saturate(160%);
    color: #2b3242;
    font: 800 12px/1.3 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    text-align: center;
    opacity: 0;
    transition: opacity 0.28s ease, transform 0.28s ease;
    pointer-events: none;
  }
  .mp-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* Lobby-wait overlay shown to an un-admitted self. */
  .mp-lobby-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(20, 26, 40, 0.28);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }
  .mp-lobby-overlay.visible { display: flex; }
  .mp-lobby-card {
    max-width: min(420px, calc(100vw - 40px));
    padding: 26px 30px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 18px 48px -18px rgba(30, 40, 70, 0.5);
    -webkit-backdrop-filter: blur(18px) saturate(170%);
    backdrop-filter: blur(18px) saturate(170%);
    text-align: center;
    color: #2b3242;
  }
  .mp-lobby-title { font: 800 16px/1.35 system-ui, -apple-system, BlinkMacSystemFont, sans-serif; }
  .mp-lobby-sub { margin-top: 8px; font: 600 12.5px/1.45 system-ui, -apple-system, BlinkMacSystemFont, sans-serif; color: #5a6172; }

  /* Host admit panel — glassy panel with a drag-bar-style header + close. */
  .mp-admit-panel {
    position: fixed;
    top: 108px;
    right: 24px;
    z-index: 40;
    display: none;
    flex-direction: column;
    gap: 8px;
    width: 268px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding: 12px 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 14px 40px -16px rgba(40, 50, 80, 0.45);
    -webkit-backdrop-filter: blur(16px) saturate(165%);
    backdrop-filter: blur(16px) saturate(165%);
    color: #2b3242;
  }
  .mp-admit-panel.visible { display: flex; }
  .mp-admit-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 8px;
  }
  .mp-admit-head::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 4px;
    border-radius: 999px;
    background: rgba(120, 130, 150, 0.35);
  }
  .mp-admit-title { font: 800 13px/1 system-ui, -apple-system, BlinkMacSystemFont, sans-serif; }
  .mp-admit-close {
    position: absolute;
    right: -2px;
    top: 0;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #5a6172;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .mp-admit-close:hover { background: rgba(0, 0, 0, 0.06); color: #2b3242; }
  .mp-admit-list { display: flex; flex-direction: column; gap: 10px; }
  .mp-admit-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.7);
  }
  .mp-admit-rowtop { display: flex; align-items: center; gap: 8px; }
  .mp-admit-rowtop .mp-avatar {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font: 800 9.5px/1 system-ui, sans-serif;
    text-transform: uppercase;
    border: 2px solid rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 3px rgba(20, 28, 45, 0.28);
    flex: 0 0 auto;
  }
  .mp-admit-name {
    font: 800 12.5px/1.2 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: #2b3242;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mp-admit-actions { display: flex; gap: 6px; }

  /* Segmented role picker — navy-outlined active, light grey inactive. */
  .mp-segmented {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
  }
  .mp-seg-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1.5px solid rgba(120, 130, 150, 0.4);
    border-radius: 10px;
    background: rgba(120, 116, 108, 0.12);
    color: #3a3f4d;
    font: 800 10.5px/1 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    padding: 6px 4px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
  }
  .mp-seg-btn svg { width: 12px; height: 12px; }
  .mp-seg-btn:hover { background: rgba(255, 255, 255, 0.55); }
  .mp-seg-btn.is-active {
    background: rgba(150, 142, 230, 0.22);
    border-color: #3a3f88;
    border-width: 2px;
    color: #2b2f6b;
  }

  /* Block-style buttons (raised outline + inner white line, SVG glyph). */
  .mp-btn {
    flex: 1 1 auto;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border-radius: 11px;
    border: 1.5px solid rgba(255, 255, 255, 0.55);
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.9),
      0 1px 2px -1px rgba(20, 30, 50, 0.2);
    font: 800 11.5px/1 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    padding: 7px 8px;
    cursor: pointer;
    transition: background 0.12s, box-shadow 0.12s, color 0.12s;
  }
  .mp-btn svg { width: 13px; height: 13px; }
  .mp-btn-admit {
    background: rgba(47, 125, 74, 0.16);
    border-color: #2f7d4a;
    color: #1f5e36;
  }
  .mp-btn-admit:hover { background: rgba(47, 125, 74, 0.26); }
  .mp-btn-decline {
    background: rgba(200, 86, 74, 0.14);
    border-color: #b04437;
    color: #8c372c;
  }
  .mp-btn-decline:hover { background: rgba(200, 86, 74, 0.24); }

  /* Host per-peer moderation menu (change role / kick). */
  .mp-mod-menu {
    position: fixed;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 208px;
    padding: 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 14px 40px -16px rgba(40, 50, 80, 0.5);
    -webkit-backdrop-filter: blur(16px) saturate(165%);
    backdrop-filter: blur(16px) saturate(165%);
    color: #2b3242;
  }
  .mp-mod-title {
    font: 800 12.5px/1.2 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ---- Multi-user chat ---- */
  /* Floating launcher (bottom-right) with an unread bubble. */
  .mp-chat-toggle {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 46;
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.74);
    color: #2b3242;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 10px 26px -10px rgba(40, 50, 80, 0.4);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    backdrop-filter: blur(12px) saturate(160%);
    cursor: pointer;
    transition: background 0.12s, transform 0.12s, box-shadow 0.12s;
  }
  .mp-chat-toggle:hover { background: rgba(255, 255, 255, 0.9); }
  .mp-chat-toggle:active { transform: scale(0.97); }
  .mp-chat-toggle.is-open {
    background: rgba(23, 107, 235, 0.16);
    border-color: #304878;
    color: #1f4ea8;
  }
  .mp-chat-toggle svg { width: 18px; height: 18px; }
  .mp-chat-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    display: none;
    align-items: center;
    justify-content: center;
    background: #d9483b;
    color: #fff;
    font: 800 10px/1 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    border: 2px solid rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 3px rgba(20, 28, 45, 0.3);
  }
  .mp-chat-badge.visible { display: inline-flex; }

  /* Glassy panel (matches .layers-panel design language). */
  .mp-chat-panel {
    position: fixed;
    right: 24px;
    bottom: 78px;
    z-index: 47;
    display: none;
    flex-direction: column;
    gap: 6px;
    width: min(300px, calc(100vw - 28px));
    height: 420px;
    max-width: calc(100vw - 28px);
    max-height: calc(100vh - 118px);
    padding: 4px 8px 8px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.6);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 24px 56px -16px rgba(40, 50, 80, 0.30);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    backdrop-filter: blur(22px) saturate(180%);
    color: #2b3242;
    overflow: hidden;
  }
  .mp-chat-panel.visible { display: flex; }
  .mp-chat-panel.dragging { transition: none; user-select: none; }

  /* Drag bar — centred grab cue, close on the right (like .layers-panel-head). */
  .mp-chat-head {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 4px 3px;
    cursor: grab;
    user-select: none;
    touch-action: none;
  }
  .mp-chat-panel.dragging .mp-chat-head { cursor: grabbing; }
  .mp-chat-head::after {
    content: '';
    width: 28px;
    height: 4px;
    border-radius: 999px;
    background: rgba(120, 130, 150, 0.35);
  }
  .mp-chat-close {
    position: absolute;
    right: -2px;
    top: 0;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #5a6172;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .mp-chat-close:hover { background: rgba(0, 0, 0, 0.06); color: #2b3242; }
  .mp-chat-close svg { width: 13px; height: 13px; }

  /* Single segmented tab in the Layers/Properties block-button style. */
  .mp-chat-tabs { flex: 0 0 auto; display: grid; grid-template-columns: 1fr; padding: 0 1px; }
  .mp-chat-tab {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1.5px solid rgba(255, 255, 255, 0.55);
    border-radius: 12px;
    background: rgba(120, 116, 108, 0.14);
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.9),
      0 1px 2px -1px rgba(20, 30, 50, 0.2);
    color: #2b3242;
    font: 800 11.5px/1 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    padding: 6px 8px;
    cursor: default;
  }
  .mp-chat-tab svg { width: 13px; height: 13px; }
  .mp-chat-tab.is-active {
    border-color: #304878;
    background: rgba(23, 107, 235, 0.14);
    color: #1f4ea8;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 rgba(30, 66, 138, 0.22),
      0 2px 3px -1px rgba(20, 30, 50, 0.22);
  }

  .mp-chat-log {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 2px;
  }
  .mp-chat-msg {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 9px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.7);
    align-self: flex-start;
    max-width: 92%;
  }
  .mp-chat-msg.is-self {
    align-self: flex-end;
    background: rgba(23, 107, 235, 0.12);
    border-color: rgba(48, 72, 120, 0.3);
  }
  .mp-chat-meta { display: flex; align-items: baseline; gap: 6px; }
  .mp-chat-name {
    font: 800 11px/1.2 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
  }
  .mp-chat-time { font: 600 9.5px/1 system-ui, sans-serif; color: #8a91a0; }
  .mp-chat-text {
    font: 600 12.5px/1.4 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: #2b3242;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
  }
  .mp-chat-typing {
    flex: 0 0 auto;
    min-height: 14px;
    padding: 0 4px;
    font: 700 10.5px/1.2 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: #5a6172;
    opacity: 0;
    transition: opacity 0.15s;
  }
  .mp-chat-typing.visible { opacity: 1; }

  .mp-chat-form { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; }
  .mp-chat-input {
    flex: 1 1 auto;
    min-width: 0;
    border: 1px solid rgba(120, 110, 90, 0.18);
    border-radius: 14px;
    padding: 9px 11px;
    background: rgba(255, 255, 255, 0.7);
    color: #2b3242;
    font: 600 12.5px/1.2 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    outline: none;
  }
  .mp-chat-input:focus { border-color: #304878; background: rgba(255, 255, 255, 0.9); }
  .mp-chat-send {
    flex: 0 0 auto;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1.5px solid #304878;
    background: rgba(23, 107, 235, 0.14);
    color: #1f4ea8;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      0 1px 2px -1px rgba(20, 30, 50, 0.2);
    cursor: pointer;
    transition: background 0.12s;
  }
  .mp-chat-send:hover { background: rgba(23, 107, 235, 0.24); }
  .mp-chat-send svg { width: 16px; height: 16px; }

  /* Guest menu hide: an admitted non-host guest cannot leave the host's world,
     so the world-management trigger + menu are removed for them. Host / null
     role / single-player are unaffected (body.mp-guest is never set there). */
  body.mp-guest #world-pill,
  body.mp-guest #world-menu { display: none !important; }

  /* Viewer / player have NO edit rights: hide ALL editing chrome so there are no
     controls to reach for. Camera gestures (orbit/zoom/pan) still work, and a
     player can still click a placed plane to fly (Esc exits). Chat, roster and
     the connection status pill stay visible. Editor keeps the chrome (scoped to
     its island); host / null-role / single-player never get body.mp-noedit. */
  body.mp-noedit #toolbar,
  body.mp-noedit #tool-palette,
  body.mp-noedit .controls,
  body.mp-noedit .appbar,
  body.mp-noedit #layers-toggle,
  body.mp-noedit #layers-panel,
  body.mp-noedit #agent-panel,
  body.mp-noedit #agent-input,
  body.mp-noedit #agent-panel-handle,
  body.mp-noedit #view-popup,
  body.mp-noedit #time-popup,
  body.mp-noedit #world-pill,
  body.mp-noedit #world-menu { display: none !important; }

  /* PLAY mode is local and intentional: keep scene/camera controls reachable,
     but remove every build/editor surface and route mutations through the same
     edit gate as multiplayer no-edit roles. */
  body.tw-play-mode #toolbar,
  body.tw-play-mode #tool-palette,
  body.tw-play-mode .flyout,
  body.tw-play-mode #layers-toggle,
  body.tw-play-mode #layers-panel,
  body.tw-play-mode #agent-panel,
  body.tw-play-mode #agent-input,
  body.tw-play-mode #agent-panel-handle,
  body.tw-play-mode #stamp-builder-panel,
  body.tw-play-mode #crowd-panel,
  body.tw-play-mode #crowd-panel-handle,
  body.tw-play-mode .unsaved-banner,
  body.tw-play-mode .radial-menu {
    display: none !important;
  }
  body.tw-play-mode #stamp-builder,
  body.tw-play-mode #generate,
  body.tw-play-mode #render-settings,
  body.tw-play-mode #import,
  body.tw-play-mode #export,
  body.tw-play-mode #reset,
  body.tw-play-mode #clear,
  body.tw-play-mode #dev-mode {
    display: none !important;
  }

  .controls {
    position: fixed;
    top: 50%;
    left: 18px;
    right: auto;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 44px;
    max-height: min(720px, calc(100vh - 188px));
    padding: 6px 5px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 999px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    z-index: 12;
  }
  .controls::-webkit-scrollbar { display: none; }
  .xr-panel {
    position: fixed;
    left: 74px;
    bottom: 18px;
    z-index: 16;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 999px;
    box-shadow: 0 4px 12px -4px rgba(40, 50, 80, 0.18);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
  }

  .xr-panel[hidden] {
    display: none !important;
  }

  .xr-panel .xr-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: var(--ink);
  }

  .xr-panel .xr-btn:hover {
    background: rgba(255, 255, 255, 0.75);
  }

  .xr-panel .xr-btn svg {
    width: 17px;
    height: 17px;
  }
  body.xr-active .xr-panel { background: rgba(42, 39, 34, 0.72); }
  body.xr-active .xr-status { color: rgba(255, 255, 255, 0.86); }
  body.xr-active .brand,
  body.xr-active .world-pill,
  body.xr-active .tool-palette,
  body.xr-active .brand-banner,
  body.xr-active .controls,
  body.xr-active .toolbar,
  body.xr-active .appbar,
  body.xr-active #minimap,
  body.xr-active #agent-input,
  body.xr-active #agent-panel {
    opacity: 0.08;
    pointer-events: none;
  }
  .btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 9px 14px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(60, 40, 10, 0.04);
    transition: background 0.12s, transform 0.08s;
  }
  .btn:hover { background: rgba(255, 255, 255, 0.55); }
  .btn:active { transform: translateY(1px); }
  .btn.on {
    background: rgba(255, 255, 255, 0.78);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 1px 2px rgba(20, 30, 50, 0.06);
  }
  .btn.on::before {
    content: '●';
    color: #6fb442;
    margin-right: 4px;
    font-size: 9px;
    vertical-align: 1px;
  }
  .btn.icon {
    padding: 0;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
  }
  .btn.icon.disabled {
    opacity: 0.4;
    pointer-events: none;
  }
  .btn.icon svg {
    width: 17px;
    height: 17px;
    display: block;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .btn.build-play-toggle {
    width: 34px;
    height: 44px;
    flex: 0 0 44px;
    padding: 2px 0 3px;
    border-radius: 12px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    font-size: 8px;
    font-weight: 850;
    line-height: 1;
    letter-spacing: 0;
    text-transform: uppercase;
  }
  .btn.build-play-toggle svg {
    width: 16px;
    height: 16px;
    display: block;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .btn.build-play-toggle .ic-play { display: none; }
  body.tw-play-mode .btn.build-play-toggle .ic-build { display: none; }
  body.tw-play-mode .btn.build-play-toggle .ic-play { display: block; }
  .file-input-proxy {
    position: fixed;
    left: -10000px;
    top: -10000px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
  }
  .btn.icon.on::before { content: none; }
  .btn.icon.on {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.78);
    box-shadow:
      inset 0 0 0 1px rgba(255, 255, 255, 0.6),
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 1px 2px rgba(20, 30, 50, 0.06);
  }
  .btn.icon.locked {
    position: relative;
    color: var(--muted);
    opacity: 0.78;
  }
  .btn.icon.locked::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 9px;
    height: 7px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 2px;
    box-shadow: 0 -5px 0 -3px var(--line);
    pointer-events: none;
  }

  /* Audio panel — persistent floating control, sits above the toolbar so it
     never overlaps the tool buttons on either desktop or mobile widths. */
  .audio-panel {
    position: fixed;
    bottom: 140px;
    right: 14px;
    z-index: 40;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 14px;
    box-shadow:
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 200px;
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
  }
  .crowd-panel {
    position: fixed;
    top: 290px;
    right: 24px;
    z-index: 42;
    width: 248px;
    max-height: calc(100vh - 340px);
    overflow: auto;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 18px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    cursor: grab;
    transition:
      transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.28s ease,
      top 0.1s ease,
      left 0.1s ease;
  }
  .crowd-panel.dragging { cursor: grabbing; transition: none; }
  .crowd-panel.hidden {
    transform: translateX(calc(100% + 28px));
    opacity: 0;
    pointer-events: none;
  }
  .crowd-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(120, 130, 150, 0.12);
    cursor: grab;
    user-select: none;
  }
  .crowd-panel-toggle {
    width: 22px;
    height: 22px;
    padding: 0;
    font-size: 16px;
    line-height: 1;
    font-weight: 500;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 1px 2px rgba(20, 30, 50, 0.04);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    transition: background 0.12s, border-color 0.12s, color 0.12s;
  }
  .crowd-panel-toggle:hover {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.68);
    border-color: rgba(255, 255, 255, 0.75);
  }
  .crowd-panel-handle {
    display: none !important;
    position: fixed;
    right: 24px;
    top: 290px;
    transform: translateY(-50%);
    z-index: 41;
    width: 34px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #8a7a58;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 20px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.12s;
    user-select: none;
  }
  .crowd-panel-handle:hover {
    color: var(--ink);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 3px rgba(20, 30, 50, 0.08),
      0 16px 40px -10px rgba(40, 50, 80, 0.28);
    transform: translateY(-50%) scale(1.02);
  }
  .crowd-panel-handle:active { transform: translateY(-50%) scale(0.98); }
  .crowd-panel-handle[hidden] { display: none; }
  .crowd-panel h3 {
    margin: 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink);
  }
  .crowd-panel .crowd-row {
    display: grid;
    grid-template-columns: 82px 1fr 44px;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--muted);
  }
  .crowd-panel .crowd-row input[type="range"] { width: 100%; }
  .crowd-panel output {
    font-variant-numeric: tabular-nums;
    text-align: right;
    color: var(--ink);
  }
  .crowd-panel select {
    grid-column: 2 / 4;
    min-width: 0;
    border: 1px solid rgba(120, 130, 150, 0.24);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink);
    font: inherit;
    padding: 4px 6px;
  }
  .crowd-panel .crowd-check {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: var(--ink);
  }
  .crowd-actions {
    display: flex;
    gap: 6px;
  }
  .crowd-actions .btn { flex: 1; padding: 7px 8px; font-size: 11px; }
  @media (max-width: 900px) {
    .crowd-panel {
      top: auto;
      bottom: 220px;
      right: 8px;
      width: 210px;
      max-height: 42vh;
    }
  }

  @media (max-width: 800px) {
    .audio-panel {
      bottom: 160px;
      right: 8px;
      min-width: 170px;
      padding: 6px 8px;
    }
  }
  .audio-row {
    display: grid;
    grid-template-columns: 26px 1fr;
    align-items: center;
    gap: 8px;
  }
  .audio-row .audio-label {
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  .audio-row input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 14px;
    background: transparent;
    cursor: pointer;
    outline: none;
  }
  .audio-row input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(120, 130, 150, 0.18);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  }
  .audio-row input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(120, 130, 150, 0.18);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  }
  .audio-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 14px;
    margin-top: -5px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.95) inset,
      0 1px 2px rgba(20, 30, 50, 0.18);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    cursor: pointer;
  }
  .audio-row input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 14px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.95) inset,
      0 1px 2px rgba(20, 30, 50, 0.18);
    cursor: pointer;
  }
  .audio-mute {
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--ink);
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .audio-mute svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .audio-mute .ic-off { display: none; }
  .audio-mute.muted { color: var(--muted); }
  .audio-mute.muted .ic-on { display: none; }
  .audio-mute.muted .ic-off { display: block; }

  /* --- Sound icon (lives inside the bottom toolbar) --- */
  button.sound-icon {
    position: fixed;
    right: 24px;
    top: 346px;
    z-index: 41;
    width: 34px;
    height: 72px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.6);
    color: #8a7a58;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    transition: background 120ms ease, transform 120ms ease, color 120ms ease, box-shadow 120ms ease;
    flex-shrink: 0;
  }
  .sound-icon:hover {
    color: var(--ink);
    transform: scale(1.02);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 3px rgba(20, 30, 50, 0.08),
      0 16px 40px -10px rgba(40, 50, 80, 0.28);
  }
  .sound-icon:active { transform: scale(0.98); }
  .sound-icon.open {
    background: rgba(60, 110, 220, 0.18);
    color: #1f4ea8;
  }
  button.layers-handle {
    position: fixed;
    right: 24px;
    top: 430px;
    z-index: 41;
    width: 34px;
    height: 72px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.6);
    color: #8a7a58;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    transition: background 120ms ease, transform 120ms ease, color 120ms ease, box-shadow 120ms ease;
    flex-shrink: 0;
  }
  .layers-handle:hover {
    color: var(--ink);
    transform: scale(1.02);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 3px rgba(20, 30, 50, 0.08),
      0 16px 40px -10px rgba(40, 50, 80, 0.28);
  }
  .layers-handle:active { transform: scale(0.98); }
  .layers-handle.on {
    background: rgba(60, 110, 220, 0.18);
    color: #1f4ea8;
  }
  .layers-handle svg {
    width: 18px;
    height: 18px;
    display: block;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  body.vehicle-demo-active .layers-handle,
  body.showcase .layers-handle { display: none; }

  .sound-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .sound-icon .ic-off { display: none; }
  .sound-icon.muted { color: var(--muted); }
  .sound-icon.muted .ic-on { display: none; }
  .sound-icon.muted .ic-off { display: block; }
  body.vehicle-demo-active .sound-icon,
  body.showcase .sound-icon { display: none; }

  /* --- Floating sound panel — anchored above the toolbar --- */
  .sound-panel {
    position: fixed;
    top: 346px;
    right: 70px;
    z-index: 50;
    width: 280px;
    max-height: calc(100vh - 380px);
    overflow: auto;
    background: rgba(255, 255, 255, 0.66);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 16px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 18px 48px -16px rgba(40, 50, 80, 0.28);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
  }
  .sound-panel[hidden] { display: none; }
  .sound-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .sound-panel-head h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
  }
  .sound-panel-close {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
  }
  .sound-panel-close:hover { background: rgba(0, 0, 0, 0.06); color: var(--ink); }
  .sound-section { display: flex; flex-direction: column; gap: 6px; }
  .sound-section-title {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
  }
  .sound-row {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .sound-row input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    height: 16px;
    cursor: pointer;
  }
  .sound-row input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(120, 130, 150, 0.18);
  }
  .sound-row input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(120, 130, 150, 0.18);
  }
  .sound-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 14px;
    margin-top: -5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 1px 2px rgba(20, 30, 50, 0.18);
  }
  .sound-row input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 14px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.6);
  }
  .sound-mute {
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--ink);
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .sound-mute svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .sound-mute .ic-off { display: none; }
  .sound-mute.muted { color: var(--muted); }
  .sound-mute.muted .ic-on { display: none; }
  .sound-mute.muted .ic-off { display: block; }
  .sound-tracklist {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
    max-height: 200px;
    overflow: auto;
  }
  .sound-track-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 12px;
    color: var(--ink);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: background 100ms ease, border-color 100ms ease;
  }
  .sound-track-item:hover {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(0, 0, 0, 0.05);
  }
  .sound-track-item.active {
    background: rgba(60, 110, 220, 0.12);
    border-color: rgba(60, 110, 220, 0.25);
    color: var(--ink);
    font-weight: 600;
  }
  .sound-track-item .track-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(120, 130, 150, 0.35);
    flex-shrink: 0;
  }
  .sound-track-item.active .track-dot {
    background: #2e8b3a;
    box-shadow: 0 0 0 3px rgba(46, 139, 58, 0.18);
  }

  /* Custom tooltip with 500ms hover delay, no delay on hide. */
  [data-tooltip] { position: relative; }
  [data-tooltip]::after {
    content: none;
  }
  .ui-tooltip {
    position: fixed;
    z-index: 1000;
    max-width: min(260px, calc(100vw - 24px));
    background: var(--ink);
    color: #fff;
    padding: 6px 9px;
    border-radius: 7px;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.25;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 0);
    transition: opacity 0.12s ease;
    box-shadow: 0 4px 14px -6px rgba(20, 18, 16, 0.35);
  }
  .ui-tooltip.visible {
    opacity: 1;
  }

  /* -------- mode indicator -------- */
  /* Persistent chip naming the current mode so a click never starts building
     by surprise. Calm for Select; "armed" colours for build/paint/erase. */
  .mode-indicator {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 16px 7px 12px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 1px 2px rgba(20, 30, 50, 0.05), 0 10px 30px -14px rgba(40, 50, 80, 0.28);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    z-index: 13;
    pointer-events: none;
    transition: background 0.18s ease, box-shadow 0.18s ease;
  }
  .mode-indicator .mode-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: none;
    background: #6fae54;
    box-shadow: 0 0 0 3px rgba(111, 174, 84, 0.22);
    transition: background 0.18s ease, box-shadow 0.18s ease;
  }
  .mode-indicator .mode-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
  }
  .mode-indicator .mode-label {
    font-size: 13px;
    font-weight: 700;
    color: #2a2723;
    letter-spacing: 0.01em;
  }
  .mode-indicator .mode-sub {
    font-size: 10.5px;
    color: rgba(42, 39, 35, 0.62);
  }
  .mode-indicator.mode-build {
    background: rgba(255, 244, 222, 0.82);
    box-shadow: 0 1px 2px rgba(20, 30, 50, 0.05), 0 0 0 1px rgba(224, 150, 40, 0.45), 0 10px 30px -12px rgba(224, 150, 40, 0.4);
  }
  .mode-indicator.mode-build .mode-dot {
    background: #e0962b;
    box-shadow: 0 0 0 3px rgba(224, 150, 40, 0.25);
  }
  .mode-indicator.mode-erase {
    background: rgba(255, 230, 228, 0.85);
    box-shadow: 0 1px 2px rgba(20, 30, 50, 0.05), 0 0 0 1px rgba(208, 70, 64, 0.5), 0 10px 30px -12px rgba(208, 70, 64, 0.42);
  }
  .mode-indicator.mode-erase .mode-dot {
    background: #d04640;
    box-shadow: 0 0 0 3px rgba(208, 70, 64, 0.28);
  }

  .toolbar {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    min-height: 54px;
    background: rgba(255, 255, 255, 0.58);
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 18px;
    display: flex;
    align-items: center;
    gap: 3px;
    box-shadow:
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    z-index: 12;
    max-width: calc(100vw - 32px);
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: none;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar-world-slot {
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 12px 0 0;
    margin-right: 8px;
    border-right: 1px solid rgba(120, 130, 150, 0.18);
    flex: 0 0 auto;
  }
  .toolbar .brand-title-btn {
    position: relative;
    height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 2px 0 0;
    font-family: inherit;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0;
    line-height: 1;
    color: var(--ink);
    white-space: nowrap;
  }
  .toolbar .brand-title-btn::before {
    content: '';
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: linear-gradient(135deg, #a6ca53, #75a83a);
    box-shadow: inset 0 -3px 0 rgba(63, 98, 29, 0.2), 0 1px 2px rgba(60, 40, 10, 0.14);
    flex: 0 0 auto;
  }
  .toolbar .brand-title-btn::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 15px;
    width: 10px;
    height: 8px;
    border: 2px solid #fff;
    border-top: 0;
    border-radius: 0 0 2px 2px;
    box-sizing: border-box;
    pointer-events: none;
  }
  .toolbar .brand-title-btn em { display: none; }
  .toolbar .brand-title-btn .brand-chevron {
    width: 11px;
    height: 11px;
    margin-left: 1px;
    color: #8d887d;
  }
  .tool-group-btn {
    width: 58px;
    height: 50px;
    border: 1px solid transparent;
    border-radius: 16px;
    background: transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    font-family: inherit;
    font-size: 10.5px;
    color: #8d887d;
    font-weight: 700;
    transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.08s;
    flex-shrink: 0;
    padding: 3px 3px 2px;
  }
  .tool-group-btn > span:not(.chev),
  .tool > span {
    max-width: 100%;
    line-height: 1.05;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tool-group-btn .chev {
    font-size: 9px;
    line-height: 1;
    margin-top: -1px;
    color: #b09863;
  }
  .tool-group-btn:hover {
    background: rgba(255, 255, 255, 0.55);
    color: var(--ink);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  }
  .tool-group-btn.active {
    background: rgba(255, 255, 255, 0.78);
    border-color: rgba(255, 255, 255, 0.6);
    color: var(--ink);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 1px 2px rgba(20, 30, 50, 0.06);
  }
  .tool-group-btn .tool-thumb {
    width: 30px;
    height: 30px;
    display: block;
    pointer-events: none;
    image-rendering: -webkit-optimize-contrast;
    filter: contrast(1.45) brightness(0.78) saturate(1.28);
  }
  .toolbar-divider {
    width: 1px;
    height: 36px;
    background: linear-gradient(
      to bottom,
      rgba(120, 130, 150, 0) 0%,
      rgba(120, 130, 150, 0.28) 50%,
      rgba(120, 130, 150, 0) 100%
    );
    margin: 0 7px;
    flex: 0 0 auto;
  }
  .toolbar .audio-panel {
    position: static;
    min-width: 132px;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0 0 0 2px;
    backdrop-filter: none;
    gap: 4px;
    z-index: auto;
  }
  .toolbar .audio-row {
    grid-template-columns: 20px 1fr;
    gap: 5px;
  }
  .toolbar .audio-mute {
    width: 20px;
    height: 20px;
    border-radius: 6px;
  }
  .toolbar .audio-row input[type="range"] {
    height: 14px;
  }
  .tool {
    width: 52px;
    height: 50px;
    border: 1px solid transparent;
    border-radius: 16px;
    background: transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    font-family: inherit;
    font-size: 10.5px;
    color: #8d887d;
    font-weight: 700;
    transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.08s;
    flex-shrink: 0;
    padding: 3px 3px 2px;
  }
  .tool:hover {
    background: rgba(255, 255, 255, 0.55);
    color: var(--ink);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  }
  .tool.active {
    background: rgba(255, 255, 255, 0.78);
    border-color: rgba(255, 255, 255, 0.6);
    color: var(--ink);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 1px 2px rgba(20, 30, 50, 0.06);
  }
  .tool:active { transform: translateY(1px); }
  .tool.group-start { margin-left: 10px; position: relative; }
  .tool.group-start::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 10px;
    bottom: 10px;
    width: 1px;
    background: var(--line);
  }
  .tool .swatch {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.10);
    position: relative;
    overflow: hidden;
    /* Punch the toolbar icons hard so the tiny thumbnails don't wash out. */
    filter: contrast(1.45) brightness(0.78) saturate(1.28);
  }
  .tool .tool-thumb {
    width: 30px;
    height: 30px;
    display: block;
    pointer-events: none;
    /* Crisp pixel-accurate downsample for the WebGL bitmap. */
    image-rendering: -webkit-optimize-contrast;
    filter: contrast(1.45) brightness(0.78) saturate(1.28);
  }

  /* Flat tool glyphs (game-icons.net, CC BY 3.0) — replace the WebGL 3D
     thumbnails. Solid fill in ink, so they override the stroke icon rules. */
  .tool .tool-glyph {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* White body so the icon reads as "dark coloured outline, inner white". */
    color: #fff;
    --glyph-outline: #2f3b57;
    pointer-events: none;
  }
  .tool .tool-glyph svg {
    width: 26px;
    height: 26px;
    display: block;
    fill: currentColor;
    overflow: visible;
  }
  /* Dark outline in a darkened version of the icon's category colour, drawn
     under the white fill (paint-order: stroke) at a constant pixel width
     (non-scaling-stroke) so it looks identical across every glyph viewBox. */
  .tool .tool-glyph svg * {
    fill: currentColor;
    stroke: var(--glyph-outline);
    stroke-width: 2.1;
    vector-effect: non-scaling-stroke;
    paint-order: stroke;
    stroke-linejoin: round;
    stroke-linecap: round;
  }
  .tool[data-pos-type="terrain"]  .tool-glyph { --glyph-outline: #3a6511; }
  .tool[data-pos-type="primary"]  .tool-glyph { --glyph-outline: #1e428a; }
  .tool[data-pos-type="tertiary"] .tool-glyph { --glyph-outline: #a05600; }
  .tool[data-pos-type="shield"]   .tool-glyph { --glyph-outline: #0e5f7e; }
  .tool[data-pos-type="neutral"]  .tool-glyph { --glyph-outline: #2f3b57; }
  .flyout-tool .tool-glyph { width: 42px; height: 42px; }
  .flyout-tool .tool-glyph svg { width: 34px; height: 34px; }
  .tool .tool-glyph.tool-glyph-empty {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: var(--glyph-color, #9b9a8f);
  }

  /* Positional-type background tint: terrain (ground) / primary (the object
     that owns a tile) / tertiary (overlays that stack onto a primary, e.g.
     fences). Placed after .tool:hover/.active so the type colour wins. */
  .tool[data-pos-type="terrain"]  { background: rgba(123, 194, 48, 0.16); }
  .tool[data-pos-type="primary"]  { background: rgba(23, 107, 235, 0.13); }
  .tool[data-pos-type="tertiary"] { background: rgba(254, 146, 14, 0.18); }
  .tool[data-pos-type="shield"]   { background: rgba(45, 215, 255, 0.15); }
  .tool[data-pos-type="neutral"]  { background: rgba(255, 255, 255, 0.42); }
  .tool[data-pos-type="terrain"]:hover  { background: rgba(123, 194, 48, 0.30); color: var(--ink); }
  .tool[data-pos-type="primary"]:hover  { background: rgba(23, 107, 235, 0.24); color: var(--ink); }
  .tool[data-pos-type="tertiary"]:hover { background: rgba(254, 146, 14, 0.32); color: var(--ink); }
  .tool[data-pos-type="shield"]:hover   { background: rgba(45, 215, 255, 0.28); color: var(--ink); }
  .tool[data-pos-type="neutral"]:hover  { background: rgba(255, 255, 255, 0.62); color: var(--ink); }
  .tool[data-pos-type="terrain"].active  { background: rgba(123, 194, 48, 0.36); border-color: rgba(123, 194, 48, 0.62); }
  .tool[data-pos-type="primary"].active  { background: rgba(23, 107, 235, 0.30); border-color: rgba(23, 107, 235, 0.58); }
  .tool[data-pos-type="tertiary"].active { background: rgba(254, 146, 14, 0.40); border-color: rgba(254, 146, 14, 0.66); }
  .tool[data-pos-type="shield"].active   { background: rgba(45, 215, 255, 0.36); border-color: rgba(45, 215, 255, 0.66); }
  .tool[data-pos-type="neutral"].active  { background: rgba(255, 255, 255, 0.78); border-color: rgba(47, 59, 87, 0.62); }

  /* Selected-tool indicator: the active group button shows the selected tool's
     own glyph (filled) plus a ring tinted by its positional type. */
  .group-icon.group-icon-glyph {
    color: #fff;
    --glyph-outline: #2f3b57;
  }
  .group-icon.group-icon-glyph svg {
    width: 32px;
    height: 32px;
    fill: currentColor;
    overflow: visible;
  }
  .group-icon.group-icon-glyph svg * {
    fill: currentColor;
    stroke: var(--glyph-outline);
    stroke-width: 2.1;
    vector-effect: non-scaling-stroke;
    paint-order: stroke;
    stroke-linejoin: round;
    stroke-linecap: round;
  }
  .tool-group-btn[data-pos-type="terrain"]  .group-icon-glyph { --glyph-outline: #3a6511; }
  .tool-group-btn[data-pos-type="primary"]  .group-icon-glyph { --glyph-outline: #1e428a; }
  .tool-group-btn[data-pos-type="tertiary"] .group-icon-glyph { --glyph-outline: #a05600; }
  .tool-group-btn[data-pos-type="shield"]   .group-icon-glyph { --glyph-outline: #0e5f7e; }
  .toolbar .tool-group-btn[data-pos-type="terrain"].active  { box-shadow: 0 0 0 2px rgba(123, 194, 48, 0.66) inset, 0 1px 2px rgba(20,30,50,0.06); }
  .toolbar .tool-group-btn[data-pos-type="primary"].active  { box-shadow: 0 0 0 2px rgba(23, 107, 235, 0.6) inset, 0 1px 2px rgba(20,30,50,0.06); }
  .toolbar .tool-group-btn[data-pos-type="tertiary"].active { box-shadow: 0 0 0 2px rgba(254, 146, 14, 0.66) inset, 0 1px 2px rgba(20,30,50,0.06); }

  .tool .swatch.eraser {
    background: repeating-linear-gradient(45deg, #e8e3d6, #e8e3d6 3px, #d6cdb8 3px, #d6cdb8 6px) !important;
    box-shadow: inset 0 0 0 1px #c4ba9e;
  }
  .tool .swatch.select {
    background: #f6efd9;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: inset 0 -3px 0 rgba(120, 90, 30, 0.16), 0 1px 2px rgba(0, 0, 0, 0.10);
  }
  .tool .swatch.select::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 5px;
    width: 8px;
    height: 14px;
    border-left: 3px solid #5f4a20;
    border-bottom: 3px solid #5f4a20;
    transform: rotate(-35deg) skewY(20deg);
  }
  .tool .swatch.auto {
    background:
      linear-gradient(135deg, #3a72c8 0 50%, #86b53e 50% 100%);
  }
  .tool.busy .swatch.auto::after {
    content: '';
    position: absolute;
    inset: 7px;
    border: 2px solid rgba(255, 255, 255, 0.82);
    border-top-color: rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
  }
  .tool kbd {
    display: inline-block;
    font-family: 'Inter', monospace;
    font-size: 9px;
    color: #b9b1a3;
    margin-top: -2px;
  }

  /* Toolbar tools (non-flyout): icons stay. On hover, the text label swaps
     for the keyboard shortcut. Flyouts are unaffected. */
  .toolbar .tool:not(.flyout-tool) kbd {
    display: none;
    margin-top: -2px;
    font-weight: 700;
    color: var(--ink);
    font-size: 10.5px;
  }
  .toolbar .tool:not(.flyout-tool):hover > span:not(.chev):not(.tool-icon) {
    display: none;
  }
  .toolbar .tool:not(.flyout-tool):hover kbd {
    display: inline-block;
  }

  /* Tool groups (Terrain, Plants, Build, ...) — render as monochrome icons
     in the main bar, matching Select/Erase. The 3D thumbnails still appear
     in the flyout. */
  .toolbar .tool-group-btn .tool-thumb,
  .toolbar .tool-group-btn > span:not(.chev):not(.group-icon),
  .toolbar .tool-group-btn .chev {
    display: none;
  }
  .toolbar .tool-group-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
    position: relative;
  }
  .toolbar .tool-group-btn::before { content: none; }
  .toolbar .tool-group-btn .group-icon,
  .toolbar .tool .tool-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
  }
  .toolbar .tool-group-btn .group-icon svg,
  .toolbar .tool .tool-icon svg,
  .tool-palette .tool .tool-icon svg {
    width: 32px;
    height: 32px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .tool-palette .tool .tool-icon { color: var(--ink); }
  /* Erase reads as a white-bodied glyph (like Select on its white tile) instead
     of grey line-art: filled white with a dark outline. Scoped to erase so
     Select / Connect / group icons keep their line-art style. */
  .toolbar .tool[data-id="erase"] .tool-icon svg,
  .tool-palette .tool[data-id="erase"] .tool-icon svg {
    fill: #fff;
    stroke: #2f3b57;
    stroke-width: 1.6;
    paint-order: stroke;
  }
  .toolbar .tool-group-btn[data-group="terrain"]::before {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><path d='M3 19.5 9.2 7.7l4.1 7.1 2.3-3.2 5.4 7.9Z'/><path d='m9.2 7.7 2.2 3.7'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><path d='M3 19.5 9.2 7.7l4.1 7.1 2.3-3.2 5.4 7.9Z'/><path d='m9.2 7.7 2.2 3.7'/></svg>");
  }
  .toolbar .tool-group-btn[data-group="plants"]::before {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><path d='M12 21V11'/><path d='M12 11C8.2 10.7 6 8.4 5.4 4.5 9.2 4.8 11.4 7.1 12 11Z'/><path d='M12 13c3.7-.3 5.9-2.6 6.5-6.5-3.8.3-6 2.6-6.5 6.5Z'/><path d='M7 21h10'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><path d='M12 21V11'/><path d='M12 11C8.2 10.7 6 8.4 5.4 4.5 9.2 4.8 11.4 7.1 12 11Z'/><path d='M12 13c3.7-.3 5.9-2.6 6.5-6.5-3.8.3-6 2.6-6.5 6.5Z'/><path d='M7 21h10'/></svg>");
  }
  .toolbar .tool-group-btn[data-group="build"]::before {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><path d='M3.5 10.2 12 3.8l8.5 6.4'/><path d='M5.8 9.4v10.1h12.4V9.4'/><path d='M10 19.5v-5.2h4v5.2'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><path d='M3.5 10.2 12 3.8l8.5 6.4'/><path d='M5.8 9.4v10.1h12.4V9.4'/><path d='M10 19.5v-5.2h4v5.2'/></svg>");
  }
  .toolbar .tool-group-btn[data-group="infra"]::before {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><circle cx='6' cy='18' r='2.6'/><circle cx='18' cy='6' r='2.6'/><path d='M8.6 18H16a3 3 0 0 0 0-6H8a3 3 0 0 1 0-6h7.4'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><circle cx='6' cy='18' r='2.6'/><circle cx='18' cy='6' r='2.6'/><path d='M8.6 18H16a3 3 0 0 0 0-6H8a3 3 0 0 1 0-6h7.4'/></svg>");
  }
  .toolbar .tool-group-btn[data-group="farm"]::before {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><path d='M12 21V5'/><path d='M7.2 8.1 12 12.9l4.8-4.8'/><path d='M7.2 13.2 12 18l4.8-4.8'/><path d='M5 20h14'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><path d='M12 21V5'/><path d='M7.2 8.1 12 12.9l4.8-4.8'/><path d='M7.2 13.2 12 18l4.8-4.8'/><path d='M5 20h14'/></svg>");
  }
  .toolbar .tool-group-btn[data-group="life"]::before {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><circle cx='7.5' cy='10' r='2.2'/><circle cx='12' cy='7' r='2.2'/><circle cx='16.5' cy='10' r='2.2'/><path d='M6.6 17.6c0-3.2 2.4-5.4 5.4-5.4s5.4 2.2 5.4 5.4c0 1.5-.9 2.4-2.2 2.4-1.1 0-1.8-.8-3.2-.8s-2.1.8-3.2.8c-1.3 0-2.2-.9-2.2-2.4Z'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><circle cx='7.5' cy='10' r='2.2'/><circle cx='12' cy='7' r='2.2'/><circle cx='16.5' cy='10' r='2.2'/><path d='M6.6 17.6c0-3.2 2.4-5.4 5.4-5.4s5.4 2.2 5.4 5.4c0 1.5-.9 2.4-2.2 2.4-1.1 0-1.8-.8-3.2-.8s-2.1.8-3.2.8c-1.3 0-2.2-.9-2.2-2.4Z'/></svg>");
  }

  /* Select + Erase render as clean monochrome icons rather than coloured
     swatches. Mask-image draws the glyph in currentColor (ink), so they
     match the group-name typography. */
  .tool .swatch.select,
  .tool .swatch.eraser {
    background: currentColor !important;
    border: none !important;
    box-shadow: none !important;
    filter: none !important;
    color: var(--ink);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: 20px 20px;
    mask-size: 20px 20px;
  }
  .tool .swatch.select::before { content: none !important; }
  .tool .swatch.select {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'><path d='M4 3.5 18.8 11l-6.2 1.6-3.1 6.2Z'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'><path d='M4 3.5 18.8 11l-6.2 1.6-3.1 6.2Z'/></svg>");
  }
  .tool .swatch.eraser {
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><path d='M4 6.5h16'/><path d='M9 6.5V4.7c0-.9.7-1.6 1.6-1.6h2.8c.9 0 1.6.7 1.6 1.6v1.8'/><path d='m18.5 6.5-.8 13.1c-.1.8-.8 1.4-1.6 1.4H7.9c-.8 0-1.5-.6-1.6-1.4L5.5 6.5'/><path d='M10 11v5.5'/><path d='M14 11v5.5'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.15' stroke-linecap='round' stroke-linejoin='round'><path d='M4 6.5h16'/><path d='M9 6.5V4.7c0-.9.7-1.6 1.6-1.6h2.8c.9 0 1.6.7 1.6 1.6v1.8'/><path d='m18.5 6.5-.8 13.1c-.1.8-.8 1.4-1.6 1.4H7.9c-.8 0-1.5-.6-1.6-1.4L5.5 6.5'/><path d='M10 11v5.5'/><path d='M14 11v5.5'/></svg>");
  }

  /* Select + Erase: icon only — drop the text label and kbd badge so the
     glyph stands alone, matching the rest of the icon-only chrome. */
  .toolbar .tool:has(.swatch.select) > span:not(.tool-icon),
  .toolbar .tool:has(.swatch.select) > kbd,
  .toolbar .tool:has(.swatch.eraser) > span:not(.tool-icon),
  .toolbar .tool:has(.swatch.eraser) > kbd {
    display: none !important;
  }
  .toolbar .tool:has(.swatch.select),
  .toolbar .tool:has(.swatch.eraser),
  .toolbar .tool.icon-only {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
  }
  .toolbar .tool.icon-only > span:not(.tool-icon),
  .toolbar .tool.icon-only > kbd {
    display: none !important;
  }
  .toolbar .tool:has(.swatch.select) .swatch,
  .toolbar .tool:has(.swatch.eraser) .swatch {
    width: 22px;
    height: 22px;
    -webkit-mask-size: 20px 20px;
    mask-size: 20px 20px;
  }

  .unsaved-banner {
    position: fixed;
    bottom: 116px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 248, 226, 0.95);
    border: 1px solid #e3cb86;
    color: #7a5d18;
    padding: 8px 14px 8px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1;
    z-index: 11;
    pointer-events: none;
    box-shadow: 0 8px 28px -18px rgba(70, 50, 10, 0.35);
    display: flex;
    align-items: center;
    gap: 9px;
    white-space: nowrap;
    max-width: calc(100vw - 32px);
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  .unsaved-banner.visible { opacity: 1; }
  .unsaved-banner[hidden] { display: none; }
  .unsaved-banner .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #d9a82b;
    box-shadow: 0 0 0 4px rgba(217, 168, 43, 0.18);
    flex-shrink: 0;
  }

  .help {
    position: fixed;
    top: 88px; right: 28px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(235, 227, 210, 0.9);
    border-radius: 12px;
    padding: 8px 10px;
    font-size: 11.5px;
    color: var(--muted);
    text-align: right;
    line-height: 1.5;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 8px 28px -22px rgba(50, 35, 10, 0.4);
  }
  .help kbd {
    display: inline-block;
    padding: 1.5px 5px;
    border-radius: 4px;
    background: var(--panel);
    border: 1px solid var(--line);
    font-size: 10.5px;
    font-family: inherit;
    color: var(--ink);
    box-shadow: 0 1px 0 rgba(0,0,0,0.03);
  }

  .grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.5;
    mix-blend-mode: multiply;
    z-index: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.4 0 0 0 0 0.3 0 0 0 0 0.15 0 0 0 0.05 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  }

  .chev {
    font-size: 10px;
    color: #b9b1a3;
    margin-top: -4px;
    line-height: 1;
  }

  /* Submenu flyout — pops above the toolbar with an OWB-style spring
     animation.  Tinyworld's existing icons (3D tool thumbnails) stay
     unchanged; only the show/hide transition is new.  Open state is
     driven by the `.open` class; `hidden` still hides for a11y. */
  .flyout {
    position: fixed;
    background: rgba(255, 255, 255, 0.6);
    padding: 4px 6px 6px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 18px;
    display: flex;
    gap: 4px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    z-index: 36;
    transform-origin: bottom center;
    transform: translate(-50%, 14px) scaleX(0.42) scaleY(0.92);
    opacity: 0;
    pointer-events: none;
    max-width: calc(100vw - 32px);
    overflow-x: auto;
    transition:
      transform 0.26s cubic-bezier(0.34, 1.36, 0.64, 1),
      opacity 0.16s ease-out;
  }
  .flyout.open {
    transform: translate(-50%, 0) scaleX(1) scaleY(1);
    opacity: 1;
    pointer-events: auto;
  }
  /* Stagger each tool/variant entry as the flyout opens so they cascade
     in like OWB's drawer items. */
  .flyout > * {
    opacity: 0;
    transform: translateX(-10px) scale(0.88);
    transition: opacity 0.18s ease-out, transform 0.20s cubic-bezier(0.34, 1.36, 0.64, 1);
  }
  .flyout.open > * {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  .flyout.open > *:nth-child(1) { transition-delay: 0.02s; }
  .flyout.open > *:nth-child(2) { transition-delay: 0.05s; }
  .flyout.open > *:nth-child(3) { transition-delay: 0.08s; }
  .flyout.open > *:nth-child(4) { transition-delay: 0.11s; }
  .flyout.open > *:nth-child(5) { transition-delay: 0.13s; }
  .flyout.open > *:nth-child(6) { transition-delay: 0.15s; }
  .flyout.open > *:nth-child(7) { transition-delay: 0.17s; }
  .flyout.open > *:nth-child(n+8) { transition-delay: 0.19s; }
  /* Group popout: a compact 2-row block of icons instead of one long row.
     Column count is set inline (ceil(n/2)) in renderToolGroupFlyout. */
  .flyout.tool-menu {
    display: grid;
    grid-auto-flow: row;
    gap: 4px;
    align-content: start;
    justify-content: center;
  }

  /* Floating block palette — shown when "Show groups" is off. */
  body.hide-groups .toolbar { display: none; }
  .tool-palette {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 13;
    width: 320px;
    height: 208px;
    min-width: 104px;
    min-height: 120px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    padding: 4px 6px 8px;
    gap: 2px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 18px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    overflow: hidden;
    resize: both;
  }
  .tool-palette[hidden] { display: none; }
  .tool-palette-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 4px 4px;
    cursor: grab;
    user-select: none;
  }
  /* Grab cue in place of the old title. */
  .tool-palette-head::after {
    content: '';
    width: 28px;
    height: 4px;
    border-radius: 999px;
    background: rgba(120, 130, 150, 0.35);
  }
  .tool-palette.dragging .tool-palette-head { cursor: grabbing; }
  .tool-palette-grid {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    display: grid;
    grid-template-columns: repeat(auto-fill, 64px);
    grid-auto-rows: 62px;
    gap: 4px;
    justify-content: center;
    align-content: start;
    scrollbar-width: thin;
  }
  /* The palette reuses .flyout-tool blocks, but they live outside .flyout, so
     restate the sizing the .flyout-scoped rule would otherwise give them. */
  .tool-palette .tool.flyout-tool {
    width: 62px;
    height: 60px;
    font-size: 10.5px;
    padding: 1px 3px 5px;
    justify-content: flex-start;
    gap: 1px;
    border-color: rgba(255, 255, 255, 0.55);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
  }

  /* Outline the block square itself to match the glyph: a dark border in the
     icon's darkened category colour + an inner white line. */
  .tool.flyout-tool[data-pos-type="terrain"],
  .tool[data-pos-type="terrain"] {
    border: 1.5px solid #3a6511;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 rgba(58, 101, 17, 0.22),
      0 2px 3px -1px rgba(20, 30, 50, 0.22);
  }
  .tool.flyout-tool[data-pos-type="primary"],
  .tool[data-pos-type="primary"] {
    border: 1.5px solid #1e428a;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 rgba(30, 66, 138, 0.22),
      0 2px 3px -1px rgba(20, 30, 50, 0.22);
  }
  .tool.flyout-tool[data-pos-type="tertiary"],
  .tool[data-pos-type="tertiary"] {
    border: 1.5px solid #a05600;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 rgba(160, 86, 0, 0.22),
      0 2px 3px -1px rgba(20, 30, 50, 0.22);
  }
  .tool.flyout-tool[data-pos-type="shield"],
  .tool[data-pos-type="shield"] {
    border: 1.5px solid #0e5f7e;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 rgba(14, 95, 126, 0.22),
      0 2px 3px -1px rgba(20, 30, 50, 0.22);
  }
  /* The tool-group bottom dock also gets a subtle press feel matching
     OWB's dock-btn.  Existing icons keep their thumbnails; only the
     active-state indicator gets the OWB accent underline. */
  .tool-group-btn:active { transform: scale(0.96); }
  .tool-group-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px; left: 50%;
    transform: translateX(-50%);
    width: 16px; height: 2px;
    background: var(--accent);
    border-radius: 2px;
  }
  .tool-group-btn { position: relative; }
  .flyout.tool-menu {
    padding: 4px 6px 6px;
    gap: 4px;
  }
  .flyout .tool.flyout-tool {
    width: 62px;
    height: 60px;
    font-size: 10.5px;
    padding: 1px 3px 5px;
    justify-content: flex-start;
    gap: 1px;
    /* Same etched edge effect as the properties-panel chips. */
    border-color: rgba(255, 255, 255, 0.55);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
  }
  .flyout .tool.flyout-tool .tool-thumb {
    width: 42px;
    height: 42px;
  }
  /* Lock label/kbd line-height so the button stays single-line regardless
     of the page font's default leading. */
  .flyout .tool.flyout-tool > span:not(.chev),
  .flyout .tool.flyout-tool > kbd {
    line-height: 1;
    margin: 0;
  }
  /* Block buttons (popout + palette): drop the keyboard shortcut entirely
     and keep a bold label, no hover swap. */
  .tool.flyout-tool kbd { display: none; }
  .tool.flyout-tool > span:not(.chev) { font-weight: 800; }

  /* Unified block buttons: bottom toolbar, grouped toolbar buttons, popouts,
     and the floating palette all share the same raised category outline. */
  .toolbar .tool[data-pos-type],
  .toolbar .tool-group-btn[data-pos-type],
  .tool-palette .tool.flyout-tool[data-pos-type],
  .flyout .tool.flyout-tool[data-pos-type] {
    --block-outline: #2f3b57;
    --block-bg: rgba(255, 255, 255, 0.42);
    --block-hover-bg: rgba(255, 255, 255, 0.62);
    --block-bevel: rgba(47, 59, 87, 0.20);
    color: var(--block-outline);
    background: var(--block-bg);
    border: 1.5px solid var(--block-outline);
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 var(--block-bevel),
      0 2px 3px -1px rgba(20, 30, 50, 0.22);
  }
  .toolbar .tool[data-pos-type]:hover,
  .toolbar .tool-group-btn[data-pos-type]:hover,
  .tool-palette .tool.flyout-tool[data-pos-type]:hover,
  .flyout .tool.flyout-tool[data-pos-type]:hover {
    color: var(--block-outline);
    background: var(--block-hover-bg);
    border-color: var(--block-outline);
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.96),
      inset 0 -3px 0 var(--block-bevel),
      0 3px 6px -2px rgba(20, 30, 50, 0.28);
  }
  .toolbar .tool[data-pos-type="terrain"],
  .toolbar .tool-group-btn[data-pos-type="terrain"],
  .tool-palette .tool.flyout-tool[data-pos-type="terrain"],
  .flyout .tool.flyout-tool[data-pos-type="terrain"] {
    --block-outline: #3a6511;
    --block-bg: rgba(123, 194, 48, 0.16);
    --block-hover-bg: rgba(123, 194, 48, 0.30);
    --block-bevel: rgba(58, 101, 17, 0.22);
  }
  .toolbar .tool[data-pos-type="primary"],
  .toolbar .tool-group-btn[data-pos-type="primary"],
  .tool-palette .tool.flyout-tool[data-pos-type="primary"],
  .flyout .tool.flyout-tool[data-pos-type="primary"] {
    --block-outline: #1e428a;
    --block-bg: rgba(23, 107, 235, 0.13);
    --block-hover-bg: rgba(23, 107, 235, 0.24);
    --block-bevel: rgba(30, 66, 138, 0.22);
  }
  .toolbar .tool[data-pos-type="tertiary"],
  .toolbar .tool-group-btn[data-pos-type="tertiary"],
  .tool-palette .tool.flyout-tool[data-pos-type="tertiary"],
  .flyout .tool.flyout-tool[data-pos-type="tertiary"] {
    --block-outline: #a05600;
    --block-bg: rgba(254, 146, 14, 0.18);
    --block-hover-bg: rgba(254, 146, 14, 0.32);
    --block-bevel: rgba(160, 86, 0, 0.22);
  }
  .toolbar .tool[data-pos-type="shield"],
  .toolbar .tool-group-btn[data-pos-type="shield"],
  .tool-palette .tool.flyout-tool[data-pos-type="shield"],
  .flyout .tool.flyout-tool[data-pos-type="shield"] {
    --block-outline: #0e5f7e;
    --block-bg: rgba(45, 215, 255, 0.15);
    --block-hover-bg: rgba(45, 215, 255, 0.28);
    --block-bevel: rgba(14, 95, 126, 0.22);
  }
  .toolbar .tool[data-pos-type="neutral"],
  .toolbar .tool-group-btn[data-pos-type="neutral"],
  .tool-palette .tool.flyout-tool[data-pos-type="neutral"],
  .flyout .tool.flyout-tool[data-pos-type="neutral"] {
    --block-outline: #2f3b57;
    --block-bg: rgba(255, 255, 255, 0.42);
    --block-hover-bg: rgba(255, 255, 255, 0.62);
    --block-bevel: rgba(47, 59, 87, 0.20);
  }
  .toolbar .tool[data-pos-type] .tool-icon,
  .toolbar .tool-group-btn[data-pos-type] .group-icon,
  .tool-palette .tool.flyout-tool[data-pos-type] .tool-icon,
  .flyout .tool.flyout-tool[data-pos-type] .tool-icon {
    color: var(--block-outline);
  }
  .toolbar .tool-group-btn[data-pos-type] .group-icon-glyph {
    --glyph-outline: var(--block-outline);
  }
  .flyout[hidden] { display: none; }
  .flyout-item {
    min-width: 56px;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
  }
  .flyout-item:hover { background: var(--line-soft); color: var(--ink); }
  .flyout-item.active {
    background: rgba(255, 255, 255, 0.78);
    border-color: rgba(255, 255, 255, 0.6);
    color: var(--ink);
  }

  /* -------- floating agent -------- */
  .agent-input {
    --agent-pulse-rgb: 214, 169, 59;
    position: fixed;
    left: 50%;
    bottom: 138px;
    transform: translateX(-50%);
    z-index: 12;
    width: min(380px, calc(100vw - 48px));
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 20px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    display: grid;
    grid-template-columns: 34px 1fr 40px;
    align-items: center;
    gap: 8px;
    padding: 8px;
    transition: border-color 0.18s ease, border-radius 0.18s ease, box-shadow 0.18s ease;
  }
  .agent-input.conversation-open {
    border-top-color: rgba(255, 255, 255, 0.30);
    border-radius: 0 0 20px 20px;
  }
  .agent-input.has-target {
    grid-template-columns: 34px minmax(86px, auto) minmax(120px, 1fr) 40px;
    width: min(520px, calc(100vw - 48px));
  }
  .agent-input.dragging { opacity: 0.92; }

  /* Subtle in-place progress while the agent is thinking / generating. */
  .agent-input.busy {
    border-color: rgba(var(--agent-pulse-rgb), 0.38);
    animation: agent-input-pulse 1.15s ease-in-out infinite;
  }

  @keyframes agent-input-pulse {
    0%, 100% {
      box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.85) inset,
        0 0 0 1px rgba(var(--agent-pulse-rgb), 0.22) inset,
        0 -1px 0 rgba(120, 130, 150, 0.10) inset,
        0 1px 2px rgba(20, 30, 50, 0.06),
        0 14px 38px -12px rgba(40, 50, 80, 0.24),
        0 0 22px rgba(var(--agent-pulse-rgb), 0.10);
    }
    50% {
      box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.85) inset,
        0 0 0 1px rgba(var(--agent-pulse-rgb), 0.34) inset,
        0 -1px 0 rgba(120, 130, 150, 0.10) inset,
        0 1px 2px rgba(20, 30, 50, 0.06),
        0 15px 40px -12px rgba(40, 50, 80, 0.26),
        0 0 26px rgba(var(--agent-pulse-rgb), 0.16);
    }
  }
  body.tool-flyout-open .agent-input {
    transform: translate(-50%, -92px);
    transition: transform 0.24s cubic-bezier(0.34, 1.36, 0.64, 1);
  }

  .vehicle-demo-badge {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 75;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: 999px;
    background: rgba(22, 24, 28, 0.78);
    color: #fff8e6;
    box-shadow: 0 16px 36px rgba(36, 28, 12, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(14px) saturate(1.2);
    font-size: 12px;
    letter-spacing: 0.02em;
    pointer-events: none;
  }
  .vehicle-demo-badge strong {
    font-weight: 800;
    color: #8fffd8;
  }
  .vehicle-demo-badge span {
    color: rgba(255, 248, 230, 0.76);
  }
  .vehicle-demo-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #21f5ac;
    box-shadow: 0 0 0 0 rgba(33, 245, 172, 0.52), 0 0 18px rgba(33, 245, 172, 0.82);
    animation: vehicle-demo-pulse 1.1s ease-in-out infinite;
  }
  body.vehicle-demo-active .agent-input,
  body.vehicle-demo-active #agent-panel,
  body.vehicle-demo-active #agent-panel-handle,
  body.vehicle-demo-active #crowd-panel,
  body.vehicle-demo-active #crowd-panel-handle,
  body.vehicle-demo-active #stamp-builder-panel {
    display: none;
  }
  @keyframes vehicle-demo-pulse {
    0%, 100% { transform: scale(0.86); box-shadow: 0 0 0 0 rgba(33, 245, 172, 0.52), 0 0 18px rgba(33, 245, 172, 0.82); }
    50% { transform: scale(1.12); box-shadow: 0 0 0 7px rgba(33, 245, 172, 0), 0 0 24px rgba(33, 245, 172, 0.92); }
  }

  /* Suggestion chips — float under the input bar and follow it when
     dragged (positioned absolute against .agent-input). Wrap onto
     multiple rows so longer suggestions don't clip. */
  .agent-suggestions {
    position: absolute;
    left: -40px;
    right: -40px;
    top: calc(100% + 8px);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 2px;
    grid-column: 1 / -1;
  }
  .agent-suggestions[hidden] { display: none; }
  .agent-suggestion-chip {
    flex-shrink: 0;
    padding: 4px 10px;
    font: inherit;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 1px 2px rgba(20, 30, 50, 0.05);
    transition: background 0.12s, transform 0.08s;
  }
  .agent-suggestion-chip:hover { background: rgba(255, 255, 255, 0.85); }
  .agent-suggestion-chip:active { transform: translateY(1px); }
  .agent-send,
  .agent-panel-toggle,
  .agent-panel-clear {
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.45);
    color: var(--ink);
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 1px 2px rgba(20, 30, 50, 0.04);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    transition: background 0.12s, border-color 0.12s;
  }
  .agent-send:hover,
  .agent-panel-toggle:hover,
  .agent-panel-clear:hover {
    background: rgba(255, 255, 255, 0.68);
    border-color: rgba(255, 255, 255, 0.75);
  }
  /* Drag grip — icon only, no border, no fill. */
  .agent-grip {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: grab;
    font: inherit;
    padding: 0;
    box-shadow: none;
    transition: color 0.12s;
  }
  .agent-grip:hover { color: var(--ink); }
  .agent-grip,
  .agent-send {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .agent-grip { cursor: grab; color: #8a7a58; }
  .agent-input.dragging .agent-grip { cursor: grabbing; }
  .agent-target-chip {
    border: 1px solid rgba(176, 148, 74, 0.32);
    background: rgba(255, 246, 196, 0.62);
    color: #4a3b1f;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-size: 11.5px;
    font-weight: 800;
    min-width: 0;
    max-width: 190px;
    height: 30px;
    padding: 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.86) inset,
      0 1px 2px rgba(60, 45, 12, 0.06);
    backdrop-filter: blur(10px) saturate(160%);
    -webkit-backdrop-filter: blur(10px) saturate(160%);
  }
  .agent-target-chip:hover {
    background: rgba(255, 248, 210, 0.86);
    border-color: rgba(176, 148, 74, 0.48);
  }
  .agent-target-chip[hidden] { display: none; }
  .agent-input input {
    border: none;
    background: transparent;
    outline: none;
    font: inherit;
    color: var(--ink);
    min-width: 0;
  }
  .agent-input input::placeholder { color: #a39a8c; }
  .agent-send { font-weight: 800; }
  .agent-send:disabled { opacity: 0.45; cursor: wait; }
  .agent-panel {
    position: fixed;
    left: 50%;
    right: auto;
    bottom: calc(138px + 52px - 1px);
    top: auto;
    transform: translateX(-50%);
    z-index: 12;
    width: min(380px, calc(100vw - 48px));
    max-height: min(42vh, 340px);
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 20px 20px 0 0;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform-origin: bottom center;
    transition:
      width 0.32s cubic-bezier(0.22, 1, 0.36, 1),
      max-height 0.32s cubic-bezier(0.22, 1, 0.36, 1),
      border-radius 0.32s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.36s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.28s ease;
  }
  /* Legacy collapsed toast pill. The normal flow now folds fully back into
     the prompt bar, but the class is still toggled by a few older paths. */
  .agent-panel.collapsed {
    max-height: 42px;
    border-radius: 14px;
    overflow: hidden;
  }

  /* Hidden state: the transcript folds into the prompt bar. */
  .agent-panel.hidden {
    max-height: 0;
    border-width: 0;
    transform: translate(-50%, 10px) scaleY(0.94) !important;
    opacity: 0.0;
    pointer-events: none;
    transition:
      max-height 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.36s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.28s ease;
  }

  /* Legacy right-edge handle retained in markup for compatibility; the prompt
     itself is now the conversation opener. */
  .agent-panel-handle {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 13;
    width: 34px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    letter-spacing: -1px;
    color: #8a7a58;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 20px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.12s;
    user-select: none;
  }
  .agent-panel-handle { display: none !important; }
  .agent-panel-handle:hover {
    color: var(--ink);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 3px rgba(20, 30, 50, 0.08),
      0 16px 40px -10px rgba(40, 50, 80, 0.28);
    transform: translateY(-50%) scale(1.02);
  }
  .agent-panel-handle:active { transform: translateY(-50%) scale(0.98); }

  /* Visibility gate: the handle only exists in the layout when there has been
     at least one real assistant message or selection activity. */
  .agent-panel-handle[hidden] { display: none; }
  .agent-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(120, 130, 150, 0.12);
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
  }
  .agent-panel.collapsed .agent-panel-head { display: none; }
  /* Selection preview — replaces the messages stream when something on
     the canvas is selected. */
  .agent-selection-preview {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid rgba(120, 130, 150, 0.12);
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .agent-selection-preview[hidden] { display: none; }
  .agent-selection-preview.selection-staging { display: none !important; }
  .agent-panel.collapsed .agent-selection-preview { display: none; }
  .agent-selection-count {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
  }
  .agent-selection-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: var(--ink);
    max-height: 180px;
    overflow-y: auto;
  }
  .agent-selection-list li {
    display: flex;
    justify-content: space-between;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 8px;
  }
  .agent-selection-list li .count {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
  }
  .agent-selection-properties {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 4px;
  }
  .agent-selection-properties[hidden] { display: none; }
  .selection-prop-category-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.48);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset;
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    backdrop-filter: blur(12px) saturate(180%);
  }
  .selection-prop-category-tab {
    min-width: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.2;
    padding: 6px 7px;
    cursor: pointer;
  }
  .selection-prop-category-tab:hover {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.46);
  }
  .selection-prop-category-tab.active,
  .selection-prop-category-tab[aria-selected="true"] {
    color: #214f8e;
    background: rgba(255, 255, 255, 0.92);
    box-shadow:
      0 1px 2px rgba(20, 30, 50, 0.10),
      0 1px 0 rgba(255, 255, 255, 0.72) inset;
    -webkit-backdrop-filter: blur(12px) saturate(190%);
    backdrop-filter: blur(12px) saturate(190%);
  }
  .selection-prop-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .selection-prop-section + .selection-prop-section {
    border-top: 1px solid rgba(120, 130, 150, 0.16);
    padding-top: 8px;
  }
  .selection-prop-section-title {
    border: 0;
    background: transparent;
    padding: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.2;
    text-transform: uppercase;
    color: #6a7688;
    cursor: pointer;
    text-align: left;
  }
  .selection-prop-section-title:hover {
    color: var(--ink);
  }
  .selection-prop-section-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 9.5px;
    font-weight: 800;
    white-space: nowrap;
  }
  .selection-prop-section-cue {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.78);
    color: #6a7688;
    font-size: 12px;
    line-height: 1;
  }
  .selection-prop-section-cue::before {
    content: '-';
  }
  .selection-prop-section.is-collapsed .selection-prop-section-cue::before {
    content: '+';
  }
  .selection-prop-section.is-collapsed .selection-prop-row {
    display: none;
  }
  .selection-prop-row {
    display: grid;
    grid-template-columns: minmax(62px, 74px) 1fr;
    align-items: start;
    gap: 8px;
    min-height: 34px;
  }
  .selection-prop-label {
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0;
    line-height: 1.2;
    padding-top: 5px;
    text-transform: uppercase;
    color: #647085;
  }
  .selection-prop-options {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
  }
  .selection-prop-options.control-stepper,
  .selection-prop-options.control-axis {
    flex-wrap: nowrap;
  }
  .selection-prop-options.control-axis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 172px;
  }
  .selection-prop-options.control-move {
    display: grid;
    grid-template-columns: repeat(3, 28px);
    grid-template-rows: repeat(3, 28px);
    gap: 4px;
    width: max-content;
  }
  .selection-prop-options.control-move .selection-prop-chip[data-action="x-"] { grid-column: 1; grid-row: 2; }
  .selection-prop-options.control-move .selection-prop-chip[data-action="x+"] { grid-column: 3; grid-row: 2; }
  .selection-prop-options.control-move .selection-prop-chip[data-action="z-"] { grid-column: 2; grid-row: 1; }
  .selection-prop-options.control-move .selection-prop-chip[data-action="z+"] { grid-column: 2; grid-row: 3; }
  .selection-prop-options.control-move .selection-prop-chip[data-action="center"] { grid-column: 2; grid-row: 2; }
  .selection-prop-options.control-move .selection-prop-chip[data-action="y-"] { grid-column: 1; grid-row: 3; }
  .selection-prop-options.control-move .selection-prop-chip[data-action="y+"] { grid-column: 3; grid-row: 1; }
  .selection-prop-chip {
    min-height: 24px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.48);
    color: var(--ink);
    font: inherit;
    font-size: 11.5px;
    font-weight: 650;
    padding: 3px 9px;
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    backdrop-filter: blur(12px) saturate(180%);
    transition: background 0.12s, border-color 0.12s, transform 0.08s, box-shadow 0.12s;
  }
  .selection-prop-chip:hover {
    background: rgba(255, 255, 255, 0.75);
    border-color: rgba(60, 130, 247, 0.24);
  }
  .selection-prop-chip.active,
  .selection-prop-chip[aria-pressed="true"] {
    background: rgba(60, 130, 247, 0.15);
    border-color: rgba(60, 130, 247, 0.42);
    color: #214f8e;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.72) inset,
      0 0 0 1px rgba(60, 130, 247, 0.08);
    -webkit-backdrop-filter: blur(12px) saturate(190%);
    backdrop-filter: blur(12px) saturate(190%);
  }
  .selection-prop-chip:active { transform: translateY(1px); }
  .selection-prop-chip.icon-chip {
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 900;
    line-height: 1;
  }
  .selection-prop-chip.round-chip {
    border-radius: 50%;
  }
  .selection-prop-chip.reset-chip {
    min-width: 32px;
    padding-inline: 8px;
  }
  .selection-prop-chip.danger-chip {
    color: #8a2f2f;
    border-color: rgba(180, 70, 70, 0.26);
  }
  .selection-prop-chip[disabled] {
    cursor: default;
    opacity: 0.45;
    transform: none;
  }
  .selection-prop-chip[disabled]:hover {
    background: rgba(255, 255, 255, 0.48);
    border-color: rgba(255, 255, 255, 0.55);
  }
  .selection-prop-chip.color-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .selection-prop-swatch {
    width: 11px;
    height: 11px;
    border-radius: 4px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
    flex: 0 0 auto;
  }
  .agent-selection-hint {
    font-size: 11px;
    color: #647085;
    font-style: italic;
  }

  /* Tabbed selection: Preview / Properties switch (one pane visible at a time) */
  .selection-tabbar {
    display: inline-flex;
    background: rgba(255,255,255,0.45);
    border: 1px solid rgba(255, 255, 255, 0.48);
    border-radius: 999px;
    padding: 2px;
    margin-bottom: 8px;
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    backdrop-filter: blur(12px) saturate(180%);
  }
  .selection-tab {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 14px;
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.1s ease;
  }
  .selection-tab.active {
    background: #fff;
    color: var(--ink);
    box-shadow:
      0 1px 2px rgba(20,30,50,0.1),
      0 1px 0 rgba(255, 255, 255, 0.72) inset;
    -webkit-backdrop-filter: blur(12px) saturate(190%);
    backdrop-filter: blur(12px) saturate(190%);
  }
  .selection-tab-content { display: none; }
  .selection-tab-content.active { display: block; }
  .selection-preview-pane {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }
  .selection-preview-pane {
    width: 100%;
  }
  .selection-preview-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
    justify-content: center;
  }
  .selection-preview-actions .selection-prop-chip {
    font-size: 10px;
    padding: 2px 8px;
    min-height: 20px;
  }
  .selection-preview-pane canvas {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    display: block;
    border-radius: 10px;
    background: rgba(255,255,255,0.35);
    border: 1px solid rgba(255,255,255,0.5);
    box-shadow: 0 1px 2px rgba(20,30,50,0.08);
  }
  .selection-details-pane {
    min-width: 0;
  }
  body.ui-theme-dark .selection-prop-category-tab,
  body.ui-theme-dark .selection-prop-section-title,
  body.ui-theme-dark .selection-prop-section-meta,
  body.ui-theme-dark .selection-prop-label,
  body.ui-theme-dark .selection-tab,
  body.ui-theme-dark .agent-selection-hint {
    color: rgba(226, 232, 242, 0.74) !important;
  }
  body.ui-theme-dark .selection-prop-chip {
    color: #f4f7ff !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
  }
  body.ui-theme-dark .selection-prop-category-tabs,
  body.ui-theme-dark .selection-tabbar {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
  }
  body.ui-theme-dark .selection-prop-category-tab:hover,
  body.ui-theme-dark .selection-tab:hover,
  body.ui-theme-dark .selection-prop-chip:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    color: #f4f7ff !important;
  }
  body.ui-theme-dark .selection-prop-category-tab.active,
  body.ui-theme-dark .selection-prop-category-tab[aria-selected="true"],
  body.ui-theme-dark .selection-tab.active,
  body.ui-theme-dark .selection-prop-chip.active,
  body.ui-theme-dark .selection-prop-chip[aria-pressed="true"] {
    color: #0e1724 !important;
    background: #dce7f8 !important;
    border-color: rgba(220, 231, 248, 0.72) !important;
  }
  .agent-panel.has-selection .agent-messages { display: none; }
  .agent-panel-toggle {
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    font-weight: 500;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
  }
  .agent-panel-toggle:hover { color: var(--ink); }
  .agent-messages {
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  /* In collapsed mode, the messages container becomes a single horizontal
     line and only the most recent message renders (as an inline ticker). */
  .agent-panel.collapsed .agent-messages {
    flex-direction: row;
    align-items: center;
    padding: 0 16px;
    gap: 0;
    overflow: hidden;
    height: 38px;
  }
  .agent-panel.collapsed .agent-msg {
    display: none;
    background: transparent;
    border: none;
    margin: 0;
    padding: 0;
    font-size: 12.5px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    width: 100%;
    text-align: center;
  }
  .agent-panel.collapsed .agent-msg:last-child {
    display: block;
  }
  .agent-panel.collapsed:empty::before,
  .agent-panel.collapsed .agent-messages:empty::before {
    content: 'Ask the agent…';
    font-size: 12px;
    color: var(--muted);
    width: 100%;
    text-align: center;
  }
  .agent-msg {
    padding: 8px 10px;
    border-radius: 11px;
    font-size: 12.5px;
    line-height: 1.35;
    color: #3c3222;
    background: #f7f1e4;
    border: 1px solid #eadfc8;
  }
  .agent-msg.user {
    margin-left: 28px;
    color: #243717;
    background: #eef7d8;
    border-color: #b7d36d;
    /* Flatter right side for user messages */
    border-radius: 14px 14px 4px 14px;
  }
  .agent-msg.assistant {
    margin-right: 28px;
    color: #3c3222;
    background: #f7f1e4;
    border-color: #eadfc8;
    /* Distinct left side treatment for AI messages (flatter left, subtle accent) */
    border-radius: 14px 14px 14px 4px;
    border-left: 3px solid #c5a87a;
    padding-left: 9px;
  }
  .agent-msg.error {
    background: #f7e4df;
    border-color: #e2b8ac;
    color: #8a2f20;
  }
  body.ui-theme-dark .agent-msg.assistant {
    color: #f4f7ff !important;
    background: rgba(255, 255, 255, 0.09) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    border-left-color: rgba(197, 168, 122, 0.82) !important;
  }
  body.ui-theme-dark .agent-msg.user {
    color: #1d2b12 !important;
    background: #dcefb4 !important;
    border-color: #a8c95f !important;
  }
  body.ui-theme-dark .agent-msg.error {
    color: #7f2418 !important;
    background: #f6ded7 !important;
    border-color: #dfae9f !important;
  }
  @media (max-width: 700px) {
    .agent-input { bottom: 114px; width: min(360px, calc(100vw - 28px)); }
    .agent-input.has-target {
      grid-template-columns: 34px minmax(80px, 112px) minmax(80px, 1fr) 40px;
      width: min(420px, calc(100vw - 28px));
    }
    .agent-target-chip {
      max-width: 112px;
      padding: 0 8px;
    }
    .agent-panel { width: min(360px, calc(100vw - 28px)); }
  }

  .generation-plan-overlay {
    position: fixed;
    inset: 0;
    z-index: 6;
    pointer-events: none;
    display: block;
    opacity: 0;
    transition: opacity 0.22s ease;
  }
  .generation-plan-overlay.visible {
    opacity: 1;
  }
  .generation-plan-overlay[hidden] {
    display: none;
  }
  .generation-plan-overlay img {
    position: absolute;
    width: min(68vmin, 720px);
    height: min(68vmin, 720px);
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 4px;
    opacity: 0.48;
    mix-blend-mode: multiply;
    filter: saturate(1.12) contrast(1.08);
    box-shadow: none;
    transform-origin: 50% 50%;
  }
  body.generation-locked canvas {
    cursor: wait;
  }

  /* -------- generate modal -------- */
  .modal {
    position: fixed; inset: 0;
    background: rgba(20, 24, 40, 0.18);
    backdrop-filter: blur(8px) saturate(140%);
    -webkit-backdrop-filter: blur(8px) saturate(140%);
    z-index: 50;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 80px 20px 20px;
  }
  .modal[hidden] { display: none; }

  body.welcome-launch-open .brand,
  body.welcome-launch-open .brand-banner,
  body.welcome-launch-open .world-pill,
  body.welcome-launch-open .token-corner,
  body.welcome-launch-open .appbar,
  body.welcome-launch-open .controls,
  body.welcome-launch-open .toolbar,
  body.welcome-launch-open #tool-palette,
  body.welcome-launch-open .flyout,
  body.welcome-launch-open #layers-toggle,
  body.welcome-launch-open #layers-panel,
  body.welcome-launch-open #agent-input,
  body.welcome-launch-open #agent-panel,
  body.welcome-launch-open #agent-panel-handle,
  body.welcome-launch-open #xr-panel,
  body.welcome-launch-open .minimap-wrap,
  body.welcome-launch-open .sound-panel,
  body.welcome-launch-open .unsaved-banner {
    display: none !important;
  }
  .launch-modal {
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(20, 24, 40, 0.22);
  }

  :root {
    --radius-sm: 6px;
    --radius-md: 10px;   /* buttons, inputs, small controls */
    --radius-lg: 14px;   /* cards inside modals, options, panels */
    --radius-xl: 20px;   /* main modal cards */
  }

  .modal-card {
    background: rgba(255, 255, 255, 0.6);
    color: var(--ink);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: var(--radius-xl);
    padding: 18px 18px 14px;
    width: min(520px, 100%);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 24px 56px -16px rgba(40, 50, 80, 0.30);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    display: flex; flex-direction: column; gap: 10px;
    font-size: 13px;
  }
  .modal-card label {
    display: flex; flex-direction: column; gap: 4px;
    font-weight: 500; color: var(--muted);
  }
  .modal-card textarea,
  .modal-card input,
  .modal-card select {
    font: inherit;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 10px;
    padding: 8px 10px;
    outline: none;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 1px 2px rgba(20, 30, 50, 0.04);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
  }
  .modal-card textarea { resize: vertical; min-height: 64px; }
  .modal-card input:focus,
  .modal-card textarea:focus,
  .modal-card select:focus {
    border-color: rgba(60, 130, 247, 0.5);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 0 0 3px rgba(60, 130, 247, 0.15);
  }
  /* Glassify every range slider that lives inside a modal / settings panel /
     time popup / range-row. Tracks become translucent rails, thumbs become
     frosted pill glass. */
  .modal-card input[type="range"],
  .settings-panel input[type="range"],
  .range-row input[type="range"],
  .time-row input[type="range"],
  .gen-slider-row input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 14px;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    outline: none;
    cursor: pointer;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-radius: 0 !important;
  }
  .modal-card input[type="range"]::-webkit-slider-runnable-track,
  .settings-panel input[type="range"]::-webkit-slider-runnable-track,
  .range-row input[type="range"]::-webkit-slider-runnable-track,
  .time-row input[type="range"]::-webkit-slider-runnable-track,
  .gen-slider-row input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(120, 130, 150, 0.18);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  }
  .modal-card input[type="range"]::-moz-range-track,
  .settings-panel input[type="range"]::-moz-range-track,
  .range-row input[type="range"]::-moz-range-track,
  .time-row input[type="range"]::-moz-range-track,
  .gen-slider-row input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(120, 130, 150, 0.18);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  }
  .modal-card input[type="range"]::-webkit-slider-thumb,
  .settings-panel input[type="range"]::-webkit-slider-thumb,
  .range-row input[type="range"]::-webkit-slider-thumb,
  .time-row input[type="range"]::-webkit-slider-thumb,
  .gen-slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 14px;
    margin-top: -5px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.95) inset,
      0 1px 3px rgba(20, 30, 50, 0.22);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    cursor: pointer;
  }
  .modal-card input[type="range"]::-moz-range-thumb,
  .settings-panel input[type="range"]::-moz-range-thumb,
  .range-row input[type="range"]::-moz-range-thumb,
  .time-row input[type="range"]::-moz-range-thumb,
  .gen-slider-row input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 14px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.95) inset,
      0 1px 3px rgba(20, 30, 50, 0.22);
    cursor: pointer;
  }
  .modal-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 2px;
  }
  .modal-card:not(.welcome-card) .modal-head strong {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 500;
    font-size: 22px;
    line-height: 1.08;
    letter-spacing: -0.015em;
    color: var(--ink);
  }
  .modal-copy,
  .confirm-copy {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
    line-height: 1.52;
  }
  .modal-close {
    background: transparent;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0 4px;
  }
  .modal-close:hover { color: var(--ink); }
  .modal-card .row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .modal-foot {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
    margin-top: 4px;
  }
  .modal-foot #gen-status,
  .modal-foot #render-status {
    font-size: 12px;
    color: var(--muted);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .modal-foot #gen-status.error { color: #b84838; }
  .modal-foot #gen-status.busy::after {
    content: '…';
    animation: dots 1s steps(4, end) infinite;
  }
  @keyframes dots {
    0%, 20% { content: ''; }
    40%     { content: '.'; }
    60%     { content: '..'; }
    80%,100%{ content: '...'; }
  }
  @keyframes spin {
    to { transform: rotate(360deg); }
  }
  .modal-card .help-line {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.4;
  }
  /* --- Enhanced Generate panel (seed / biomes / elevation / plan) --- */
  .modal-card.gen-card {
    width: min(620px, calc(100vw - 32px));
    max-height: calc(100vh - 72px);
    overflow-y: auto;
    gap: 16px;
    padding: 24px 28px 20px;
    background: rgba(244, 245, 239, 0.82);
    border-color: rgba(255, 255, 255, 0.68);
    border-radius: 24px;
  }
  .gen-card .modal-head { margin-bottom: 0; }
  .gen-card > label {
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
  }
  .gen-card textarea {
    min-height: 78px;
    border-radius: 16px;
    background: rgba(255,255,255,0.78);
    border-color: rgba(120,130,150,0.18);
  }
  .gen-section {
    background: rgba(255,255,255,0.20);
    border: 0;
    border-top: 1px solid rgba(255,255,255,0.54);
    border-radius: 0;
    padding: 16px 0 0;
  }
  .gen-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }
  .gen-section-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: 0.09em;
    text-transform: uppercase;
  }
  .gen-section-sum {
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.48);
    border: 1px solid rgba(120,130,150,0.14);
    transition: background 0.12s, color 0.12s, border-color 0.12s;
  }
  .gen-section-sum.bad {
    background: #f8e2d9;
    border-color: #dfaa98;
    color: #8c3c25;
  }
  .gen-section-sum.good {
    background: #edf6df;
    border-color: #b6cf90;
    color: #4a6a2a;
  }
  .gen-row-seed {
    display: grid;
    grid-template-columns: 1fr repeat(3, 38px);
    align-items: center;
    gap: 10px;
  }
  .gen-row-seed input {
    min-width: 0;
    font: inherit;
    font-size: 13px;
    background: rgba(255,255,255,0.78);
    border: 1px solid rgba(120,130,150,0.18);
    border-radius: 14px;
    padding: 10px 12px;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
  }
  .gen-mini {
    background: rgba(255,255,255,0.52);
    border: 1px solid rgba(120,130,150,0.16);
    border-radius: 13px;
    cursor: pointer;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: background 0.12s, color 0.12s, transform 0.12s;
  }
  .gen-mini:hover { background: rgba(255, 255, 255, 0.78); color: var(--ink); }
  .gen-mini:active { transform: translateY(1px); }
  .gen-sliders {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .modal-card .gen-slider-row {
    display: grid;
    grid-template-columns: 136px minmax(130px, 1fr) 46px;
    align-items: center;
    gap: 14px;
    font-weight: 500;
    color: var(--muted);
    font-size: 13px;
  }
  .gen-slider-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
  }
  .gen-swatch {
    width: 11px;
    height: 11px;
    border-radius: 4px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.10);
    display: inline-block;
  }
  /* Gen sliders now fully inherit the main frosted rectangular slider style
     (no more special circular thumbs or thinner tracks) */
  .gen-slider-val {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    font-size: 12.5px;
  }
  .modal-card .gen-check {
    display: grid;
    grid-template-columns: 42px 1fr;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
  }
  .modal-card .gen-check + .gen-check { margin-top: 10px; }
  .gen-check input[type=checkbox] { margin: 0; }
  .gen-check .gen-hint {
    display: block;
    font-style: normal;
    color: var(--muted);
    font-size: 12px;
    margin: 2px 0 0;
  }

  /* --- Showcase mode (hide chrome, let the scene speak) --- */
  body.showcase .brand,
  body.showcase .controls,
  body.showcase .world-pill,
  body.showcase .tool-palette,
  body.showcase .brand-banner,
  body.showcase .toolbar,
  body.showcase .audio-panel,
  body.showcase .help,
  body.showcase .unsaved-banner,
  body.showcase .minimap-wrap,
  body.showcase #agent-input,
  body.showcase #agent-panel,
  body.showcase #agent-panel-handle,
  body.showcase #crowd-panel,
  body.showcase #crowd-panel-handle,
  body.showcase #stamp-builder-panel {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
  }
  body.showcase .controls #showcase-mode { opacity: 1; pointer-events: auto; }
  .showcase-exit {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 130;
    display: none;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 999px;
    border: 2px solid rgba(37, 73, 144, 0.96);
    background: rgba(255, 255, 255, 0.86);
    color: #253f78;
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.96),
      inset 0 -4px 0 rgba(37, 63, 120, 0.16),
      0 10px 24px rgba(28, 40, 68, 0.22);
    backdrop-filter: blur(10px);
    cursor: pointer;
  }
  body.showcase .showcase-exit { display: inline-flex; }
  .showcase-exit svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
  }
  .showcase-exit:hover { background: rgba(255, 255, 255, 0.96); }
  .showcase-exit:focus-visible {
    outline: 3px solid rgba(77, 124, 255, 0.34);
    outline-offset: 3px;
  }

  /* --- Minimap --- */
  .minimap-wrap {
    position: fixed;
    /* Default anchor: top-right, under the appbar icon pill.
       Overridden by JS-set top/left when the user drags it. */
    top: 72px; right: 24px;
    bottom: auto; left: auto;
    z-index: 30;
    display: flex; align-items: flex-start; gap: 6px;
    flex-direction: row-reverse;
    transition: transform 0.18s ease;
    cursor: grab;
    /* Stop the browser claiming touch-drags as page scroll before our pointer
       handlers run, so the minimap stays draggable on mobile. */
    touch-action: none;
    max-width: calc(100vw - 16px);
  }
  .minimap-wrap.dragging { cursor: grabbing; transition: none; }
  .minimap-wrap.collapsed { transform: none; }
  .minimap-card {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 18px;
    padding: 8px;
    box-sizing: border-box;
    max-width: 100%;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
  }
  .minimap-card canvas {
    display: block;
    width: min(168px, calc(100vw - 32px));
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
  }
  .minimap-wrap.collapsed .minimap-card canvas { display: none; }
  .minimap-foot {
    display: flex; justify-content: space-between;
    margin-top: 6px;
    font-size: 10.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
  }
  .minimap-toggle {
    font-size: 11px; line-height: 1; padding: 0 3px; margin-left: 4px;
    border: none; background: transparent; color: var(--muted); cursor: pointer;
  }
  .minimap-toggle:hover { color: var(--ink); }
  .minimap-autoexpand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 7px;
    padding-top: 7px;
    border-top: 1px solid rgba(255, 255, 255, 0.44);
    font-size: 10.5px;
    color: var(--ink);
    cursor: pointer;
    user-select: none;
  }
  .minimap-autoexpand input {
    appearance: none;
    width: 30px;
    height: 17px;
    border-radius: 999px;
    background: rgba(42, 39, 34, 0.22);
    border: 1px solid rgba(42, 39, 34, 0.16);
    position: relative;
    transition: background 0.16s ease, border-color 0.16s ease;
  }
  .minimap-autoexpand input::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 11px;
    height: 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 2px rgba(42, 39, 34, 0.22);
    transition: transform 0.16s ease;
  }
  .minimap-autoexpand input:checked {
    background: rgba(128, 174, 82, 0.82);
    border-color: rgba(88, 130, 42, 0.35);
  }
  .minimap-autoexpand input:checked::after {
    transform: translateX(13px);
  }
  .minimap-autoexpand.is-disabled {
    cursor: not-allowed;
    opacity: 0.55;
  }
  .minimap-autoexpand.is-disabled input {
    pointer-events: none;
    cursor: not-allowed;
  }
  /* --- Topbar popups (view / time / weather) --- */
  .topbar-popup {
    position: fixed;
    top: 28px; left: 84px; right: auto;
    z-index: 60;
    width: 240px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 16px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 12px 36px -12px rgba(40, 50, 80, 0.22);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    padding: 8px;
    font-size: 13px;
    color: var(--ink);
    animation: world-menu-pop 0.14s ease-out;
  }
  .topbar-popup[hidden] { display: none; }
  .topbar-popup-title {
    font-size: 10.5px; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--muted);
    padding: 4px 6px 8px;
  }
  .view-option {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    text-align: left;
    padding: 7px 8px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--ink);
    font: inherit;
  }
  .view-option:hover { background: rgba(255, 255, 255, 0.55); }
  .view-option.active {
    background: rgba(255, 255, 255, 0.78);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 1px 2px rgba(20, 30, 50, 0.06);
  }
  .view-thumb {
    width: 40px; height: 36px;
    border-radius: 6px;
    background: #f3ecdc;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .view-body { display: flex; flex-direction: column; line-height: 1.25; }
  .view-body strong { font-size: 12.5px; font-weight: 500; color: var(--ink); }
  .view-body em { font-style: normal; font-size: 11px; color: var(--muted); }

  .time-popup { width: 280px; }
  .time-row {
    display: flex; flex-direction: column; gap: 4px;
    padding: 6px 8px;
  }
  .time-row-label {
    font-size: 11px; font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.02em;
  }
  .time-row input[type=range] {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 4px;
    background: var(--line); border-radius: 999px; outline: none;
  }
  .time-row input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
  }
  .time-row-val {
    font-variant-numeric: tabular-nums;
    color: var(--ink); font-size: 12.5px;
    align-self: flex-end;
  }
  .time-row-pills { gap: 6px; }
  .pill-row { display: flex; gap: 4px; flex-wrap: wrap; }
  .pill {
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 4px 9px;
    border-radius: 999px;
    font: inherit;
    font-size: 11.5px;
    cursor: pointer;
  }
  .pill:hover { background: rgba(255, 255, 255, 0.55); }
  .pill.active {
    background: rgba(255, 255, 255, 0.78); border-color: rgba(255, 255, 255, 0.6);
    color: var(--ink); font-weight: 500;
  }
  .time-foot {
    padding: 6px 8px 2px;
    color: var(--muted);
    font-size: 10.5px;
  }
  .time-foot em { font-style: normal; }

  /* Subtle time-of-day + weather tint overlay (separate element so it
     never clobbers the live #cloud-layer animation). Sits above the canvas
     but below tooltips / modals. */
  #tod-tint {
    position: fixed; inset: 0;
    z-index: 9;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease, background 0.4s ease;
    background: transparent;
  }
  body.tod-dawn  #tod-tint { opacity: 1; background: linear-gradient(180deg, rgba(255, 200, 150, 0.18), transparent 55%); }
  body.tod-day   #tod-tint { opacity: 0; }
  body.tod-dusk  #tod-tint { opacity: 1; background: linear-gradient(180deg, rgba(255, 140, 90, 0.24), transparent 55%); }
  body.tod-night #tod-tint { opacity: 1; background: linear-gradient(180deg, rgba(10, 30, 70, 0.36), rgba(10, 30, 70, 0.1) 60%, transparent); }

  /* Night / dusk UI adaptation — solid off-white chrome so dark icons
     stay legible. Backdrop-filter is dropped because over a near-black
     scene a low-alpha background + blur reads as transparent — instead
     we paint a fully opaque pill. */
  body.tod-night .toolbar,
  body.tod-dusk  .toolbar,
  body.tod-night .controls,
  body.tod-dusk  .controls,
  body.tod-night .appbar,
  body.tod-dusk  .appbar,
  body.tod-night .agent-input,
  body.tod-dusk  .agent-input,
  body.tod-night .agent-panel,
  body.tod-dusk  .agent-panel,
  body.tod-night .crowd-panel,
  body.tod-dusk  .crowd-panel,
  body.tod-night .crowd-panel-handle,
  body.tod-dusk  .crowd-panel-handle,
  body.tod-night .minimap-card,
  body.tod-dusk  .minimap-card,
  body.tod-night .flyout,
  body.tod-dusk  .flyout,
  body.tod-night .tool-palette,
  body.tod-dusk  .tool-palette,
  body.tod-night .audio-panel,
  body.tod-dusk  .audio-panel,
  body.tod-night .sound-panel,
  body.tod-dusk  .sound-panel,
  body.tod-night .sound-icon,
  body.tod-dusk  .sound-icon,
  body.tod-night .layers-handle,
  body.tod-dusk  .layers-handle,
  body.tod-night .layers-panel,
  body.tod-dusk  .layers-panel,
  body.tod-night .topbar-popup,
  body.tod-dusk  .topbar-popup,
  body.tod-night .world-menu,
  body.tod-dusk  .world-menu,
  body.tod-night .stamp-panel,
  body.tod-dusk  .stamp-panel,
  body.tod-night .modal-card,
  body.tod-dusk  .modal-card {
    --ink: #2a2722;
    --muted: #6f695f;
    --line: rgba(120, 130, 150, 0.24);
    --line-soft: rgba(120, 130, 150, 0.14);
    background-color: #f3f5f9 !important;
    background-image: none !important;
    border-color: rgba(120, 130, 150, 0.35) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 1px 2px rgba(0, 0, 0, 0.25),
      0 20px 48px -14px rgba(0, 0, 0, 0.6) !important;
  }
  body.tod-night .brand .title,
  body.tod-dusk  .brand .title {
    color: #f0f4ff !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  }
  body.tod-night .brand .sub,
  body.tod-dusk  .brand .sub {
    color: rgba(225, 232, 245, 0.85) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  }
  /* Force ALL chrome icons + button surfaces to use dark ink colour so
     they stand out on the now-bright pills. Override hover/active that
     normally tints the icon. */
  body.tod-night .btn.icon,
  body.tod-dusk  .btn.icon,
  body.tod-night .toolbar .tool,
  body.tod-dusk  .toolbar .tool,
  body.tod-night .toolbar .tool-group-btn,
  body.tod-dusk  .toolbar .tool-group-btn,
  body.tod-night .agent-grip,
  body.tod-dusk  .agent-grip,
  body.tod-night .agent-input input,
  body.tod-dusk  .agent-input input,
  body.tod-night .modal-card,
  body.tod-dusk  .modal-card,
  body.tod-night .modal-card label,
  body.tod-dusk  .modal-card label,
  body.tod-night .modal-card output,
  body.tod-dusk  .modal-card output,
  body.tod-night .layers-panel,
  body.tod-dusk  .layers-panel,
  body.tod-night .layers-tab,
  body.tod-dusk  .layers-tab,
  body.tod-night .layers-tree summary,
  body.tod-dusk  .layers-tree summary,
  body.tod-night .layers-row,
  body.tod-dusk  .layers-row,
  body.tod-night .selection-prop-category-tab,
  body.tod-dusk  .selection-prop-category-tab,
  body.tod-night .selection-prop-section-title,
  body.tod-dusk  .selection-prop-section-title,
  body.tod-night .selection-prop-label,
  body.tod-dusk  .selection-prop-label,
  body.tod-night .selection-prop-chip,
  body.tod-dusk  .selection-prop-chip,
  body.tod-night .settings-section-title,
  body.tod-dusk  .settings-section-title,
  body.tod-night .range-row span,
  body.tod-dusk  .range-row span,
  body.tod-night .time-foot,
  body.tod-dusk  .time-foot,
  body.tod-night .modal-copy,
  body.tod-dusk  .modal-copy {
    color: var(--ink) !important;
  }
  body.tod-night .layers-panel::before,
  body.tod-dusk  .layers-panel::before {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0) 42%) !important;
  }
  body.tod-night .selection-prop-category-tabs,
  body.tod-dusk  .selection-prop-category-tabs,
  body.tod-night .selection-tabbar,
  body.tod-dusk  .selection-tabbar,
  body.tod-night .layers-tree details,
  body.tod-dusk  .layers-tree details {
    background: rgba(255, 255, 255, 0.66) !important;
    border-color: rgba(120, 130, 150, 0.22) !important;
  }
  body.tod-night .selection-prop-chip,
  body.tod-dusk  .selection-prop-chip {
    background: rgba(255, 255, 255, 0.78) !important;
    border-color: rgba(100, 110, 130, 0.26) !important;
  }
  body.tod-night .selection-prop-category-tab.active,
  body.tod-dusk  .selection-prop-category-tab.active,
  body.tod-night .selection-prop-category-tab[aria-selected="true"],
  body.tod-dusk  .selection-prop-category-tab[aria-selected="true"],
  body.tod-night .selection-prop-chip.active,
  body.tod-dusk  .selection-prop-chip.active,
  body.tod-night .selection-prop-chip[aria-pressed="true"],
  body.tod-dusk  .selection-prop-chip[aria-pressed="true"],
  body.tod-night .layers-tab.is-active,
  body.tod-dusk  .layers-tab.is-active {
    color: #214f8e !important;
    background: rgba(255, 255, 255, 0.94) !important;
    border-color: rgba(48, 72, 120, 0.58) !important;
  }
  /* Slider chrome inside settings — keep the rail readable too. */
  body.tod-night .modal-card input[type="range"]::-webkit-slider-runnable-track,
  body.tod-dusk  .modal-card input[type="range"]::-webkit-slider-runnable-track,
  body.tod-night .settings-panel input[type="range"]::-webkit-slider-runnable-track,
  body.tod-dusk  .settings-panel input[type="range"]::-webkit-slider-runnable-track {
    background: rgba(20, 30, 50, 0.18);
  }
  /* Popup label / value text — these inherit var(--muted) which becomes
     ghost-faint against the now-opaque white card. Push to dark ink. */
  body.tod-night .topbar-popup,
  body.tod-dusk  .topbar-popup,
  body.tod-night .topbar-popup-title,
  body.tod-dusk  .topbar-popup-title,
  body.tod-night .time-row-label,
  body.tod-dusk  .time-row-label,
  body.tod-night .time-row-val,
  body.tod-dusk  .time-row-val,
  body.tod-night .topbar-popup .pill,
  body.tod-dusk  .topbar-popup .pill {
    color: var(--ink) !important;
  }
  /* Agent input placeholder readable on the bright night chrome. */
  body.tod-night .agent-input input::placeholder,
  body.tod-dusk  .agent-input input::placeholder {
    color: rgba(60, 60, 70, 0.55) !important;
  }
  body.ui-theme-dark {
    --ink: #f4f7ff;
    --muted: #b9c2d0;
    --panel: #111722;
    --line: rgba(255, 255, 255, 0.16);
    --line-soft: rgba(255, 255, 255, 0.09);
    color: var(--ink);
  }
  body.ui-theme-dark .toolbar,
  body.ui-theme-dark .controls,
  body.ui-theme-dark .appbar,
  body.ui-theme-dark .agent-input,
  body.ui-theme-dark .agent-panel,
  body.ui-theme-dark .crowd-panel,
  body.ui-theme-dark .crowd-panel-handle,
  body.ui-theme-dark .minimap-card,
  body.ui-theme-dark .flyout,
  body.ui-theme-dark .tool-palette,
  body.ui-theme-dark .audio-panel,
  body.ui-theme-dark .sound-panel,
  body.ui-theme-dark .sound-icon,
  body.ui-theme-dark .layers-handle,
  body.ui-theme-dark .layers-panel,
  body.ui-theme-dark .topbar-popup,
  body.ui-theme-dark .world-menu,
  body.ui-theme-dark .stamp-panel,
  body.ui-theme-dark .mp-admit-panel,
  body.ui-theme-dark .mp-chat-panel,
  body.ui-theme-dark .mp-mod-menu,
  body.ui-theme-dark .mp-lobby-card,
  body.ui-theme-dark .modal-card,
  body.ui-theme-dark .world-pill,
  body.ui-theme-dark .tips-panel {
    --ink: #f4f7ff;
    --muted: #b9c2d0;
    --line: rgba(255, 255, 255, 0.18);
    --line-soft: rgba(255, 255, 255, 0.10);
    color: var(--ink) !important;
    background-color: rgba(16, 22, 33, 0.92) !important;
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)) !important;
    border-color: rgba(255, 255, 255, 0.16) !important;
    backdrop-filter: blur(22px) saturate(135%) !important;
    -webkit-backdrop-filter: blur(22px) saturate(135%) !important;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.12) inset,
      0 -1px 0 rgba(0, 0, 0, 0.36) inset,
      0 16px 42px -16px rgba(0, 0, 0, 0.72) !important;
  }
  body.ui-theme-dark .brand .title {
    color: #f4f7ff !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.72);
  }
  body.ui-theme-dark .brand .sub,
  body.ui-theme-dark .brand-title-btn .brand-chevron {
    color: rgba(226, 232, 242, 0.82) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  }
  body.ui-theme-dark .btn.icon,
  body.ui-theme-dark .toolbar .tool,
  body.ui-theme-dark .toolbar .tool-group-btn,
  body.ui-theme-dark .agent-grip,
  body.ui-theme-dark .agent-input input,
  body.ui-theme-dark .modal-card,
  body.ui-theme-dark .modal-card label,
  body.ui-theme-dark .modal-card output,
  body.ui-theme-dark .settings-section-title,
  body.ui-theme-dark .range-row span,
  body.ui-theme-dark .time-foot,
  body.ui-theme-dark .modal-copy,
  body.ui-theme-dark .topbar-popup,
  body.ui-theme-dark .topbar-popup-title,
  body.ui-theme-dark .time-row-label,
  body.ui-theme-dark .time-row-val,
  body.ui-theme-dark .topbar-popup .pill,
  body.ui-theme-dark .sound-panel,
  body.ui-theme-dark .sound-panel-head h3,
  body.ui-theme-dark .sound-section-title,
  body.ui-theme-dark .sound-track-item,
  body.ui-theme-dark .sound-mute,
  body.ui-theme-dark .sound-panel-close,
  body.ui-theme-dark .sound-icon,
  body.ui-theme-dark .layers-handle {
    color: var(--ink) !important;
  }
  body.ui-theme-dark input,
  body.ui-theme-dark select,
  body.ui-theme-dark textarea,
  body.ui-theme-dark .world-menu-input,
  body.ui-theme-dark .palette-search,
  body.ui-theme-dark .stamp-builder-search {
    color: #f4f7ff !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.16) !important;
  }
  body.ui-theme-dark input::placeholder,
  body.ui-theme-dark textarea::placeholder,
  body.ui-theme-dark .agent-input input::placeholder {
    color: rgba(215, 223, 236, 0.58) !important;
  }
  body.ui-theme-dark .settings-tab.active,
  body.ui-theme-dark .topbar-popup .pill.active,
  body.ui-theme-dark .btn.primary,
  body.ui-theme-dark .toolbar .tool.active,
  body.ui-theme-dark .toolbar .tool-group-btn.active {
    color: #0e1724 !important;
    background: #dce7f8 !important;
    border-color: rgba(220, 231, 248, 0.72) !important;
  }
  body.ui-theme-dark .sound-icon.open,
  body.ui-theme-dark .layers-handle.on,
  body.ui-theme-dark .sound-track-item.active {
    color: #0e1724 !important;
    background: #dce7f8 !important;
    border-color: rgba(220, 231, 248, 0.72) !important;
  }
  body.ui-theme-dark .sound-track-item:hover {
    background: rgba(255, 255, 255, 0.10) !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
  }
  body.ui-theme-dark .sound-track-item .track-dot {
    background: rgba(230, 237, 248, 0.38) !important;
  }
  body.ui-theme-dark .sound-track-item.active .track-dot {
    background: #45a35c !important;
    box-shadow: 0 0 0 3px rgba(69, 163, 92, 0.22) !important;
  }
  body.ui-theme-dark .sound-row input[type="range"]::-webkit-slider-runnable-track {
    background: rgba(230, 237, 248, 0.26) !important;
  }
  body.ui-theme-dark .sound-row input[type="range"]::-moz-range-track {
    background: rgba(230, 237, 248, 0.26) !important;
  }
  body.ui-theme-dark .sound-row input[type="range"]::-webkit-slider-thumb {
    background: #eef4ff !important;
    border-color: rgba(255, 255, 255, 0.70) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45) !important;
  }
  body.ui-theme-dark .sound-row input[type="range"]::-moz-range-thumb {
    background: #eef4ff !important;
    border-color: rgba(255, 255, 255, 0.70) !important;
  }
  body.ui-theme-dark .settings-panel input[type="range"]::-webkit-slider-runnable-track,
  body.ui-theme-dark .modal-card input[type="range"]::-webkit-slider-runnable-track {
    background: rgba(230, 237, 248, 0.26);
  }
  body.ui-theme-dark .world-menu-head,
  body.ui-theme-dark .world-menu-section + .world-menu-section,
  body.ui-theme-dark .world-menu-foot,
  body.ui-theme-dark .settings-tabs {
    border-color: rgba(255, 255, 255, 0.14) !important;
  }
  body.ui-theme-dark .world-menu-foot {
    background: rgba(8, 12, 18, 0.52) !important;
  }
  body.ui-theme-dark .world-menu-icon,
  body.ui-theme-dark .view-thumb,
  body.ui-theme-dark .layers-row-icon,
  body.ui-theme-dark .layers-count,
  body.ui-theme-dark .layers-row-coord,
  body.ui-theme-dark .selection-prop-section-cue,
  body.ui-theme-dark .settings-tab-count,
  body.ui-theme-dark .world-menu-foot-btn,
  body.ui-theme-dark .world-menu-rename {
    color: #dbe7f8 !important;
    background: rgba(255, 255, 255, 0.10) !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
  }
  body.ui-theme-dark .world-menu-slot.active,
  body.ui-theme-dark .settings-tab.active,
  body.ui-theme-dark .topbar-popup .pill.active,
  body.ui-theme-dark .view-option.active,
  body.ui-theme-dark .flyout-item.active,
  body.ui-theme-dark .layers-tab.is-active,
  body.ui-theme-dark .layers-row.is-selected,
  body.ui-theme-dark .layers-cell.is-selected > summary,
  body.ui-theme-dark .selection-tab.active,
  body.ui-theme-dark .selection-prop-category-tab.active,
  body.ui-theme-dark .selection-prop-category-tab[aria-selected="true"],
  body.ui-theme-dark .selection-prop-chip.active,
  body.ui-theme-dark .selection-prop-chip[aria-pressed="true"],
  body.ui-theme-dark .btn.primary,
  body.ui-theme-dark .toolbar .tool.active,
  body.ui-theme-dark .toolbar .tool-group-btn.active,
  body.ui-theme-dark .sound-icon.open,
  body.ui-theme-dark .layers-handle.on,
  body.ui-theme-dark .sound-track-item.active {
    color: #0e1724 !important;
    background: #dce7f8 !important;
    border-color: rgba(220, 231, 248, 0.72) !important;
  }
  body.ui-theme-dark .world-menu-slot.active .slot-date,
  body.ui-theme-dark .world-menu-slot.active .slot-delete,
  body.ui-theme-dark .settings-tab.active .settings-tab-hint,
  body.ui-theme-dark .layers-row.is-selected .layers-row-main em,
  body.ui-theme-dark .layers-row.is-selected .layers-row-coord,
  body.ui-theme-dark .layers-cell.is-selected .layers-cell-main em,
  body.ui-theme-dark .layers-cell.is-selected .layers-row-coord,
  body.ui-theme-dark .layers-cell.is-selected .layers-count {
    color: rgba(14, 23, 36, 0.68) !important;
  }
  body.ui-theme-dark .world-menu-item:hover,
  body.ui-theme-dark .world-menu-slot:hover,
  body.ui-theme-dark .layers-row:hover,
  body.ui-theme-dark .layers-tree details,
  body.ui-theme-dark .selection-prop-chip,
  body.ui-theme-dark .selection-prop-category-tabs,
  body.ui-theme-dark .selection-tabbar,
  body.ui-theme-dark .agent-selection-list li {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
  }
  body.ui-theme-dark .layers-tree details details {
    background: rgba(255, 255, 255, 0.06) !important;
  }
  body.ui-theme-dark .layers-panel::before {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0) 42%) !important;
  }
  body.ui-theme-dark .slot-cloud-badge,
  body.ui-theme-dark .save-cloud-badge {
    color: #b9f2bd !important;
    background: rgba(73, 160, 88, 0.18) !important;
    border-color: rgba(119, 210, 132, 0.32) !important;
  }

  .toolbar .tool,
  .toolbar .tool-group-btn,
  .tool-palette .tool,
  .flyout .tool.flyout-tool {
    position: relative;
  }
  .toolbar .tool.active,
  .toolbar .tool[aria-pressed="true"],
  .toolbar .tool-group-btn.active,
  .tool-palette .tool.active,
  .flyout .tool.flyout-tool.active {
    --active-outline: #1e428a;
    --active-fill: #f3f8ff;
    --active-fill-low: #d8e9ff;
    --active-ring: rgba(84, 137, 230, 0.58);
    --active-bevel: rgba(30, 66, 138, 0.30);
    color: var(--active-outline) !important;
    background: linear-gradient(180deg, var(--active-fill), var(--active-fill-low)) !important;
    border-color: var(--active-outline) !important;
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.98),
      inset 0 -4px 0 var(--active-bevel),
      0 0 0 2px var(--active-ring),
      0 8px 16px -10px rgba(20, 30, 50, 0.72) !important;
  }
  .toolbar .tool.active[data-pos-type="terrain"],
  .toolbar .tool-group-btn.active[data-pos-type="terrain"],
  .tool-palette .tool.active[data-pos-type="terrain"],
  .flyout .tool.flyout-tool.active[data-pos-type="terrain"] {
    --active-outline: #3a6511;
    --active-fill: #f4fbec;
    --active-fill-low: #d9efb8;
    --active-ring: rgba(123, 194, 48, 0.54);
    --active-bevel: rgba(58, 101, 17, 0.28);
  }
  .toolbar .tool.active[data-pos-type="primary"],
  .toolbar .tool[aria-pressed="true"][data-pos-type="primary"],
  .toolbar .tool-group-btn.active[data-pos-type="primary"],
  .tool-palette .tool.active[data-pos-type="primary"],
  .flyout .tool.flyout-tool.active[data-pos-type="primary"] {
    --active-outline: #1e428a;
    --active-fill: #f3f8ff;
    --active-fill-low: #d8e9ff;
    --active-ring: rgba(84, 137, 230, 0.58);
    --active-bevel: rgba(30, 66, 138, 0.30);
  }
  .toolbar .tool.active[data-pos-type="tertiary"],
  .toolbar .tool-group-btn.active[data-pos-type="tertiary"],
  .tool-palette .tool.active[data-pos-type="tertiary"],
  .flyout .tool.flyout-tool.active[data-pos-type="tertiary"] {
    --active-outline: #a05600;
    --active-fill: #fff8ec;
    --active-fill-low: #ffe0ad;
    --active-ring: rgba(254, 146, 14, 0.54);
    --active-bevel: rgba(160, 86, 0, 0.30);
  }
  .toolbar .tool.active[data-pos-type="shield"],
  .toolbar .tool[aria-pressed="true"][data-pos-type="shield"],
  .toolbar .tool-group-btn.active[data-pos-type="shield"],
  .tool-palette .tool.active[data-pos-type="shield"],
  .flyout .tool.flyout-tool.active[data-pos-type="shield"] {
    --active-outline: #0e5f7e;
    --active-fill: #effcff;
    --active-fill-low: #c9f0ff;
    --active-ring: rgba(45, 215, 255, 0.48);
    --active-bevel: rgba(14, 95, 126, 0.28);
  }
  .toolbar .tool.active::after,
  .toolbar .tool[aria-pressed="true"]::after,
  .toolbar .tool-group-btn.active::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -7px;
    transform: translateX(-50%);
    width: 24px;
    height: 4px;
    border-radius: 999px;
    background: var(--active-outline);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.34);
  }
  .toolbar .tool.active .tool-icon,
  .toolbar .tool[aria-pressed="true"] .tool-icon,
  .toolbar .tool-group-btn.active .group-icon,
  .tool-palette .tool.active .tool-icon,
  .tool-palette .tool.active .swatch,
  .flyout .tool.flyout-tool.active .tool-icon,
  .flyout .tool.flyout-tool.active .swatch {
    color: var(--active-outline) !important;
  }
  body.ui-theme-dark .toolbar .tool.active,
  body.ui-theme-dark .toolbar .tool[aria-pressed="true"],
  body.ui-theme-dark .toolbar .tool-group-btn.active,
  body.ui-theme-dark .tool-palette .tool.active,
  body.ui-theme-dark .flyout .tool.flyout-tool.active {
    color: var(--active-outline) !important;
    background: linear-gradient(180deg, var(--active-fill), var(--active-fill-low)) !important;
    border-color: var(--active-outline) !important;
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.98),
      inset 0 -4px 0 var(--active-bevel),
      0 0 0 2px var(--active-ring),
      0 8px 16px -10px rgba(0, 0, 0, 0.86) !important;
  }
  body.ui-theme-dark .toolbar .tool.active .tool-icon,
  body.ui-theme-dark .toolbar .tool[aria-pressed="true"] .tool-icon,
  body.ui-theme-dark .toolbar .tool-group-btn.active .group-icon,
  body.ui-theme-dark .tool-palette .tool.active .tool-icon,
  body.ui-theme-dark .tool-palette .tool.active .swatch,
  body.ui-theme-dark .flyout .tool.flyout-tool.active .tool-icon,
  body.ui-theme-dark .flyout .tool.flyout-tool.active .swatch {
    color: var(--active-outline) !important;
  }
  body.ui-theme-dark .toolbar .tool.active::after,
  body.ui-theme-dark .toolbar .tool[aria-pressed="true"]::after,
  body.ui-theme-dark .toolbar .tool-group-btn.active::after {
    background: var(--active-outline) !important;
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.48),
      0 0 12px var(--active-ring) !important;
  }
  body.ui-theme-dark .agent-target-chip,
  body.ui-theme-dark .agent-selection-count {
    color: #f5f8ff !important;
  }
  body.ui-theme-dark .agent-target-chip {
    background: rgba(75, 91, 128, 0.72) !important;
    border-color: rgba(210, 224, 255, 0.38) !important;
    box-shadow:
      inset 0 0 0 1px rgba(255, 255, 255, 0.22),
      0 0 0 1px rgba(84, 137, 230, 0.32),
      0 8px 16px -12px rgba(0, 0, 0, 0.72) !important;
  }
  body.ui-theme-dark .agent-target-chip:hover {
    background: rgba(93, 111, 154, 0.82) !important;
    border-color: rgba(224, 234, 255, 0.55) !important;
  }
  body.ui-theme-dark .selection-tab.active,
  body.ui-theme-dark .selection-prop-category-tab.active,
  body.ui-theme-dark .selection-prop-category-tab[aria-selected="true"],
  body.ui-theme-dark .selection-prop-chip.active,
  body.ui-theme-dark .selection-prop-chip[aria-pressed="true"],
  body.ui-theme-dark .layers-row.is-selected,
  body.ui-theme-dark .layers-cell.is-selected > summary {
    color: #10213e !important;
    background: linear-gradient(180deg, #f4f8ff, #d9e9ff) !important;
    border-color: rgba(80, 134, 224, 0.78) !important;
    box-shadow:
      inset 0 0 0 1px rgba(255, 255, 255, 0.94),
      inset 0 -3px 0 rgba(30, 66, 138, 0.18),
      0 0 0 1px rgba(84, 137, 230, 0.42) !important;
  }
  body.ui-theme-dark .layers-row.is-selected,
  body.ui-theme-dark .layers-cell.is-selected > summary {
    box-shadow:
      inset 3px 0 0 #5489e6,
      inset 0 0 0 1px rgba(255, 255, 255, 0.88),
      0 0 0 1px rgba(84, 137, 230, 0.42) !important;
  }
  body.ui-theme-dark .layers-row.is-selected .layers-row-main em,
  body.ui-theme-dark .layers-row.is-selected .layers-row-coord,
  body.ui-theme-dark .layers-cell.is-selected .layers-cell-main em,
  body.ui-theme-dark .layers-cell.is-selected .layers-row-coord,
  body.ui-theme-dark .layers-cell.is-selected .layers-count {
    color: rgba(16, 33, 62, 0.70) !important;
  }
  .toolbar .tool:focus-visible,
  .toolbar .tool-group-btn:focus-visible,
  .tool-palette .tool:focus-visible,
  .flyout .tool.flyout-tool:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.92);
    outline-offset: 2px;
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.96),
      0 0 0 3px rgba(84, 137, 230, 0.50),
      0 8px 16px -12px rgba(20, 30, 50, 0.62);
  }

  /* Unified chrome icon buttons: appbar, language picker, top pills, chat, and
     the side rail share the block-button outline/inner-line language used by
     the toolbar. */
  .appbar .btn.icon[data-pos-type],
  .token-corner .btn.icon[data-pos-type],
  .controls .btn.icon[data-pos-type],
  .language-trigger[data-pos-type],
  .sound-icon[data-pos-type],
  .layers-handle[data-pos-type],
  .mp-chat-toggle[data-pos-type],
  .world-pill[data-pos-type],
  .multiplayer-status[data-pos-type],
  .multiplayer-roster[data-pos-type] {
    --chrome-outline: #2f3b57;
    --chrome-bg: rgba(255, 255, 255, 0.42);
    --chrome-hover-bg: rgba(255, 255, 255, 0.62);
    --chrome-bevel: rgba(47, 59, 87, 0.20);
    --chrome-ring: rgba(84, 137, 230, 0.34);
    --chrome-active-outline: #1e428a;
    --chrome-active-fill: #f3f8ff;
    --chrome-active-fill-low: #d8e9ff;
    --chrome-active-ring: rgba(84, 137, 230, 0.58);
    --chrome-active-bevel: rgba(30, 66, 138, 0.30);
    min-height: 0;
    color: var(--chrome-outline);
    background: var(--chrome-bg);
    border: 1.5px solid var(--chrome-outline);
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 var(--chrome-bevel),
      0 2px 3px -1px rgba(20, 30, 50, 0.22);
    transition:
      background 0.12s ease,
      border-color 0.12s ease,
      box-shadow 0.12s ease,
      color 0.12s ease,
      transform 0.12s ease;
  }
  .appbar .btn.icon[data-pos-type],
  .token-corner .btn.icon[data-pos-type],
  .controls .btn.icon[data-pos-type] {
    border-radius: 11px;
  }
  .controls .build-play-toggle[data-pos-type] {
    --chrome-outline: #1e428a;
    --chrome-bg: rgba(23, 107, 235, 0.13);
    --chrome-hover-bg: rgba(23, 107, 235, 0.24);
    --chrome-bevel: rgba(30, 66, 138, 0.22);
    --chrome-ring: rgba(84, 137, 230, 0.40);
    color: var(--chrome-outline);
    background: var(--chrome-bg);
    border: 1.5px solid var(--chrome-outline);
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 var(--chrome-bevel),
      0 2px 3px -1px rgba(20, 30, 50, 0.22);
  }
  .controls .build-play-toggle[data-pos-type]:hover {
    color: var(--chrome-outline);
    background: var(--chrome-hover-bg);
    border-color: var(--chrome-outline);
    transform: translateY(-1px);
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.96),
      inset 0 -3px 0 var(--chrome-bevel),
      0 3px 6px -2px rgba(20, 30, 50, 0.28);
  }
  .controls .build-play-toggle[data-pos-type].on {
    --chrome-active-outline: #a05600;
    --chrome-active-fill: #fff8ec;
    --chrome-active-fill-low: #ffe0ad;
    --chrome-active-ring: rgba(254, 146, 14, 0.54);
    --chrome-active-bevel: rgba(160, 86, 0, 0.30);
    color: var(--chrome-active-outline) !important;
    background: linear-gradient(180deg, var(--chrome-active-fill), var(--chrome-active-fill-low)) !important;
    border-color: var(--chrome-active-outline) !important;
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.98),
      inset 0 -4px 0 var(--chrome-active-bevel),
      0 0 0 2px var(--chrome-active-ring),
      0 8px 16px -10px rgba(20, 30, 50, 0.72) !important;
  }
  .appbar .btn.icon[data-pos-type] {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
  }
  .token-corner .btn.icon[data-pos-type] {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
  }
  .controls .btn.icon[data-pos-type] {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 12px;
  }
  .appbar .btn.icon[data-pos-type] svg {
    width: 15px;
    height: 15px;
  }
  .token-corner .btn.icon[data-pos-type] svg,
  .controls .btn.icon[data-pos-type] svg {
    width: 18px;
    height: 18px;
  }
  .sound-icon[data-pos-type],
  .layers-handle[data-pos-type],
  .mp-chat-toggle[data-pos-type] {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 13px;
  }
  .sound-icon[data-pos-type] svg,
  .layers-handle[data-pos-type] svg,
  .mp-chat-toggle[data-pos-type] svg {
    width: 22px;
    height: 22px;
  }
  .world-pill[data-pos-type],
  .multiplayer-status[data-pos-type],
  .multiplayer-roster[data-pos-type] {
    border-radius: 999px;
  }
  .language-trigger[data-pos-type] {
    width: 46px;
    height: 30px;
    padding: 2px 5px 2px 4px;
    flex: 0 0 46px;
    border-radius: 11px;
    opacity: 0.92;
    background: var(--chrome-bg);
  }
  .language-trigger[data-pos-type] .language-current-flag {
    border-radius: 5px;
    overflow: hidden;
  }
  .appbar .btn.icon[data-pos-type]:hover,
  .token-corner .btn.icon[data-pos-type]:hover,
  .controls .btn.icon[data-pos-type]:hover,
  .language-trigger[data-pos-type]:hover,
  .sound-icon[data-pos-type]:hover,
  .layers-handle[data-pos-type]:hover,
  .mp-chat-toggle[data-pos-type]:hover,
  .world-pill[data-pos-type]:hover {
    color: var(--chrome-outline);
    background: var(--chrome-hover-bg);
    border-color: var(--chrome-outline);
    opacity: 1;
    transform: translateY(-1px);
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.96),
      inset 0 -3px 0 var(--chrome-bevel),
      0 3px 6px -2px rgba(20, 30, 50, 0.28);
  }
  .appbar .btn.icon[data-pos-type="primary"],
  .token-corner .btn.icon[data-pos-type="primary"],
  .controls .btn.icon[data-pos-type="primary"],
  .language-trigger[data-pos-type="primary"],
  .sound-icon[data-pos-type="primary"],
  .layers-handle[data-pos-type="primary"],
  .mp-chat-toggle[data-pos-type="primary"],
  .world-pill[data-pos-type="primary"],
  .multiplayer-status[data-pos-type="primary"] {
    --chrome-outline: #1e428a;
    --chrome-bg: rgba(23, 107, 235, 0.13);
    --chrome-hover-bg: rgba(23, 107, 235, 0.24);
    --chrome-bevel: rgba(30, 66, 138, 0.22);
  }
  .world-pill[data-pos-type="primary"] {
    --chrome-bg: rgba(255, 255, 255, 0.82);
    --chrome-hover-bg: rgba(255, 255, 255, 0.94);
  }
  .world-pill[data-pos-type]:hover {
    transform: translateX(-50%);
  }
  .appbar .btn.icon[data-pos-type="tertiary"],
  .token-corner .btn.icon[data-pos-type="tertiary"],
  .controls .btn.icon[data-pos-type="tertiary"],
  .language-trigger[data-pos-type="tertiary"],
  .sound-icon[data-pos-type="tertiary"],
  .layers-handle[data-pos-type="tertiary"],
  .mp-chat-toggle[data-pos-type="tertiary"] {
    --chrome-outline: #a05600;
    --chrome-bg: rgba(254, 146, 14, 0.18);
    --chrome-hover-bg: rgba(254, 146, 14, 0.32);
    --chrome-bevel: rgba(160, 86, 0, 0.22);
  }
  .appbar .btn.icon[data-pos-type="shield"],
  .token-corner .btn.icon[data-pos-type="shield"],
  .controls .btn.icon[data-pos-type="shield"],
  .language-trigger[data-pos-type="shield"],
  .sound-icon[data-pos-type="shield"],
  .layers-handle[data-pos-type="shield"],
  .mp-chat-toggle[data-pos-type="shield"] {
    --chrome-outline: #0e5f7e;
    --chrome-bg: rgba(45, 215, 255, 0.15);
    --chrome-hover-bg: rgba(45, 215, 255, 0.28);
    --chrome-bevel: rgba(14, 95, 126, 0.22);
  }
  .appbar .btn.icon[data-pos-type].active,
  .appbar .btn.icon[data-pos-type].on,
  .token-corner .btn.icon[data-pos-type].active,
  .token-corner .btn.icon[data-pos-type].on,
  .controls .btn.icon[data-pos-type].active,
  .controls .btn.icon[data-pos-type].on,
  .language-trigger[data-pos-type][aria-expanded="true"],
  .sound-icon[data-pos-type].open,
  .layers-handle[data-pos-type].on,
  .mp-chat-toggle[data-pos-type].is-open,
  .world-pill[data-pos-type][aria-expanded="true"] {
    color: var(--chrome-active-outline) !important;
    background: linear-gradient(180deg, var(--chrome-active-fill), var(--chrome-active-fill-low)) !important;
    border-color: var(--chrome-active-outline) !important;
    opacity: 1;
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.98),
      inset 0 -4px 0 var(--chrome-active-bevel),
      0 0 0 2px var(--chrome-active-ring),
      0 8px 16px -10px rgba(20, 30, 50, 0.72) !important;
  }
  .appbar .btn.icon[data-pos-type="tertiary"].active,
  .appbar .btn.icon[data-pos-type="tertiary"].on,
  .token-corner .btn.icon[data-pos-type="tertiary"].active,
  .token-corner .btn.icon[data-pos-type="tertiary"].on,
  .controls .btn.icon[data-pos-type="tertiary"].active,
  .controls .btn.icon[data-pos-type="tertiary"].on,
  .language-trigger[data-pos-type="tertiary"][aria-expanded="true"] {
    --chrome-active-outline: #a05600;
    --chrome-active-fill: #fff8ec;
    --chrome-active-fill-low: #ffe0ad;
    --chrome-active-ring: rgba(254, 146, 14, 0.54);
    --chrome-active-bevel: rgba(160, 86, 0, 0.30);
  }
  .appbar .btn.icon[data-pos-type="shield"].active,
  .appbar .btn.icon[data-pos-type="shield"].on,
  .token-corner .btn.icon[data-pos-type="shield"].active,
  .token-corner .btn.icon[data-pos-type="shield"].on,
  .controls .btn.icon[data-pos-type="shield"].active,
  .controls .btn.icon[data-pos-type="shield"].on,
  .language-trigger[data-pos-type="shield"][aria-expanded="true"] {
    --chrome-active-outline: #0e5f7e;
    --chrome-active-fill: #effcff;
    --chrome-active-fill-low: #c9f0ff;
    --chrome-active-ring: rgba(45, 215, 255, 0.48);
    --chrome-active-bevel: rgba(14, 95, 126, 0.28);
  }
  .appbar .btn.icon[data-pos-type]:focus-visible,
  .token-corner .btn.icon[data-pos-type]:focus-visible,
  .controls .btn.icon[data-pos-type]:focus-visible,
  .language-trigger[data-pos-type]:focus-visible,
  .sound-icon[data-pos-type]:focus-visible,
  .layers-handle[data-pos-type]:focus-visible,
  .mp-chat-toggle[data-pos-type]:focus-visible,
  .world-pill[data-pos-type]:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.92);
    outline-offset: 2px;
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.96),
      0 0 0 3px rgba(84, 137, 230, 0.50),
      0 8px 16px -12px rgba(20, 30, 50, 0.62);
  }
  body.ui-theme-dark .appbar .btn.icon[data-pos-type]:not(.active):not(.on),
  body.ui-theme-dark .token-corner .btn.icon[data-pos-type]:not(.active):not(.on),
  body.ui-theme-dark .controls .btn.icon[data-pos-type]:not(.active):not(.on),
  body.ui-theme-dark .language-trigger[data-pos-type]:not([aria-expanded="true"]),
  body.ui-theme-dark .sound-icon[data-pos-type]:not(.open),
  body.ui-theme-dark .layers-handle[data-pos-type]:not(.on),
  body.ui-theme-dark .mp-chat-toggle[data-pos-type]:not(.is-open),
  body.ui-theme-dark .world-pill[data-pos-type]:not([aria-expanded="true"]),
  body.ui-theme-dark .multiplayer-status[data-pos-type],
  body.ui-theme-dark .multiplayer-roster[data-pos-type] {
    --chrome-outline: #dcecff;
    --chrome-dark-bg: rgba(34, 41, 58, 0.88);
    --chrome-dark-hover-bg: rgba(48, 58, 80, 0.92);
    --chrome-dark-bevel: rgba(0, 0, 0, 0.24);
    color: var(--chrome-outline) !important;
    background: var(--chrome-dark-bg) !important;
    border-color: var(--chrome-outline) !important;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.20),
      inset 0 -3px 0 var(--chrome-dark-bevel),
      0 2px 5px -2px rgba(0, 0, 0, 0.58) !important;
  }
  body.ui-theme-dark .appbar .btn.icon[data-pos-type="primary"]:not(.active):not(.on),
  body.ui-theme-dark .token-corner .btn.icon[data-pos-type="primary"]:not(.active):not(.on),
  body.ui-theme-dark .controls .btn.icon[data-pos-type="primary"]:not(.active):not(.on) {
    --chrome-outline: #9fc1ff;
    --chrome-dark-bg: rgba(40, 54, 92, 0.88);
    --chrome-dark-hover-bg: rgba(50, 70, 118, 0.92);
  }
  body.ui-theme-dark .appbar .btn.icon[data-pos-type="tertiary"]:not(.active):not(.on),
  body.ui-theme-dark .token-corner .btn.icon[data-pos-type="tertiary"]:not(.active):not(.on),
  body.ui-theme-dark .controls .btn.icon[data-pos-type="tertiary"]:not(.active):not(.on) {
    --chrome-outline: #ffc26e;
    --chrome-dark-bg: rgba(88, 56, 30, 0.88);
    --chrome-dark-hover-bg: rgba(112, 72, 36, 0.92);
  }
  body.ui-theme-dark .appbar .btn.icon[data-pos-type="shield"]:not(.active):not(.on),
  body.ui-theme-dark .token-corner .btn.icon[data-pos-type="shield"]:not(.active):not(.on),
  body.ui-theme-dark .controls .btn.icon[data-pos-type="shield"]:not(.active):not(.on) {
    --chrome-outline: #75ddff;
    --chrome-dark-bg: rgba(30, 72, 92, 0.88);
    --chrome-dark-hover-bg: rgba(36, 92, 115, 0.92);
  }
  body.ui-theme-dark .appbar .btn.icon[data-pos-type]:not(.active):not(.on):hover,
  body.ui-theme-dark .token-corner .btn.icon[data-pos-type]:not(.active):not(.on):hover,
  body.ui-theme-dark .controls .btn.icon[data-pos-type]:not(.active):not(.on):hover,
  body.ui-theme-dark .language-trigger[data-pos-type]:not([aria-expanded="true"]):hover,
  body.ui-theme-dark .sound-icon[data-pos-type]:not(.open):hover,
  body.ui-theme-dark .layers-handle[data-pos-type]:not(.on):hover,
  body.ui-theme-dark .mp-chat-toggle[data-pos-type]:not(.is-open):hover,
  body.ui-theme-dark .world-pill[data-pos-type]:not([aria-expanded="true"]):hover {
    background: var(--chrome-dark-hover-bg) !important;
    border-color: var(--chrome-outline) !important;
  }
  body.ui-theme-dark .appbar .btn.icon[data-pos-type].active,
  body.ui-theme-dark .appbar .btn.icon[data-pos-type].on,
  body.ui-theme-dark .token-corner .btn.icon[data-pos-type].active,
  body.ui-theme-dark .token-corner .btn.icon[data-pos-type].on,
  body.ui-theme-dark .controls .btn.icon[data-pos-type].active,
  body.ui-theme-dark .controls .btn.icon[data-pos-type].on,
  body.ui-theme-dark .sound-icon[data-pos-type].open,
  body.ui-theme-dark .layers-handle[data-pos-type].on,
  body.ui-theme-dark .mp-chat-toggle[data-pos-type].is-open,
  body.ui-theme-dark .language-trigger[data-pos-type][aria-expanded="true"],
  body.tod-night .appbar .btn.icon[data-pos-type].active,
  body.tod-night .appbar .btn.icon[data-pos-type].on,
  body.tod-night .token-corner .btn.icon[data-pos-type].active,
  body.tod-night .token-corner .btn.icon[data-pos-type].on,
  body.tod-night .controls .btn.icon[data-pos-type].active,
  body.tod-night .controls .btn.icon[data-pos-type].on,
  body.tod-night .sound-icon[data-pos-type].open,
  body.tod-night .layers-handle[data-pos-type].on,
  body.tod-night .mp-chat-toggle[data-pos-type].is-open,
  body.tod-night .language-trigger[data-pos-type][aria-expanded="true"],
  body.tod-dusk .appbar .btn.icon[data-pos-type].active,
  body.tod-dusk .appbar .btn.icon[data-pos-type].on,
  body.tod-dusk .token-corner .btn.icon[data-pos-type].active,
  body.tod-dusk .token-corner .btn.icon[data-pos-type].on,
  body.tod-dusk .controls .btn.icon[data-pos-type].active,
  body.tod-dusk .controls .btn.icon[data-pos-type].on,
  body.tod-dusk .sound-icon[data-pos-type].open,
  body.tod-dusk .layers-handle[data-pos-type].on,
  body.tod-dusk .mp-chat-toggle[data-pos-type].is-open,
  body.tod-dusk .language-trigger[data-pos-type][aria-expanded="true"] {
    color: var(--chrome-active-outline) !important;
    background: linear-gradient(180deg, var(--chrome-active-fill), var(--chrome-active-fill-low)) !important;
    border-color: var(--chrome-active-outline) !important;
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.98),
      inset 0 -4px 0 var(--chrome-active-bevel),
      0 0 0 2px var(--chrome-active-ring),
      0 8px 16px -10px rgba(0, 0, 0, 0.86) !important;
  }
  body.ui-theme-dark .appbar-sep {
    background: rgba(220, 232, 255, 0.22);
  }
  body.weather-cloudy #tod-tint { background: linear-gradient(180deg, rgba(180,180,180,0.18), transparent 70%); opacity: 1; }

  /* --- Brand → World menu popup --- */
  .brand-title-btn {
    pointer-events: auto;
    background: transparent;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 500;
    font-size: 28px;
    letter-spacing: -0.02em;
    line-height: 1;
    text-align: left;
  }
  .brand-title-btn em {
    font-style: italic;
    font-weight: 400;
    color: #a08454;
  }
  .brand-title-btn .brand-chevron {
    color: var(--muted);
    transition: transform 0.16s ease;
    align-self: center;
    margin-top: 2px;
  }
  .brand-title-btn[aria-expanded="true"] .brand-chevron { transform: rotate(180deg); }
  .brand-title-btn:hover { color: var(--ink); }

  .world-menu {
    position: fixed;
    top: 86px; left: 28px;
    z-index: 60;
    width: 340px;                    /* a bit wider for breathing room */
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: var(--radius-xl);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 16px 48px -14px rgba(40, 50, 80, 0.28);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    overflow: hidden;
    font-size: 13px;
    color: var(--ink);
    animation: world-menu-pop 0.14s ease-out;
  }
  .world-menu[hidden] { display: none; }
  @keyframes world-menu-pop {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .world-menu-head {
    display: flex; gap: 6px;
    padding: 10px 10px 8px;
    border-bottom: 1px solid var(--line-soft);
  }
  .world-menu-input {
    flex: 1;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 9px;
    font: inherit;
    font-size: 13px;
    color: var(--ink);
    outline: none;
  }
  .world-menu-input:focus { border-color: rgba(60, 130, 247, 0.5); }
  .world-menu-rename {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
  }
  .world-menu-rename:hover { color: var(--ink); background: rgba(255, 255, 255, 0.55); }
  .world-menu-section { padding: 6px; }
  .world-menu-section + .world-menu-section { border-top: 1px solid var(--line-soft); }
  .world-menu-section-title {
    font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--muted);
    padding: 8px 10px 4px;
    opacity: 0.75;
  }
  .world-menu-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    background: transparent;
    border: none;
    text-align: left;
    padding: 9px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--ink);
    font: inherit; font-size: 13px;
    min-height: 36px;
  }
  .world-menu-item:hover { background: rgba(255, 255, 255, 0.55); }
  .world-menu-icon {
    width: 28px; height: 28px;     /* even bigger icons */
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted);
    border-radius: var(--radius-sm);
    background: #f3ecdc;
    flex-shrink: 0;
    font-size: 16px;
  }
  .world-menu-label { flex: 1; }
  .world-menu-hint {
    font-size: 11px; color: var(--muted);
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  }
  .world-menu-list {
    list-style: none; margin: 0; padding: 4px 0;
    max-height: 320px;              /* taller before scrolling */
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .world-menu-list::-webkit-scrollbar {
    width: 6px;
  }
  .world-menu-list::-webkit-scrollbar-thumb {
    background: rgba(120, 130, 150, 0.35);
    border-radius: 3px;
  }
  .world-menu-slot {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 8px;
    border-radius: 7px;
    cursor: pointer;
    color: var(--ink);
    font-size: 12.5px;
  }
  .world-menu-slot:hover { background: rgba(255, 255, 255, 0.55); }
  .world-menu-slot.active { background: rgba(255, 255, 255, 0.78); }
  .world-menu-slot .slot-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
  }
  .slot-cloud-badge,
  .save-cloud-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 1px 5px;
    border: 1px solid rgba(83, 121, 89, 0.28);
    border-radius: 999px;
    background: rgba(237, 247, 231, 0.76);
    color: #3f6f41;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
    vertical-align: middle;
  }
  .world-menu-slot .slot-date { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .world-menu-slot .slot-delete {
    background: transparent; border: none; color: var(--muted); cursor: pointer;
    width: 22px; height: 22px; border-radius: 5px;
    display: inline-flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.12s, background 0.12s, color 0.12s;
  }
  .world-menu-slot:hover .slot-delete { opacity: 1; }
  .world-menu-slot .slot-delete:hover { color: #b84838; background: var(--line); }
  .world-menu-empty {
    padding: 12px 12px 14px;
    color: var(--muted);
    font-size: 12px;
  }
  .world-menu-foot {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
    border-top: 1px solid var(--line-soft);
    background: var(--bg);
    scrollbar-width: none;
  }
  .world-menu-foot::-webkit-scrollbar { display: none; }
  .world-menu-foot-btn {
    --chrome-outline: #2f3b57;
    --chrome-bg: rgba(255, 255, 255, 0.42);
    --chrome-hover-bg: rgba(255, 255, 255, 0.62);
    --chrome-bevel: rgba(47, 59, 87, 0.20);
    flex: 0 0 auto;
    min-width: 116px;
    max-width: 148px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    background: var(--chrome-bg);
    border: 1.5px solid var(--chrome-outline);
    border-radius: 11px;
    padding: 6px 10px;
    font: inherit; font-size: 12px;
    font-weight: 750;
    color: var(--chrome-outline);
    cursor: pointer;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 var(--chrome-bevel),
      0 2px 3px -1px rgba(20, 30, 50, 0.22);
  }
  .world-menu-foot-btn span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .world-menu-foot-btn svg { flex: 0 0 auto; }
  .world-menu-foot-btn:hover { background: var(--chrome-hover-bg); }

  /* --- Command palette (⌘K) --- */
  .palette-overlay {
    position: fixed; inset: 0;
    background: rgba(20, 18, 16, 0.34);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 80;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 96px 20px 20px;
  }
  .palette-overlay[hidden] { display: none; }
  .palette {
    width: min(560px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 24px 60px -16px rgba(40, 28, 8, 0.32), 0 4px 14px -4px rgba(40, 28, 8, 0.14);
    overflow: hidden;
    display: flex; flex-direction: column;
    font-size: 13px;
  }
  .palette-search-icon {
    position: absolute;
    margin: 16px 0 0 16px;
    color: var(--muted);
    pointer-events: none;
  }
  .palette-search {
    appearance: none; outline: none;
    width: 100%;
    border: none;
    border-bottom: 1px solid var(--line);
    font: inherit;
    font-size: 15px;
    padding: 16px 16px 16px 44px;
    background: transparent;
    color: var(--ink);
  }
  .palette-search::placeholder { color: var(--muted); }
  .palette-results {
    max-height: 360px;
    overflow-y: auto;
    padding: 6px;
    background: var(--panel);
  }
  .palette-group {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 10px 12px 4px;
  }
  .palette-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--ink);
    line-height: 1.3;
  }
  .palette-item:hover,
  .palette-item.active {
    background: rgba(255, 255, 255, 0.55);
  }
  .palette-item-icon {
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px;
    background: #f3ecdc;
    color: var(--muted);
    flex-shrink: 0;
  }
  .palette-item-icon svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .palette-item-icon .swatch { width: 10px; height: 10px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }
  .palette-item-body { flex: 1; min-width: 0; }
  .palette-item-label {
    font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .palette-item-hint {
    font-size: 11.5px;
    color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .palette-item-kbd {
    font-size: 10.5px;
    color: var(--muted);
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    padding: 2px 5px;
    background: #f3ecdc;
    border-radius: var(--radius-sm);
  }
  .palette-empty {
    padding: 26px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 12.5px;
  }
  .palette-footer {
    display: flex; gap: 14px;
    padding: 8px 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
    background: var(--bg);
  }
  .palette-footer kbd {
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 10.5px;
    padding: 1px 5px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 4px;
    margin-right: 3px;
  }

  .confirm-card { width: min(380px, 100%); }
  .confirm-card .modal-head strong {
    font-size: 20px;
  }
  .confirm-actions { justify-content: flex-end; gap: 8px; margin-top: 6px; }

  .gen-actions {
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
  }
  .btn.confirm-destructive {
    background: #b84838;
    border-color: #a23a2b;
    color: #fff;
    font-weight: 600;
  }
  .btn.confirm-destructive:hover { background: #a23a2b; }

  /* Strong primary action button for Generate (matches weight of destructive reset button) */
  #gen-go {
    background: #3a72c8;
    border-color: #2f5aa3;
    color: #fff;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 10px;
  }
  #gen-go:hover {
    background: #2f5aa3;
  }
  .range-row {
    display: grid;
    grid-template-columns: 116px 1fr 44px;
    gap: 10px;
    align-items: center;
    color: var(--muted);
    font-weight: 500;
  }
  .range-row input[type="range"] {
    padding: 0;
  }
  .check-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  /* Style checkboxes inside settings as iOS-style toggle switches with a
     rounded-rectangle knob (matches the slider thumb language). */
  .check-row input[type="checkbox"],
  .modal-card input[type="checkbox"],
  .settings-panel input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 38px;
    height: 22px;
    border-radius: 7px;
    background: rgba(120, 130, 150, 0.20);
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
    position: relative;
    cursor: pointer;
    transition: background 0.18s cubic-bezier(0.22, 1, 0.36, 1);
    flex-shrink: 0;
    outline: none;
    margin: 0;
    padding: 0;
  }
  .check-row input[type="checkbox"]::before,
  .modal-card input[type="checkbox"]::before,
  .settings-panel input[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.95) inset,
      0 1px 2px rgba(20, 30, 50, 0.18);
    transition: left 0.18s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .check-row input[type="checkbox"]:checked,
  .modal-card input[type="checkbox"]:checked,
  .settings-panel input[type="checkbox"]:checked {
    background: rgba(60, 130, 247, 0.85);
    border-color: rgba(60, 130, 247, 0.55);
  }
  .check-row input[type="checkbox"]:checked::before,
  .modal-card input[type="checkbox"]:checked::before,
  .settings-panel input[type="checkbox"]:checked::before {
    left: 18px;
  }
  .settings-card {
    width: min(780px, calc(100vw - 32px));
    min-height: 500px;
  }
  .settings-layout {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 14px;
    min-height: 380px;
  }
  .settings-searchbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin: 2px 0 12px;
  }
  .settings-search {
    width: 100%;
    min-height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.58);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.62);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    padding: 8px 11px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.78) inset;
  }
  .settings-search:focus {
    outline: 2px solid rgba(96, 125, 179, 0.36);
    outline-offset: 1px;
  }
  .settings-search-status {
    min-width: 74px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
  }
  .settings-tabs {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 10px;
    border-right: 1px solid var(--line);
  }
  .settings-tab {
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    padding: 10px 11px;
  }
  .settings-tab-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    white-space: normal;
  }
  .settings-tab-label,
  .settings-tab-hint {
    overflow-wrap: anywhere;
  }
  .settings-tab-hint {
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.25;
  }
  .settings-tab.active .settings-tab-hint,
  .settings-tab:hover .settings-tab-hint {
    color: var(--ink);
    opacity: 0.72;
  }
  .settings-tab:hover { background: rgba(255, 255, 255, 0.45); color: var(--ink); }
  .settings-tab:focus-visible {
    outline: 2px solid rgba(96, 125, 179, 0.44);
    outline-offset: 2px;
  }
  .settings-tab.active {
    background: rgba(255, 255, 255, 0.78);
    border-color: rgba(255, 255, 255, 0.6);
    color: var(--ink);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 1px 2px rgba(20, 30, 50, 0.06);
  }
  .settings-tab.search-miss:not(.active) { opacity: 0.45; }
  .settings-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(96, 125, 179, 0.14);
    color: #38547a;
    font-size: 10px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
  }
  .settings-tab-count[hidden] { display: none; }
  .settings-panels {
    min-width: 0;
  }
  .settings-panel {
    display: none;
    flex-direction: column;
    gap: 10px;
  }
  .settings-panel.active { display: flex; }
  .settings-section-title {
    margin-top: 2px;
    padding-bottom: 2px;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .settings-section-title.sponsors-title {
    margin-top: 28px;
    padding-top: 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--muted, #6b6b6b);
  }
  .sponsors-logos {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    padding: 6px 2px 2px;
  }
  .settings-section-title.credits-title {
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--muted, #6b6b6b);
  }
  .settings-credits {
    margin: 6px 2px 2px;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--muted, #6b6b6b);
  }
  .settings-credits a { color: inherit; text-decoration: underline; }
  .sponsor-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    line-height: 0;
    border-radius: 8px;
    overflow: hidden;
    transition: opacity 120ms ease, transform 120ms ease;
    opacity: 0.92;
  }
  .sponsor-logo:hover { opacity: 1; transform: translateY(-1px); }
  .sponsor-logo:focus-visible {
    outline: 2px solid rgba(60, 110, 220, 0.6);
    outline-offset: 2px;
  }
  .sponsor-logo img {
    display: block;
    width: 200px;
    height: auto;
    max-width: 100%;
  }
  .dev-defaults-section {
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px dashed rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .dev-defaults-section[hidden] { display: none; }
  .dev-defaults-title {
    color: #c25a1a;
  }
  .dev-defaults-help {
    margin: 0;
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--muted, #6b6b6b);
  }
  .dev-defaults-help code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 10.5px;
  }
  .dev-defaults-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
  }
  .dev-defaults-btn {
    padding: 6px 14px;
    font-weight: 600;
  }
  .dev-defaults-status {
    font-size: 11.5px;
    color: var(--muted, #6b6b6b);
    min-height: 1em;
  }
  .dev-defaults-status.is-ok { color: #2e8b3a; }
  .dev-defaults-status.is-err { color: #c0392b; }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .layers-panel {
    --ink: #262b34;
    --muted: #647085;
    --line: rgba(92, 104, 126, 0.22);
    --line-soft: rgba(92, 104, 126, 0.14);
    position: fixed;
    right: 24px;
    top: 92px;
    z-index: 47;
    width: min(300px, calc(100vw - 28px));
    height: 480px;
    min-width: 220px;
    min-height: 220px;
    max-width: calc(100vw - 28px);
    max-height: calc(100vh - 118px);
    resize: both;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 8px 8px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: var(--radius-xl);
    background: rgba(246, 248, 252, 0.88);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 24px 56px -16px rgba(40, 50, 80, 0.30);
    backdrop-filter: blur(24px) saturate(150%);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    overflow: hidden;
    color: var(--ink);
  }
  .layers-panel[hidden] { display: none; }
  .layers-panel.dragging {
    cursor: grabbing;
    transition: none;
    user-select: none;
  }
  .layers-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0) 44%);
    opacity: 0.9;
  }
  .layers-panel > * {
    position: relative;
    z-index: 1;
  }
  /* Drag bar — grab cue centred, like the blocks panel; close on the right. */
  .layers-panel-head {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 4px 3px;
    cursor: grab;
    user-select: none;
  }
  .layers-panel.dragging .layers-panel-head { cursor: grabbing; }
  .layers-panel-head::after {
    content: '';
    width: 28px;
    height: 4px;
    border-radius: 999px;
    background: rgba(120, 130, 150, 0.35);
  }
  .layers-panel-close {
    position: absolute;
    right: -2px;
    top: 0;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
  }
  .layers-panel-close:hover { background: rgba(0, 0, 0, 0.06); color: var(--ink); }
  /* Tabbed bar in the block-button style. */
  .layers-tabs {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    padding: 0 1px;
  }
  .layers-tab {
    appearance: none;
    border: 1.5px solid rgba(255, 255, 255, 0.55);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.54);
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.9),
      0 1px 2px -1px rgba(20, 30, 50, 0.2);
    color: var(--ink);
    font: inherit;
    font-size: 11.5px;
    font-weight: 800;
    padding: 6px 8px;
    cursor: pointer;
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    backdrop-filter: blur(12px) saturate(180%);
    transition: background 0.12s, box-shadow 0.12s, color 0.12s;
  }
  .layers-tab:hover { background: rgba(255, 255, 255, 0.5); }
  .layers-tab.is-active {
    border-color: #304878;
    background: rgba(23, 107, 235, 0.14);
    color: #1f4ea8;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 rgba(30, 66, 138, 0.22),
      0 2px 3px -1px rgba(20, 30, 50, 0.22);
    -webkit-backdrop-filter: blur(12px) saturate(190%);
    backdrop-filter: blur(12px) saturate(190%);
  }
  .layers-tabpanel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .layers-tabpanel[hidden] { display: none; }
  .layers-props { flex: 1 1 auto; overflow: auto; }
  .layers-props-empty { font-size: 11.5px; color: #58647a; margin: 6px 2px; }
  .layers-search input {
    width: 100%;
    border: 1px solid rgba(120, 110, 90, 0.18);
    border-radius: 14px;
    padding: 9px 11px;
    background: rgba(255, 255, 255, 0.84);
    color: var(--ink);
    font: inherit;
    font-size: 12px;
    outline: none;
  }
  .layers-search input:focus {
    border-color: rgba(58, 114, 200, 0.42);
    box-shadow: 0 0 0 3px rgba(58, 114, 200, 0.12);
  }
  .layers-tree {
    overflow: auto;
    padding-right: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(70, 55, 35, 0.24) transparent;
  }
  .layers-tree details {
    margin: 2px 0;
    border: 1px solid rgba(120, 110, 90, 0.10);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.62);
  }
  .layers-tree details details {
    margin-left: 8px;
    margin-right: 0;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.48);
  }
  .layers-tree summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 7px;
    cursor: pointer;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--ink);
    list-style: none;
  }
  .layers-tree summary::-webkit-details-marker { display: none; }
  .layers-tree summary::before {
    content: '▸';
    color: #647085;
    font-size: 11px;
    transition: transform 0.12s;
  }
  .layers-tree details[open] > summary::before { transform: rotate(90deg); }
  .layers-count {
    margin-left: auto;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.76);
  }
  .layers-branch {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 4px 4px 14px;
  }
  .layers-row {
    width: 100%;
    display: grid;
    grid-template-columns: 18px 1fr auto;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 3px 6px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
    font: inherit;
  }
  .layers-row:hover {
    background: rgba(255, 255, 255, 0.78);
    border-color: rgba(120, 110, 90, 0.13);
  }
  .layers-row.is-selected {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(58, 114, 200, 0.34);
    box-shadow: inset 3px 0 0 rgba(58, 114, 200, 0.74);
  }
  .layers-row-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.78);
    font-size: 11px;
  }
  .layers-row-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
  }
  .layers-row-main strong {
    font-size: 12px;
    font-weight: 700;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .layers-row-main em {
    font-style: normal;
    font-size: 10.5px;
    color: #647085;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .layers-row-coord {
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 10px;
    color: #647085;
    padding: 2px 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
  }
  .layers-cell-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
  }
  .layers-cell-main strong {
    font-size: 12px;
    font-weight: 700;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .layers-cell-main em {
    font-style: normal;
    font-size: 10.5px;
    font-weight: 600;
    color: #647085;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .layers-cell > summary .layers-row-coord { margin-left: auto; }
  .layers-cell > summary .layers-count { margin-left: 6px; }
  .layers-cell.is-selected > summary {
    background: rgba(58, 114, 200, 0.12);
    border-radius: 12px;
    box-shadow: inset 3px 0 0 rgba(58, 114, 200, 0.74);
  }
  .layers-empty {
    margin: 0;
    padding: 10px;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.4;
  }
  .layers-subparts {
    margin-left: 18px;
    padding-left: 8px;
    border-left: 1px solid rgba(90, 100, 120, 0.18);
  }
  .layers-part-row {
    min-height: 30px;
    background: rgba(255, 255, 255, 0.34);
  }
  .layers-part-row .layers-row-icon {
    color: #1e428a;
    font-weight: 900;
  }
  body.showcase .layers-panel,
  body.xr-active .layers-panel { display: none; }

  /* -------- radial object menu (prototype) -------- */
  .radial-menu {
    position: fixed;
    left: 0; top: 0;                 /* anchored via per-frame translate3d */
    z-index: 46;
    width: 0;
    height: 0;
    pointer-events: none;            /* only the buttons are interactive */
    will-change: transform;
  }
  .radial-menu[hidden] { display: none; }
  .radial-btn {
    position: absolute;
    left: 0; top: 0;
    transform: translate(-50%, -50%);
    width: 54px;
    height: 54px;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    border: 1px solid rgba(255, 255, 255, 0.76);
    border-radius: 50%;
    background: rgba(246, 248, 252, 0.88);
    color: #273244;
    cursor: pointer;
    pointer-events: auto;
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 1px 2px rgba(20, 30, 50, 0.10),
      0 12px 28px -12px rgba(20, 30, 50, 0.48);
    transition: background 0.12s, transform 0.1s, box-shadow 0.12s;
  }
  /* "Spin in": each button pops + un-rotates into place, staggered by --d. */
  @keyframes radial-pop {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.2) rotate(-150deg); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
  }
  .radial-btn {
    animation: radial-pop 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
    animation-delay: var(--d, 0s);
  }
  .radial-btn:hover {
    background: rgba(255, 255, 255, 0.96);
    transform: translate(-50%, -50%) scale(1.08);
  }
  .radial-btn:active { transform: translate(-50%, -50%) scale(0.96); }
  /* Close / Back sits in the top slot — slightly darker so it reads as chrome. */
  .radial-btn.radial-top {
    width: 44px;
    height: 44px;
  }
  .radial-btn.radial-top:hover { transform: translate(-50%, -50%) scale(1.1); }
  .radial-btn[data-pos-type] {
    --radial-outline: #2f3b57;
    --radial-ink: #17223a;
    --radial-bg: rgba(248, 251, 255, 0.96);
    --radial-hover-bg: rgba(255, 255, 255, 0.99);
    --radial-bevel: rgba(47, 59, 87, 0.20);
    --radial-ring: rgba(84, 137, 230, 0.40);
    color: var(--radial-ink);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.98), var(--radial-bg));
    border: 1.5px solid var(--radial-outline);
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.96),
      inset 0 -3px 0 var(--radial-bevel),
      0 0 0 2px rgba(255, 255, 255, 0.72),
      0 8px 16px -9px rgba(18, 28, 48, 0.54);
  }
  .radial-btn[data-pos-type]:hover {
    color: var(--radial-ink);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 1), var(--radial-hover-bg));
    border-color: var(--radial-outline);
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.96),
      inset 0 -3px 0 var(--radial-bevel),
      0 0 0 2px rgba(255, 255, 255, 0.82),
      0 10px 20px -10px rgba(18, 28, 48, 0.60);
  }
  .radial-btn[data-pos-type="terrain"] {
    --radial-outline: #2f5d0f;
    --radial-ink: #23470b;
    --radial-bg: rgba(230, 247, 212, 0.96);
    --radial-hover-bg: rgba(242, 253, 228, 0.99);
    --radial-bevel: rgba(58, 101, 17, 0.22);
    --radial-ring: rgba(123, 194, 48, 0.40);
  }
  .radial-btn[data-pos-type="primary"] {
    --radial-outline: #1e428a;
    --radial-ink: #143878;
    --radial-bg: rgba(232, 241, 255, 0.96);
    --radial-hover-bg: rgba(244, 249, 255, 0.99);
    --radial-bevel: rgba(30, 66, 138, 0.22);
    --radial-ring: rgba(84, 137, 230, 0.40);
  }
  .radial-btn[data-pos-type="tertiary"] {
    --radial-outline: #a05600;
    --radial-ink: #6f3e00;
    --radial-bg: rgba(255, 239, 214, 0.96);
    --radial-hover-bg: rgba(255, 246, 231, 0.99);
    --radial-bevel: rgba(160, 86, 0, 0.22);
    --radial-ring: rgba(254, 146, 14, 0.40);
  }
  .radial-btn[data-pos-type="shield"] {
    --radial-outline: #0e5f7e;
    --radial-ink: #074d66;
    --radial-bg: rgba(222, 250, 255, 0.96);
    --radial-hover-bg: rgba(237, 253, 255, 0.99);
    --radial-bevel: rgba(14, 95, 126, 0.22);
    --radial-ring: rgba(45, 215, 255, 0.36);
  }
  .radial-btn[data-pos-type="neutral"] {
    --radial-outline: #2f3b57;
    --radial-ink: #202b42;
    --radial-bg: rgba(247, 249, 253, 0.96);
    --radial-hover-bg: rgba(255, 255, 255, 0.99);
    --radial-bevel: rgba(47, 59, 87, 0.20);
    --radial-ring: rgba(84, 137, 230, 0.34);
  }
  /* Colour swatch buttons (Color drill-down). */
  .radial-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), inset 0 -2px 3px rgba(0, 0, 0, 0.18);
  }
  .radial-swatch-reset {
    background:
      linear-gradient(45deg, transparent 44%, #c0392b 44%, #c0392b 56%, transparent 56%),
      rgba(255, 255, 255, 0.85);
  }
  .radial-btn.pulse {
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 var(--radial-bevel, rgba(30, 66, 138, 0.22)),
      0 0 0 3px var(--radial-ring, rgba(84, 137, 230, 0.40)),
      0 10px 24px -12px rgba(40, 50, 80, 0.34);
  }
  .radial-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
  }
  .radial-icon svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.25;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .radial-label {
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    color: currentColor;
    letter-spacing: 0.01em;
  }
  .radial-btn[data-pos-type] .radial-icon,
  .radial-btn[data-pos-type] .radial-label {
    color: var(--radial-ink);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.70);
  }
  body.showcase .radial-menu,
  body.xr-active .radial-menu { display: none; }

  /* -------- dark floating UI refinement -------- */
  body.ui-theme-dark .agent-input,
  body.ui-theme-dark .agent-panel {
    --ink: #f4f7ff;
    --muted: #aeb6c4;
    color: #f4f7ff !important;
    background-color: rgba(24, 26, 35, 0.90) !important;
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.10),
      inset 0 -1px 0 rgba(0, 0, 0, 0.44),
      0 2px 4px rgba(0, 0, 0, 0.34),
      0 18px 44px -16px rgba(0, 0, 0, 0.68) !important;
    backdrop-filter: blur(22px) saturate(135%) !important;
    -webkit-backdrop-filter: blur(22px) saturate(135%) !important;
  }
  body.ui-theme-dark .agent-input input {
    color: #f4f7ff !important;
  }
  body.ui-theme-dark .agent-input input::placeholder {
    color: rgba(218, 225, 238, 0.58) !important;
  }
  body.ui-theme-dark .agent-send,
  body.ui-theme-dark .agent-panel-toggle,
  body.ui-theme-dark .agent-panel-clear {
    color: #f4f7ff !important;
    background: rgba(132, 142, 158, 0.78) !important;
    border-color: rgba(235, 241, 250, 0.72) !important;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.32),
      0 2px 6px rgba(0, 0, 0, 0.34) !important;
  }
  body.ui-theme-dark .agent-send:hover,
  body.ui-theme-dark .agent-panel-toggle:hover,
  body.ui-theme-dark .agent-panel-clear:hover {
    background: rgba(154, 164, 180, 0.86) !important;
  }
  body.ui-theme-dark .agent-target-chip {
    color: #f6f8ff !important;
    background: rgba(76, 91, 126, 0.78) !important;
    border-color: rgba(172, 190, 232, 0.54) !important;
    box-shadow:
      inset 0 0 0 1px rgba(255, 255, 255, 0.18),
      0 0 0 2px rgba(92, 127, 193, 0.34) !important;
  }
  body.ui-theme-dark .agent-grip {
    color: rgba(224, 230, 242, 0.78) !important;
  }
  body.ui-theme-dark .agent-suggestion-chip {
    color: rgba(255, 255, 255, 0.92) !important;
    background: rgba(255, 255, 255, 0.24) !important;
    border-color: rgba(255, 255, 255, 0.62) !important;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.22);
  }
  body.ui-theme-dark .agent-suggestion-chip:hover {
    background: rgba(255, 255, 255, 0.34) !important;
  }
  .agent-attachments {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 4px 2px 42px;
    min-width: 0;
  }
  .agent-attachments[hidden] { display: none; }
  .agent-attachment-chip {
    max-width: 190px;
    min-height: 24px;
    padding: 2px 8px;
    border: 1px solid rgba(191, 209, 255, 0.42);
    border-radius: 999px;
    background: rgba(86, 111, 169, 0.34);
    color: #edf4ff;
    font: inherit;
    font-size: 10.5px;
    font-weight: 750;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
  }
  .drop-hot {
    outline: 2px solid rgba(145, 185, 255, 0.88) !important;
    outline-offset: 4px;
    box-shadow:
      0 0 0 4px rgba(145, 185, 255, 0.20),
      0 18px 44px -16px rgba(0, 0, 0, 0.68) !important;
  }
  .tinyworld-drop-status {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 96;
    padding: 8px 12px;
    border: 1px solid rgba(210, 224, 255, 0.36);
    border-radius: 999px;
    background: rgba(24, 26, 35, 0.90);
    color: #f4f7ff;
    font-size: 12px;
    font-weight: 750;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
    pointer-events: none;
  }
  .tinyworld-drop-status[data-tone="error"] {
    border-color: rgba(255, 188, 170, 0.54);
    color: #ffd9cd;
  }
  .tinyworld-drop-status[hidden] { display: none; }

  body.ui-theme-dark .radial-btn {
    color: #f2f7ff !important;
    background: rgba(28, 32, 43, 0.88) !important;
    border-color: rgba(235, 241, 250, 0.62) !important;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.16),
      inset 0 -2px 0 rgba(0, 0, 0, 0.28),
      0 10px 24px -12px rgba(0, 0, 0, 0.70) !important;
  }
  body.ui-theme-dark .radial-btn:hover {
    background: rgba(47, 55, 72, 0.92) !important;
  }
  body.ui-theme-dark .radial-btn.radial-top {
    color: rgba(242, 247, 255, 0.78) !important;
    background: rgba(118, 128, 145, 0.78) !important;
  }
  body.ui-theme-dark .radial-label {
    color: rgba(224, 231, 244, 0.76) !important;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.36);
  }
  body.ui-theme-dark .radial-swatch-reset {
    background:
      linear-gradient(45deg, transparent 44%, #f06f5f 44%, #f06f5f 56%, transparent 56%),
      rgba(35, 39, 51, 0.94);
  }
  body.ui-theme-dark .radial-btn[data-pos-type] {
    --radial-outline: #dcecff;
    --radial-ink: #f6fbff;
    --radial-dark-bg: rgba(34, 41, 58, 0.88);
    --radial-dark-hover-bg: rgba(48, 58, 80, 0.92);
    --radial-bevel: rgba(0, 0, 0, 0.24);
    --radial-ring: rgba(152, 185, 255, 0.48);
    color: var(--radial-ink) !important;
    background: var(--radial-dark-bg) !important;
    border-color: var(--radial-outline) !important;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.20),
      inset 0 -3px 0 var(--radial-bevel),
      0 2px 5px -2px rgba(0, 0, 0, 0.58) !important;
  }
  body.ui-theme-dark .radial-btn[data-pos-type]:hover {
    background: var(--radial-dark-hover-bg) !important;
    border-color: var(--radial-outline) !important;
  }
  body.ui-theme-dark .radial-btn[data-pos-type="terrain"] {
    --radial-outline: #a8df72;
    --radial-ink: #f3ffe8;
    --radial-dark-bg: rgba(51, 72, 42, 0.88);
    --radial-dark-hover-bg: rgba(64, 90, 50, 0.92);
    --radial-ring: rgba(164, 225, 112, 0.42);
  }
  body.ui-theme-dark .radial-btn[data-pos-type="primary"] {
    --radial-outline: #9fc1ff;
    --radial-ink: #f5f9ff;
    --radial-dark-bg: rgba(40, 54, 92, 0.88);
    --radial-dark-hover-bg: rgba(50, 70, 118, 0.92);
    --radial-ring: rgba(118, 164, 255, 0.48);
  }
  body.ui-theme-dark .radial-btn[data-pos-type="tertiary"] {
    --radial-outline: #ffc26e;
    --radial-ink: #fff8ec;
    --radial-dark-bg: rgba(88, 56, 30, 0.88);
    --radial-dark-hover-bg: rgba(112, 72, 36, 0.92);
    --radial-ring: rgba(255, 169, 76, 0.46);
  }
  body.ui-theme-dark .radial-btn[data-pos-type="shield"] {
    --radial-outline: #75ddff;
    --radial-ink: #edfbff;
    --radial-dark-bg: rgba(30, 72, 92, 0.88);
    --radial-dark-hover-bg: rgba(36, 92, 115, 0.92);
    --radial-ring: rgba(77, 218, 255, 0.44);
  }
  body.ui-theme-dark .radial-btn[data-pos-type="neutral"] {
    --radial-outline: #dcecff;
  }
  body.ui-theme-dark .radial-btn[data-pos-type] .radial-label {
    color: var(--radial-ink) !important;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.58);
  }
  body.ui-theme-dark .radial-btn[data-pos-type] .radial-icon {
    color: var(--radial-ink) !important;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.58);
  }
  body.ui-theme-dark .radial-btn[data-pos-type].pulse {
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.20),
      inset 0 -3px 0 var(--radial-bevel),
      0 0 0 3px var(--radial-ring),
      0 10px 24px -12px rgba(0, 0, 0, 0.70) !important;
  }

  body.ui-theme-dark .toolbar .tool.active,
  body.ui-theme-dark .toolbar .tool[aria-pressed="true"],
  body.ui-theme-dark .toolbar .tool-group-btn.active,
  body.ui-theme-dark .tool-palette .tool.active,
  body.ui-theme-dark .flyout .tool.flyout-tool.active {
    --active-outline: #dcecff;
    --active-fill: rgba(70, 88, 126, 0.92);
    --active-fill-low: rgba(38, 46, 66, 0.94);
    --active-ring: rgba(152, 185, 255, 0.58);
    --active-bevel: rgba(0, 0, 0, 0.34);
    color: #f4f9ff !important;
    background: linear-gradient(180deg, var(--active-fill), var(--active-fill-low)) !important;
    border-color: var(--active-outline) !important;
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.42),
      inset 0 -4px 0 var(--active-bevel),
      0 0 0 2px var(--active-ring),
      0 10px 20px -12px rgba(0, 0, 0, 0.92) !important;
  }
  body.ui-theme-dark .toolbar .tool.active[data-pos-type="terrain"],
  body.ui-theme-dark .toolbar .tool-group-btn.active[data-pos-type="terrain"],
  body.ui-theme-dark .tool-palette .tool.active[data-pos-type="terrain"],
  body.ui-theme-dark .flyout .tool.flyout-tool.active[data-pos-type="terrain"] {
    --active-fill: rgba(70, 94, 62, 0.92);
    --active-fill-low: rgba(42, 58, 38, 0.96);
    --active-ring: rgba(164, 225, 112, 0.48);
  }
  body.ui-theme-dark .toolbar .tool.active[data-pos-type="primary"],
  body.ui-theme-dark .toolbar .tool[aria-pressed="true"][data-pos-type="primary"],
  body.ui-theme-dark .toolbar .tool-group-btn.active[data-pos-type="primary"],
  body.ui-theme-dark .tool-palette .tool.active[data-pos-type="primary"],
  body.ui-theme-dark .flyout .tool.flyout-tool.active[data-pos-type="primary"] {
    --active-fill: rgba(48, 70, 118, 0.94);
    --active-fill-low: rgba(27, 38, 68, 0.98);
    --active-ring: rgba(118, 164, 255, 0.54);
  }
  body.ui-theme-dark .toolbar .tool.active[data-pos-type="tertiary"],
  body.ui-theme-dark .toolbar .tool-group-btn.active[data-pos-type="tertiary"],
  body.ui-theme-dark .tool-palette .tool.active[data-pos-type="tertiary"],
  body.ui-theme-dark .flyout .tool.flyout-tool.active[data-pos-type="tertiary"] {
    --active-fill: rgba(112, 72, 35, 0.94);
    --active-fill-low: rgba(66, 41, 24, 0.98);
    --active-ring: rgba(255, 169, 76, 0.50);
  }
  body.ui-theme-dark .toolbar .tool.active[data-pos-type="shield"],
  body.ui-theme-dark .toolbar .tool[aria-pressed="true"][data-pos-type="shield"],
  body.ui-theme-dark .toolbar .tool-group-btn.active[data-pos-type="shield"],
  body.ui-theme-dark .tool-palette .tool.active[data-pos-type="shield"],
  body.ui-theme-dark .flyout .tool.flyout-tool.active[data-pos-type="shield"] {
    --active-fill: rgba(36, 92, 115, 0.94);
    --active-fill-low: rgba(24, 54, 72, 0.98);
    --active-ring: rgba(77, 218, 255, 0.50);
  }
  body.ui-theme-dark .toolbar .tool.active .tool-glyph,
  body.ui-theme-dark .toolbar .tool[aria-pressed="true"] .tool-glyph,
  body.ui-theme-dark .toolbar .tool-group-btn.active .group-icon-glyph,
  body.ui-theme-dark .tool-palette .tool.active .tool-glyph,
  body.ui-theme-dark .flyout .tool.flyout-tool.active .tool-glyph {
    color: #fff !important;
    --glyph-outline: var(--active-outline);
  }
  body.ui-theme-dark .toolbar .tool.active > span:not(.tool-icon):not(.chev),
  body.ui-theme-dark .toolbar .tool[aria-pressed="true"] > span:not(.tool-icon):not(.chev),
  body.ui-theme-dark .toolbar .tool-group-btn.active > span:not(.group-icon):not(.chev),
  body.ui-theme-dark .tool-palette .tool.active > span:not(.tool-icon):not(.chev),
  body.ui-theme-dark .flyout .tool.flyout-tool.active > span:not(.tool-icon):not(.chev) {
    color: #f4f9ff !important;
  }
  body.ui-theme-dark .flyout .tool.flyout-tool,
  body.ui-theme-dark .tool-palette .tool.flyout-tool {
    color: rgba(230, 237, 249, 0.86) !important;
    border-color: rgba(220, 232, 255, 0.42) !important;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.20),
      inset 0 -3px 0 rgba(0, 0, 0, 0.24),
      0 2px 5px -2px rgba(0, 0, 0, 0.58) !important;
  }
  body.ui-theme-dark .flyout .tool.flyout-tool > span:not(.chev),
  body.ui-theme-dark .tool-palette .tool.flyout-tool > span:not(.chev) {
    color: rgba(232, 238, 250, 0.84) !important;
  }
  body.ui-theme-dark .flyout .tool.flyout-tool:hover,
  body.ui-theme-dark .tool-palette .tool.flyout-tool:hover {
    color: #fff !important;
    border-color: rgba(244, 248, 255, 0.62) !important;
    filter: brightness(1.08);
  }
  body.ui-theme-dark .toolbar .tool[data-pos-type]:not(.active):not([aria-pressed="true"]),
  body.ui-theme-dark .toolbar .tool-group-btn[data-pos-type]:not(.active),
  body.ui-theme-dark .tool-palette .tool.flyout-tool[data-pos-type]:not(.active),
  body.ui-theme-dark .flyout .tool.flyout-tool[data-pos-type]:not(.active) {
    --block-outline: #dcecff;
    --block-dark-bg: rgba(34, 41, 58, 0.88);
    --block-dark-hover-bg: rgba(48, 58, 80, 0.92);
    --block-dark-bevel: rgba(0, 0, 0, 0.24);
    color: #f4f9ff !important;
    background: var(--block-dark-bg) !important;
    border-color: var(--block-outline) !important;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.20),
      inset 0 -3px 0 var(--block-dark-bevel),
      0 2px 5px -2px rgba(0, 0, 0, 0.58) !important;
  }
  body.ui-theme-dark .toolbar .tool[data-pos-type]:not(.active):not([aria-pressed="true"]):hover,
  body.ui-theme-dark .toolbar .tool-group-btn[data-pos-type]:not(.active):hover,
  body.ui-theme-dark .tool-palette .tool.flyout-tool[data-pos-type]:not(.active):hover,
  body.ui-theme-dark .flyout .tool.flyout-tool[data-pos-type]:not(.active):hover {
    background: var(--block-dark-hover-bg) !important;
    border-color: var(--block-outline) !important;
  }
  body.ui-theme-dark .toolbar .tool[data-pos-type="terrain"]:not(.active):not([aria-pressed="true"]),
  body.ui-theme-dark .toolbar .tool-group-btn[data-pos-type="terrain"]:not(.active),
  body.ui-theme-dark .tool-palette .tool.flyout-tool[data-pos-type="terrain"]:not(.active),
  body.ui-theme-dark .flyout .tool.flyout-tool[data-pos-type="terrain"]:not(.active) {
    --block-outline: #a8df72;
    --block-dark-bg: rgba(51, 72, 42, 0.88);
    --block-dark-hover-bg: rgba(64, 90, 50, 0.92);
  }
  body.ui-theme-dark .toolbar .tool[data-pos-type="primary"]:not(.active):not([aria-pressed="true"]),
  body.ui-theme-dark .toolbar .tool-group-btn[data-pos-type="primary"]:not(.active),
  body.ui-theme-dark .tool-palette .tool.flyout-tool[data-pos-type="primary"]:not(.active),
  body.ui-theme-dark .flyout .tool.flyout-tool[data-pos-type="primary"]:not(.active) {
    --block-outline: #9fc1ff;
    --block-dark-bg: rgba(40, 54, 92, 0.88);
    --block-dark-hover-bg: rgba(50, 70, 118, 0.92);
  }
  body.ui-theme-dark .toolbar .tool[data-pos-type="tertiary"]:not(.active):not([aria-pressed="true"]),
  body.ui-theme-dark .toolbar .tool-group-btn[data-pos-type="tertiary"]:not(.active),
  body.ui-theme-dark .tool-palette .tool.flyout-tool[data-pos-type="tertiary"]:not(.active),
  body.ui-theme-dark .flyout .tool.flyout-tool[data-pos-type="tertiary"]:not(.active) {
    --block-outline: #ffc26e;
    --block-dark-bg: rgba(88, 56, 30, 0.88);
    --block-dark-hover-bg: rgba(112, 72, 36, 0.92);
  }
  body.ui-theme-dark .toolbar .tool[data-pos-type="shield"]:not(.active):not([aria-pressed="true"]),
  body.ui-theme-dark .toolbar .tool-group-btn[data-pos-type="shield"]:not(.active),
  body.ui-theme-dark .tool-palette .tool.flyout-tool[data-pos-type="shield"]:not(.active),
  body.ui-theme-dark .flyout .tool.flyout-tool[data-pos-type="shield"]:not(.active) {
    --block-outline: #75ddff;
    --block-dark-bg: rgba(30, 72, 92, 0.88);
    --block-dark-hover-bg: rgba(36, 92, 115, 0.92);
  }
  body.ui-theme-dark .toolbar .tool[data-pos-type="neutral"]:not(.active):not([aria-pressed="true"]),
  body.ui-theme-dark .toolbar .tool-group-btn[data-pos-type="neutral"]:not(.active),
  body.ui-theme-dark .tool-palette .tool.flyout-tool[data-pos-type="neutral"]:not(.active),
  body.ui-theme-dark .flyout .tool.flyout-tool[data-pos-type="neutral"]:not(.active) {
    --block-outline: #dcecff;
  }
  body.ui-theme-dark .toolbar .tool[data-pos-type]:not(.active):not([aria-pressed="true"]) .tool-icon,
  body.ui-theme-dark .toolbar .tool-group-btn[data-pos-type]:not(.active) .group-icon,
  body.ui-theme-dark .tool-palette .tool.flyout-tool[data-pos-type]:not(.active) .tool-icon,
  body.ui-theme-dark .flyout .tool.flyout-tool[data-pos-type]:not(.active) .tool-icon {
    color: var(--block-outline) !important;
  }

  .stamp-panel {
    position: fixed;
    left: 18px;
    top: 92px;
    z-index: 48;
    width: min(440px, calc(100vw - 28px));
    max-height: min(690px, calc(100vh - 118px));
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.6);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.85) inset,
      0 -1px 0 rgba(120, 130, 150, 0.10) inset,
      0 1px 2px rgba(20, 30, 50, 0.05),
      0 24px 56px -16px rgba(40, 50, 80, 0.30);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    overflow: hidden;
  }
  .stamp-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 40%);
    opacity: 0.9;
  }
  .stamp-panel > * {
    position: relative;
    z-index: 1;
  }
  .stamp-panel[hidden] { display: none; }
  .stamp-panel.dragging {
    cursor: grabbing;
    transition: none;
    user-select: none;
  }
  .stamp-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    cursor: grab;
    touch-action: none;
  }
  .stamp-panel-title {
    min-width: 0;
  }
  .stamp-panel-title strong {
    display: block;
    font-family: 'Fraunces', Georgia, serif;
    font-size: 25px;
    line-height: 0.96;
    color: var(--ink);
    letter-spacing: -0.035em;
  }
  .stamp-panel-title span {
    display: block;
    margin-top: 5px;
    color: #655843;
    font-size: 12px;
    line-height: 1.35;
  }
  .stamp-panel-close {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(72, 52, 31, 0.10);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.50);
    color: #4d3d2a;
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset;
  }
  .stamp-panel-close:hover {
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink);
  }
  .stamp-panel-note {
    margin: -3px 0 0;
    color: #5d513e;
    font-size: 12px;
    line-height: 1.4;
  }
  .stamp-panel-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(72, 52, 31, 0.10);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.38);
    color: #5f523f;
    font-size: 11px;
    line-height: 1.3;
  }
  .stamp-panel-summary strong {
    color: var(--ink);
    font-weight: 800;
  }
  .stamp-builder-controls,
  .stamp-builder-tools {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
  }
  .stamp-builder-search {
    flex: 1 1 180px;
    min-width: 0;
    height: 34px;
    border: 1px solid rgba(72, 52, 31, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.62);
    color: var(--ink);
    padding: 0 12px;
    font: inherit;
    font-size: 12px;
    outline: none;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset;
  }
  .stamp-builder-search::placeholder { color: rgba(78, 64, 46, 0.62); }
  .stamp-builder-search:focus {
    border-color: rgba(153, 101, 24, 0.46);
    box-shadow:
      0 0 0 3px rgba(190, 128, 28, 0.13),
      0 1px 0 rgba(255, 255, 255, 0.72) inset;
  }
  .stamp-builder-tools .btn,
  .stamp-panel-foot .btn,
  .stamp-model-actions .btn {
    height: 32px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
  }
  .stamp-builder-settings {
    display: grid;
    gap: 9px;
    padding: 11px;
    border: 1px solid rgba(72, 52, 31, 0.12);
    border-radius: 16px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.56), rgba(242, 229, 205, 0.48));
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.70) inset;
  }
  .stamp-builder-settings[hidden] { display: none; }
  .stamp-model-settings-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 800;
  }
  .stamp-model-settings-head span {
    color: #6d604b;
    font-size: 11px;
    font-weight: 700;
    text-align: right;
  }
  .stamp-model-range {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr) 46px;
    gap: 8px;
    align-items: center;
    color: #5d513e;
    font-size: 11px;
    font-weight: 800;
  }
  .stamp-model-range input[type="range"] {
    width: 100%;
    accent-color: #a7772a;
  }
  .stamp-model-range output {
    text-align: right;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
  }
  .stamp-model-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
  }
  .stamp-category-strip {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 31px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 0 2px 3px 0;
    margin: -1px 0 0;
    scrollbar-width: thin;
  }
  .stamp-category-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 9px;
    border: 1px solid rgba(72, 52, 31, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.42);
    color: #675942;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.62) inset;
  }
  .stamp-category-btn:hover {
    background: rgba(255, 255, 255, 0.68);
    color: var(--ink);
  }
  .stamp-category-btn.active {
    border-color: rgba(153, 101, 24, 0.52);
    background: rgba(255, 239, 191, 0.72);
    color: var(--ink);
  }
  .stamp-category-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    color: #806334;
    font-size: 9px;
    font-variant-numeric: tabular-nums;
  }
  .stamp-builder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
    gap: 10px;
    max-height: min(392px, calc(100vh - 424px));
    overflow: auto;
    padding: 2px 5px 2px 0;
    overscroll-behavior: contain;
  }
  .stamp-builder-empty {
    grid-column: 1 / -1;
    border: 1px dashed rgba(82, 64, 39, 0.22);
    border-radius: 16px;
    padding: 18px;
    color: #6b5a44;
    background: rgba(255, 255, 255, 0.35);
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
  }
  .stamp-card {
    position: relative;
    border: 1px solid rgba(69, 51, 28, 0.15);
    border-radius: 16px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.66), rgba(229, 215, 187, 0.45));
    padding: 8px;
    display: grid;
    gap: 7px;
    min-height: 136px;
    cursor: pointer;
    overflow: hidden;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.62) inset,
      0 10px 22px -20px rgba(54, 39, 24, 0.38);
    transition: background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
  }
  .stamp-card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0) 50%);
  }
  .stamp-card:hover {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(236, 222, 192, 0.56));
    border-color: rgba(68, 48, 24, 0.27);
    transform: translateY(-1px);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.74) inset,
      0 16px 30px -22px rgba(54, 39, 24, 0.54);
  }
  .stamp-card.selected {
    background:
      radial-gradient(circle at 50% 0%, rgba(255, 238, 175, 0.74), rgba(255, 238, 175, 0) 56%),
      linear-gradient(180deg, rgba(255, 247, 213, 0.96), rgba(238, 201, 112, 0.42));
    border-color: rgba(153, 101, 24, 0.74);
    box-shadow:
      0 0 0 2px rgba(190, 128, 28, 0.22),
      0 14px 28px -18px rgba(86, 62, 22, 0.46);
  }
  .stamp-card.unsupported {
    opacity: 0.58;
    cursor: not-allowed;
    filter: grayscale(0.28);
  }
  .stamp-card-delete {
    position: absolute;
    z-index: 2;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border: 1px solid rgba(92, 61, 31, 0.22);
    border-radius: 50%;
    background: rgba(255, 248, 232, 0.86);
    color: #6f5132;
    font-size: 17px;
    font-weight: 900;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(54, 39, 24, 0.14);
  }
  .stamp-card-delete:hover {
    background: #fff3df;
    border-color: rgba(134, 74, 30, 0.42);
    color: #8b4f2e;
  }
  .stamp-card canvas {
    position: relative;
    z-index: 1;
    width: 88px;
    height: 88px;
    align-self: center;
    justify-self: center;
    border-radius: 13px;
    background:
      radial-gradient(circle at 50% 42%, rgba(255, 250, 230, 0.98), rgba(187, 171, 136, 0.46));
    filter: brightness(0.74) contrast(1.38) saturate(0.98) drop-shadow(0 6px 7px rgba(54, 39, 24, 0.24));
  }
  .stamp-card strong {
    position: relative;
    z-index: 1;
    font-size: 11px;
    line-height: 1.15;
    color: var(--ink);
    min-height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  .stamp-card-meta {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    gap: 5px;
    flex-wrap: wrap;
    min-height: 18px;
  }
  .stamp-card-chip {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.52);
    border: 1px solid rgba(72, 52, 31, 0.10);
    color: #675942;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .stamp-card-chip.model { color: #385466; }
  .stamp-card-chip.warn { color: #8b4f2e; }
  .visually-hidden-file {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
  }
  .stamp-panel-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid rgba(68, 48, 24, 0.12);
    padding-top: 10px;
  }
  #stamp-builder-status {
    color: #5f523f;
    font-size: 12px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  @media (max-width: 700px) {
    .stamp-panel {
      left: 12px;
      top: 72px;
      width: min(360px, calc(100vw - 24px));
      max-height: calc(100vh - 104px);
      border-radius: 18px;
    }
    .stamp-builder-grid {
      grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
      max-height: calc(100vh - 464px);
    }
    .stamp-model-range { grid-template-columns: 58px minmax(0, 1fr) 42px; }
    .settings-layout { grid-template-columns: 1fr; }
    .settings-searchbar {
      grid-template-columns: 1fr;
      gap: 4px;
    }
    .settings-search-status { text-align: left; }
    .settings-tabs {
      flex-direction: row;
      overflow-x: auto;
      border-right: none;
      border-bottom: 1px solid var(--line);
      padding-right: 0;
      padding-bottom: 8px;
    }
    .settings-tab {
      flex: 0 0 auto;
      white-space: nowrap;
    }
    .settings-tab-copy { white-space: nowrap; }
    .settings-tab-hint { display: none; }
  }
  .welcome-card {
    width: min(600px, calc(100vw - 32px));
    padding: 14px;
    gap: 12px;
    border-radius: 26px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid rgba(255, 255, 255, 0.62);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 -1px 0 rgba(120, 130, 150, 0.12) inset,
      0 30px 70px -24px rgba(20, 30, 50, 0.38);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
  }
  .launch-card {
    align-items: stretch;
  }
  .welcome-logo {
    display: block;
    width: 100%;
    max-height: min(62vh, 560px);
    aspect-ratio: 1 / 1;
    object-fit: contain;
    border-radius: 20px;
    background: #b7ddff;
    box-shadow:
      inset 0 0 0 1px rgba(255, 255, 255, 0.55),
      0 12px 28px -18px rgba(20, 30, 50, 0.42);
  }
  .welcome-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .welcome-mode-btn {
    --welcome-outline: #2f3b57;
    --welcome-fill: rgba(255, 255, 255, 0.7);
    --welcome-bevel: rgba(47, 59, 87, 0.22);
    min-height: 54px;
    border: 1.5px solid var(--welcome-outline);
    border-radius: 16px;
    background: var(--welcome-fill);
    color: var(--welcome-outline);
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0;
    cursor: pointer;
    outline: none;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -4px 0 var(--welcome-bevel),
      0 3px 5px -2px rgba(20, 30, 50, 0.25);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  }
  .welcome-mode-btn:hover {
    transform: translateY(-1px);
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.96),
      inset 0 -4px 0 var(--welcome-bevel),
      0 6px 10px -5px rgba(20, 30, 50, 0.32);
  }
  .welcome-mode-btn:active {
    transform: translateY(1px);
  }
  .welcome-mode-btn:focus-visible {
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.96),
      inset 0 -4px 0 var(--welcome-bevel),
      0 0 0 3px rgba(255, 255, 255, 0.86),
      0 0 0 6px rgba(23, 107, 235, 0.28);
  }
  .welcome-build {
    --welcome-outline: #1e428a;
    --welcome-fill: rgba(23, 107, 235, 0.13);
    --welcome-bevel: rgba(30, 66, 138, 0.22);
  }
  .welcome-play {
    --welcome-outline: #3a6511;
    --welcome-fill: rgba(123, 194, 48, 0.16);
    --welcome-bevel: rgba(58, 101, 17, 0.24);
  }
  .welcome-credit {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 5px 10px;
    margin: -2px 4px 2px;
    color: rgba(35, 44, 61, 0.70);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
  }
  .welcome-credit a {
    color: #1e428a;
    text-decoration: none;
    white-space: nowrap;
  }
  .welcome-credit a:hover,
  .welcome-credit a:focus-visible {
    color: #123475;
    text-decoration: underline;
    outline: none;
  }
  body.ui-theme-dark .welcome-card {
    background: rgba(16, 22, 33, 0.86) !important;
    border-color: rgba(255, 255, 255, 0.18) !important;
    color: #f4f7ff !important;
  }
  body.ui-theme-dark .welcome-logo {
    background: #8ccaff;
  }
  body.ui-theme-dark .welcome-credit {
    color: rgba(244, 247, 255, 0.76);
  }
  body.ui-theme-dark .welcome-credit a {
    color: #a9c6ff;
  }
  body.ui-theme-dark .welcome-credit a:hover,
  body.ui-theme-dark .welcome-credit a:focus-visible {
    color: #d4e2ff;
  }
  @media (max-width: 600px) {
    .launch-modal { padding: 16px; }
    .welcome-card {
      width: calc(100vw - 24px);
      padding: 10px;
      border-radius: 22px;
    }
    .welcome-logo {
      max-height: min(58vh, 420px);
      border-radius: 16px;
    }
    .welcome-actions { gap: 10px; }
    .welcome-mode-btn {
      min-height: 48px;
      border-radius: 14px;
      font-size: 16px;
    }
    .welcome-credit {
      gap: 4px 8px;
      font-size: 12px;
    }
  }
  @media (max-height: 700px) {
    .welcome-card { width: min(500px, calc(100vw - 32px)); }
    .welcome-logo { max-height: 52vh; }
  }

  /* -------- auth modal -------- */
  .auth-modal {
    position: fixed; inset: 0;
    background: var(--bg);
    z-index: 100;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
  }
  .auth-modal[hidden] { display: none; }
  .auth-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 32px 28px 24px;
    width: min(400px, 100%);
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 16px;
  }
  .auth-card .auth-title {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 26px;
    line-height: 1;
    letter-spacing: -0.03em;
    text-align: center;
  }
  .auth-card .auth-title em {
    font-style: italic;
    color: #a08454;
  }
  .auth-card .auth-subtitle {
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    margin-top: -8px;
  }
  .auth-card label {
    display: flex; flex-direction: column; gap: 4px;
    font-size: 12px; font-weight: 500; color: var(--muted);
  }
  .auth-card input[type="email"],
  .auth-card input[type="password"],
  .auth-card input[type="text"] {
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.15s;
  }
  .auth-card input:focus {
    border-color: rgba(60, 130, 247, 0.5);
  }
  .auth-btn {
    background: var(--ink);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 11px 16px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.12s, transform 0.08s;
  }
  .auth-btn:hover { opacity: 0.88; }
  .auth-btn:active { transform: translateY(1px); }
  .auth-btn:disabled { opacity: 0.5; cursor: not-allowed; }
  .auth-link {
    background: none; border: none;
    color: var(--accent);
    font: inherit; font-size: 13px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .auth-link:hover { color: var(--ink); }
  .auth-footer {
    text-align: center;
    font-size: 13px;
    color: var(--muted);
  }
  .auth-error {
    background: #fdf2f0;
    border: 1px solid #f0d2cc;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    color: #b84838;
  }
  .auth-error[hidden] { display: none; }
  .auth-success {
    background: #f0f7ec;
    border: 1px solid #c8dfc0;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    color: #3d7a2a;
  }
  .auth-success[hidden] { display: none; }
  .auth-form[hidden] { display: none; }
  .auth-divider {
    display: flex; align-items: center; gap: 12px;
    font-size: 12px; color: var(--muted);
  }
  .auth-divider::before,
  .auth-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--line);
  }
  .auth-oauth-btn,
  .auth-google-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, border-color 0.15s;
  }
  .auth-oauth-btn:hover,
  .auth-google-btn:hover { background: #fafaf8; border-color: #ccc; }
  .auth-oauth-btn:active,
  .auth-google-btn:active { transform: translateY(1px); }
  .auth-oauth-btn svg,
  .auth-google-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
  .auth-oauth-btn[hidden] { display: none; }
  .auth-oauth-section[hidden] { display: none; }

  #cloud-layer {
    position: fixed;
    inset: -12%;
    z-index: 6;
    pointer-events: none;
    opacity: 0;
    mix-blend-mode: screen;
    filter: blur(10px);
    background:
      radial-gradient(circle at 16% 28%, rgba(255,255,255,0.55) 0 4%, transparent 9%),
      radial-gradient(circle at 34% 18%, rgba(255,255,255,0.42) 0 5%, transparent 11%),
      radial-gradient(circle at 62% 34%, rgba(255,255,255,0.46) 0 4%, transparent 10%),
      radial-gradient(circle at 78% 18%, rgba(255,255,255,0.36) 0 5%, transparent 12%),
      radial-gradient(circle at 48% 74%, rgba(255,255,255,0.30) 0 4%, transparent 11%);
    background-size: 54% 54%, 62% 62%, 70% 70%, 58% 58%, 76% 76%;
    animation: cloudDrift 80s linear infinite;
  }
  @keyframes cloudDrift {
    from { transform: translate3d(-4%, -2%, 0); }
    to { transform: translate3d(4%, 2%, 0); }
  }

  #under-occlusion-cloud-wipe {
    position: fixed;
    left: -30vw;
    top: 6vh;
    width: 160vw;
    height: 80vh;
    z-index: 6;
    pointer-events: none;
    opacity: 0;
    mix-blend-mode: screen;
    filter: blur(6px);
    will-change: opacity, transform;
    transform: translate3d(-58vw, 0, 0) rotate(-4deg);
    background:
      radial-gradient(ellipse at 10% 52%, rgba(255,255,255,0.00) 0 16%, rgba(255,255,255,0.28) 22%, rgba(255,255,255,0.00) 40%),
      radial-gradient(ellipse at 26% 44%, rgba(255,255,255,0.42) 0 13%, rgba(255,255,255,0.16) 28%, transparent 44%),
      radial-gradient(ellipse at 43% 56%, rgba(255,255,255,0.50) 0 17%, rgba(255,255,255,0.15) 31%, transparent 50%),
      radial-gradient(ellipse at 61% 43%, rgba(255,255,255,0.40) 0 14%, rgba(255,255,255,0.13) 28%, transparent 46%),
      radial-gradient(ellipse at 78% 55%, rgba(255,255,255,0.32) 0 12%, rgba(255,255,255,0.11) 26%, transparent 42%),
      linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.16) 22%, rgba(255,255,255,0.32) 50%, rgba(255,255,255,0.14) 76%, transparent 100%);
  }

  /* -------- profile / saves -------- */
  .saves-list { list-style: none; padding: 0; margin: 10px 0 0; max-height: 300px; overflow-y: auto; }
  .saves-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 6px;
    background: var(--panel);
    cursor: pointer;
    transition: background 0.12s;
  }
  .saves-list li:hover { background: rgba(255, 255, 255, 0.55); }
  .saves-list .save-name { font-weight: 500; font-size: 13px; }
  .saves-list .save-date { font-size: 11px; color: var(--muted); }
  .saves-list .save-actions { display: flex; gap: 6px; }
  .saves-list .save-actions button {
    background: none; border: none; cursor: pointer;
    font-size: 14px; padding: 2px 6px; border-radius: 4px;
    color: var(--muted); transition: color 0.12s, background 0.12s;
  }
  .saves-list .save-actions button:hover { color: var(--ink); background: var(--line); }
  .profile-section { margin-bottom: 16px; }
  .profile-section label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 500; }
  .profile-section input[type="text"],
  .profile-section input[type="url"],
  .profile-section textarea {
    width: 100%; padding: 8px 10px;
    border: 1px solid var(--line); border-radius: 8px;
    font-family: inherit; font-size: 13px;
    background: var(--panel); color: var(--ink);
  }
  .wallet-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.48);
  }
  .wallet-summary > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
  }
  .wallet-kicker {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
  }
  #wallet-address {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
  }
  #wallet-token-count {
    font-size: 12px;
    color: var(--muted);
  }
  .wallet-status {
    flex: 0 0 auto;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(120, 130, 150, 0.16);
    color: #5a6172;
    font-size: 11px;
    font-weight: 800;
  }
  .wallet-status.ok { background: rgba(63, 179, 111, 0.16); color: #2f7d4a; }
  .wallet-status.warn { background: rgba(216, 154, 43, 0.16); color: #8a641f; }
  .wallet-status.err { background: rgba(200, 86, 74, 0.14); color: #8c372c; }
  .wallet-actions,
  .wallet-payment-row,
  .players-search-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
  }
  .wallet-actions .btn,
  .wallet-payment-row .btn,
  .players-search-row .btn {
    white-space: nowrap;
  }
  .wallet-payment-row input,
  .players-search-row input {
    flex: 1 1 auto;
    min-width: 0;
  }
  .wallet-payment-link {
    display: inline-flex;
    align-items: center;
    margin-top: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .wallet-payment-link[hidden] { display: none; }
  .wallet-activity-list,
  .players-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
    max-height: 240px;
    overflow-y: auto;
  }
  .wallet-activity-list li,
  .players-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 6px;
    background: var(--panel);
    font-size: 12.5px;
  }
  .wallet-activity-list .activity-main,
  .players-list .player-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .wallet-activity-list .activity-main strong,
  .players-list .player-main strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .wallet-activity-list .activity-meta,
  .players-list .player-meta {
    color: var(--muted);
    font-size: 11px;
  }
  .players-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  .players-stat {
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.48);
    text-align: center;
  }
  .players-stat strong {
    display: block;
    font-size: 16px;
    line-height: 1.1;
  }
  .players-stat span {
    font-size: 10.5px;
    color: var(--muted);
  }
  .players-list .player-actions {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
  }
  .players-list .player-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--muted);
  }
  .players-list .player-actions button:hover {
    color: var(--ink);
    background: var(--line);
  }
  .wallet-empty { padding: 12px 10px; }
  .api-keys-list {
    list-style: none; padding: 0; margin: 8px 0 0;
    max-height: 180px; overflow-y: auto;
  }
  .api-keys-list li {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 6px;
    background: var(--panel);
    font-size: 12.5px;
  }
  .api-keys-list .api-key-label { font-weight: 500; }
  .api-keys-list .api-key-meta { font-size: 11px; color: var(--muted); }
  .api-keys-list .api-key-actions { display: flex; gap: 6px; }
  .api-keys-list .api-key-actions button {
    background: none; border: none; cursor: pointer;
    font-size: 12px; padding: 4px 8px; border-radius: 4px;
    color: var(--muted);
  }
  .api-keys-list .api-key-actions button:hover { color: var(--ink); background: var(--line); }
  .api-key-reveal {
    margin-top: 10px;
    padding: 10px 12px;
    background: #fdf7e2;
    border: 1px solid #e3cb86;
    border-radius: 8px;
    font-family: 'Inter', monospace;
    font-size: 12px;
    color: #5a4516;
    word-break: break-all;
    line-height: 1.4;
  }
  .api-key-reveal[hidden] { display: none; }
  .api-key-reveal strong { display: block; font-family: 'Inter', sans-serif; font-size: 12px; margin-bottom: 4px; color: #7a5d18; }
  #api-status { font-size: 12px; color: var(--muted); flex: 1; }
  #api-status.error { color: #b84838; }
  #api-status.success { color: #3d7a2a; }
  #account-modal .modal-card {
    width: min(720px, calc(100vw - 32px));
    max-height: min(760px, calc(100vh - 32px));
    overflow: auto;
    padding: 18px;
    gap: 12px;
  }
  #account-modal .modal-head {
    align-items: flex-start;
    gap: 16px;
  }
  #account-modal .modal-head strong {
    font-family: inherit;
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0;
    line-height: 1.12;
  }
  #account-modal .modal-copy {
    margin: -4px 0 4px;
    max-width: 560px;
    font-size: 13px;
    line-height: 1.45;
  }
  #account-modal .modal-close {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1.5px solid #2f3b57;
    background: rgba(255, 255, 255, 0.42);
    color: #2f3b57;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 rgba(47, 59, 87, 0.20),
      0 2px 3px -1px rgba(20, 30, 50, 0.22);
  }
  #account-modal .tab-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  #account-modal .tab-bar::-webkit-scrollbar { display: none; }
  #account-modal .tab-bar button {
    flex: 0 0 auto;
    min-width: 112px;
    min-height: 40px;
    padding: 0 14px;
    border: 1.5px solid #2f3b57;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.42);
    color: #2f3b57;
    font-size: 13px;
    font-weight: 850;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 rgba(47, 59, 87, 0.20),
      0 2px 3px -1px rgba(20, 30, 50, 0.22);
  }
  #account-modal .tab-bar button.active {
    background: linear-gradient(180deg, #f3f8ff, #d8e9ff);
    color: #1e428a;
    border-color: #1e428a;
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.98),
      inset 0 -4px 0 rgba(30, 66, 138, 0.30),
      0 0 0 2px rgba(84, 137, 230, 0.58),
      0 8px 16px -10px rgba(20, 30, 50, 0.72);
  }
  #account-modal .profile-section {
    margin-bottom: 12px;
  }
  #account-modal .profile-section label {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 850;
    color: #5a6172;
  }
  #account-modal .profile-section input[type="text"],
  #account-modal .profile-section input[type="url"],
  #account-modal .profile-section textarea {
    border-radius: 12px;
    border: 1.5px solid rgba(47, 59, 87, 0.28);
    background: rgba(255, 255, 255, 0.58);
    padding: 10px 12px;
    font-size: 13px;
  }
  .profile-section textarea { resize: vertical; min-height: 60px; }
  .profile-hint { margin-top: 4px; font-size: 11px; color: var(--muted); }
  .profile-photo-row { display: flex; align-items: center; gap: 12px; }
  .profile-photo-actions { display: flex; flex-direction: column; gap: 6px; }
  #account-modal .profile-photo-row { align-items: flex-start; }
  #account-modal .profile-photo-actions {
    flex: 1 1 auto;
    min-width: 0;
  }
  #profile-photo-file {
    width: 100%;
    border: 1.5px solid #2f3b57;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.42);
    color: #5a6172;
    padding: 7px;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 rgba(47, 59, 87, 0.16);
  }
  #profile-photo-file::file-selector-button {
    margin-right: 10px;
    border: 0;
    border-radius: 9px;
    background: linear-gradient(180deg, #f3f8ff, #d8e9ff);
    color: #1e428a;
    font: inherit;
    font-size: 12px;
    font-weight: 850;
    padding: 8px 10px;
  }
  #profile-photo-clear {
    align-self: flex-start;
    border: 1.5px solid #2f3b57;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.42);
    color: #2f3b57;
    font-weight: 850;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 255, 255, 0.92),
      inset 0 -3px 0 rgba(47, 59, 87, 0.18);
  }
  .profile-avatar-preview {
    width: 72px; height: 72px; border-radius: 50%;
    object-fit: cover; border: 2px solid var(--line);
    margin: 0; background: rgba(255, 255, 255, 0.78);
  }
  .tab-bar { display: flex; gap: 4px; margin-bottom: 14px; }
  .tab-bar button {
    flex: 1; padding: 8px;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--panel); font-family: inherit;
    font-size: 13px; font-weight: 500;
    color: var(--muted); cursor: pointer;
    transition: background 0.12s, color 0.12s;
  }
  .tab-bar button.active { background: var(--ink); color: var(--panel); border-color: var(--ink); }
  .save-empty { text-align: center; padding: 30px 10px; color: var(--muted); font-size: 13px; }
  /* ---- compact screens ---- */
  @media (max-width: 600px) {
    .help { display: none; }

    .brand {
      top: 14px;
      left: 12px;
    }
    .brand-logo { width: 156px; }
    .brand-banner { display: none; }

    /* Token text stays plain; only the GitHub button carries chrome. */
    .token-corner {
      top: 18px;
      right: 24px;
      font-size: 11px;
    }

    /* Appbar: bottom right corner */
    .appbar {
      top: auto;
      left: auto;
      right: 12px;
      bottom: 80px;
    }
    .language-menu {
      left: auto;
      right: 0;
    }
    .appbar .btn.icon { width: 28px; height: 28px; flex-basis: 28px; }
    .appbar .btn.icon svg { width: 14px; height: 14px; }
    .token-corner .token-sep,
    .token-corner .ca { display: none; }

    /* Controls panel: left side, vertically centered */
    .controls {
      top: 50%;
      left: 5px;
      right: auto;
      transform: translateY(-50%);
      width: 38px;
      max-height: calc(100vh - 200px);
      min-height: 0;
      max-width: none;
      padding: 4px 3px;
    }
    .btn.icon {
      width: 30px;
      height: 30px;
      flex-basis: 30px;
    }
    .btn.icon svg { width: 15px; height: 15px; }

    /* Minimap */
    .minimap-wrap { top: 90px; right: 12px; }
    .minimap-card canvas { width: 105px; height: 105px; }

    /* Popups */
    .topbar-popup { top: 90px; left: 58px; }

    /* Toolbar: bottom center */
    .toolbar {
      top: auto;
      bottom: 12px;
      left: 50%;
      right: auto;
      transform: translateX(-50%);
      min-height: 50px;
      max-width: calc(100vw - 24px);
      padding: 0 5px;
      gap: 1px;
    }
    .toolbar-world-slot { height: 42px; padding-right: 6px; margin-right: 4px; }
    .toolbar .brand-title-btn { height: 36px; font-size: 11px; }
    .toolbar .brand-title-btn::before { width: 22px; height: 22px; }
    .toolbar .brand-title-btn::after { left: 6px; top: 14px; width: 9px; height: 7px; }
    .tool-group-btn { width: 50px; height: 48px; font-size: 9px; padding: 2px; border-radius: 14px; }
    .tool-group-btn .tool-thumb { width: 26px; height: 26px; }
    .toolbar .audio-panel { min-width: 120px; }
    .toolbar .audio-row { grid-template-columns: 20px 62px 26px; }
    .tool { width: 48px; height: 48px; font-size: 9px; padding: 2px; border-radius: 14px; }
    .tool .swatch { width: 20px; height: 20px; }
    .tool .tool-thumb { width: 26px; height: 26px; }

    /* Unsaved banner */
    .unsaved-banner { bottom: 86px; font-size: 11px; padding: 6px 10px 6px 8px; }
  }

  /* ---- very small screens ---- */
  @media (max-width: 400px) {
    .appbar { top: auto; left: auto; right: 8px; bottom: 72px; }
    .appbar .btn.icon { width: 26px; height: 26px; flex-basis: 26px; }
    .token-corner { top: 18px; right: 8px; font-size: 10px; }
    .minimap-wrap { top: 80px; right: 8px; }
    .topbar-popup { top: 80px; left: 50px; }
    .controls { left: 6px; width: 36px; }
    .toolbar { bottom: 10px; max-width: calc(100vw - 16px); }
    .tool-group-btn { width: 46px; height: 44px; }
    .tool { width: 44px; height: 44px; }
    .unsaved-banner { bottom: 78px; }
  }
  @media (hover: none), (pointer: coarse) {
    .help { display: none; }
    .btn { padding: 11px 14px; min-height: 44px; }
    .btn.icon { padding: 0; width: 40px; height: 40px; min-height: 40px; }
    .tool { min-width: 50px; min-height: 50px; }
    .tool-group-btn { min-width: 54px; min-height: 50px; }
    .flyout-item { min-height: 40px; padding: 10px 14px; }
    .tool kbd { display: none; }
  }
  html.ai-disabled [data-ai-interface] { display: none !important; }
  html.ai-disabled #agent-panel.has-selection {
    display: flex !important;
  }
  html.ai-disabled #agent-panel.has-selection .agent-panel-clear,
  html.ai-disabled #agent-panel.has-selection .agent-messages {
    display: none !important;
  }


/* -------- flyable plane flight -------- */
body.flight-active { cursor: none; }
.flight-hud {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 9000;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(14, 18, 24, 0.78);
  color: #eaf2ff;
  font: 12px/1.2 system-ui, sans-serif;
  letter-spacing: 0.04em;
  pointer-events: none;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
.flight-hud b { color: #ffd27a; }
  #flight-combat-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 60; display: none; }
  body.flight-active #flight-combat-overlay { display: block; }
  #flight-reticle { position: absolute; width: 38px; height: 38px; margin: -19px 0 0 -19px;
    border: 1.5px solid rgba(120,230,255,0.85); border-radius: 50%;
    box-shadow: 0 0 6px rgba(120,230,255,0.4); }
  #flight-reticle::before, #flight-reticle::after { content: ''; position: absolute; background: rgba(120,230,255,0.85); }
  #flight-reticle::before { left: 50%; top: -8px; width: 1px; height: 8px; }
  #flight-reticle::after { top: 50%; left: -8px; height: 1px; width: 8px; }
  .fc-target-bracket { position: absolute; border: 1px solid rgba(255,179,106,0.9); box-sizing: border-box; }
  .fc-target-card { position: absolute; font: 10px/1.35 ui-monospace, Menlo, monospace;
    color: #ffd9a8; background: rgba(8,14,25,0.7); border: 1px solid rgba(255,179,106,0.5);
    padding: 2px 5px; white-space: pre; border-radius: 3px; }
  .fc-target-bracket.locked { border-color: rgba(120,255,150,0.95); box-shadow: 0 0 8px rgba(120,255,150,0.5); }
.flight-menu {
  position: fixed;
  z-index: 9100;
  transform: translate(-50%, -120%);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.flight-menu-btn {
  padding: 8px 18px;
  border: 0;
  border-radius: 8px;
  background: #c8503a;
  color: #fff;
  font: 600 13px/1 system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
.flight-menu-btn:hover { background: #d96148; }
