/* 双人节拍 2.0 外壳：夜色光场、顶栏、移动 4-Tab Dock、全屏门禁、备忘录遮屏、后台匹配胶囊。
   循环动画只操作 transform 与 opacity。 */
@layer shell {
  .solo-setup .solo-options button,
  .multi-title a {
    min-height: 44px;
  }
  .multi-title a {
    display: inline-flex;
    align-items: center;
  }
  .solo-persona-prompt {
    margin-top: 6px;
    color: var(--soft);
  }

  /* ---------- 轻量两层 GPU 光场（随 data-cue 切色） ---------- */
  .night-field {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
    background: radial-gradient(135% 75% at 50% -6%, var(--field-c1) 0%, var(--field-c2) 56%, var(--field-c3) 100%);
    transition: --field-c1 .8s ease, --field-c2 .8s ease, --field-c3 .8s ease, --field-a .8s ease, --field-b .8s ease;
  }
  .night-field::before,
  .night-field::after {
    content: "";
    position: absolute;
    width: 72vmax;
    height: 72vmax;
    border-radius: 50%;
    pointer-events: none;
    will-change: transform;
    opacity: .42;
  }
  .night-field::before {
    left: -26vmax;
    top: -28vmax;
    background: radial-gradient(closest-side, var(--field-a), transparent 72%);
    animation: field-drift-a 24s ease-in-out infinite alternate;
  }
  .night-field::after {
    right: -28vmax;
    bottom: -30vmax;
    opacity: .36;
    background: radial-gradient(closest-side, var(--field-b), transparent 72%);
    animation: field-drift-b 30s ease-in-out infinite alternate;
  }
  @keyframes field-drift-a {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    100% { transform: translate3d(24%, 26%, 0) scale(1.14); }
  }
  @keyframes field-drift-b {
    0% { transform: translate3d(0, 0, 0) scale(1.06); }
    100% { transform: translate3d(-26%, -22%, 0) scale(.92); }
  }

  body[data-cue="fast"] .night-field {
    --field-c1: #62173c; --field-c2: #210a1a; --field-c3: #130810;
    --field-a: #ad2662; --field-b: #6e1c48;
  }
  body[data-cue="slow"] .night-field {
    --field-c1: #5a2a16; --field-c2: #210f12; --field-c3: #13090f;
    --field-a: #ab532b; --field-b: #6c2d1b;
  }
  body[data-cue="stop"] .night-field {
    --field-c1: #2b2060; --field-c2: #140e27; --field-c3: #0d0917;
    --field-a: #5340b5; --field-b: #2b2270;
  }
  body[data-cue="grant"] .night-field {
    --field-c1: #5a3c19; --field-c2: #221216; --field-c3: #140a10;
    --field-a: #b88433; --field-b: #783354;
  }

  /* ---------- 全局容器与顶栏 ---------- */
  .shell {
    width: min(1080px, calc(100% - 32px));
    margin-inline: auto;
  }
  .header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: #170a14ee;
    border-bottom: 1px solid var(--hair);
  }
  .header-inner {
    min-height: var(--header-h);
    height: auto;
    padding-block: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .site-name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding-inline: 4px;
    color: var(--text);
    text-decoration: none;
    font-family: var(--serif);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .04em;
    white-space: nowrap;
  }
  .site-mark {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--go);
    box-shadow: 0 0 12px var(--go);
    flex: none;
  }
  .section-back {
    display: none;
    align-items: center;
    min-height: 44px;
    padding-inline: 8px;
    color: var(--soft);
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
  }
  body[data-play-page] .section-back { display: inline-flex; }
  body[data-play-page] .site-name { display: none; }

  .header-tools {
    margin-inline-start: auto;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .tool-icon-btn {
    min-width: 44px;
    min-height: 44px;
    border-radius: var(--r-pill);
    display: inline-grid;
    place-items: center;
    color: var(--soft);
    background: transparent;
    transition: background-color .2s, color .2s, transform .2s var(--spring);
  }
  .tool-icon-btn:active { transform: scale(.92); }
  .tool-icon-btn[aria-pressed="true"] {
    color: var(--gold);
    background: var(--veil-2);
  }
  @media (hover: hover) {
    .tool-icon-btn:hover { background: var(--veil-2); color: var(--text); }
  }
  .tool-icon-btn svg { width: 19px; height: 19px; }

  .language-switch {
    position: relative;
    margin-inline-start: 0;
    font-size: 13px;
  }
  .header-inner > .site-name + .language-switch {
    margin-inline-start: auto;
  }
  .language-switch summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: var(--r-pill);
    border: 1px solid var(--hair);
    background: var(--veil);
    color: var(--soft);
    list-style: none;
    cursor: pointer;
    white-space: nowrap;
  }
  .language-switch summary::-webkit-details-marker { display: none; }
  .language-switch nav {
    position: absolute;
    z-index: 40;
    inset-inline-end: 0;
    top: calc(100% + 6px);
    min-width: 140px;
    padding: 6px;
    border-radius: var(--r-2);
    border: 1px solid var(--hair-2);
    background: var(--panel-strong);
    box-shadow: 0 16px 40px #00000099;
  }
  .language-switch a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding-inline: 12px;
    border-radius: var(--r-1);
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
  }
  .language-switch a:is(:hover, :focus-visible, [aria-current]) {
    background: var(--veil-2);
    color: var(--gold-2);
  }

  /* ---------- 4-Tab 导航（桌面顶栏 / 移动底部悬浮 Dock） ---------- */
  .view-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-inline-start: 16px;
  }
  .view-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    min-width: 44px;
    padding: 0 14px;
    border-radius: var(--r-pill);
    color: var(--dim);
    font-size: 14px;
    font-weight: 550;
    white-space: nowrap;
    transition: color .2s, background-color .2s;
  }
  .view-tab[aria-current="page"] {
    color: var(--text);
    background: var(--veil-2);
  }
  .view-tab[aria-current="page"] .tab-icon { color: var(--gold); }
  .tab-icon svg { width: 18px; height: 18px; }
  .tab-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--r-pill);
    background: var(--go);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-grid;
    place-items: center;
  }
  body:has(#room:not([hidden])) .view-tabs,
  body:has(#watch-room:not([hidden])) .view-tabs,
  body:has(#room:not([hidden])) .footer,
  body:has(#watch-room:not([hidden])) .footer,
  body[data-trial-only] .view-tabs {
    display: none;
  }
  @media (max-width: 759px) {
    .view-tabs {
      position: fixed;
      z-index: 45;
      left: 10px;
      right: 10px;
      bottom: calc(10px + env(safe-area-inset-bottom));
      margin: 0;
      height: var(--nav-h);
      padding: 5px;
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 2px;
      border-radius: var(--r-3);
      background: #1a0a16;
      border: 1px solid var(--hair-2);
      box-shadow: 0 14px 36px #000000cc;
    }
    .view-tab {
      flex-direction: column;
      gap: 2px;
      padding: 4px 2px;
      min-height: 52px;
      font-size: clamp(10.5px, 2.8vw, 12px);
      border-radius: var(--r-2);
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .view-tab .tab-badge {
      position: absolute;
      top: 4px;
      left: calc(50% + 8px);
    }
    body:has(#lobby:not([hidden])) main {
      padding-bottom: calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
    }
  }

  /* ---------- 后台匹配悬浮胶囊 ---------- */
  .match-pill {
    position: fixed;
    z-index: 44;
    top: calc(var(--header-h) + 8px);
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100% - 24px);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 6px 14px;
    border-radius: var(--r-pill);
    background: var(--panel-strong);
    border: 1px solid #ff8fb155;
    box-shadow: 0 10px 30px #00000088;
    font-size: 13px;
    color: var(--text);
  }
  .match-pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--go);
    animation: pill-pulse 1.6s ease-in-out infinite;
    flex: none;
  }
  @keyframes pill-pulse {
    0%, 100% { opacity: .4; transform: scale(.85); }
    50% { opacity: 1; transform: scale(1.15); }
  }
  .match-pill button {
    min-height: 44px;
    padding: 0 12px;
    border-radius: var(--r-pill);
    font-size: 13px;
    font-weight: 600;
    background: var(--veil-2);
    color: var(--text);
  }
  .match-pill [data-action="pill-open"] {
    background: var(--rose-grad);
    color: var(--gold-ink);
  }

  /* ---------- 通用按钮与控件（保证 ≥44px 触区） ---------- */
  .button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    min-width: 44px;
    padding: 10px 18px;
    border-radius: var(--r-pill);
    font-size: 15px;
    font-weight: 600;
    border: 1px solid transparent;
    text-decoration: none;
    transition: transform .22s var(--spring), background-color .2s, border-color .2s, color .2s;
  }
  .button:not(:disabled):active { transform: scale(.96); }
  .button.primary {
    background: var(--rose-grad);
    color: var(--gold-ink);
    box-shadow: 0 8px 24px #ff5a9338;
  }
  .button.outline {
    background: var(--veil);
    border-color: var(--hair-2);
    color: var(--text);
  }
  .button.danger {
    background: #ff5c6c24;
    border-color: #ff7a8244;
    color: #ffd0d5;
  }
  .text-button,
  .icon-button {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding-inline: 10px;
    border-radius: var(--r-pill);
    color: var(--soft);
    text-decoration: none;
  }
  .social-panel {
    background: var(--panel-solid);
    border: 1px solid var(--hair);
    border-radius: var(--r-2);
    padding: 18px;
    margin-block: 16px;
  }
  dialog {
    background: var(--panel-strong);
    color: var(--text);
    border: 1px solid var(--hair-2);
    border-radius: var(--r-3);
    box-shadow: 0 24px 70px #000000cc;
    max-width: min(460px, calc(100vw - 24px));
  }
  dialog::backdrop {
    background: #0d040cd9;
  }

  /* ---------- 全屏氛围门禁 ---------- */
  .gate {
    position: fixed;
    inset: 0;
    z-index: 80;
    overflow-y: auto;
    display: grid;
    place-items: center;
    padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
    background: radial-gradient(120% 70% at 50% 0%, #501639 0%, #1d0c19 56%, #130810 100%);
  }
  .gate-inner {
    width: min(420px, 100%);
    display: grid;
    gap: 14px;
    text-align: center;
  }
  .gate-lights {
    display: flex;
    justify-content: center;
    gap: 10px;
  }
  .gate-lights i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: block;
  }
  .gate-lights i[data-light="go"] { background: var(--go); }
  .gate-lights i[data-light="slow"] { background: var(--slow); }
  .gate-lights i[data-light="stop"] { background: var(--stop); }
  .gate-title {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(30px, 8vw, 44px);
    line-height: 1.15;
    color: var(--text);
  }
  .gate-line {
    margin: 0;
    font-family: var(--hand);
    font-size: clamp(17px, 4.4vw, 22px);
    color: var(--gold-2);
  }
  .gate-card {
    display: grid;
    gap: 14px;
    padding: 20px 18px;
    border-radius: var(--r-3);
    background: var(--panel-solid);
    border: 1px solid var(--hair-2);
    text-align: start;
  }
  .gate-field {
    display: grid;
    gap: 8px;
    font-size: 14px;
    color: var(--soft);
  }
  .gate-field input {
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    border-radius: var(--r-1);
    border: 1px solid var(--hair-2);
    background: var(--ink-1);
    color: var(--text);
    font-size: 15px;
  }
  .gate-switch {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    min-height: 46px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
  }
  .gate-switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
  }
  .switch-track {
    width: 48px;
    height: 28px;
    padding: 3px;
    border-radius: var(--r-pill);
    background: #ffffff20;
    border: 1px solid var(--hair-2);
    display: flex;
    align-items: center;
    transition: background-color .2s;
  }
  .switch-track i {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--text);
    transform: translateX(0);
    transition: transform .22s var(--spring);
  }
  .gate-switch input:checked + .switch-track {
    background: var(--go);
    border-color: transparent;
  }
  .gate-switch input:checked + .switch-track i {
    transform: translateX(20px);
  }
  .gate-switch input:focus-visible + .switch-track {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
  }
  .gate-enter {
    width: 100%;
    min-height: 50px;
    font-size: 16px;
  }
  .gate-promise {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--dim);
  }
  .gate-leave {
    min-height: 44px;
    justify-self: center;
    padding: 0 18px;
    border-radius: var(--r-pill);
    color: var(--dim);
    font-size: 14px;
  }

  /* 站内中性离开页 */
  .leave-veil {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #f5f5f7;
    color: #202124;
  }
  .leave-box {
    max-width: 420px;
    display: grid;
    gap: 14px;
    text-align: center;
  }
  .leave-box h2 { margin: 0; font-size: 20px; color: #202124; }
  .leave-box p { margin: 0; font-size: 14px; color: #5f6368; }
  .leave-box button {
    justify-self: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: var(--r-pill);
    border: 1px solid #dadce0;
    background: #fff;
    color: #3c4043;
    font-size: 14px;
  }

  /* ---------- 备忘录遮屏（老板键） ---------- */
  .cover {
    position: fixed;
    inset: 0;
    z-index: 120;
    overflow-y: auto;
    padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
    background: #faf8f3;
    color: #26231e;
    user-select: none;
    -webkit-user-select: none;
  }
  .cover-page {
    max-width: 560px;
    margin-inline: auto;
    display: grid;
    gap: 18px;
  }
  .cover-page header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: 12px;
    border-bottom: 1px solid #e7e1d5;
    color: #8a7f6d;
    font-size: 14px;
  }
  .cover-page h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #1f1c18;
  }
  .cover-page ul {
    margin: 0;
    padding-inline-start: 20px;
    display: grid;
    gap: 12px;
    font-size: 16px;
    line-height: 1.6;
    color: #3a352e;
  }
  .cover-hint {
    margin-top: 28px;
    font-size: 12px;
    color: #b4aa9a;
    text-align: center;
  }

  /* ---------- Footer 与 Guide 页面触区修复 ---------- */
  .footer {
    margin-top: 40px;
    padding: 24px 0 calc(28px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--hair);
    color: var(--dim);
    font-size: 13px;
    display: grid;
    gap: 14px;
  }
  @media (max-width: 759px) {
    body:has(#lobby:not([hidden])) .footer {
      padding-bottom: calc(var(--nav-h) + 32px + env(safe-area-inset-bottom));
    }
  }
  .footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
  }
  .footer-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: var(--r-1);
    color: var(--soft);
    text-decoration: none;
  }
  .footer-links a:hover { background: var(--veil); color: var(--text); }
  .footer-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
  }
  .footer-meta .profile {
    min-height: 44px;
    padding: 0 12px 0 6px;
    border-radius: var(--r-pill);
    border: 1px solid var(--hair);
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }
  .guide-page {
    width: min(760px, calc(100% - 32px));
    margin: 20px auto 48px;
  }
  .guide-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
  }
  .guide-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding-inline: 8px;
    text-decoration: none;
  }
  .guide-page article {
    background: var(--panel-solid);
    border: 1px solid var(--hair);
    border-radius: var(--r-2);
    padding: 18px;
    margin-block: 14px;
  }
  .directory-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-block: 16px;
  }
  .play-guide {
    background: var(--panel-solid);
    border: 1px solid var(--hair);
    border-radius: var(--r-3);
    padding: 22px 20px;
    margin-top: 28px;
    color: var(--soft);
  }
  .play-guide h2, .play-guide h3 { color: var(--text); }
  .play-guide a { color: var(--gold-2); }
}
