/* shell.css — 桌面底与左侧说明栏、手机框、tab 屏/底部导航/彩线指示器/角标、推入页面层、浮层组件（toast/横幅/底部弹窗/长按菜单/确认框/粒子/下拉刷新/紧凑标题栏）、启动画面、外观切换 */

/* ---------- 桌面与手机框 ---------- */
.app-desk {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 80px;
}
.app {
  position: relative;
  flex: none;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  touch-action: manipulation;
}
@media (max-width: 559.98px) {
  body { background: var(--bg); }
}
@media (min-width: 560px) {
  .app-desk { padding: 24px; }
  /* 外框含 10px 边框：内容区 390 × clamp(640px, 100dvh - 48px, 844px) */
  .app {
    width: 410px;
    height: clamp(660px, calc(100vh - 28px), 864px);
    height: clamp(660px, calc(100dvh - 28px), 864px);
    border: 10px solid var(--frame);
    border-radius: 44px;
    box-shadow: 0 40px 90px -24px rgba(31, 29, 26, .38), 0 14px 32px rgba(31, 29, 26, .12);
  }
}
@media (min-width: 560px) and (max-height: 687.98px) {
  .app-desk { padding: 12px 24px; }
  .app { height: calc(100vh - 24px); height: calc(100dvh - 24px); border-radius: 36px; }
}
/* 横屏手机（触屏且很矮）：不画手机框，和窄屏一样全屏 */
@media (min-width: 560px) and (max-height: 600px) and (pointer: coarse) {
  body { background: var(--bg); }
  .app-desk { padding: 0; }
  .app { width: 100%; height: 100%; border: 0; border-radius: 0; box-shadow: none; }
}

/* ---------- 左侧试用说明栏（≥960px） ---------- */
.app-intro {
  display: none;
  flex: none;
  flex-direction: column;
  width: 300px;
  color: var(--ink);
}
/* 说明栏内容约 606px 高：窗口再矮就不显示（否则上下被裁、且无法滚动） */
@media (min-width: 960px) and (min-height: 640px) {
  .app-intro { display: flex; }
}
.app-intro-brand {
  font-family: var(--font-char);
  font-size: 92px;
  line-height: 1;
  letter-spacing: 6px;
  margin-left: -4px;
}
.app-intro-sub { margin-top: 12px; font-size: 13px; letter-spacing: 6px; color: var(--desk-muted); }
.app-intro-tag { margin-top: 18px; font-family: var(--font-display); font-size: 19px; font-weight: 600; line-height: 1.5; }
.app-intro-trial { margin-top: 30px; }
.app-intro-head { display: flex; align-items: baseline; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.app-intro-count { font-family: var(--font-display); font-weight: 500; color: var(--desk-muted); font-variant-numeric: tabular-nums; }
.app-intro-bar { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin: 10px 0 12px; }
.app-intro-bar > i { height: 3px; border-radius: 2px; background: var(--desk-line); transition: background-color var(--dur-4) var(--ease-out); }
.app-intro-bar > i.is-on { background: var(--c-deep); }
.app-trial { display: flex; flex-direction: column; gap: 2px; }
.app-trial-item { display: flex; align-items: center; gap: 12px; min-height: 36px; font-size: 14px; color: var(--ink-2); }
.app-trial-box {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  box-shadow: inset 0 0 0 1.5px var(--desk-line);
  color: var(--c-on-deep);
  transition: background-color var(--dur-3) var(--ease-out), box-shadow var(--dur-3);
}
.app-trial-box svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 22; stroke-dashoffset: 22; transition: stroke-dashoffset 420ms 120ms var(--ease-out); }
.app-trial-item.is-done .app-trial-box { background: var(--c-deep); box-shadow: inset 0 0 0 1.5px var(--c-deep); }
.app-trial-item.is-done .app-trial-box svg { stroke-dashoffset: 0; }
.app-trial-label { transition: color var(--dur-3); }
.app-trial-item.is-done .app-trial-label { color: var(--desk-muted); }
.app-trial-item.just-done .app-trial-box { animation: app-trial-pop 560ms var(--ease-spring); }
.app-trial-item.just-done .app-trial-label { animation: app-trial-nudge 560ms var(--ease-out); }
@keyframes app-trial-pop { 0% { transform: scale(.6); } 55% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes app-trial-nudge { 0% { transform: translateX(0); } 40% { transform: translateX(4px); } 100% { transform: translateX(0); } }
.app-intro-invite { margin-top: 14px; font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
.app-intro-invite b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.app-intro-invite .is-full { color: var(--danger); }
.app-intro-foot { margin-top: 28px; font-size: 12px; line-height: 1.6; color: var(--desk-muted); }
/* 640–719px 高的窗口：压缩说明栏间距和字号 */
@media (min-width: 960px) and (max-height: 719.98px) {
  .app-intro-brand { font-size: 72px; }
  .app-intro-tag { margin-top: 12px; font-size: 17px; }
  .app-intro-invite { margin-top: 10px; }
  .app-intro-trial { margin-top: 20px; }
  .app-trial-item { min-height: 32px; }
  .app-intro-foot { margin-top: 16px; }
}

/* ---------- 三层：tab 层 / 推入页面层 / 浮层 ---------- */
.app-tabs, .app-pages, .app-overlays { position: absolute; inset: 0; }
.app-tabs {
  z-index: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-columns: 100%;
  background: var(--bg);
}
.app-screen {
  grid-row: 1;
  grid-column: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
  visibility: hidden;
  background: var(--bg);
}
.app-screen.is-active { visibility: visible; }
.app-screen > .app-view, .app-page > .app-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.app-page > .app-view { background: var(--bg); }

.app-dim {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: var(--dim);
  opacity: 0;
  pointer-events: none;
}

.app-pages { z-index: 2; pointer-events: none; }
.app-page {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  touch-action: pan-y pinch-zoom;
  outline: none;
}
.app-page.is-moving { box-shadow: -12px 0 32px rgba(31, 29, 26, .12); }

.app-overlays { z-index: 3; pointer-events: none; }
.app-overlays > * { pointer-events: auto; }
.app-overlays > .ui-fx, .app-overlays > .ui-toasts, .app-overlays > .ui-conn { pointer-events: none; }
.app.is-busy .app-tabs, .app.is-busy .app-pages { pointer-events: none; }
.app.is-busy .app-page { pointer-events: none; }

/* ---------- 底部导航 ---------- */
.app-tabbar {
  grid-row: 2;
  grid-column: 1;
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 8px 12px 8px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.app-tab {
  position: relative;
  width: 80px;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0 0 6px;
  border-radius: 12px;
  color: var(--muted);
  transition: color var(--dur-2) var(--ease-out);
}
.app-tab.is-active { color: var(--ink); }
.app-tab-icon { position: relative; width: 24px; height: 24px; }
.app-tab-icon > svg { position: absolute; inset: 0; transition: opacity var(--dur-2) var(--ease-out); }
.app-tab-icon > .app-tab-i-on { opacity: 0; }
.app-tab.is-active .app-tab-i-on { opacity: 1; }
.app-tab.is-active .app-tab-i-off { opacity: 0; }
.app-tab-label { font-size: 11px; line-height: 14px; }
.app-tab.is-active .app-tab-label { font-weight: 700; }
.app-tab-badge {
  position: absolute;
  left: calc(100% - 7px);
  top: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--c-deep);
  color: var(--c-on-deep);
  box-shadow: 0 0 0 2px var(--bg);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.app-tab-badge.is-dot { min-width: 9px; width: 9px; height: 9px; padding: 0; left: calc(100% - 3px); top: -2px; }
.app-tab-ind {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  gap: 2px;
  pointer-events: none;
}
.app-tab-ind > i { display: block; width: 7px; height: 3px; border-radius: 1.5px; background: var(--c-deep); }

/* ---------- 浮层：通用遮罩 ---------- */
.ui-scrim { position: absolute; inset: 0; background: var(--scrim); }

/* toast */
.ui-toasts {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 96px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
/* 有浮层（故事/灯箱/弹窗/菜单）时改到顶部，避开故事大字说明和弹窗底部输入框 */
.ui-toasts.is-top { top: 76px; bottom: auto; }
.ui-toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow-2);
  font-size: 14px;
  line-height: 1.4;
}

/* 消息横幅 */
.ui-banner {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 14px 10px 10px;
  border-radius: 20px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: var(--shadow-2), inset 0 0 0 1px var(--line);
  color: var(--ink);
  text-align: left;
  touch-action: none;
}
.ui-banner-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ui-banner-title { font-size: 15px; font-weight: 700; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-banner-text { font-size: 14px; line-height: 1.4; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-banner-time { align-self: flex-start; padding-top: 2px; font-size: 12px; color: var(--muted); }

/* 连接状态条（同步层：断开超过 3 秒时出现；不挡操作） */
.ui-conn {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 78;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  /* 两侧留出页面顶部按钮的位置（对话页左上返回、右上「换色」），窄屏下不压住它们；放不下时省略 */
  max-width: calc(100% - 184px);
  padding: 6px 14px 6px 12px;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.3;
  white-space: nowrap;
  transform: translate(-50%, 0);
}
.ui-conn-t { overflow: hidden; text-overflow: ellipsis; }
.ui-conn-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: ui-conn-pulse 1.1s var(--ease-in-out) infinite alternate;
}
.ui-conn.is-offline .ui-conn-dot { background: var(--danger); animation: none; }
.ui-conn.is-restored .ui-conn-dot { background: #2F6F4E; animation: none; }
@keyframes ui-conn-pulse { from { opacity: .25; transform: scale(.75); } to { opacity: 1; transform: scale(1); } }

/* 底部弹窗 */
.ui-sheet-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.ui-sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: calc(100% - 28px);
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-2);
  outline: none;
}
.ui-sheet::after { content: ''; position: absolute; left: 0; right: 0; top: calc(100% - 1px); height: 80px; background: var(--surface); } /* 弹簧过冲不露底 */
.ui-sheet.ui-sheet--half { height: 56%; }
.ui-sheet.ui-sheet--full { height: calc(100% - 28px); }
.ui-sheet-head { flex: none; padding: 8px 8px 2px; touch-action: none; cursor: grab; }
.ui-sheet-head:active { cursor: grabbing; }
.ui-sheet-grip { display: block; width: 38px; height: 5px; margin: 0 auto 6px; border-radius: 3px; background: var(--line); }
.ui-sheet-titlebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; padding: 0 0 4px 12px; }
.ui-sheet-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; line-height: 1.3; }
.ui-sheet-close { color: var(--muted); }
.ui-sheet-actions { flex: none; display: flex; align-items: center; gap: 4px; margin-left: auto; }
.ui-sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 20px 20px; }
.ui-sheet-foot { flex: none; padding: 10px 12px 12px; border-top: 1px solid var(--line-2); background: var(--surface); }

/* 长按菜单 */
.ui-menu-layer { position: absolute; inset: 0; z-index: 30; }
.ui-menu-backdrop {
  position: absolute;
  inset: 0;
  background: var(--menu-scrim);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  backdrop-filter: blur(12px) saturate(1.1);
}
.ui-menu-lift { position: absolute; z-index: 2; pointer-events: none; will-change: transform; }
.ui-menu-platter { position: absolute; z-index: 1; pointer-events: none; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-2); }
.ui-menu {
  position: absolute;
  z-index: 3;
  min-width: 190px;
  max-width: 250px;
  padding: 6px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.ui-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 15px;
  text-align: left;
  transition: background-color var(--dur-1);
}
.ui-menu-item:focus-visible { background: var(--surface-2); outline: none; }
@media (hover: hover) {
  .ui-menu-item:hover { background: var(--surface-2); }
  .ui-menu-react:hover { background: var(--surface-2); }
}
.ui-menu-item .ui-ico { color: var(--ink-2); }
.ui-menu-item.is-danger, .ui-menu-item.is-danger .ui-ico { color: var(--danger); }
.ui-menu-sep { height: 1px; margin: 4px 8px; background: var(--line-2); }
.ui-menu-reacts {
  position: absolute;
  z-index: 3;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.ui-menu-react {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-deep);
  transition: transform var(--dur-1) var(--ease-out), background-color var(--dur-1);
}
.ui-menu-react:active { transform: scale(.88); }

/* 确认框 */
.ui-confirm-layer {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.ui-confirm {
  position: relative;
  width: 100%;
  max-width: 300px;
  padding: 22px 18px 16px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  text-align: center;
  outline: none;
}
.ui-confirm-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; line-height: 1.4; }
.ui-confirm-text { margin-top: 8px; font-size: 14px; line-height: 1.6; color: var(--muted); }
.ui-confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }

/* 粒子与大爱心 */
.ui-fx { position: absolute; inset: 0; z-index: 85; overflow: hidden; }
.ui-particle { position: absolute; left: 0; top: 0; display: block; will-change: transform, opacity; }
.ui-particle > svg { display: block; width: 100%; height: 100%; }
.ui-heartpop { position: absolute; left: 0; top: 0; display: block; will-change: transform, opacity; filter: drop-shadow(0 8px 18px rgba(31, 29, 26, .22)); }
.ui-heartpop > svg { display: block; width: 100%; height: 100%; }

/* 下拉刷新 */
.ui-ptr {
  position: absolute;
  left: 0;
  right: 0;
  height: 76px;
  z-index: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: none;
  opacity: 0;
}
.ui-ptr-mark { position: relative; width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; }
.ui-ptr-ring { position: absolute; inset: 0; width: 46px; height: 46px; overflow: visible; color: var(--ink); }
.ui-ptr-ring circle { fill: none; stroke: currentColor; stroke-linecap: round; }
.ui-ptr-char { position: relative; font-family: var(--font-char); font-size: 25px; line-height: 1; color: var(--ink); }
.ui-ptr.is-spinning .ui-ptr-ring { animation: ui-ptr-spin 1s linear infinite; }
.ui-ptr-text { height: 15px; font-size: 11px; line-height: 15px; color: var(--muted); opacity: 0; transform: translateY(-4px); transition: opacity var(--dur-2), transform var(--dur-2) var(--ease-out); }
.ui-ptr.is-done .ui-ptr-text { opacity: 1; transform: none; }
.ui-ptr-host { position: relative; z-index: 1; }
@keyframes ui-ptr-spin { to { transform: rotate(360deg); } }

/* 大标题折叠后的紧凑标题栏 */
.ui-compact {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 6;
  height: 50px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 6px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: inset 0 -1px 0 transparent;
  opacity: 0;
  pointer-events: none;
  transition: box-shadow var(--dur-2);
}
.ui-compact.is-shown { pointer-events: auto; box-shadow: inset 0 -1px 0 var(--line); }
.ui-compact-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.ui-compact-left { justify-self: start; display: flex; align-items: center; }
.ui-compact-right { justify-self: end; display: flex; align-items: center; }

/* ---------- 启动画面 ---------- */
.app-splash {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: var(--bg);
  pointer-events: auto;
  transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out);
}
/* 同步层就绪（或决定显示登录页）后淡出 */
.app-splash.is-out { opacity: 0; transform: scale(1.02); pointer-events: none; }
.app-splash-inner { position: relative; display: flex; align-items: flex-end; gap: 6px; }
.app-splash-msg {
  position: absolute;
  left: 24px;
  right: 24px;
  top: calc(50% + 74px);
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
  opacity: 0;
  transition: opacity var(--dur-3) var(--ease-out);
}
.app-splash.has-msg .app-splash-msg { opacity: 1; }
/* 本会话已经看过写字动画 / 减少动态：静态字样 */
.app-splash.is-static .app-splash-word { -webkit-mask-image: none; mask-image: none; animation: none; }
.app-splash.is-static .app-splash-seal { animation: none; opacity: 1; transform: rotate(-6deg) scale(1); }
.app-splash-word {
  font-family: var(--font-char);
  font-size: 96px;
  line-height: 1;
  letter-spacing: 4px;
  color: var(--ink);
  -webkit-mask-image: linear-gradient(90deg, #000 44%, transparent 56%);
  mask-image: linear-gradient(90deg, #000 44%, transparent 56%);
  -webkit-mask-size: 260% 100%;
  mask-size: 260% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: 100% 0;
  mask-position: 100% 0;
  animation: app-splash-write 560ms var(--ease-in-out) forwards;
}
.app-splash-seal {
  margin-bottom: 10px;
  padding: 3px 4px;
  border-radius: 4px;
  background: var(--c-deep);
  color: var(--c-on-deep);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
  writing-mode: vertical-rl;
  letter-spacing: 2px;
  opacity: 0;
  transform: rotate(-6deg) scale(1.6);
  animation: app-splash-seal 260ms 400ms var(--ease-spring) forwards;
}
@keyframes app-splash-write { to { -webkit-mask-position: 0 0; mask-position: 0 0; } }
@keyframes app-splash-seal { to { opacity: 1; transform: rotate(-6deg) scale(1); } }
/* index.html 里写好的启动画面（脚本下载完之前就显示）：首次绘制后稍等再写字，脚本若很快就绪还能改成静态字样（本会话看过时） */
.app-splash.is-boot .app-splash-word { animation-delay: 250ms; }
.app-splash.is-boot .app-splash-seal { animation-delay: 650ms; }
@media (prefers-reduced-motion: reduce) {
  .app-splash.is-boot .app-splash-word { -webkit-mask-image: none; mask-image: none; animation: none; }
  .app-splash.is-boot .app-splash-seal { animation: none; opacity: 1; transform: rotate(-6deg) scale(1); }
}
/* 脚本就绪前：说明栏里还没渲染的试用清单先藏起来（core 在 Dada.start() 时给 <html> 加 .js-ready） */
html:not(.js-ready) .app-intro-trial { visibility: hidden; }

/* ---------- 外观切换 ---------- */
:root.vt-circle::view-transition-old(root),
:root.vt-circle::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
:root.vt-circle::view-transition-old(root) { z-index: 1; }
:root.vt-circle::view-transition-new(root) { z-index: 2; }
.theme-fade, .theme-fade * {
  transition: background-color 420ms var(--ease-out), color 420ms var(--ease-out), border-color 420ms var(--ease-out), fill 420ms, stroke 420ms, box-shadow 420ms !important;
}
