:root {
      --bg0: #efe8da;
      --bg1: #f7f2e8;
      --paper: rgba(255, 252, 246, 0.88);
      --ink: #1c3228;
      --ink-soft: #3d5348;
      --muted: #6e7a72;
      --line: rgba(40, 70, 55, 0.12);
      --accent: #2f6b4f;
      --accent-2: #3f8563;
      --accent-soft: rgba(47, 107, 79, 0.12);
      --danger: #a34535;
      --danger-soft: rgba(163, 69, 53, 0.1);
      --shadow: 0 18px 40px rgba(55, 45, 25, 0.08);
      --radius: 18px;
      --font-display: "Noto Serif SC", "Songti SC", serif;
      --font-ui: "Noto Sans SC", "PingFang SC", sans-serif;
    }

    * { box-sizing: border-box; }
    /* 默认即壳色；纸质聊天底只在解锁后启用，避免冷启动先闪深色 */
    html, body {
      margin: 0;
      padding: 0;
      min-height: 100%;
      height: 100%;
      font-family: var(--font-ui);
      color: var(--ink);
      background-color: #f2f2f7;
      background-image: linear-gradient(180deg, #ffffff 0%, #f2f2f7 100%);
    }
    html.disguise-unlocked,
    html.disguise-unlocked body {
      background:
        radial-gradient(1200px 700px at 12% -10%, rgba(63, 133, 99, 0.16), transparent 55%),
        radial-gradient(900px 600px at 100% 0%, rgba(180, 140, 70, 0.14), transparent 50%),
        linear-gradient(160deg, var(--bg1), var(--bg0));
    }

    /* 伪装态：计算器壳色（对齐密聊 pwa-calc-boot，避免冷启动黑闪） */
    html.disguise-boot,
    html.disguise-active,
    html.pwa-calc-boot {
      background-color: #f2f2f7 !important;
      background-image: linear-gradient(180deg, #ffffff 0%, #f2f2f7 100%) !important;
      color-scheme: light only !important;
    }
    html.disguise-boot body,
    html.disguise-active body,
    html.pwa-calc-boot body {
      background-color: #f2f2f7 !important;
      background-image: linear-gradient(180deg, #ffffff 0%, #f2f2f7 100%) !important;
      overflow: hidden;
    }
    html.disguise-active #app-root,
    html.disguise-boot #app-root {
      visibility: hidden !important;
      pointer-events: none !important;
      opacity: 0 !important;
    }

    body::before {
      content: none;
      display: none;
    }
    html.disguise-unlocked body::before {
      content: "";
      display: block;
      position: fixed;
      inset: 0;
      pointer-events: none;
      opacity: 0.35;
      background-image:
        linear-gradient(rgba(40, 70, 55, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(40, 70, 55, 0.03) 1px, transparent 1px);
      background-size: 28px 28px;
      mask-image: radial-gradient(ellipse at center, #000 40%, transparent 85%);
    }

    /* —— 聊天 UI —— */
    #app-root {
      position: relative;
      z-index: 1;
      height: 100%;
    }
    .shell {
      position: relative;
      z-index: 1;
      max-width: 760px;
      height: 100%;
      margin: 0 auto;
      padding: 18px 14px calc(14px + env(safe-area-inset-bottom));
      display: flex;
      flex-direction: column;
      gap: 12px;
      animation: rise 0.55s ease both;
    }
    @keyframes rise {
      from { opacity: 0; transform: translateY(10px); }
      to { opacity: 1; transform: none; }
    }
    @keyframes fadein {
      from { opacity: 0; transform: translateY(6px); }
      to { opacity: 1; transform: none; }
    }
    .brand {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 2px 4px 8px;
    }
    .brand__identity {
      display: flex;
      align-items: center;
      gap: 11px;
      min-width: 0;
      border: 0;
      background: transparent;
      padding: 4px;
      margin: -4px;
      border-radius: 14px;
      text-align: left;
      font: inherit;
      cursor: pointer;
      color: inherit;
      transition: opacity 0.15s ease;
      -webkit-tap-highlight-color: transparent;
    }
    .brand__identity:hover { opacity: 0.82; }
    .brand__identity:active { opacity: 0.65; }
    .brand__identity:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .brand__install-hint {
      flex: 0 0 auto;
      align-self: flex-start;
      margin-top: 2px;
      width: 17px;
      height: 17px;
      display: grid;
      place-items: center;
      border-radius: 50%;
      color: var(--accent);
      background: var(--accent-soft);
      opacity: 0.75;
    }
    .brand__logo {
      flex-shrink: 0;
      width: 42px;
      height: 42px;
      display: grid;
      place-items: center;
      color: #fff;
      border-radius: 13px;
      background: linear-gradient(155deg, var(--accent-2), var(--accent));
      box-shadow: 0 6px 16px rgba(47, 107, 79, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.28);
    }
    .brand__text { display: block; min-width: 0; }
    .brand h1 {
      margin: 0;
      font-family: var(--font-display);
      font-size: clamp(1.5rem, 4vw, 1.8rem);
      letter-spacing: 0.06em;
      font-weight: 700;
      line-height: 1.15;
      color: var(--ink);
    }
    .brand p {
      margin: 3px 0 0;
      color: var(--muted);
      font-size: 0.78rem;
      letter-spacing: 0.02em;
    }
    .brand-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
    .brand-actions button {
      border: 1px solid var(--line);
      background: rgba(255,255,255,0.72);
      color: var(--ink-soft);
      border-radius: 999px;
      padding: 7px 14px;
      font: inherit;
      font-size: 0.78rem;
      font-weight: 600;
      cursor: pointer;
      text-decoration: none;
      display: inline-flex;
      align-items: center;
      transition: background 0.15s ease, border-color 0.15s ease;
    }
    /* display:inline-flex 会盖掉原生 [hidden]，必须显式藏 */
    .brand-actions button[hidden],
    .brand-menu[hidden] {
      display: none !important;
    }
    .brand-menu {
      position: relative;
      display: inline-flex;
    }
    .brand-menu__btn {
      width: 36px;
      height: 36px;
      padding: 0 !important;
      justify-content: center;
      border-radius: 999px !important;
    }
    .brand-menu__btn[aria-expanded="true"] {
      background: var(--accent-soft);
      border-color: rgba(47, 107, 79, 0.28);
      color: var(--accent);
    }
    /* 清屏图标：与「更多」同规格，用危险色提示破坏性操作 */
    #btn-clear.brand-menu__btn {
      color: var(--danger);
      border-color: rgba(163, 69, 53, 0.3);
    }
    #btn-clear.brand-menu__btn:hover,
    #btn-clear.brand-menu__btn:active {
      background: var(--danger-soft);
      border-color: rgba(163, 69, 53, 0.45);
      color: var(--danger);
    }
    #btn-clear.brand-menu__btn:disabled { opacity: 0.55; cursor: wait; }
    .brand-menu__panel {
      position: absolute;
      top: calc(100% + 8px);
      right: 0;
      z-index: 80;
      min-width: 148px;
      padding: 6px;
      border-radius: 14px;
      border: 1px solid var(--line);
      background: rgba(255, 252, 246, 0.96);
      box-shadow: 0 14px 32px rgba(55, 45, 25, 0.14);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      display: flex;
      flex-direction: column;
      gap: 2px;
      animation: fadein 0.18s ease both;
    }
    .brand-menu__panel[hidden] { display: none !important; }
    .brand-menu__item {
      border: 0 !important;
      background: transparent !important;
      border-radius: 10px !important;
      padding: 10px 12px !important;
      text-align: left;
      color: var(--ink-soft) !important;
      font-size: 0.88rem !important;
      font-weight: 600 !important;
      width: 100%;
      justify-content: flex-start !important;
      box-shadow: none !important;
    }
    .brand-menu__item:hover,
    .brand-menu__item:active {
      background: var(--accent-soft) !important;
      color: var(--accent) !important;
    }
    /* 新建房间：菜单里的正向强调项，与设置类项区分 */
    .brand-menu__item--accent {
      display: flex !important;
      align-items: center;
      gap: 8px;
      margin-top: 4px;
      border-top: 1px solid var(--line) !important;
      border-radius: 0 0 10px 10px !important;
      padding-top: 12px !important;
      color: var(--accent) !important;
    }
    .brand-menu__item--accent svg { flex: 0 0 auto; opacity: 0.9; }
    .brand-menu__item--accent:hover,
    .brand-menu__item--accent:active {
      background: var(--accent-soft) !important;
      color: var(--accent) !important;
    }
    .avatar-swatches {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      padding: 8px 2px 4px;
      justify-content: flex-start;
      align-items: center;
    }
    .avatar-swatch {
      width: 48px;
      height: 48px;
      flex: 0 0 48px;
      border: 2px solid transparent;
      border-radius: 50%;
      cursor: pointer;
      padding: 0;
      overflow: hidden;
      background: #f3f0ea;
      box-shadow: 0 2px 8px rgba(40, 70, 55, 0.12);
    }
    .avatar-swatch img {
      display: block;
      width: 48px;
      height: 48px;
      object-fit: cover;
      border-radius: 50%;
    }
    .avatar-swatch.is-active {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px var(--accent-soft);
    }
    .avatar-upload-row {
      margin-top: 12px;
    }
    .avatar-upload-btn {
      width: 100%;
      border: 1px dashed rgba(47, 107, 79, 0.35);
      background: rgba(47, 107, 79, 0.06);
      color: var(--accent);
      border-radius: 12px;
      padding: 10px 14px;
      font: inherit;
      font-weight: 600;
      cursor: pointer;
    }
    .avatar-upload-btn:hover {
      background: rgba(47, 107, 79, 0.12);
    }
    .brand-actions button:hover {
      background: #fff;
      border-color: rgba(47, 107, 79, 0.28);
    }
    .brand-actions #btn-home {
      background: var(--accent-soft);
      border-color: rgba(47, 107, 79, 0.22);
      color: var(--accent);
    }
    .brand-actions #btn-home:hover {
      background: rgba(47, 107, 79, 0.18);
      border-color: rgba(47, 107, 79, 0.32);
    }
    .panel {
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
      background: var(--paper);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      overflow: hidden;
    }
    .join {
      flex: 1;
      display: grid;
      place-items: center;
      padding: 22px 16px;
      background:
        radial-gradient(ellipse at 18% 12%, rgba(63, 133, 99, 0.14), transparent 52%),
        radial-gradient(ellipse at 88% 8%, rgba(180, 140, 70, 0.12), transparent 48%),
        linear-gradient(165deg, rgba(255, 252, 246, 0.55), rgba(239, 232, 218, 0.35));
    }
    /* display:grid 会盖掉原生 hidden，必须显式藏 */
    #join-view[hidden],
    #chat-view[hidden],
    .join[hidden] { display: none !important; }

    .love-letter {
      width: min(100%, 380px);
      perspective: 1400px;
      animation: fadein 0.55s ease both;
    }
    .love-letter__inner {
      position: relative;
      width: 100%;
      min-height: 320px;
      transform-style: preserve-3d;
      transition: transform 0.78s cubic-bezier(0.4, 0.15, 0.2, 1), min-height 0.25s ease;
    }
    .love-letter.is-flipped .love-letter__inner {
      transform: rotateY(180deg);
    }
    .love-letter__face {
      position: absolute;
      inset: 0;
      backface-visibility: hidden;
      -webkit-backface-visibility: hidden;
    }
    .love-letter__face--back {
      transform: rotateY(180deg);
    }
    .love-letter__paper {
      position: relative;
      height: 100%;
      min-height: 320px;
      box-sizing: border-box;
      padding: 22px 22px 18px;
      border-radius: 18px;
      border: 1px solid rgba(40, 70, 55, 0.1);
      background:
        radial-gradient(120% 60% at 100% 0%, rgba(255, 255, 255, 0.6), transparent 55%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 40%),
        repeating-linear-gradient(
          transparent,
          transparent 27px,
          rgba(47, 107, 79, 0.05) 28px
        ),
        linear-gradient(165deg, #fffdf8, #f7f1e4);
      box-shadow:
        0 1px 2px rgba(55, 45, 25, 0.06),
        0 18px 42px rgba(55, 45, 25, 0.13);
      display: flex;
      flex-direction: column;
    }
    .love-letter__paper--back {
      background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 36%),
        linear-gradient(165deg, #fffdf8, #f3ecdc);
    }
    /* 邮戳：右上朱红双圈印章 */
    .letter-stamp {
      position: absolute;
      top: 18px;
      right: 18px;
      width: 50px;
      height: 50px;
      display: grid;
      place-items: center;
      border: 1.5px solid rgba(163, 69, 53, 0.5);
      border-radius: 50%;
      color: rgba(163, 69, 53, 0.72);
      font-family: var(--font-display);
      font-size: 0.62rem;
      line-height: 1.15;
      letter-spacing: 0.06em;
      text-align: center;
      transform: rotate(-11deg);
      box-shadow: inset 0 0 0 3px rgba(255, 252, 246, 0.9), inset 0 0 0 4px rgba(163, 69, 53, 0.3);
      pointer-events: none;
    }
    /* 背面「寄」字火漆印章 */
    .letter-seal {
      position: absolute;
      top: 18px;
      right: 18px;
      width: 38px;
      height: 38px;
      display: grid;
      place-items: center;
      border-radius: 50%;
      background: linear-gradient(145deg, #b2563f, #933c2c);
      color: #fdf3ec;
      font-family: var(--font-display);
      font-size: 1.05rem;
      font-weight: 700;
      box-shadow: 0 4px 10px rgba(147, 60, 44, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.28);
      transform: rotate(9deg);
      pointer-events: none;
    }
    .love-letter__eyebrow {
      display: flex;
      align-items: center;
      gap: 9px;
      margin: 0 0 12px;
      padding-right: 58px;
      font-size: 0.78rem;
      letter-spacing: 0.18em;
      color: var(--accent);
      font-weight: 600;
      flex-shrink: 0;
    }
    .love-letter__eyebrow i {
      display: block;
      width: 16px;
      height: 1px;
      background: rgba(47, 107, 79, 0.4);
      flex-shrink: 0;
    }
    /* 书信落款 */
    /* display:flex 会盖掉原生 hidden，必须显式藏 */
    .love-letter__sign[hidden],
    .love-letter__flip-btn[hidden] { display: none !important; }
    .love-letter__sign {
      display: flex;
      align-items: center;
      gap: 10px;
      margin: 8px 0 2px;
      flex-shrink: 0;
      animation: fadein 0.4s ease both;
    }
    .love-letter__sign-line {
      width: 26px;
      height: 1px;
      background: rgba(47, 107, 79, 0.35);
    }
    .love-letter__sign-name {
      font-family: var(--font-display);
      font-size: 0.8rem;
      color: var(--muted);
      letter-spacing: 0.12em;
    }
    .love-letter__type {
      margin: 0;
      flex: 0 0 auto;
      min-height: 0;
      white-space: pre-wrap;
      word-break: break-word;
      font-family: var(--font-display);
      font-size: 1.12rem;
      /* 与信纸横线 28px 对齐，每行间距一致 */
      line-height: 28px;
      letter-spacing: 0.08em;
      color: var(--ink);
    }
    .love-letter__caret {
      display: inline-block;
      width: 2px;
      height: 1.05em;
      margin-left: 2px;
      vertical-align: -3px;
      background: var(--accent);
      animation: loveCaret 1s step-end infinite;
    }
    .love-letter__caret.is-done { opacity: 0; animation: none; }
    @keyframes loveCaret {
      50% { opacity: 0; }
    }
    #love-paper-front { cursor: default; }
    .love-letter__flip-btn {
      align-self: stretch;
      margin-top: 16px;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      border: 1px solid rgba(47, 107, 79, 0.28);
      border-radius: 999px;
      padding: 13px 16px;
      background: linear-gradient(180deg, var(--accent-2), var(--accent));
      color: #f7fff9;
      font: inherit;
      font-size: 0.92rem;
      font-weight: 700;
      letter-spacing: 0.08em;
      cursor: pointer;
      box-shadow: 0 10px 22px rgba(47, 107, 79, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.16);
      transition: filter 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
      animation: fadein 0.45s ease both;
    }
    .love-letter__flip-btn svg { opacity: 0.85; transition: transform 0.18s ease; }
    .love-letter__flip-btn:hover {
      filter: brightness(1.05);
      box-shadow: 0 12px 26px rgba(47, 107, 79, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.16);
    }
    .love-letter__flip-btn:hover svg { transform: translateX(3px); }
    .love-letter__flip-btn:active { transform: scale(0.98); }
    .love-letter__back-link {
      align-self: flex-start;
      border: 0;
      background: transparent;
      color: var(--muted);
      font: inherit;
      font-size: 0.82rem;
      padding: 0;
      margin: 0 0 14px;
      cursor: pointer;
    }
    .love-letter__back-link:hover { color: var(--accent); }
    .love-letter__paper--back h2 {
      position: relative;
      margin: 0 0 12px;
      padding-bottom: 10px;
      font-family: var(--font-display);
      font-size: 1.45rem;
      font-weight: 700;
      letter-spacing: 0.04em;
    }
    .love-letter__paper--back h2::after {
      content: '';
      position: absolute;
      left: 0;
      bottom: 0;
      width: 38px;
      height: 2px;
      border-radius: 2px;
      background: linear-gradient(90deg, var(--accent), rgba(47, 107, 79, 0.15));
    }
    .love-letter__paper--back .hint {
      margin: 0 0 20px;
      padding: 10px 13px;
      border-radius: 12px;
      border: 1px solid rgba(47, 107, 79, 0.1);
      background: rgba(47, 107, 79, 0.045);
      color: var(--muted);
      line-height: 1.7;
      font-size: 0.85rem;
    }
    .love-letter__paper--back label {
      display: block;
      margin-bottom: 8px;
      font-size: 0.88rem;
      color: var(--ink-soft);
      font-weight: 600;
      letter-spacing: 0.02em;
    }
    .join-row { display: flex; gap: 10px; align-items: stretch; }
    .join-row input[type="text"],
    .pin-row input[type="password"],
    .pin-row input[type="text"] {
      flex: 1;
      min-width: 0;
      border: 1px solid var(--line);
      background: #fffdf8;
      border-radius: 14px;
      padding: 14px 15px;
      font: inherit;
      font-size: 1rem;
      color: var(--ink);
      outline: none;
      transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }
    .join-row input[type="text"]:focus,
    .pin-row input:focus,
    .input-wrapper:focus-within {
      border-color: rgba(47, 107, 79, 0.42);
      box-shadow: 0 0 0 4px var(--accent-soft);
    }
    .join-row input[type="submit"],
    .pin-row button {
      border: none;
      border-radius: 14px;
      padding: 0 20px;
      background: linear-gradient(180deg, var(--accent-2), var(--accent));
      color: #f7fff9;
      font: inherit;
      font-weight: 700;
      letter-spacing: 0.04em;
      cursor: pointer;
      box-shadow: 0 8px 18px rgba(47, 107, 79, 0.22);
      transition: filter 0.15s ease, transform 0.12s ease;
    }
    .join-row input[type="submit"]:active,
    .pin-row button:active { filter: brightness(0.96); transform: scale(0.98); }
    .error {
      margin: 0 0 14px;
      padding: 10px 12px;
      border-radius: 10px;
      background: var(--danger-soft);
      color: var(--danger);
      font-size: 0.9rem;
    }
    #chat-view {
      --wx-bar-height: 54px;
      --bottom-dock-height: 54px;
      --accessory-inset: 0px;
      --keyboard-inset: 0px;
      --wx-accessory-slot-h: 240px;
      --chat-safe-b: env(safe-area-inset-bottom, 0px);
      position: relative;
      overflow: hidden;
    }
    #chatbox {
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      padding: 14px 14px 10px;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      overscroll-behavior: contain;
      -webkit-overflow-scrolling: touch;
      scroll-behavior: smooth;
    }
    #chat-view.kb-open #chatbox {
      padding-bottom: 8px;
    }
    #chatbox > .empty { align-self: center; }
    .empty {
      margin: auto 10px;
      padding: 30px 26px 26px;
      text-align: center;
      color: var(--muted);
      font-size: 0.9rem;
      line-height: 1.6;
      border-radius: 18px;
      background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 252, 246, 0.42));
      border: 1px solid rgba(47, 107, 79, 0.12);
      box-shadow: 0 10px 30px rgba(55, 45, 25, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
      max-width: 300px;
    }
    .empty::before {
      content: "";
      display: block;
      width: 52px;
      height: 52px;
      margin: 0 auto 14px;
      border-radius: 50%;
      background-color: rgba(47, 107, 79, 0.08);
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='26' height='26' fill='none' stroke='%232f6b4f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2.4'/%3E%3Cpath d='M3.6 6.6 12 13l8.4-6.4'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: center;
      border: 1px solid rgba(47, 107, 79, 0.16);
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    }
    .message-time-divider {
      align-self: stretch;
      text-align: center;
      margin: 6px 0 14px;
      padding: 0;
      width: 100%;
    }
    .message-time-divider span {
      display: inline-block;
      padding: 3px 11px;
      border-radius: 999px;
      font-size: 0.7rem;
      color: var(--muted);
      letter-spacing: 0.03em;
      background: rgba(255, 255, 255, 0.62);
      border: 1px solid rgba(40, 70, 55, 0.05);
      box-shadow: 0 1px 2px rgba(55, 45, 25, 0.04);
    }
    .msg-row {
      display: flex;
      align-items: flex-start;
      gap: 9px;
      margin: 0 0 14px;
      max-width: 100%;
      width: 100%;
    }
    .msg-row.msg-new { animation: fadein .28s ease both; }
    .msg-row--out { flex-direction: row-reverse; }
    .user-avatar {
      position: relative;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      color: #fff;
      font-weight: 700;
      text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
      box-shadow: 0 4px 12px rgba(40, 70, 55, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.28);
      border: 1px solid rgba(255, 255, 255, 0.25);
    }
    .msg-avatar {
      width: 40px;
      height: 40px;
      border-radius: 13px;
      font-size: 14px;
      box-shadow: 0 3px 10px rgba(40, 70, 55, 0.16), 0 1px 2px rgba(40, 70, 55, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
    .user-avatar__fallback { position: relative; z-index: 0; line-height: 1; }
    .user-avatar--img {
      background: #efeae2 !important;
      padding: 0;
    }
    .user-avatar__img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .msg-main {
      display: flex;
      flex-direction: column;
      max-width: min(calc(100% - 50px), 420px);
      min-width: 0;
    }
    .msg-row--out .msg-main { align-items: flex-end; }
    .msg-row--in .msg-main { align-items: flex-start; }
    .msg-sender-name {
      display: flex;
      align-items: center;
      gap: 6px;
      max-width: 100%;
      margin: 0 0 5px 3px;
      font-size: 0.73rem;
      font-weight: 600;
      line-height: 1.2;
      color: var(--ink-soft);
      opacity: 0.82;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .msg-sender-name--self { margin-right: 2px; margin-left: 0; justify-content: flex-end; }
    .msg-badge {
      display: inline-block;
      padding: 1px 7px;
      border-radius: 999px;
      background: var(--danger-soft);
      color: var(--danger);
      font-size: 0.7rem;
      font-weight: 700;
      flex-shrink: 0;
    }
    .msg-bubble {
      padding: 10px 14px;
      border-radius: 16px;
      background: linear-gradient(180deg, #fff, rgba(255, 252, 246, 0.94));
      border: 1px solid rgba(40, 70, 55, 0.06);
      border-bottom-left-radius: 5px;
      max-width: 100%;
      box-shadow: 0 2px 4px rgba(55, 45, 25, 0.03), 0 8px 20px rgba(55, 45, 25, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    }
    .msg-bubble--mine {
      background: linear-gradient(155deg, #3f8563, #2f6b4f);
      border-color: rgba(47, 107, 79, 0.4);
      border-bottom-left-radius: 16px;
      border-bottom-right-radius: 5px;
      box-shadow: 0 2px 5px rgba(47, 107, 79, 0.12), 0 8px 20px rgba(47, 107, 79, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.16);
    }
    .msg-bubble--mine .msg-bubble__content { color: #f7fff9; }
    .msg-bubble--admin:not(.msg-bubble--mine) {
      background: linear-gradient(180deg, rgba(163, 69, 53, 0.07), rgba(255, 255, 255, 0.6));
      border-color: rgba(163, 69, 53, 0.14);
    }
    .msg-bubble__content {
      line-height: 1.58;
      font-size: 0.98rem;
      word-break: break-word;
      white-space: pre-wrap;
      color: var(--ink);
    }
    .msg-bubble--image {
      position: relative;
      padding: 4px;
      background: transparent !important;
      border-color: transparent !important;
      box-shadow: none;
    }
    .msg-bubble__content--image { line-height: 0; }
    .msg-image {
      display: block;
      max-width: min(52vw, 220px);
      max-height: 220px;
      min-width: 72px;
      min-height: 96px;
      width: auto;
      height: auto;
      border-radius: 16px;
      object-fit: cover;
      cursor: zoom-in;
      background: rgba(15, 23, 42, 0.06);
      box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
    }
    .msg-bubble--image.msg-bubble--sending .msg-image { opacity: 0.72; }
    .msg-bubble--video {
      position: relative;
      padding: 0;
      background: transparent !important;
      border-color: transparent !important;
      box-shadow: none;
      overflow: visible;
    }
    .msg-bubble__content--video {
      position: relative;
      line-height: 0;
    }
    .msg-video-card {
      position: relative;
      display: block;
      border: 0;
      padding: 0;
      margin: 0;
      width: min(52vw, 220px);
      min-width: 160px;
      min-height: 120px;
      border-radius: 16px;
      overflow: hidden;
      background: #0f172a;
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
      box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
      transition: transform 0.14s ease;
    }
    .msg-video-card:active { transform: scale(0.985); }
    .msg-video-thumb {
      display: block;
      width: 100%;
      height: auto;
      max-height: 220px;
      min-height: 120px;
      object-fit: cover;
      vertical-align: top;
      pointer-events: none;
      background: #0f172a;
    }
    .msg-video-fallback {
      display: grid;
      place-items: center;
      min-height: 140px;
      color: rgba(255, 255, 255, 0.85);
      font-size: 0.88rem;
      background: linear-gradient(145deg, #334155, #0f172a);
      pointer-events: none;
    }
    .msg-video-play {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      width: 46px;
      height: 46px;
      border-radius: 999px;
      display: grid;
      place-items: center;
      background: rgba(15, 23, 42, 0.48);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      color: #fff;
      font-size: 15px;
      padding-left: 2px;
      pointer-events: none;
      box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
      border: 1px solid rgba(255, 255, 255, 0.18);
    }
    .msg-video-duration {
      position: absolute;
      right: 8px;
      bottom: 7px;
      padding: 2px 7px;
      border-radius: 6px;
      background: rgba(0, 0, 0, 0.42);
      color: #fff;
      font-size: 11px;
      line-height: 1.25;
      font-variant-numeric: tabular-nums;
      letter-spacing: 0.02em;
      pointer-events: none;
    }
    .msg-bubble--video.msg-bubble--sending .msg-video-card { opacity: 0.78; }
    .video-lightbox {
      position: fixed;
      inset: 0;
      z-index: 12000;
      display: grid;
      place-items: center;
      padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
      background: rgba(0, 0, 0, 0.92);
      animation: fadein 0.2s ease both;
    }
    .video-lightbox[hidden] { display: none !important; }
    .video-lightbox__player {
      width: min(100%, 720px);
      max-height: min(78vh, 720px);
      background: #000;
      border-radius: 16px;
      box-shadow: 0 22px 56px rgba(0, 0, 0, 0.5);
    }
    .video-lightbox::after {
      content: "轻触空白处关闭";
      position: absolute;
      left: 50%;
      bottom: max(22px, env(safe-area-inset-bottom, 0px));
      transform: translateX(-50%);
      padding: 6px 14px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.1);
      text-align: center;
      color: rgba(255, 255, 255, 0.72);
      font-size: 12px;
      letter-spacing: 0.04em;
      pointer-events: none;
      white-space: nowrap;
    }
    .msg-image-sending {
      position: absolute;
      left: 50%;
      bottom: 12px;
      transform: translateX(-50%);
      padding: 4px 10px;
      border-radius: 999px;
      font-size: 11px;
      line-height: 1.2;
      color: #fff;
      background: rgba(15, 23, 42, 0.58);
      backdrop-filter: blur(4px);
      -webkit-backdrop-filter: blur(4px);
      pointer-events: none;
      white-space: nowrap;
    }
    .composer {
      flex-shrink: 0;
      margin-top: auto;
      display: flex;
      flex-direction: column;
      width: 100%;
      border-top: 1px solid rgba(40, 70, 55, 0.07);
      background: linear-gradient(180deg, rgba(255, 252, 246, 0.92), rgba(255, 250, 242, 0.97));
      backdrop-filter: blur(14px) saturate(1.15);
      -webkit-backdrop-filter: blur(14px) saturate(1.15);
      padding: 0 0 max(8px, var(--chat-safe-b, env(safe-area-inset-bottom, 0px)));
      box-sizing: border-box;
      box-shadow: 0 -8px 24px rgba(55, 45, 25, 0.04);
    }
    /* 对齐密聊：仅软键盘用 --keyboard-inset 上移；表情/+ 回文档流贴底 */
    #chat-view.kb-ios-lift.kb-open .composer {
      position: fixed !important;
      left: 0 !important;
      right: 0 !important;
      bottom: 0 !important;
      width: 100% !important;
      max-width: 100% !important;
      margin: 0 !important;
      z-index: 620 !important;
      transform: translateY(calc(-1 * var(--keyboard-inset, 0px))) !important;
      padding-bottom: 0 !important;
      border-radius: 0;
    }
    #chat-view.kb-accessory.kb-open .composer,
    #chat-view.kb-cap-resize.kb-open .composer,
    #chat-view:not(.kb-open) .composer {
      position: relative !important;
      top: auto !important;
      bottom: auto !important;
      left: auto !important;
      right: auto !important;
      width: 100% !important;
      max-width: 100% !important;
      transform: none !important;
      z-index: auto !important;
    }
    #chat-view.kb-open .composer {
      padding-bottom: 0;
    }
    /* 对齐密聊：面板在输入框下方，固定槽高占键盘位 */
    .emoji-panel {
      display: none;
      flex-wrap: wrap;
      align-content: flex-start;
      gap: 0;
      margin: 0;
      padding: 12px 8px 14px;
      height: var(--wx-accessory-slot-h, 240px);
      max-height: var(--wx-accessory-slot-h, 240px);
      overflow-y: auto;
      background: rgba(247, 244, 236, 0.88);
      border-top: 1px solid rgba(40, 70, 55, 0.07);
      -webkit-overflow-scrolling: touch;
      box-sizing: border-box;
      animation: wxAccessoryIn 0.22s cubic-bezier(0.32, 0.72, 0.24, 1);
    }
    .emoji-panel:not([hidden]) { display: flex; }
    .emoji-panel[hidden],
    .chat-plus-panel[hidden] { display: none !important; }
    .emoji-panel button,
    .emoji-item {
      width: 44px;
      height: 44px;
      padding: 6px;
      border: none;
      border-radius: 10px;
      background: transparent;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 1.45rem;
      line-height: 1;
      cursor: pointer;
      font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif;
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
    }
    .emoji-panel button:hover { background: rgba(47, 107, 79, 0.1); }
    .emoji-panel button:active {
      background: rgba(0, 0, 0, 0.06);
      transform: scale(0.92);
    }
    .chat-plus-panel {
      display: none;
      grid-template-columns: repeat(4, 1fr);
      gap: 18px 0;
      align-content: start;
      margin: 0;
      padding: 22px 14px 14px;
      height: var(--wx-accessory-slot-h, 240px);
      max-height: var(--wx-accessory-slot-h, 240px);
      overflow: hidden;
      background: rgba(247, 244, 236, 0.88);
      border-top: 1px solid rgba(40, 70, 55, 0.07);
      box-sizing: border-box;
      animation: wxAccessoryIn 0.22s cubic-bezier(0.32, 0.72, 0.24, 1);
    }
    .chat-plus-panel:not([hidden]) { display: grid; }
    @keyframes wxAccessoryIn {
      from { opacity: 0; transform: translateY(6px); }
      to { opacity: 1; transform: translateY(0); }
    }
    .chat-plus-panel__item {
      border: none;
      background: transparent;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 9px;
      cursor: pointer;
      color: var(--ink-soft);
      font: inherit;
      font-size: 12px;
      font-weight: 500;
      padding: 0;
      -webkit-tap-highlight-color: transparent;
    }
    .chat-plus-panel__item:disabled { opacity: 0.55; cursor: wait; }
    .chat-plus-panel__icon {
      width: 58px;
      height: 58px;
      border-radius: 18px;
      background: linear-gradient(180deg, #fff, rgba(255, 252, 246, 0.96));
      border: 1px solid rgba(40, 70, 55, 0.07);
      display: grid;
      place-items: center;
      color: var(--accent);
      box-shadow: 0 8px 18px rgba(40, 70, 55, 0.09);
      transition: transform 0.15s ease, box-shadow 0.15s ease;
    }
    .chat-plus-panel__item:active .chat-plus-panel__icon {
      transform: scale(0.94);
      box-shadow: 0 4px 10px rgba(40, 70, 55, 0.08);
    }
    .input-bar {
      display: flex;
      align-items: flex-end;
      gap: 5px;
      min-height: 54px;
      padding: 9px 11px 8px;
      box-sizing: border-box;
    }
    .wx-bar-btn {
      width: 38px;
      height: 38px;
      margin-bottom: 1px;
      padding: 0;
      border: none;
      background: transparent;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      color: var(--ink-soft);
      cursor: pointer;
      flex-shrink: 0;
      border-radius: 11px;
      transition: background 0.15s ease, color 0.15s ease;
    }
    .wx-bar-btn:active { background: rgba(40, 70, 55, 0.06); }
    .wx-bar-btn.active { color: var(--accent); background: var(--accent-soft); }
    .wx-bar-btn svg { display: block; }
    .input-area {
      flex: 1;
      min-width: 0;
      display: flex;
      align-items: flex-end;
      margin-bottom: 1px;
    }
    .input-wrapper {
      flex: 1;
      min-width: 0;
      background: #fff;
      border: 1px solid rgba(40, 70, 55, 0.1);
      border-radius: 20px;
      padding: 8px 15px;
      min-height: 38px;
      display: flex;
      align-items: flex-end;
      box-sizing: border-box;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 1px 2px rgba(55, 45, 25, 0.03);
      transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    }
    .input-wrapper:focus-within {
      border-color: rgba(47, 107, 79, 0.4);
      background: #fffefb;
      box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    }
    #msg {
      width: 100%;
      border: 0;
      background: transparent;
      outline: none;
      resize: none;
      font: inherit;
      font-size: 17px;
      line-height: 22px;
      color: var(--ink);
      padding: 0;
      margin: 0;
      min-height: 22px;
      max-height: 132px;
      overflow-y: hidden;
      word-wrap: break-word;
      white-space: pre-wrap;
      font-family: var(--font-ui), "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif;
    }
    #msg:focus {
      border-color: transparent;
      box-shadow: none;
    }
    .msg-bubble__content {
      font-family: var(--font-ui), "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif;
    }
    .input-bar__action {
      flex-shrink: 0;
      width: 52px;
      min-height: 38px;
      margin-bottom: 1px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .wx-send-btn {
      border: 0;
      background: linear-gradient(180deg, var(--accent-2), var(--accent));
      color: #fff;
      font: inherit;
      font-size: 0.92rem;
      font-weight: 700;
      padding: 0 10px;
      width: 100%;
      height: 36px;
      line-height: 36px;
      border-radius: 18px;
      cursor: pointer;
      box-shadow: 0 7px 16px rgba(47, 107, 79, 0.26);
      letter-spacing: 0.04em;
      transition: filter 0.12s ease, transform 0.12s ease;
    }
    .wx-send-btn:active { filter: brightness(0.96); transform: scale(0.97); }
    .wx-send-btn[hidden],
    .wx-bar-btn[hidden] { display: none !important; }
    .composer-foot {
      display: flex;
      justify-content: space-between;
      gap: 10px;
      padding: 0 14px 2px;
      min-height: 1.15em;
      font-size: 0.76rem;
      color: var(--muted);
    }
    #char-count.over { color: var(--danger); font-weight: 600; }
    #notice:not(:empty) { color: var(--danger); font-weight: 500; }
    .img-lightbox {
      position: fixed;
      inset: 0;
      z-index: 9999;
      background: rgba(0,0,0,0.88);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: max(20px, env(safe-area-inset-top, 0px)) 20px max(20px, env(safe-area-inset-bottom, 0px));
      cursor: zoom-out;
      animation: fadein 0.18s ease both;
    }
    .img-lightbox[hidden] { display: none !important; }
    .img-lightbox img {
      max-width: min(96vw, 920px);
      max-height: 90vh;
      border-radius: 12px;
      box-shadow: 0 18px 48px rgba(0,0,0,0.42);
    }
    .img-lightbox::after {
      content: "轻触空白处关闭";
      position: absolute;
      left: 50%;
      bottom: max(22px, env(safe-area-inset-bottom, 0px));
      transform: translateX(-50%);
      padding: 6px 14px;
      border-radius: 999px;
      background: rgba(255, 255, 255, 0.1);
      color: rgba(255, 255, 255, 0.72);
      font-size: 12px;
      letter-spacing: 0.04em;
      pointer-events: none;
      white-space: nowrap;
    }

    .utility-backdrop {
      position: fixed;
      inset: 0;
      z-index: 90;
      display: none;
      background: rgba(28, 22, 16, 0.42);
      -webkit-backdrop-filter: blur(3px);
      backdrop-filter: blur(3px);
    }
    .utility-backdrop.open {
      display: block;
      animation: fadein 0.18s ease both;
    }
    .pin-panel {
      display: none;
      position: fixed;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      z-index: 91;
      width: min(360px, calc(100vw - 32px));
      max-height: min(78vh, 560px);
      overflow: auto;
      -webkit-overflow-scrolling: touch;
      box-sizing: border-box;
      padding: 16px 18px 18px;
      border-radius: 18px;
      border: 1px solid rgba(47, 107, 79, 0.14);
      background: rgba(255, 252, 246, 0.98);
      box-shadow: 0 18px 48px rgba(40, 50, 40, 0.22);
    }
    .pin-panel.open {
      display: block;
      animation: utility-pop 0.22s ease both;
    }
    @keyframes utility-pop {
      from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); }
      to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    }
    .pin-panel__head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 6px;
    }
    .pin-panel h3 {
      margin: 0;
      font-family: var(--font-display);
      font-size: 1.08rem;
    }
    .pin-panel__close {
      flex: 0 0 auto;
      width: 32px;
      height: 32px;
      border: 0;
      border-radius: 999px;
      background: rgba(40, 50, 40, 0.06);
      color: var(--muted);
      font-size: 1.25rem;
      line-height: 1;
      cursor: pointer;
    }
    .pin-panel__close:hover {
      background: rgba(40, 50, 40, 0.1);
      color: var(--ink);
    }
    .pin-panel p { margin: 0 0 12px; color: var(--muted); font-size: 0.85rem; line-height: 1.55; }
    .pin-panel__tip { margin-top: 8px !important; margin-bottom: 0 !important; font-size: 0.82rem !important; }
    .pin-row { display: flex; gap: 8px; }
    .pin-row button { min-width: 72px; height: 46px; }

    /* 清屏确认弹窗：沿用 pin-panel 容器，危险色主题 */
    .confirm-panel { text-align: center; padding: 22px 20px 20px; }
    .confirm-panel__mark {
      width: 48px;
      height: 48px;
      margin: 0 auto 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 999px;
      color: var(--danger);
      background: var(--danger-soft);
      border: 1px solid rgba(163, 69, 53, 0.18);
    }
    .confirm-panel h3 { font-size: 1.15rem; margin-bottom: 8px; }
    .confirm-panel p { text-align: center; }
    .confirm-panel__actions {
      display: flex;
      gap: 10px;
      margin-top: 16px;
    }
    .confirm-panel__btn {
      flex: 1;
      min-width: 0;
      height: 44px;
      border-radius: 12px;
      font: inherit;
      font-size: 0.88rem;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease, filter 0.15s ease;
    }
    .confirm-panel__btn:active { transform: scale(0.98); }
    .confirm-panel__btn--ghost {
      border: 1px solid var(--line);
      background: rgba(255, 255, 255, 0.7);
      color: var(--ink-soft);
    }
    .confirm-panel__btn--ghost:hover {
      background: #fff;
      border-color: rgba(47, 107, 79, 0.28);
    }
    .confirm-panel__btn--danger {
      border: 1px solid var(--danger);
      background: var(--danger);
      color: #fff;
    }
    .confirm-panel__btn--danger:hover { filter: brightness(1.06); }
    .confirm-panel__btn:disabled { opacity: 0.55; cursor: wait; }
    /* 主色实心按钮：用于创建/打开房间等正向操作 */
    .confirm-panel__btn--primary {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      text-align: center;
      text-decoration: none;
      border: 1px solid var(--accent);
      background: linear-gradient(180deg, var(--accent-2), var(--accent));
      color: #fff;
      box-shadow: 0 6px 14px rgba(47, 107, 79, 0.22);
    }
    .confirm-panel__btn--primary:hover { filter: brightness(1.06); }
    .confirm-panel__btn--primary svg { flex: 0 0 auto; opacity: 0.9; transition: transform 0.18s ease; }
    .confirm-panel__btn--primary:hover svg { transform: translateX(2px); }

    /* —— 新建房间 / 生成链接面板 —— */
    .pin-panel__label {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 8px;
      margin: 0 0 7px;
      font-size: 0.82rem;
      font-weight: 600;
      color: var(--ink-soft);
    }
    .pin-panel__label span {
      font-size: 0.72rem;
      font-weight: 400;
      color: var(--muted);
      opacity: 0.85;
    }
    .pin-panel__input {
      width: 100%;
      height: 42px;
      box-sizing: border-box;
      padding: 0 12px;
      border: 1px solid rgba(40, 70, 55, 0.16);
      border-radius: 11px;
      background: #fff;
      color: var(--ink);
      font: inherit;
      font-size: 0.88rem;
      outline: none;
      transition: border-color 0.18s ease, box-shadow 0.18s ease;
    }
    .pin-panel__input::placeholder { color: #a3aca5; }
    .pin-panel__input:focus {
      border-color: rgba(47, 107, 79, 0.45);
      box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.1);
    }
    .pin-panel__input[readonly] {
      color: var(--ink-soft);
      background: rgba(47, 107, 79, 0.04);
    }

    .room-panel {
      padding: 20px 20px 20px;
      background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.6), transparent 42%),
        rgba(255, 252, 246, 0.98);
      box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.85) inset,
        0 2px 6px rgba(40, 50, 40, 0.08),
        0 22px 54px rgba(40, 50, 40, 0.24);
    }
    .room-panel__intro {
      display: flex;
      align-items: center;
      gap: 13px;
      padding: 2px 0 16px;
      margin-bottom: 16px;
      border-bottom: 1px solid var(--line);
    }
    .room-panel__mark {
      flex: 0 0 auto;
      width: 46px;
      height: 46px;
      display: grid;
      place-items: center;
      border-radius: 14px;
      color: var(--accent);
      background: linear-gradient(155deg, rgba(63, 133, 99, 0.16), rgba(47, 107, 79, 0.07));
      border: 1px solid rgba(47, 107, 79, 0.16);
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    }
    .room-panel__intro .pin-panel__hint {
      margin: 0;
      display: flex;
      flex-direction: column;
      gap: 3px;
    }
    .room-panel__hint-main {
      font-size: 0.84rem;
      line-height: 1.55;
      color: var(--ink-soft);
      font-weight: 500;
    }
    .room-panel__hint-sub {
      font-size: 0.75rem;
      line-height: 1.5;
      color: var(--muted);
    }
    .room-panel__actions { margin-top: 14px; }
    .room-panel__actions .confirm-panel__btn { height: 44px; }

    .room-panel__result-head {
      display: flex;
      align-items: center;
      gap: 9px;
      margin-bottom: 16px;
      padding: 9px 12px;
      border-radius: 11px;
      background: linear-gradient(135deg, rgba(63, 133, 99, 0.13), rgba(47, 107, 79, 0.06));
      border: 1px solid rgba(47, 107, 79, 0.14);
      font-size: 0.9rem;
      font-weight: 700;
      letter-spacing: 0.01em;
      color: var(--accent);
    }
    .room-panel__check {
      width: 22px;
      height: 22px;
      display: grid;
      place-items: center;
      border-radius: 50%;
      color: #fff;
      background: var(--accent);
      box-shadow: 0 3px 8px rgba(47, 107, 79, 0.25);
    }
    .room-panel__linkbox { position: relative; }
    .room-panel.is-created .room-panel__form { display: none; }
    .room-panel__result { animation: fadein 0.28s ease both; }

    .room-panel__list-wrap {
      margin-top: 18px;
      padding-top: 14px;
      border-top: 1px solid var(--line);
    }
    .room-panel__list-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 10px;
      font-size: 0.82rem;
      font-weight: 700;
      color: var(--ink-soft);
      letter-spacing: 0.02em;
    }
    .room-panel__refresh {
      border: 0;
      background: transparent;
      color: var(--accent);
      font: inherit;
      font-size: 0.78rem;
      font-weight: 600;
      cursor: pointer;
      padding: 4px 6px;
      border-radius: 8px;
    }
    .room-panel__refresh:hover { background: rgba(47, 107, 79, 0.08); }
    .room-panel__list {
      display: flex;
      flex-direction: column;
      gap: 8px;
      max-height: min(42vh, 320px);
      overflow: auto;
      -webkit-overflow-scrolling: touch;
      padding-right: 2px;
    }
    .room-panel__list-empty {
      margin: 0;
      padding: 14px 10px;
      text-align: center;
      font-size: 0.8rem;
      color: var(--muted);
    }
    .room-card {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 8px 10px;
      align-items: center;
      padding: 11px 12px;
      border-radius: 12px;
      border: 1px solid rgba(47, 107, 79, 0.12);
      background: rgba(255, 255, 255, 0.72);
    }
    .room-card.is-current {
      border-color: rgba(47, 107, 79, 0.28);
      background: linear-gradient(135deg, rgba(63, 133, 99, 0.1), rgba(255, 255, 255, 0.75));
    }
    .room-card__meta { min-width: 0; }
    .room-card__title {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 0.86rem;
      font-weight: 700;
      color: var(--ink);
      word-break: break-all;
    }
    .room-card__badge {
      flex: 0 0 auto;
      font-size: 0.68rem;
      font-weight: 700;
      color: var(--accent);
      background: rgba(47, 107, 79, 0.12);
      border-radius: 999px;
      padding: 1px 7px;
    }
    .room-card__sub {
      margin-top: 3px;
      font-size: 0.72rem;
      line-height: 1.45;
      color: var(--muted);
    }
    .room-card__actions {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      justify-content: flex-end;
    }
    .room-card__btn {
      border: 0;
      border-radius: 9px;
      height: 32px;
      padding: 0 10px;
      font: inherit;
      font-size: 0.74rem;
      font-weight: 600;
      cursor: pointer;
      background: rgba(47, 107, 79, 0.1);
      color: var(--accent);
    }
    .room-card__btn:hover { filter: brightness(0.97); }
    .room-card__btn--ghost {
      background: rgba(40, 50, 40, 0.06);
      color: var(--ink-soft);
    }
    .room-card__btn--danger {
      background: rgba(196, 72, 54, 0.12);
      color: #b33a2b;
    }

    .room-panel__qr {
      margin-top: 14px;
      text-align: center;
    }
    .room-panel__qr-frame {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 12px;
      border-radius: 16px;
      background: #fff;
      border: 1px solid rgba(47, 107, 79, 0.14);
      box-shadow: 0 8px 22px rgba(40, 50, 40, 0.08);
      min-width: 168px;
      min-height: 168px;
    }
    .room-panel__qr-frame img {
      display: block;
      width: 148px;
      height: 148px;
      image-rendering: pixelated;
    }
    .room-panel__qr-tip {
      margin: 8px 0 0;
      font-size: 0.75rem;
      color: var(--muted);
    }

    .room-qr-modal {
      position: fixed;
      inset: 0;
      z-index: 12040;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 18px;
      box-sizing: border-box;
      background: rgba(30, 36, 32, 0.42);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
    }
    .room-qr-modal[hidden] { display: none !important; }
    .room-qr-modal__card {
      width: min(360px, 100%);
      padding: 18px 18px 16px;
      border-radius: 18px;
      background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.72), transparent 40%),
        rgba(255, 252, 246, 0.98);
      box-shadow: 0 22px 54px rgba(40, 50, 40, 0.28);
    }
    .room-qr-modal__head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 6px;
    }
    .room-qr-modal__head h3 {
      margin: 0;
      font-size: 1.05rem;
    }
    .room-qr-modal__note {
      margin: 0 0 12px;
      font-size: 0.8rem;
      color: var(--muted);
      line-height: 1.45;
    }
    .room-qr-modal__frame {
      display: flex;
      margin: 0 auto 12px;
    }

    /* —— 无房间态 room-gate（聊天链路入口）—— */
    .room-gate {
      width: min(420px, 100%);
      max-width: 100%;
      margin: 0 auto;
      box-sizing: border-box;
      padding: 32px 22px 26px;
      text-align: center;
      border-radius: 20px;
      border: 1px solid rgba(47, 107, 79, 0.12);
      background:
        radial-gradient(120% 70% at 50% -10%, rgba(255, 255, 255, 0.95), transparent 62%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.55), transparent 46%),
        linear-gradient(165deg, #fffdf8, #f5eee0);
      box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        0 18px 44px rgba(55, 45, 25, 0.1);
      animation: fadein 0.3s ease both;
      overflow: hidden;
    }
    .room-gate__mark {
      display: grid;
      place-items: center;
      width: 60px;
      height: 60px;
      margin: 0 auto 18px;
      border-radius: 50%;
      color: var(--accent);
      background: linear-gradient(155deg, rgba(63, 133, 99, 0.14), rgba(47, 107, 79, 0.05));
      border: 1px solid rgba(47, 107, 79, 0.15);
      box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 0 0 5px rgba(47, 107, 79, 0.045);
    }
    .room-gate__title {
      margin: 0 0 12px;
      font-family: var(--font-display);
      font-size: 1.34rem;
      font-weight: 700;
      letter-spacing: 0.06em;
      color: var(--ink);
    }
    .room-gate__desc {
      margin: 0 auto 22px;
      max-width: 328px;
      color: var(--ink-soft);
      font-family: var(--font-display);
      font-size: 0.9rem;
      line-height: 1.9;
      letter-spacing: 0.02em;
    }
    .room-gate__admin,
    .room-gate__guest {
      padding-top: 20px;
      border-top: 1px solid var(--line);
      position: relative;
    }
    /* 分隔线中央一点暖意，呼应信笺落款 */
    .room-gate__admin::before,
    .room-gate__guest::before {
      content: "";
      position: absolute;
      top: -4px;
      left: 50%;
      width: 7px;
      height: 7px;
      transform: translateX(-50%) rotate(45deg);
      background: #f5eee0;
      border: 1px solid var(--line);
      border-radius: 1px;
    }
    .room-gate__note {
      margin: 0 0 14px;
      color: var(--ink-soft);
      font-size: 0.85rem;
      font-weight: 600;
    }
    .room-gate__note code {
      padding: 1px 6px;
      border-radius: 5px;
      background: var(--accent-soft);
      color: var(--accent);
      font-size: 0.9em;
    }
    .room-gate__sub {
      margin: 16px 0 0;
      color: var(--ink-soft);
      font-family: var(--font-display);
      font-size: 0.8rem;
      line-height: 1.8;
      letter-spacing: 0.02em;
      opacity: 0.82;
    }
    .room-gate__join {
      text-align: left;
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
    }
    .room-gate__label {
      display: block;
      margin: 0 0 8px;
      font-size: 0.78rem;
      font-weight: 700;
      color: var(--ink-soft);
      letter-spacing: 0.02em;
    }
    /* 手机窄屏：输入框与按钮上下排，避免「进入」被挤出屏幕 */
    .room-gate__row {
      display: flex;
      flex-direction: column;
      gap: 10px;
      align-items: stretch;
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
    }
    .room-gate__input {
      display: block;
      width: 100%;
      max-width: 100%;
      min-width: 0;
      height: 46px;
      padding: 0 12px;
      border: 1px solid rgba(47, 107, 79, 0.18);
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.92);
      color: var(--ink);
      font: inherit;
      font-size: 16px; /* iOS 避免自动放大 */
      box-sizing: border-box;
    }
    .room-gate__input:focus {
      outline: none;
      border-color: rgba(47, 107, 79, 0.45);
      box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.12);
    }
    .room-gate__tip {
      margin: 8px 0 0;
      font-size: 0.78rem;
      color: #b33a2b;
      word-break: break-word;
    }
    .room-gate__create {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      width: 100%;
      min-height: 46px;
      padding: 0 18px;
      border: 1px solid var(--accent);
      border-radius: 12px;
      background: linear-gradient(180deg, var(--accent-2), var(--accent));
      color: #fff;
      font: inherit;
      font-size: 0.95rem;
      font-weight: 700;
      letter-spacing: 0.02em;
      cursor: pointer;
      box-shadow: 0 8px 18px rgba(47, 107, 79, 0.22);
      transition: transform 0.15s ease, filter 0.15s ease;
      box-sizing: border-box;
    }
    .room-gate__create--ghost {
      width: 100%;
      margin-top: 4px;
      background: rgba(47, 107, 79, 0.08);
      color: var(--accent);
      box-shadow: none;
    }
    @media (min-width: 420px) {
      .room-gate__row {
        flex-direction: row;
        align-items: stretch;
      }
      .room-gate__create {
        width: auto;
        flex: 0 0 auto;
        min-width: 88px;
        padding: 0 16px;
      }
    }
    .room-gate__create:hover { filter: brightness(1.06); }
    .room-gate__create:active { transform: scale(0.98); }
    .room-gate__create svg { flex: 0 0 auto; opacity: 0.9; transition: transform 0.18s ease; }
    .room-gate__create:hover svg { transform: translateX(2px); }

    /* —— 安装到手机面板 —— */
    .install-panel .pin-panel__head { margin-bottom: 8px; }
    .install-panel__lead {
      margin: 0 0 16px;
      color: var(--muted);
      font-size: 0.84rem;
      line-height: 1.6;
    }
    .install-panel__options {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .install-option {
      display: flex;
      align-items: center;
      gap: 12px;
      width: 100%;
      box-sizing: border-box;
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 13px;
      background: rgba(255, 255, 255, 0.72);
      font: inherit;
      text-align: left;
      cursor: pointer;
      transition: border-color 0.16s ease, background 0.16s ease, transform 0.12s ease;
      -webkit-tap-highlight-color: transparent;
    }
    .install-option:hover {
      border-color: rgba(47, 107, 79, 0.32);
      background: rgba(63, 133, 99, 0.06);
    }
    .install-option:active { transform: scale(0.99); }
    .install-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .install-option__icon {
      flex: 0 0 auto;
      width: 40px;
      height: 40px;
      display: grid;
      place-items: center;
      border-radius: 11px;
      color: var(--accent);
      background: linear-gradient(155deg, rgba(63, 133, 99, 0.16), rgba(47, 107, 79, 0.07));
      border: 1px solid rgba(47, 107, 79, 0.14);
    }
    .install-option__icon--apk { color: var(--danger); background: var(--danger-soft); border-color: rgba(163, 69, 53, 0.14); }
    .install-option__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
    .install-option__title { font-size: 0.9rem; font-weight: 700; color: var(--ink); }
    .install-option__desc { font-size: 0.76rem; color: var(--muted); }
    .install-option__arrow { flex: 0 0 auto; color: var(--muted); opacity: 0.7; }
    html.utility-modal-open,
    html.utility-modal-open body {
      overflow: hidden;
    }

    /* 窄屏也保持「卡片浮在纸质彩底上」，与桌面同一构图（仅收紧边距） */
    @media (max-width: 499px) {
      html, body {
        height: 100%;
        height: 100dvh;
        overflow: hidden;
      }
      #app-root {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        overflow: hidden;
        background: transparent;
      }
      .shell {
        max-width: 100%;
        height: 100%;
        margin: 0;
        padding:
          max(10px, env(safe-area-inset-top, 0px))
          10px
          calc(10px + env(safe-area-inset-bottom, 0px));
        gap: 10px;
        animation: none;
        box-sizing: border-box;
      }
      .brand {
        flex-shrink: 0;
        align-items: center;
        gap: 8px;
        padding: 2px 4px 0;
        background: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border-bottom: none;
        box-shadow: none;
        touch-action: none;
      }
      .brand h1 {
        font-size: 1.2rem;
        letter-spacing: 0.03em;
      }
      .brand p { display: none; }
      .brand-actions button {
        padding: 6px 12px;
        font-size: 0.76rem;
        background: rgba(255, 255, 255, 0.55);
      }
      .panel {
        flex: 1;
        min-height: 0;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        background: var(--paper);
      }
      .join { padding: 18px 12px; }
      .room-gate { padding: 24px 16px 20px; }
      .join-row { flex-direction: column; }
      .join-row input[type="submit"] { height: 48px; box-shadow: 0 10px 22px rgba(47, 107, 79, 0.24); }
      .chat-plus-panel { grid-template-columns: repeat(3, 1fr); }
      #chatbox { padding: 12px 12px 8px; }
      /* 卡片外层 shell 已吃 safe-area，输入条不再二次垫高 */
      #chat-view {
        --chat-safe-b: 0px;
      }
      .composer {
        padding-bottom: 4px;
      }
      .composer-foot {
        padding-bottom: 0;
        min-height: 0;
      }
      .input-bar {
        padding-top: 6px;
        padding-bottom: 4px;
      }
    }
    @media (min-width: 500px) {
      .shell {
        max-width: 760px;
        padding: 18px 14px calc(14px + env(safe-area-inset-bottom));
      }
      .panel {
        border-radius: var(--radius);
        box-shadow: var(--shadow);
      }
    }

    /* 对齐密聊 CoverShellFab：解锁后右下角弯箭头回壳 */
    .cover-shell-fab {
      position: fixed;
      right: 16px;
      bottom: calc(108px + env(safe-area-inset-bottom, 0px));
      z-index: 110;
      width: 46px;
      height: 46px;
      border: 1px solid rgba(255, 255, 255, 0.7);
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.94);
      color: #e11d48;
      box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
      display: grid;
      place-items: center;
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
      padding: 0;
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      transition: transform 0.15s ease, box-shadow 0.15s ease;
    }
    .cover-shell-fab[hidden] { display: none !important; }
    .cover-shell-fab:active { transform: scale(0.94); box-shadow: 0 6px 16px rgba(15, 23, 42, 0.14); }
    html.disguise-active .cover-shell-fab,
    html.disguise-boot .cover-shell-fab,
    html.pwa-calc-boot .cover-shell-fab {
      display: none !important;
    }
