  /* ==========================================================================
     UNIFIED DIALOG SYSTEM — one overlay, one card, one motion for every modal
     Covers: currency modal, no-beef card, BGM picker sheet, iOS install sheet.
     Toast styles live separately below and are intentionally untouched.
     ========================================================================== */
  .modal-overlay,
  .pwa-ios-hint {
    position: fixed;
    inset: 0;
    background: rgba(31, 30, 28, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9000;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
  }

  .modal-overlay {
    display: none;
    align-items: center;
    justify-content: center;
  }

  .modal-overlay.show {
    display: flex;
  }

  .pwa-ios-hint {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .modal-overlay.show,
  .pwa-ios-hint {
    animation: dlgOverlayIn 160ms var(--ease-out);
  }

  @keyframes dlgOverlayIn {
    from { opacity: 0; }
  }

  /* Lock the page behind any open dialog. Toggled by the open/close helpers. */
  body.dialog-open {
    overflow: hidden;
  }

  .modal-card,
  .pwa-ios-hint-card {
    background: var(--color-washi-1);
    border: 1px solid var(--color-washi-4);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius-xl);
    width: 100%;
    padding: 24px 24px 22px;
    position: relative;
    box-sizing: border-box;
    box-shadow: var(--shadow-modal);
    animation: dlgCardIn 240ms var(--ease-out);
  }

  @keyframes dlgCardIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
  }

  .modal-card {
    max-width: 620px;
    max-height: min(88dvh, 860px);
    overflow-y: auto;
  }

  .modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--color-washi-2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-sumi-600);
    transition: var(--transition-snappy);
    touch-action: manipulation;
  }

  .modal-close:hover {
    color: var(--color-sumi-900);
    background: #EAE5DC;
  }

  .modal-close:active {
    transform: scale(0.95);
  }

  /* Year-end shutdown plan: single button in the warnings card + folding sections */
  .shutdown-plan-btn {
    display: block;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    min-height: 52px;
    padding: 12px 20px;
    background: #0F172A;
    color: #FFFFFF;
    border: 1.5px solid #0F172A;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
  }

  .shutdown-plan-btn:active {
    transform: scale(0.98);
  }

  .shutdown-plan-card {
    max-width: 620px;
  }

  .shutdown-details {
    border-bottom: 1px solid var(--color-washi-4);
    padding: 4px 0;
  }

  .shutdown-details summary {
    min-height: 48px;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-indigo);
    padding: 6px 4px;
    touch-action: manipulation;
  }

  .shutdown-details summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
  }

  .shutdown-details ul {
    margin: 4px 0 14px;
    padding-left: 20px;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--color-sumi-600);
  }

  .shutdown-details li {
    margin-bottom: 6px;
  }

  :root[data-theme="dark"] .shutdown-plan-btn {
    background: #FFFFFF;
    color: #0F172A;
    border-color: #FFFFFF;
  }

  :root[data-theme="dark"] .shutdown-details summary {
    color: #FFFFFF;
  }

  :root[data-theme="dark"] .shutdown-details ul {
    color: #E2E8F0;
  }

  .japanese-speech-box {
    background: #FFF8F7;
    border: 2px dashed var(--accent);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    margin: 20px 0;
  }

  .japanese-text {
    font-family: "Shippori Mincho", "Noto Serif JP", serif;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--color-sumi-900);
    line-height: 1.6;
    margin-bottom: 12px;
  }

  .furigana-text {
    font-size: 0.85rem;
    color: var(--color-sumi-600);
    margin-bottom: 12px;
  }

  .chinese-meaning {
    font-size: 1rem;
    color: var(--accent);
    font-weight: 600;
  }

  /* ==========================================================================
     SHADCN/UI STYLE TOAST SYSTEM (Wabi-Sabi Modern Japanese Palette)
     ========================================================================== */
  .toast,
  .shadcn-toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    left: auto;
    width: auto;
    min-width: 290px;
    max-width: 420px;
    background: #FFFFFF;
    color: var(--color-sumi-900);
    border: 1px solid rgba(229, 222, 210, 0.95);
    border-radius: var(--radius-lg, 12px);
    padding: 12px 14px;
    box-shadow: 0 10px 30px -4px rgba(28, 25, 23, 0.14), 0 4px 12px -2px rgba(28, 25, 23, 0.08);
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.2s ease;
    box-sizing: border-box;
    font-family: "Zen Kaku Gothic New", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  .toast.show,
  .shadcn-toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }

  .shadcn-toast-icon-wrap {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(28, 46, 74, 0.06);
    border: 1px solid rgba(28, 46, 74, 0.10);
    flex-shrink: 0;
    margin-top: 1px;
    transition: background 0.15s ease, border-color 0.15s ease;
  }

  .shadcn-toast-icon {
    font-size: 0.95rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Variant-specific icon tints */
  .shadcn-toast[data-variant="success"] .shadcn-toast-icon-wrap {
    background: rgba(45, 106, 79, 0.10);
    border-color: rgba(45, 106, 79, 0.25);
    color: var(--color-matcha);
  }
  .shadcn-toast[data-variant="grab"] .shadcn-toast-icon-wrap {
    background: rgba(0, 177, 79, 0.12);
    border-color: rgba(0, 177, 79, 0.3);
    color: #00873D;
  }
  .shadcn-toast[data-variant="warning"] .shadcn-toast-icon-wrap {
    background: rgba(217, 119, 6, 0.10);
    border-color: rgba(217, 119, 6, 0.28);
    color: #D97706;
  }
  .shadcn-toast[data-variant="accent"] .shadcn-toast-icon-wrap,
  .shadcn-toast[data-variant="copy"] .shadcn-toast-icon-wrap {
    background: rgba(186, 60, 56, 0.08);
    border-color: rgba(186, 60, 56, 0.22);
    color: var(--accent);
  }
  .shadcn-toast[data-variant="music"] .shadcn-toast-icon-wrap {
    background: rgba(222, 96, 85, 0.10);
    border-color: rgba(222, 96, 85, 0.25);
  }

  .shadcn-toast-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .shadcn-toast-title {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--color-sumi-900);
    line-height: 1.35;
    letter-spacing: -0.01em;
  }

  .shadcn-toast-desc {
    font-size: 0.80rem;
    font-weight: 400;
    color: var(--color-sumi-600);
    line-height: 1.45;
    word-break: break-word;
  }

  .shadcn-toast-close {
    width: 22px;
    height: 22px;
    min-width: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--color-sumi-400);
    cursor: pointer;
    padding: 0;
    margin-top: 1px;
    margin-right: -4px;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .shadcn-toast-close:hover {
    background: rgba(28, 25, 23, 0.08);
    color: var(--color-sumi-900);
  }

  .shadcn-toast-close:active {
    transform: scale(0.92);
  }

  /* Mobile: Center bottom with safe area */
  @media (max-width: 640px) {
    .toast,
    .shadcn-toast {
      bottom: calc(20px + env(safe-area-inset-bottom, 0px));
      left: 16px;
      right: 16px;
      min-width: 0;
      max-width: calc(100vw - 32px);
      margin: 0 auto;
      transform: translateY(20px) scale(0.96);
    }
    .toast.show,
    .shadcn-toast.show {
      transform: translateY(0) scale(1);
    }
  }

  /* ==========================================================================
     TOPBAR ACTIONS & BGM (Stay on top only)
     ========================================================================== */
  .editorial-topbar-inner {
    display: flex;
    align-items: center;
    /* Brand mark removed; the controls alone sit flush right. */
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
    width: 100%;
    padding-right: 0;
  }

  /* iOS has no install API, so we explain the share-sheet route in a sheet. */
  /* Size variant: install + BGM sheets are narrower than content modals. */
  .pwa-ios-hint-card {
    max-width: 380px;
    max-height: min(88dvh, 720px);
    overflow-y: auto;
  }
  .pwa-ios-hint-card h4 {
    margin: 0 0 8px;
    padding-right: 36px;
    color: var(--jp-kachi);
    font-size: 1.1rem;
    line-height: 1.35;
  }
  .pwa-ios-hint-card p {
    margin: 0 0 10px;
    font-size: 0.86rem;
    color: var(--jp-sumi);
    line-height: 1.6;
  }
  .pwa-ios-hint-card ol {
    margin: 0 0 16px;
    padding-left: 20px;
    font-size: 0.86rem;
    color: var(--jp-sumi);
    line-height: 1.8;
  }
  .pwa-ios-hint-icon { font-size: 1.05rem; }

  /* ==========================================================================
     SOUNDTRACK PICKER
     Reuses the .pwa-ios-hint overlay shell; only the inner card is new.
     ========================================================================== */
  .bgm-picker-card {
    max-width: 420px;
    padding: 22px 20px 18px;
  }
  .bgm-picker-card h4 {
    margin: 0 0 4px;
    color: var(--jp-kachi);
    font-size: 1.05rem;
  }
  .bgm-picker-hint {
    font-size: 0.78rem;
    color: var(--jp-sumi-muted);
    margin: 0 0 14px;
  }

  .bgm-pick-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: min(52vh, 380px);
    overflow-y: auto;
    margin-bottom: 16px;
    /* Room for the scrollbar so it does not sit on the row text. */
    padding-right: 4px;
  }

  .bgm-pick-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--jp-border);
    border-radius: var(--radius-sm);
    background: #FFFFFF;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background var(--duration-base) var(--ease-out),
                border-color var(--duration-base) var(--ease-out);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
  }
  .bgm-pick-row:hover {
    background: var(--jp-subtle);
    border-color: var(--color-indigo);
  }
  .bgm-pick-row.current {
    border-color: var(--jp-shu);
    background: var(--jp-shu-soft);
  }
  .bgm-pick-row:focus-visible {
    outline: 2px solid var(--color-indigo);
    outline-offset: 1px;
  }

  .bgm-pick-eq {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 12px;
    flex-shrink: 0;
    width: 12px;
  }
  .bgm-pick-eq i {
    display: block;
    width: 2px;
    height: 4px;
    border-radius: 1px;
    background: var(--color-sumi-600);
    opacity: 0.6;
  }
  /* Only the playing row animates, matching the hero chip. */
  .bgm-pick-row.current .bgm-pick-eq i {
    background: var(--jp-shu);
    opacity: 1;
    animation: chipEq 900ms ease-in-out infinite alternate;
  }
  .bgm-pick-row.current .bgm-pick-eq i:nth-child(2) { animation-delay: 180ms; }
  .bgm-pick-row.current .bgm-pick-eq i:nth-child(3) { animation-delay: 360ms; }

  @media (prefers-reduced-motion: reduce) {
    .bgm-pick-row.current .bgm-pick-eq i { animation: none; height: 9px; }
  }

  .bgm-pick-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
  }
  .bgm-pick-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--jp-sumi);
    line-height: 1.35;
  }
  .bgm-pick-desc {
    font-size: 0.75rem;
    color: var(--jp-sumi-muted);
    line-height: 1.35;
  }
  .bgm-pick-mark {
    font-size: 0.95rem;
    color: var(--jp-shu);
    flex-shrink: 0;
    width: 1em;
    text-align: center;
  }

  /* ==========================================================================
     TOP BAR CONTROLS (shared pill chip)
     One visual language for the music toggle and the install button so they
     read as a single control cluster in the hero's top-right corner.
     ========================================================================== */
  .topbar-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    /* Light glass, so the chip stays legible over any part of the photo. */
    background: rgba(255, 255, 255, 0.14);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.28);
    padding: 6px 13px 6px 11px;
    border-radius: var(--radius-pill);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.10);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1;
    transition: background var(--duration-base) var(--ease-out),
                border-color var(--duration-base) var(--ease-out),
                transform var(--duration-base) var(--ease-out);
    backdrop-filter: blur(14px) saturate(1.1);
    -webkit-backdrop-filter: blur(14px) saturate(1.1);
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
    white-space: nowrap;
    min-height: 34px;
  }

  .topbar-chip:hover {
    background: rgba(255, 255, 255, 0.24);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
  }

  .topbar-chip:active {
    transform: translateY(0) scale(0.97);
  }

  /* Keyboard users need a visible target; the hero has no other focus stops. */
  .topbar-chip:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.9);
    outline-offset: 2px;
  }

  .topbar-chip[hidden] { display: none; }

  /* Playing state: the accent returns, plus a small equaliser. */
  .topbar-music-btn.playing {
    background: rgba(186, 60, 56, 0.34);
    border-color: rgba(255, 255, 255, 0.45);
  }

  .chip-eq {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 11px;
    margin-left: 1px;
  }
  .chip-eq i {
    display: block;
    width: 2px;
    height: 4px;
    border-radius: 1px;
    background: currentColor;
    opacity: 0.85;
  }
  /* Animate only while playing; a paused chip should be still. */
  .topbar-music-btn.playing .chip-eq i {
    animation: chipEq 900ms ease-in-out infinite alternate;
  }
  .topbar-music-btn.playing .chip-eq i:nth-child(2) { animation-delay: 180ms; }
  .topbar-music-btn.playing .chip-eq i:nth-child(3) { animation-delay: 360ms; }

  @keyframes chipEq {
    from { height: 3px; }
    to   { height: 11px; }
  }

  @media (prefers-reduced-motion: reduce) {
    .topbar-music-btn.playing .chip-eq i { animation: none; height: 8px; }
  }

  

  .topbar-music-btn .music-icon {
    font-size: 0.95rem;
    line-height: 1;
    display: inline-block;
  }

  .topbar-install-btn .install-icon {
    font-size: 0.95rem;
    line-height: 1;
  }
  .topbar-install-btn .install-text { font-size: 0.8rem; }

  .topbar-music-btn.playing .music-icon {
    animation: musicSpin 3.5s linear infinite;
  }

  @keyframes musicSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }

  .topbar-music-btn.paused-hint::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--accent);
    opacity: 0.6;
    animation: musicPulse 1.8s ease-out infinite;
    pointer-events: none;
  }

  @keyframes musicPulse {
    0% { transform: scale(0.95); opacity: 0.6; }
    70% { transform: scale(1.1); opacity: 0; }
    100% { transform: scale(1.1); opacity: 0; }
  }

  /* ==========================================================================
     BACK TO TOP BUTTON
     ========================================================================== */
  .back-to-top-btn {
    position: fixed;
    bottom: 26px;
    right: 22px;
    z-index: 995;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(28, 46, 74, 0.90);
    color: #FFFFFF;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.9);
    transition: opacity var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out), visibility var(--duration-base) var(--ease-out), background-color var(--duration-fast), border-color var(--duration-fast);
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .back-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
  }

  .back-to-top-btn:hover {
    background: var(--accent);
    transform: translateY(-3px) scale(1.06);
    box-shadow: 0 8px 24px rgba(186, 60, 56, 0.4);
    border-color: rgba(255, 255, 255, 0.65);
  }

  .back-to-top-btn:active {
    transform: translateY(0) scale(0.94);
  }

  .back-to-top-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--duration-fast) var(--ease-out);
  }

  .back-to-top-btn:hover .back-to-top-icon {
    transform: translateY(-2px);
  }

