:root{
    --screen-height: 100vh;
    --ref-width: 941px;
    --ref-height: 1672px;
    --font-en: "Cormorant Garamond", Georgia, serif;
    --font-cn: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
    --wall-light: url("/chat-light.webp");
    --wall-harbor: url("/chat-harbor.webp");
    --wall-default: var(--wall-light);
    --avatar-default: url("/avatar-sea.png");
    /* ── PEARL TIDE · 珍珠潮汐(default) ── */
    --bg: #F7FAFC;
    --header-bg: #F7FAFC;
    --hairline: rgba(120,142,165,.24);
    --text: #253447;
    --text-soft: #5E7080;
    --text-faint: #8A99A8;
    --bubble-ai-bg: #ECEEF3;
    --bubble-ai-fg: #253447;
    --bubble-ai-line: transparent;
    --bubble-human-bg: #DFE5EE;
    --bubble-human-fg: #253447;
    --bubble-human-line: transparent;
    --accent: #4C6378;
    --send-bg: #2C4056;
    --tick: #7E93A4;
    --accent-fg: #ffffff;
    --think-flourish: rgba(99, 121, 142, 0.52);
    --think-label: #6A7E8E;
    --think-body: #56697A;
    --composer-bg: #EEF4FA;
    --field-bg: rgba(247,250,252,.92);
    --field-line: rgba(151,169,181,.18);
    --shadow: 0 18px 46px rgba(74, 93, 108, 0.10);
    --soft-shadow: 0 14px 34px rgba(86, 104, 118, 0.08);
    --scrim: linear-gradient(180deg, rgba(255,255,255,0.38), rgba(255,255,255,0.12) 30%, rgba(255,255,255,0.04) 68%, rgba(255,255,255,0.22));
    --header-h: clamp(56px, 10vw, 120px);
    --side-pad: clamp(16px, 4vw, 40px);
    --avatar-size: clamp(32px, 5vw, 48px);
    --bubble-radius: clamp(14px, 2vw, 20px);
    --composer-h: clamp(44px, 6vw, 72px);
    --motion-fast: 150ms;
    --motion-normal: 260ms;
    --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
    /* composer 占据的底部区域(含安全区/键盘):scroll 底 padding 与边缘渐隐共用同一来源,保持对齐 */
    --composer-zone: calc(var(--composer-h) + 16px + env(safe-area-inset-bottom));
    --edge-fade-top: clamp(24px, 5vw, 52px);
    --edge-fade-tail: clamp(16px, 3vw, 30px);
    /* profile / settings — frosted glass, blends into the wallpaper */
    --card-bg: rgba(244,248,250,.42);
    --card-line: rgba(150,168,182,.12);
    --card-shadow: 0 10px 28px rgba(70,92,108,.05);
    --seg-track: rgba(140,160,176,.11);
    --seg-thumb: rgba(255,255,255,.68);
    --seg-thumb-shadow: 0 2px 8px rgba(40,60,78,.08);
    --row-press: rgba(140,160,176,.09);
    --slider-track: rgba(143,162,176,.28);
    --slider-thumb: #44627b;
    --info-ring: rgba(143,162,176,.38);
    --status-dot: #5fbf8f;
    /* voice call (speaking overlay) */
    --call-glass-top: rgba(255,255,255,.46);
    --call-glass-bot: rgba(255,255,255,.20);
    --call-glass-edge: rgba(255,255,255,.58);
    --call-glass-hi: rgba(255,255,255,.72);
    --call-glass-glow: rgba(150,172,196,.20);
    --call-glass-shadow: 0 20px 50px rgba(74,93,108,.16);
    --call-scrim: rgba(64,82,102,.06);
    --call-hangup-bg: #cf8d92;
    --call-hangup-shadow: rgba(176,96,104,.34);
  }
  @supports (height: 100dvh){
    :root{ --screen-height: 100dvh; }
  }
  /* ── HARBOR · 海港(通用开源主题 / Tidal Echo) ── 中性冷调,供 fork 使用;只覆盖带色相变量,其余继承 PEARL TIDE */
  :root[data-theme="harbor"]{
      --wall-default: var(--wall-harbor);
      --bg: #F4F2EF;
      --header-bg: #F4F2EF;
      --hairline: rgba(74,93,108,.20);
      --text: #36404B;
      --text-soft: #5E6B78;
      --text-faint: #9197A0;
      --bubble-ai-bg: #EAE6E4;
      --bubble-ai-fg: #36404B;
      --bubble-human-bg: #E1E0E3;
      --bubble-human-fg: #36404B;
      --accent: #4A5D6C;
      --send-bg: #4A5D6C;
      --tick: #7E8E9C;
      --accent-fg: #ffffff;
      --think-flourish: rgba(74, 93, 108, 0.48);
      --think-label: #5E6B78;
      --think-body: #4F5D6A;
      --composer-bg: #EFEBE8;
      --field-bg: rgba(244,242,239,.92);
      --slider-thumb: #4A5D6C;
      --status-dot: #6FA98C;
  }

  *{ box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body{ margin:0; padding:0; height:100%; overflow:hidden; overscroll-behavior:none; }
  body{ position: fixed; inset: 0; width: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-cn);
    font-size: clamp(14px, 1.45vw, 16px);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overscroll-behavior: none;
  }

  .app{
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    width: min(100vw, var(--ref-width));
    margin: 0 auto;
    overflow: hidden;
  }
  .wall{
    position:fixed;
    inset:0;
    width:100vw;
    height:var(--screen-height);
    z-index:0;
    background-color: var(--bg);
    background-image: var(--wall-default);
    background-size: cover; background-position: center;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }
  .wall::after{
    content:""; position:absolute; inset:0; background: var(--scrim); pointer-events:none;
  }
  .topbar, .scroll, .composer{ position: relative; z-index: 1; }

  /* ── Header (floating frosted pill + corner avatar) ── */
  .topbar{
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
    height: calc(var(--header-h) + env(safe-area-inset-top));
    padding: calc(env(safe-area-inset-top) + 8px) var(--side-pad) 10px;
    border-bottom: 1px solid var(--hairline);
    pointer-events: none;
  }
  .topbar > *{ pointer-events: auto; }
  .peerpill{
    display:flex; flex-direction:column; align-items:center; line-height:1.15;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0 76px;
  }
  .peerpill .name{
    font-family: "Songti SC", "Noto Serif SC", "STSong", "SimSun", serif;
    font-size: clamp(18px, 3vw, 28px);
    font-weight: 500;
    color: var(--text);
    letter-spacing: 0;
    text-shadow: 0 1px 18px rgba(255,255,255,0.3);
  }
  .ys-header-left{
    position:absolute;
    left: calc(var(--side-pad) + 4px);
    top: calc(env(safe-area-inset-top) + clamp(14px, 2.5vw, 36px));
    height:36px;
    display:flex;
    align-items:center;
    gap:8px;
  }
  .ys-connection-status{
    font-family: var(--font-en), var(--font-cn);
    font-size: clamp(12px, 1.8vw, 16px);
    color: var(--text-soft);
    margin:0;
    letter-spacing: 0;
    flex:none;
  }
  .app[data-conn="reconnecting"] .ys-connection-status{ color:#9a8061; }
  .ys-connection-status.typing{
    color: #4f9fda;
    font-weight: 500;
    text-shadow: 0 0 16px rgba(79,159,218,.24);
    display: inline-flex; align-items: center;
  }
  .typing-dots{ display:inline-flex; align-items:center; gap:3px; margin-left:6px; }
  .typing-dots i{ width:4px; height:4px; border-radius:50%; background:currentColor; animation: typingDot 1.25s ease-in-out infinite; }
  .typing-dots i:nth-child(2){ animation-delay:.16s; }
  .typing-dots i:nth-child(3){ animation-delay:.32s; }
  @keyframes typingDot{ 0%,70%,100%{ transform:translateY(0); opacity:.4; } 35%{ transform:translateY(-3px); opacity:1; } }
  .backbtn{
    position:static;
    width:36px; height:36px; border-radius:50%; padding:0; flex:none; cursor:pointer;
    border: none; background: transparent;
    color: var(--text); display:grid; place-items:center;
    transition: transform .15s ease;
  }
  .backbtn:active{ transform: scale(.9); }
  .backbtn svg{ width:22px; height:22px; display:block; margin-left:-2px; }
  .header-actions{
    position:absolute;
    right: calc(var(--side-pad) - 2px);
    top: calc(env(safe-area-inset-top) + clamp(14px, 2.5vw, 36px));
    display:flex;
    align-items:center;
    justify-content:flex-end;
    gap: clamp(24px, 4vw, 42px);
    height:36px;
  }
  .topbtn{
    width:36px;
    height:36px;
    border:0;
    border-radius:50%;
    padding:0;
    background:transparent;
    color: var(--text);
    display:grid;
    place-items:center;
    cursor:pointer;
    transition: transform .15s ease;
  }
  .topbtn:active{ transform: scale(.9); }
  .topbtn svg{ width:24px; height:24px; display:block; }
  .topbtn.more svg{ width:22px; height:22px; }
  .avatar{
    position:absolute; right: calc(var(--side-pad) - 3px); top: calc(env(safe-area-inset-top) + clamp(14px, 2.5vw, 36px));
    width: var(--avatar-size); height: var(--avatar-size); border-radius:50%; padding:0; flex:none; cursor:pointer;
    border: none;
    background-image: var(--avatar-default);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
    box-shadow: 0 12px 24px rgba(24,46,67,0.16);
  }
  .avatar:focus-visible,
  .backbtn:focus-visible,
  button:focus-visible,
  textarea:focus-visible,
  input:focus-visible{
    outline: 2px solid var(--accent);
    outline-offset: 3px;
  }
