/* UI 原语。颜色/圆角/间距一律取令牌 */

/* ---- Page ---- */
.page { height: 100%; display: flex; flex-direction: column; background: var(--bg); }
/* 左边缘往右滑返回。逻辑在 ui/page.js */
/* 跟着手指走的那一段：不要过渡，否则手指到哪儿它慢半拍 */
.page.is-swiping { transition: none; will-change: transform; }
/* 松手之后补完或者弹回去。page.js 按这条过渡的时长决定什么时候收尾 */
.page.is-settling { transition: transform var(--dur) var(--ease); }
/* 让出来的那一条是外壳底色。给这一页压一道阴影，看着才像一层浮起来往右挪，
   而不是页面裂了一道缝 */
.page.is-swiping, .page.is-settling { box-shadow: var(--shadow-3); }
.page-body { flex: 1; min-height: 0; }
/* 底下没有页签栏时，滚动区一直铺到屏幕底，最后一行会压在 Home Indicator 下面。
   有页签栏的那些不加 —— 页签栏自己已经把安全区让出来了。 */
.page > .page-body:last-child { padding-bottom: var(--safe-bottom); }
/* 底栏自己已经把安全区算进去的（会话的输入栏、美化生成面板），这里不再让一次 ——
   两处都让，iPhone 上输入栏下面就平白空出 34 像素 */
.page > .page-body:last-child:has(.composer-bar, .gen-panel) { padding-bottom: 0; }

.navbar {
  flex: none; height: var(--navbar-h);
  display: grid; grid-template-columns: 56px 1fr 56px; align-items: center;
  background: var(--bg);
}
.nav-left  { display: flex; justify-content: flex-start; padding-left: var(--sp-1); }
.nav-right { display: flex; justify-content: flex-end; gap: var(--sp-1); padding-right: var(--sp-2); }
/* 右上角放得下两个图标按钮时不要挤成两行 */
.navbar { grid-template-columns: 56px 1fr auto; }
.nav-right { min-width: 56px; }
.nav-title { text-align: center; font-size: var(--fs-15); font-weight: var(--fw-semi); }

/* ---- 应用内 TabBar ---- */
/* 高度要把安全区**加上去**，不能让它从里面挖。
   box-sizing 是 border-box（base.css），写成 height: var(--tabbar-h) 加
   padding-bottom: 34px，能放东西的就只剩 20px —— 图标和字会顶出底栏上沿，
   字还会压进 Home Indicator 那条。dock 那边（shell.css）一直是 calc 写法，
   这里漏了。 */
.tabbar {
  flex: none;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; background: var(--bg);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; color: var(--text-3);
  transition: color var(--dur-fast) var(--ease);
}
.tab.is-active { color: var(--accent); }
.tab-icon { position: relative; }
.tab-label { font-size: var(--fs-11); }
.tab-badge {
  position: absolute; top: -4px; right: -8px; min-width: 15px; height: 15px;
  padding: 0 4px; border-radius: var(--r-full); background: var(--accent);
  color: var(--on-accent); font-size: 9px; line-height: 15px; text-align: center;
}

/* ---- 按钮 ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  border-radius: var(--r-sm); font-weight: var(--fw-medium); white-space: nowrap;
}
.btn-md { height: 40px; padding: 0 var(--sp-4); font-size: var(--fs-14); }
.btn-sm { height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-12); border-radius: var(--r-xs); }
.btn-lg { height: 46px; padding: 0 var(--sp-5); font-size: var(--fs-15); }
.btn-full { width: 100%; }
a.btn { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-ghost   { background: var(--surface-2); color: var(--text); }
.btn-outline { background: none; color: var(--text); box-shadow: inset 0 0 0 1px var(--border-2); }
.btn-danger  { background: var(--danger-weak); color: var(--danger); font-weight: var(--fw-semi); }
.btn:disabled { opacity: .4; pointer-events: none; }

/* 图标按钮画出来是 34，**摸得着的是 44**。
   两家的人机指南都给到 44 到 48，而手指的接触面本来就有十来毫米宽 ——
   按钮画大了难看，所以只把命中区撑开：一个看不见的伪元素往外扩五像素。
   .press 的按下反馈仍然落在看得见的那一块上。 */
.icon-btn {
  position: relative;
  width: 34px; height: 34px; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center; color: var(--text);
}
.icon-btn::after {
  content: ''; position: absolute; inset: -5px;
}
.icon-btn.is-active { color: var(--accent); background: var(--accent-weak); }

/* ---- 表单 ---- */
.field { display: block; margin-bottom: var(--sp-4); }
.field-label { font-size: var(--fs-13); color: var(--text-2); margin-bottom: var(--sp-2); }
.field-desc  { font-size: var(--fs-12); color: var(--text-3); margin-top: var(--sp-2); line-height: 1.5; }
/* 填的东西本身有问题时那一行。和 field-desc 同一位置，只是颜色不同 ——
   说明是一直在的，这一条只在填错时出现 */
.field-warn  { font-size: var(--fs-12); color: var(--danger); margin-top: var(--sp-2); line-height: 1.5; }

/* 数字输入：一个输入框加一个单位 */
.num-row { display: flex; align-items: center; gap: var(--sp-3); }
.num-row input { flex: 1; min-width: 0; }
.num-unit { flex: none; font-size: var(--fs-15); color: var(--text-3); }

/* 未读数。消息列表直接用这个类，不经过组件 */
.badge {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: var(--r-full);
  background: var(--accent); color: var(--on-accent);
  font-size: var(--fs-11); line-height: 17px; text-align: center;
}

.switch {
  width: 46px; height: 27px; border-radius: var(--r-full); background: var(--surface-3);
  padding: 2px; display: flex; transition: background var(--dur) var(--ease);
}
.switch.is-on { background: var(--accent); }
.switch-dot {
  width: 23px; height: 23px; border-radius: var(--r-full); background: var(--surface);
  box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease);
}
.switch.is-on .switch-dot { transform: translateX(19px); }

.segmented {
  display: flex; gap: 2px; padding: 2px; background: var(--surface-2);
  border-radius: var(--r-sm);
}
.seg-item {
  flex: 1; height: 30px; border-radius: var(--r-xs); font-size: var(--fs-13);
  color: var(--text-2); transition: all var(--dur-fast) var(--ease);
}
.seg-item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* ---- 头像 / 角标 ---- */
/* 尺寸从公开变量读起，没有才用组件传下来的那一份。
   这三条从前是内联写的，内联赢过一切，「美化」改不动头像 —— 见 4.136。
   --ph-avatar-size 只管会话里的头像（.ph-face 那一层），不然一份会话美化
   会把整个应用的头像一起改大。圆角是全局的，形状本来就该一致。 */
.avatar {
  object-fit: cover; background: var(--surface-3); flex: none;
  width: var(--av-size, 44px); height: var(--av-size, 44px);
  border-radius: var(--ph-avatar-r, var(--avatar-r, var(--av-r, 14px)));
  font-size: var(--av-fs, 17px);
}
.ph-face .avatar {
  width: var(--ph-avatar-size, var(--av-size, 36px));
  height: var(--ph-avatar-size, var(--av-size, 36px));
}
.avatar-fallback {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); font-weight: var(--fw-medium); text-transform: uppercase;
}

.spinner {
  display: inline-block; border: 2px solid var(--border-2);
  border-top-color: var(--accent); border-radius: var(--r-full);
  animation: spin .7s linear infinite;
}

/* ---- 列表 ---- */
.list-wrap { margin: var(--sp-4) 0; }
.list-title {
  font-size: var(--fs-12); color: var(--text-3);
  padding: 0 var(--sp-4) var(--sp-2);
}
.list { background: var(--surface); }
.list-inset { margin: 0 var(--sp-3); border-radius: var(--r-md); overflow: hidden; }
.list-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); min-height: 50px;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
/* 区域内滚动。条数不定的列表在这里截断并自己滚，页面本身的滚动不受影响。
   高度取的是「四行半」——露半行出来，一眼就知道下面还有 */
.list-cap {
  max-height: 248px; overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.list-item.is-danger .li-title { color: var(--danger); }
.li-left  { flex: none; display: flex; color: var(--text-2); }
.li-body  { flex: 1; min-width: 0; }
.li-title { font-size: var(--fs-15); }
.li-multiline .li-title { white-space: normal; line-height: 1.55; }
.li-sub   { font-size: var(--fs-12); color: var(--text-3); margin-top: 2px; line-height: 1.5; }
.li-right { flex: none; display: flex; align-items: center; gap: var(--sp-2); color: var(--text-3); font-size: var(--fs-13); }
/* 没标 multiline 的那一行，副标题只占一行，多出来的省略 —— 列表是用来扫一眼的，
   要看全文就点进去。右边的状态字同理，太长时省略，不把标题挤走 */
.li-body:not(.li-multiline) .li-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-value { max-width: 10em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-arrow { color: var(--text-3); flex: none; }

/* ---- 空态 ---- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-2); padding: var(--sp-8) var(--sp-5); color: var(--text-3); text-align: center;
}
.empty-title { font-size: var(--fs-14); color: var(--text-2); margin-top: var(--sp-2); }
.empty-desc  { font-size: var(--fs-12); line-height: 1.6; max-width: 260px; }

/* ---- 浮层 ---- */
.overlay {
  position: absolute; inset: 0; z-index: var(--z-sheet);
  background: var(--scrim); display: flex; align-items: flex-end;
  animation: fade-in var(--dur-fast) var(--ease);
}
.overlay-center { align-items: center; justify-content: center; padding: var(--sp-5); }
.overlay.is-preview { background: transparent; }
.overlay.is-preview .sheet { box-shadow: var(--shadow-3); }

.sheet {
  /* 高度由调用方给，但走变量而不是内联样式：契约钩子上写内联样式，
     外部作者写什么都盖不住它，而且完全看不出为什么（见 ARCHITECTURE 4.136） */
  width: 100%; height: var(--sheet-h, auto);
  max-height: 85%; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding-bottom: var(--safe-bottom);
  animation: slide-up var(--dur) var(--ease-out);
}
.sheet-grip {
  width: 34px; height: 4px; border-radius: var(--r-full); background: var(--border-2);
  margin: var(--sp-2) auto var(--sp-1);
}
.sheet-title {
  text-align: center; font-size: var(--fs-15); font-weight: var(--fw-semi);
  padding: var(--sp-2) var(--sp-4) var(--sp-3);
}
.sheet-body { flex: 1; min-height: 0; padding: 0 var(--sp-4) var(--sp-4); }

/* 整屏浮层。盖住整个应用层,状态栏留着不动,看起来就是一个普通页面。 */
.fullsheet {
  position: absolute; inset: 0; z-index: var(--z-sheet);
  background: var(--bg);
  animation: slide-in var(--dur) var(--ease-out);
}

.modal {
  width: 100%; max-width: 320px; background: var(--surface);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-3);
}
.modal-title {
  font-size: var(--fs-15); font-weight: var(--fw-semi); text-align: center;
  padding: var(--sp-5) var(--sp-4) var(--sp-2);
}
.modal-body { padding: var(--sp-2) var(--sp-4) var(--sp-4); }
.modal-message { font-size: var(--fs-13); color: var(--text-2); text-align: center; line-height: 1.6; }
.modal-actions { display: flex; border-top: 1px solid var(--border); }
.modal-btn {
  flex: 1; height: 46px; font-size: var(--fs-15); color: var(--text-2);
  border-right: 1px solid var(--border);
}
.modal-btn:last-child { border-right: none; }
.modal-btn-primary { color: var(--accent); font-weight: var(--fw-medium); }
.modal-btn-primary.is-danger { color: var(--danger); font-weight: var(--fw-semi); }

/* 组件式浮层渲染到所在那一层的最后面（overlay.js 的 Portal）。这一层本身不占位 */
.sheet-host { display: contents; }
/* 整屏浮层从应用层顶上盖起，顶栏自己让出刘海那一条，和应用页的顶栏一样 */
.sheet-host > .fullsheet > .page > .navbar:first-child {
  height: calc(var(--navbar-h) + var(--top-inset));
  padding-top: var(--top-inset);
}

.overlay-host { position: fixed; inset: 0; pointer-events: none; z-index: var(--z-toast); }
.toast-stack {
  position: absolute; left: 0; right: 0; bottom: 96px;
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
}
.toast {
  display: flex; align-items: center; gap: var(--sp-2);
  max-width: 78%; padding: var(--sp-2) var(--sp-4);
  background: var(--toast-bg); color: var(--toast-fg);
  border-radius: var(--r-full); font-size: var(--fs-13);
  animation: fade-in var(--dur-fast) var(--ease);
}
.toast-error { background: var(--toast-error); color: var(--on-scrim); }

/* 挂了长按手势的元素必须带上这个类。见 CLAUDE.md 第 12 条。
   不加的话 iOS 会在长按时弹出系统自己的选中与「拷贝」浮层，
   和本项目的长按菜单同时出现，两边抢同一个手势。
   要复制就在自己的菜单里给一个「复制」。 */
/* 整个外壳默认不可选。
 *
 * 只给挂了长按的那几处加 .no-callout 是不够的：提示行、日期行、按钮旁边的
 * 空白，长按一样弹系统的选中与「拷贝」浮层，和本项目自己的长按菜单撞在一起。
 * 这里是手机，不是网页，本来就没有「选中一段文字」这回事。
 *
 * 要复制就在自己的菜单里给一个「复制」——消息菜单里本来就有（第 12 条）。
 * 真正要能选的只有输入框，下面单独放开。
 */
.root, .no-callout {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
/* 输入框必须能选：不放开的话，光标、拖选、系统的「粘贴」全都不正常 */
input, textarea, [contenteditable="true"], .selectable {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

/* 扫码登录 */
.qr-box { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.qr-img {
  width: 180px; height: 180px; border-radius: var(--r-md);
  background: var(--scrim-fill); padding: var(--sp-2);
}
.qr-note { font-size: var(--fs-13); color: var(--text-3); text-align: center; line-height: 1.6; }

/* 账号登录（ui/qrlogin.js 的 AccountLogin）：短信验证码或密码，给没有手机扫码的人 */
.acct-login { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-4); }
.acct-row { display: flex; gap: var(--sp-2); align-items: center; }
.acct-row > input { flex: 1; min-width: 0; }
.acct-row > input.acct-ct { flex: none; width: 4.5em; text-align: center; }
.acct-row > .btn { flex: none; }
.acct-note { font-size: var(--fs-12); color: var(--text-3); line-height: 1.6; }
.acct-note.is-error { color: var(--danger); }
.acct-sep { font-size: var(--fs-12); color: var(--text-3); text-align: center; margin-top: var(--sp-5); }
