:root {
  --bg: #0b0d10;
  --surface: #14171c;
  --surface-2: #1c2027;
  --line: #262b34;
  --text: #e9edf2;
  --muted: #8a93a2;
  --accent: #3f7cff;
  --orange: #ff9f0a;
  --danger: #ff5a5f;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

input, select {
  font: inherit;
  color: inherit;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.screen[hidden],
.thread[hidden],
.tab-panel[hidden],
.empty[hidden] { display: none; }

/* ============================== 计算器 ============================== */

:root {
  --calc-bg: #f3f4f6;
  --calc-key: #ffffff;
  --calc-text: #141518;
  --calc-muted: #9b9da4;
  --calc-line: #e7e8eb;
  --calc-orange: #ff6a00;
  --calc-orange-soft: #fff2e8;
}

.screen-calc {
  background: var(--calc-bg);
  color: var(--calc-text);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(var(--safe-b) + 8px);
}

.calc-app {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 12px;
}

/* Author display rules (flex/grid) beat the UA [hidden] rule, so state
   toggling has to be spelled out for every container inside the app. */
.calc-app [hidden] { display: none !important; }

.calc-top {
  flex: none;
  height: 52px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

#calc-back-btn { grid-column: 1; grid-row: 1; justify-self: start; }
.calc-tabs, .calc-page-title { grid-column: 2; grid-row: 1; }
#calc-more { grid-column: 3; grid-row: 1; justify-self: end; }

.calc-topbtn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a4c52;
  border-radius: 12px;
}
.calc-topbtn:active { background: rgba(0, 0, 0, 0.05); }
.calc-topbtn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#calc-more svg { width: 22px; height: 22px; }

.calc-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 30px;
}
.calc-tab {
  position: relative;
  padding: 10px 2px;
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--calc-muted);
  transition: color 0.15s ease;
}
.calc-tab.active {
  color: var(--calc-text);
  font-weight: 500;
}
.calc-page-title {
  text-align: center;
  font-size: 17px;
  font-weight: 500;
  color: var(--calc-text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.calc-menu {
  position: absolute;
  top: 52px;
  right: 12px;
  z-index: 30;
  min-width: 156px;
  padding: 6px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.16);
}
.calc-menu[hidden] { display: none; }
.calc-menu button {
  display: block;
  width: 100%;
  padding: 11px 14px;
  text-align: left;
  font-size: 15px;
  color: #222;
  border-radius: 9px;
}
.calc-menu button:active { background: #f1f2f4; }

.calc-pages {
  flex: 1;
  min-height: 0;
  display: flex;
}

.calc-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.calc-display {
  position: relative;
  flex: 1;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  padding: 4px 10px 8px;
  overflow: hidden;
}

/* 组合键进度：只在按对操作符后出现，刻意做得几乎看不见 */
.secret-mark {
  --mark-color: #8f99a8;
  align-self: flex-end;
  width: 19px;
  height: 19px;
  margin: 0 3px 7px 0;
  opacity: 0;
  pointer-events: none;
  transform-origin: 50% 50%;
  transition: opacity 0.3s ease;
}
.secret-mark svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--mark-color);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.secret-mark[data-step="1"] { opacity: 0.12; }
.secret-mark[data-step="2"] { opacity: 0.20; }
.secret-mark[data-step="3"] { opacity: 0.29; }
.secret-mark[data-step="4"] { opacity: 0.40; }

/* One colour per state, no colour shared between states. The blink pattern
   carries the event; every tone stays muted so it never reads as app chrome. */
.secret-mark[data-tone="chord"]   { --mark-color: #8f99a8; } /* 组合键 1–4 格 */
.secret-mark[data-tone="wait"]    { --mark-color: #5d78b8; } /* 进入口令、等待输入 */
.secret-mark[data-tone="typing"]  { --mark-color: #4f93a3; } /* 已输入 1–5 位 */
.secret-mark[data-tone="valid"]   { --mark-color: #7f9a45; } /* 已输入 6–12 位 */
.secret-mark[data-tone="reject"]  { --mark-color: #b39a3f; } /* 位数不足按 = */
.secret-mark[data-tone="checking"]{ --mark-color: #8a6fae; } /* 正在校验 */
.secret-mark[data-tone="success"] { --mark-color: #4d9a72; } /* 口令正确 */
.secret-mark[data-tone="wrong"]   { --mark-color: #b0505a; } /* 错第 1–2 次 */
.secret-mark[data-tone="third"]   { --mark-color: #c0703f; } /* 错第 3 次 */
.secret-mark[data-tone="cooldown"]{ --mark-color: #9a5a8a; } /* 冷却期内重试 */

/* Waiting for digits: slow breathing, in whatever colour the current input state owns. */
.secret-mark[data-pulse="breathe"] { animation: mark-breathe 2.6s ease-in-out infinite; }
@keyframes mark-breathe {
  0%, 100% { opacity: 0.30; transform: scale(1); }
  50% { opacity: 0.62; transform: scale(1.04); }
}

/* One digit accepted: a single short flash. */
.secret-mark[data-pulse="short"] { animation: mark-short 0.22s ease-out; }
@keyframes mark-short {
  0% { opacity: 0.85; transform: scale(1.16); }
  100% { opacity: 0.45; transform: scale(1); }
}

/* Wrong passcode: two short flashes. */
.secret-mark[data-pulse="double"] { animation: mark-double 0.5s ease-out; }
@keyframes mark-double {
  0%, 100% { opacity: 0.25; }
  12% { opacity: 0.92; }
  34% { opacity: 0.22; }
  54% { opacity: 0.92; }
  80% { opacity: 0.30; }
}

/* Cooldown / third failure: one slow long flash. */
.secret-mark[data-pulse="long"] { animation: mark-long 1.15s ease-in-out; }
@keyframes mark-long {
  0% { opacity: 0.12; transform: scale(0.92); }
  42% { opacity: 0.82; transform: scale(1.1); }
  100% { opacity: 0.16; transform: scale(0.98); }
}

/* Decrypting: a faster pulse than idle, still faint. */
.secret-mark[data-pulse="checking"] { animation: mark-check 0.9s ease-in-out infinite; }
@keyframes mark-check {
  0%, 100% { opacity: 0.24; transform: scale(0.96); }
  50% { opacity: 0.78; transform: scale(1.06); }
}

/* Accepted: long, with a small scale-up before the screen changes. */
.secret-mark[data-pulse="success"] { animation: mark-success 0.65s ease-out; }
@keyframes mark-success {
  0% { opacity: 0.9; transform: scale(1.3); }
  55% { opacity: 0.72; transform: scale(1.05); }
  100% { opacity: 0.45; transform: scale(1); }
}

/* 顶部算式记录：最近三条，浅灰右对齐；margin-bottom:auto 把它顶到显示区上方，
   当前算式和结果仍然贴着底部。 */
.calc-history {
  align-self: stretch;
  margin: 4px 0 auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: right;
  color: #c3c5ca;
  font-size: 19px;
  line-height: 1.45;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}
.calc-history-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calc-history-result {
  margin-left: 6px;
}

.calc-sub {
  height: 22px;
  font-size: 14px;
  color: var(--calc-muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.calc-value {
  font-size: clamp(46px, 13vw, 78px);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.08;
  color: var(--calc-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  max-width: 100%;
  font-variant-numeric: tabular-nums;
}

.calc-pad {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 8px 0 4px;
}

.key {
  aspect-ratio: 1.1 / 1;
  border-radius: 18px;
  background: var(--calc-key);
  color: var(--calc-text);
  font-size: clamp(20px, 5.6vw, 28px);
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, transform 0.12s ease;
}

.key:active {
  background: #e9eaed;
  transform: scale(0.985);
}

.key[disabled] { cursor: default; }

.key-fn {
  background: var(--calc-key);
  color: var(--calc-orange);
  font-size: clamp(20px, 5.4vw, 27px);
}
.key-fn:active { background: var(--calc-orange-soft); }
.key-fn-muted { color: #f4cfb5; }

.key-op {
  background: var(--calc-key);
  color: var(--calc-orange);
  font-size: clamp(23px, 6.4vw, 32px);
}
.key-op:active { background: var(--calc-orange-soft); }
.key-op-muted { color: #f4d3bc; }
.key-op[data-k="eq"],
.key-op[data-ck="eq"] {
  background: var(--calc-orange);
  color: #fff;
}
.key-op[data-k="eq"]:active,
.key-op[data-ck="eq"]:active { background: #e96000; }

/* 位图图标：保留原图的橙色与粗细，透明底，点击交给按钮本身 */
.key-glyph {
  display: block;
  width: 29px;
  height: 29px;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.calc-pad-sci {
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  padding-top: 4px;
}
.calc-pad-sci .key {
  aspect-ratio: auto;
  height: clamp(42px, 7.2vh, 62px);
  border-radius: 13px;
  font-size: clamp(12px, 3.5vw, 17px);
}
.calc-pad-sci .key-fn,
.calc-pad-sci .key-op { font-size: clamp(14px, 4vw, 20px); }
.calc-pad-sci .key-glyph { width: 24px; height: 24px; }

.key-sci { color: #3c3e44; background: var(--calc-key); }
.key-sci:active { background: #e9eaed; }
.key-sci.is-on { color: var(--calc-orange); background: var(--calc-orange-soft); }

/* --------------------------------------------------------- 换算宫格 */

.conv-page { justify-content: stretch; }

.conv-home {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 6px 6px 18px;
  -webkit-overflow-scrolling: touch;
}

.conv-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 2px;
  /* Let the five rows breathe into the spare height on tall phones instead
     of leaving one empty block under BMI. Short screens still scroll. */
  align-content: space-between;
}

/* Conversion tiles share the word "conv" with the chat list; keep the class
   name distinct so the calculator grid can never leak into conversation rows. */
.conv-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  padding: 20px 4px;
  border-radius: 16px;
  color: #5d6067;
  -webkit-tap-highlight-color: transparent;
}
.conv-tile:active { background: rgba(0, 0, 0, 0.04); }
.conv-tile svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: #6c6f76;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.conv-tile span {
  font-size: 15px;
  color: #44474d;
  letter-spacing: 0.01em;
}

.conv-detail {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.conv-detail[hidden] { display: none; }

.conv-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 20px 14px;
  -webkit-overflow-scrolling: touch;
}

/* 单位行 */
.unit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 19px 2px;
  border-bottom: 1px solid var(--calc-line);
  cursor: pointer;
}
.unit-row:last-of-type { border-bottom: 0; }
.unit-row:active { opacity: 0.72; }

.unit-label {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: none;
  max-width: 48%;
  font-size: 17px;
  color: #3d4046;
}
.unit-label .sym {
  font-size: 13px;
  color: #b0b3b9;
  font-weight: 300;
}
.unit-label svg {
  width: 14px;
  height: 14px;
  margin-left: 1px;
  fill: none;
  stroke: #b8bbc1;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.unit-value {
  flex: 1;
  min-width: 0;
  text-align: right;
  font-size: clamp(24px, 6.4vw, 32px);
  font-weight: 300;
  color: var(--calc-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.unit-row.active .unit-value { color: var(--calc-orange); }

.conv-note {
  padding: 14px 0 4px;
  text-align: center;
  font-size: 12px;
  line-height: 1.7;
  color: #a5a8ae;
}

/* 换算数字键盘 */
.conv-pad {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  padding-top: 8px;
}
.conv-pad[hidden] { display: none; }
.conv-pad .key {
  aspect-ratio: 1.24 / 1;
  border-radius: 15px;
  font-size: clamp(19px, 5.4vw, 26px);
}
.conv-pad .key[disabled] { opacity: 0.55; }

.conv-hex {
  flex: none;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding-top: 8px;
}
.conv-hex[hidden] { display: none; }
.conv-hex button {
  height: 42px;
  border-radius: 12px;
  background: var(--calc-key);
  color: #3c3e44;
  font-size: 15px;
}
.conv-hex button:active { background: #e9eaed; }

/* --------------------------------------------------------- 表单类换算 */

.form-field {
  padding: 16px 2px 14px;
  border-bottom: 1px solid var(--calc-line);
}
.form-field label,
.form-caption {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
  color: #56595f;
}
.form-field input {
  width: 100%;
  height: 40px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 25px;
  font-weight: 300;
  color: var(--calc-text);
}
.form-field input::placeholder { color: #c3c6cb; font-weight: 300; }

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  padding: 4px 0;
}
.seg button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 16px;
  color: #3d4046;
}
.seg .dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid #cfd2d7;
  background: #fff;
}
.seg button.on .dot {
  border-color: var(--calc-orange);
  background: radial-gradient(circle, var(--calc-orange) 0 46%, #fff 51% 100%);
}
.seg button.on { color: var(--calc-text); }

.form-hint {
  padding: 12px 2px 0;
  font-size: 12px;
  line-height: 1.6;
  color: #a5a8ae;
}
.form-error {
  padding: 10px 2px 0;
  font-size: 13px;
  color: #d9483b;
  min-height: 22px;
}

.primary-btn {
  width: 100%;
  height: 52px;
  margin-top: 22px;
  border-radius: 26px;
  background: var(--calc-orange);
  color: #fff;
  font-size: 18px;
  font-weight: 500;
}
.primary-btn:active { background: #e96000; }

.result-card {
  margin: 20px 0 6px;
  padding: 18px;
  background: #fff;
  border-radius: 18px;
}
.result-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 500;
  color: #96999f;
}
.result-main {
  margin-bottom: 10px;
  font-size: clamp(30px, 8vw, 40px);
  font-weight: 300;
  color: var(--calc-orange);
  font-variant-numeric: tabular-nums;
}
.result-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  font-size: 15px;
  color: #7e8188;
}
.result-row b {
  font-weight: 500;
  color: #2f3136;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 大写数字 */
.money-raw {
  padding: 16px 2px 2px;
  text-align: right;
  font-size: 24px;
  font-weight: 300;
  color: #b6b9bf;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.money-out {
  padding: 10px 2px 26px;
  text-align: right;
  font-size: clamp(24px, 6.6vw, 34px);
  font-weight: 400;
  line-height: 1.6;
  color: var(--calc-text);
  word-break: break-all;
}

/* 亲戚称呼 */
.kin-chain {
  min-height: 38px;
  padding: 18px 2px 2px;
  text-align: right;
  font-size: 21px;
  font-weight: 300;
  color: #6b6e75;
  word-break: break-all;
}
.kin-result {
  min-height: 150px;
  padding: 24px 2px 10px;
  text-align: right;
  font-size: clamp(30px, 8.4vw, 42px);
  font-weight: 300;
  color: var(--calc-orange);
  line-height: 1.4;
  word-break: break-all;
}
.kin-pad {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  padding-top: 8px;
}
.kin-pad .key {
  aspect-ratio: 1.35 / 1;
  border-radius: 15px;
  font-size: clamp(16px, 4.6vw, 21px);
}
.kin-pad .key-ac { color: var(--calc-orange); }
.kin-pad .key-eq {
  grid-column: 1 / -1;
  aspect-ratio: auto;
  height: 52px;
  background: var(--calc-orange);
  color: #fff;
}

/* --------------------------------------------------------- 单位选择面板 */

.conv-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.28);
}
.conv-sheet-backdrop[hidden] { display: none; }
.conv-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);
}
.conv-sheet[hidden] { display: none; }
.conv-sheet-title {
  flex: none;
  padding: 16px 0 8px;
  text-align: center;
  font-size: 14px;
  color: #9a9da3;
}
.conv-sheet-list {
  overflow-y: auto;
  padding: 0 10px 16px;
}
.conv-sheet-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 15px 18px;
  border-radius: 12px;
  font-size: 17px;
  color: #2f3136;
}
.conv-sheet-item:active { background: #f4f5f7; }
.conv-sheet-item.on {
  color: var(--calc-orange);
  background: var(--calc-orange-soft);
}
.conv-sheet-item .check {
  color: var(--calc-orange);
  opacity: 0;
  font-size: 16px;
}
.conv-sheet-item.on .check { opacity: 1; }

@media (max-width: 360px) {
  .calc-app { padding: 0 8px; }
  .calc-pad { gap: 7px; }
  .calc-pad-sci { gap: 5px; }
  .conv-grid { gap: 0; }
  .conv-tile { padding: 16px 2px; }
  .conv-tile svg { width: 34px; height: 34px; }
}

@media (min-width: 700px) {
  .calc-app { max-width: 480px; }
}

/* ============================== 聊天 ============================== */

.screen-chat { background: #000; }

.chat-shell {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-top {
  height: 54px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  flex: none;
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(54px + env(safe-area-inset-top, 0px));
}

.chat-title { font-size: 17px; font-weight: 600; letter-spacing: 0.01em; }

.ghost {
  font-size: 13px;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
}
.ghost:active { background: var(--surface-2); }

/* 顶栏常驻的「有新版本」：开着网页时服务端换了构建号就出现，点一下刷新。
   不自动弹走页面，因为输入框里可能正打着没发的话。 */
.chat-top .update-chip {
  margin-left: auto;
  margin-right: 6px;
  color: var(--orange);
  border: 1px solid var(--orange);
  background: rgba(255, 159, 10, 0.12);
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 999px;
  white-space: nowrap;
  animation: chip-in 220ms ease-out;
}
@keyframes chip-in { from { opacity: 0; } to { opacity: 1; } }

.chat-body { flex: 1; position: relative; overflow: hidden; }

.tab-panel { position: absolute; inset: 0; overflow-y: auto; }

.conv-list { padding: 4px 0; }

.conv-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 11px 16px;
  width: 100%;
  text-align: left;
}
.conv-item:active { background: var(--surface); }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(140deg, #3f7cff, #7a4cff);
  text-transform: uppercase;
}

.avatar-lg { width: 68px; height: 68px; font-size: 26px; }

.conv-main { flex: 1; min-width: 0; }
.conv-name {
  font-size: 15px;
  font-weight: 500;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-preview {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-time { font-size: 11px; color: #5d6673; flex: none; align-self: flex-start; margin-top: 4px; }

.conv-meta-col { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.conv-flags { display: flex; gap: 5px; color: #6b7482; }
.conv-flags svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* 未读计数：只有真有新消息没看过才出现，0 条时由 JS 加 hidden */
.conv-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.conv-unread[hidden] { display: none; }

.conv-item.row-wrap { padding: 0 6px 0 0; gap: 0; }
.conv-open {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 11px 6px 11px 16px;
  color: inherit;
}
.conv-card {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  color: #5d6673;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.conv-card:active { background: var(--surface-2); color: var(--text); }

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  padding: 24px;
  text-align: center;
  pointer-events: none;
}
/* keep the blank state clear of the add-contact form above it (now two rows tall) */
#panel-contacts .empty { top: 110px; }
.empty-title { font-size: 15px; color: #b6bfcc; }
.empty-sub { font-size: 13px; line-height: 1.5; }

.chat-tabs {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  background: #0e1116;
  padding-bottom: var(--safe-b);
}

.tab {
  height: 52px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #6b7482;
  font-size: 10.5px;
}
.tab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab.active { color: var(--accent); }

/* 底部标签页的未读总数。它必须压住 1px 上边框，所以往左上探出图标。 */
.tab-badge {
  position: absolute;
  top: 6px;
  left: calc(50% + 5px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px #0e1116;
  pointer-events: none;
  animation: badge-pop .26s ease-out 1;
}
@keyframes badge-pop {
  from { transform: scale(.6); opacity: .35; }
  to { transform: none; opacity: 1; }
}
.tab-badge[hidden] { display: none; }

/* 来消息提示：会话行一次低对比度脉冲 + 未读红点 + 标签页总数。
   全是视觉信号，不放声音、不震动，免打扰会话由 JS 决定不闪。 */
@keyframes conv-pulse {
  0% { background-color: rgba(63, 124, 255, 0.26); }
  55% { background-color: rgba(63, 124, 255, 0.13); }
  100% { background-color: transparent; }
}
.conv-item.is-new { animation: conv-pulse 2.2s ease-out 1; }

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px) scale(.985); }
  to { opacity: 1; transform: none; }
}
.msg.is-new .bubble { animation: bubble-in .34s ease-out 1; }

@media (prefers-reduced-motion: reduce) {
  .conv-item.is-new { animation: none; }
  .msg.is-new .bubble { animation: none; }
  .tab-badge { animation: none; }
}

/* 会话内的联系人 / 我 */

.add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px 8px;
}
.add-row input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 12px;
  outline: none;
  font-size: 14px;
}
.add-row input:focus { border-color: #3a4a6b; }
.add-row button {
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
}
/* 验证留言单独一行：窄屏上不跟 ID 输入框挤在一起 */
#add-note { flex: 1 1 100%; }

/* 通讯录顶部的「新的朋友」入口。它常驻在添加框下面，有申请时才计数。 */
.request-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.request-row[hidden] { display: none; }
.request-row:active { background: var(--surface-2); }
.request-ico {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, #1f7a63, #2fa389);
  color: #fff;
}
.request-ico svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.request-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.request-title { font-size: 15px; font-weight: 500; }
.request-sub {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.request-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.request-row.is-new { animation: conv-pulse 2.2s ease-out 1; }
/* 黑名单搬到了「我」页，用普通行的文字显示人数，不再需要申请行那种计数徽章；
   红色（.is-blocked）只用在「有人被挡住」这个事实本身，不表示待处理。 */

/* 一条申请：谁、留了什么话、同意或拒绝 */
.req-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.req-item:last-child { border-bottom: 0; }
.req-head { display: flex; align-items: center; gap: 10px; }
.req-name { font-size: 16px; font-weight: 600; }
.req-when { font-size: 12px; color: var(--muted); margin-left: auto; }
.req-note {
  font-size: 14px;
  line-height: 1.5;
  color: #c8d0dc;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
}
/* 「没有留言」这句占位话要说得轻，但不能借用 .empty —— 那个类是列表空态的
   绝对定位覆盖层（position:absolute; inset:0），套在一行留言上会让它铺满整个
   底部面板、盖住「同意 / 拒绝」，看上去就是面板是空的、按钮不见了。 */
.req-note.is-quiet { color: var(--muted); }
.req-actions { display: flex; gap: 10px; }
.req-actions .btn { flex: 1; }
.req-done { font-size: 14px; color: var(--muted); }
.req-item.is-done { gap: 6px; }
/* 空列表也要有一页话说：以前这里靠一条 toast 提示，面板本身留白，
   看上去就像「申请点开了但什么都没有」。 */
.req-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 34px 10px 26px;
  text-align: center;
}
.req-empty-title { font-size: 17px; font-weight: 600; }
.req-empty-sub { font-size: 14px; line-height: 1.55; color: var(--muted); }
.req-empty .btn { min-width: 120px; margin-top: 8px; }

/* 会话底部的验证状态条：对方没同意之前，这里说明为什么发不出去；
   如果是对方在等你同意，验证留言和「同意 / 拒绝」也直接放在这里，
   不然点进会话只剩一片空白，找不到任何可以按的地方。 */
.friend-gate {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 10px 14px;
  background: rgba(63, 124, 255, 0.12);
  border-top: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.45;
  color: #c8d0dc;
}
.friend-gate[hidden] { display: none; }
.friend-gate-main { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 7px; }
.friend-gate-note {
  align-self: flex-start;
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  word-break: break-word;
}
.friend-gate-note[hidden] { display: none; }
.friend-gate-actions { flex: none; display: flex; gap: 8px; margin-left: auto; }
.friend-gate-btn {
  flex: none;
  height: 34px;
  padding: 0 14px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
}
.friend-gate-btn.quiet {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.friend-gate-btn:disabled { opacity: .5; }
/* 未通过验证时输入框整排灰掉，一看就知道此刻不能打字 */
#msg-input:disabled,
#send-btn:disabled { opacity: .45; }

/* 通讯录里未通过验证的联系人行：名字后面的状态标签 */
.conv-state {
  font-size: 12px;
  color: var(--orange);
  margin-top: 3px;
}
.conv-state.ok { color: #2fa389; }


.me-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 16px 20px;
  width: 100%;
  text-align: center;
  color: inherit;
  border-radius: 0;
}
.me-card:active { background: var(--surface); }
.me-name { font-size: 17px; font-weight: 600; }
.me-bio {
  font-size: 12.5px;
  color: #aab3c0;
  line-height: 1.45;
  max-width: 280px;
}
.me-bio:empty { display: none; }
.me-handle { font-size: 11.5px; color: var(--muted); letter-spacing: 0.01em; }
.me-sub { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }

.rows { margin: 4px 16px; border-radius: 12px; background: var(--surface); overflow: hidden; }
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
  color: inherit;
  background: none;
}
.row:last-child { border-bottom: 0; }
.row-btn:active { background: var(--surface-2); }
.row-val { color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62%; }
.row-val.mono { font-size: 10.5px; letter-spacing: 0.03em; font-variant-numeric: tabular-nums; }
/* 资料卡上的黑名单状态：已经拉黑的人要说得醒目，否则点的人会以为没生效。 */
.row-val.is-blocked { color: var(--danger); }

.danger {
  margin: 20px 16px 6px;
  padding: 12px;
  border-radius: 12px;
  background: #221317;
  color: var(--danger);
  font-size: 14px;
  width: calc(100% - 32px);
}
.fineprint { margin: 0 16px 24px; font-size: 11.5px; color: #5d6673; line-height: 1.5; }

/* 会话详情 */

.thread {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  z-index: 3;
}

.thread-top {
  height: calc(50px + env(safe-area-inset-top, 0px));
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: env(safe-area-inset-top, 0px) 8px 0 4px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.icon-btn {
  width: 36px;
  height: 36px;
  font-size: 26px;
  line-height: 1;
  color: #b6bfcc;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 4px;
}
.icon-btn:active { background: var(--surface-2); }

.thread-title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  color: inherit;
  padding: 4px 2px;
  border-radius: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-title:active { background: var(--surface-2); }

.menu-btn { font-size: 22px; padding-bottom: 6px; }

.thread-search {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #0e1116;
}
.thread-search[hidden] { display: none; }
.thread-search input {
  flex: 1;
  min-width: 0;
  height: 34px;
  border-radius: 17px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 12px;
  outline: none;
  font-size: 13.5px;
}
.thread-search input:focus { border-color: #3a4a6b; }
.search-count { font-size: 11px; color: var(--muted); flex: none; }
mark { background: rgba(255, 159, 10, 0.32); color: inherit; border-radius: 3px; }

.ttl {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--line);
  color: #c7cfdb;
  font-size: 11.5px;
  padding: 5px 8px;
  border-radius: 8px;
  margin-right: 4px;
  outline: none;
}

.thread-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0 14px;
  display: flex;
  flex-direction: column;
}

.msg { display: flex; padding: 2px 14px; }
.msg.out { justify-content: flex-end; }

.bubble {
  max-width: 76%;
  background: var(--surface-2);
  padding: 9px 12px 8px;
  border-radius: 16px;
  border-bottom-left-radius: 6px;
  font-size: 14.5px;
  line-height: 1.42;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.out .bubble {
  background: #2f62f0;
  color: #fff;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 6px;
}

.msg-meta {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 4px;
  font-size: 10.5px;
  color: #6b7482;
}
.msg.out .msg-meta { color: #a8bcf5; }
.msg-meta .burn { color: var(--orange); font-variant-numeric: tabular-nums; }
.msg.out .msg-meta .burn { color: #ffcf80; }

.composer {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(8px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: #0e1116;
}
.composer input {
  flex: 1;
  height: 38px;
  border-radius: 19px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 14px;
  outline: none;
  font-size: 14.5px;
}
.composer input:focus { border-color: #3a4a6b; }
.composer button {
  height: 38px;
  padding: 0 16px;
  border-radius: 19px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
}

/* ============================== 二次访问 ============================== */

.screen-second {
  background: #0b0d10;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.second-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.second-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.second-badge svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: #aab3c0;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.second-card h2 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.second-sub { margin: 0 0 16px; font-size: 13px; color: var(--muted); }

#second-form { width: 100%; display: flex; flex-direction: column; gap: 10px; }

#second-pass {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 12px;
  text-align: center;
  font-size: 19px;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  outline: none;
}
#second-pass:focus { border-color: #3a4a6b; }
#second-pass::placeholder { font-size: 13px; letter-spacing: 0.02em; text-indent: 0; color: #5d6673; }

#second-submit {
  height: 46px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
#second-submit:disabled { opacity: 0.55; }

.second-card .link { margin-top: 12px; }

/* ============================== 软件授权 ============================== */

.screen-license {
  background: #0b0d10;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.license-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.license-card h2 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.license-card .second-sub { margin-bottom: 14px; }

.license-state {
  width: 100%;
  border: 1px solid #2c3325;
  background: #141a12;
  color: #b9d4a4;
  border-radius: 10px;
  padding: 9px 11px;
  margin-bottom: 12px;
  font-size: 12.5px;
  line-height: 1.5;
  text-align: left;
  overflow-wrap: anywhere;
}
.license-state[data-tone="bad"] {
  border-color: #3a2326;
  background: #1b1314;
  color: #f0a7a9;
}
.license-state[data-tone="wait"] {
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
}

#license-form { width: 100%; display: flex; flex-direction: column; gap: 10px; }

#license-code {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 12px;
  text-align: center;
  font-size: 17px;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  font-variant-numeric: tabular-nums;
  outline: none;
}
#license-code:focus { border-color: #3a4a6b; }
#license-code::placeholder { font-size: 14px; letter-spacing: 0.06em; text-indent: 0.06em; color: #5d6673; }

#license-submit {
  height: 46px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
#license-submit:disabled { opacity: 0.55; }

.license-device {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
}
.license-device code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  color: #aeb7c5;
  font-size: 11px;
}
.license-device .link { padding: 0; flex: none; }

.license-actions {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

/* ============================== 初始化 ============================== */

.screen-setup {
  background: #0b0d10;
  align-items: center;
  /* Auto margins on .setup do the vertical centering: a centered flex line
     clips its top once the tips push past a 640px-tall screen. */
  justify-content: flex-start;
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.setup {
  width: 100%;
  max-width: 360px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setup h2 { margin: 0 0 8px; font-size: 22px; font-weight: 600; }
.setup-sub { margin: 0 0 12px; font-size: 13px; color: var(--muted); line-height: 1.5; }

/* 注册 / 登录切换：首屏最显眼的控件，新手一眼就知道自己在哪一步 */
.setup-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.setup-tab {
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 600;
}
.setup-tab.on {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.setup-note {
  font-size: 12.5px;
  line-height: 1.5;
  color: #9dc0ff;
  background: #121a2b;
  border: 1px solid #223148;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}
.setup-note[hidden] { display: none; }

.setup-pass {
  font-size: 12px;
  color: #c8a05a;
  background: #1a1712;
  border: 1px solid #2e2718;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}

.setup-tips {
  margin: 14px 0 0;
  padding: 0 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}
.setup-tips[hidden] { display: none; }
.setup-tips li { overflow-wrap: anywhere; }

#setup-form { display: flex; flex-direction: column; gap: 12px; }

#setup-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}
/* display:flex above otherwise overrides the UA [hidden] rule, leaving the
   invite field visible in login mode (it is only needed for registration). */
#setup-form label[hidden] { display: none; }

#setup-form input {
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 12px;
  font-size: 15px;
  outline: none;
}
#setup-form input:focus { border-color: #3a4a6b; }

/* Password reveal: the eye sits inside the field's right padding so the input
   keeps its own border and focus ring. */
.pw-field { position: relative; display: block; }
/* The id-qualified `#setup-form input` shorthand above wins over a plain class
   selector, so the extra right padding has to carry the same id to apply. */
#setup-form .pw-field input { width: 100%; padding-right: 46px; }
.pw-eye {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pw-eye:active { color: var(--text); }
.pw-eye svg { width: 21px; height: 21px; display: block; }
.pw-eye .eye-closed { display: none; }
.pw-field[data-shown="1"] .eye-open { display: none; }
.pw-field[data-shown="1"] .eye-closed { display: block; }

#setup-submit {
  height: 46px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  margin-top: 4px;
}
#setup-submit:disabled { opacity: 0.55; }

.setup-err { min-height: 18px; font-size: 12.5px; color: var(--danger); }

.setup-links { display: flex; justify-content: space-between; margin-top: 8px; }
.link { font-size: 13px; color: var(--muted); padding: 6px 0; }
.link:active { color: var(--text); }

/* ============================== 底部面板 ============================== */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  z-index: 55;
  animation: fade-in 0.16s ease-out;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  /* 手机地址栏会让 1vh 比可视高度大出一截，只写 vh 时申请面板底部的
     「同意 / 拒绝」有可能被顶到屏幕外。dvh 按可视高度算，老浏览器退回 vh。 */
  max-height: 84vh;
  max-height: min(84vh, 84dvh);
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  /* env() is 0 on any device without a bottom inset, which left the last button
     of a sheet glued to the screen edge — 删除并拉黑 / 拒绝 were reachable but
     read as cut off. Keep the safe-area value when it is larger. */
  padding-bottom: max(var(--safe-b), 14px);
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.5);
  animation: sheet-in 0.18s ease-out;
}

.sheet[hidden],
.sheet-backdrop[hidden] { display: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-in {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 10px 8px 18px;
  flex: none;
}
.sheet-title { font-size: 16px; font-weight: 600; }
/* min-height:0 让它在 flex 列里真的能收缩，长列表靠这里滚动，
   而不是把面板整体撑到屏幕外面去。 */
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 16px 18px; }
.sheet-text { font-size: 13.5px; color: #aab3c0; line-height: 1.55; margin: 4px 0 10px; }
.sheet-note { font-size: 11.5px; color: #6b7482; line-height: 1.55; margin: 10px 0 0; }

.menu-list { display: flex; flex-direction: column; margin: 0 -16px; }
.menu-item {
  padding: 15px 18px;
  text-align: left;
  font-size: 15px;
  border-bottom: 1px solid var(--line);
  color: inherit;
}
.menu-item:last-child { border-bottom: 0; }
.menu-item:active { background: var(--surface-2); }
.menu-item.danger-item { color: var(--danger); }
/* 拉黑 / 移出黑名单是网络操作，按钮按下去要立刻显出「已在路上」，
   否则连点两次会把同一件事发两遍。 */
.menu-item:disabled,
.btn:disabled {
  opacity: 0.5;
}
.menu-item .menu-hint { float: right; font-size: 12px; color: var(--muted); }

.card-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 0 16px;
  text-align: center;
}
.card-name { font-size: 17px; font-weight: 600; }
.card-handle { font-size: 11.5px; color: var(--muted); }
.card-bio { font-size: 13px; color: #aab3c0; line-height: 1.5; max-width: 300px; }
.card-empty { font-size: 12px; color: #6b7482; line-height: 1.5; max-width: 280px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); margin: 12px 0; }
.field input,
.field textarea {
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0e1116;
  padding: 0 12px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  width: 100%;
}
.field textarea { height: 76px; padding: 10px 12px; resize: none; line-height: 1.45; }
.field input:focus,
.field textarea:focus { border-color: #3a4a6b; }

.sheet-actions { display: flex; gap: 10px; margin-top: 14px; }
.logout-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.logout-choices .btn { flex: none; width: 100%; }
.btn {
  flex: 1;
  height: 44px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 14.5px;
  color: inherit;
}
.btn:active { filter: brightness(1.2); }
.btn.primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn.danger-btn { background: #221317; color: var(--danger); }

.device-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.device-row:last-of-type { border-bottom: 0; }
.device-main { flex: 1; min-width: 0; }
.device-name { font-size: 14px; }
.device-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.device-badge { font-size: 10.5px; color: var(--accent); border: 1px solid #2c4270; border-radius: 999px; padding: 2px 8px; flex: none; }
.device-remove { font-size: 12.5px; color: var(--danger); padding: 6px 8px; border-radius: 8px; flex: none; }
.device-remove:active { background: #221317; }

/* ============================== Toast ============================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(150px + var(--safe-b));
  transform: translateX(-50%);
  background: #24272e;
  color: #e6ebf2;
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 10px;
  max-width: 80vw;
  text-align: center;
  /* Toasts are raised from inside sheets (e.g. an empty nickname), so they
     must paint above the sheet layer instead of behind its backdrop. */
  z-index: 70;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.16s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================ 头像与富消息 ============================ */

.avatar.has-img { background: none; }
.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.avatar-sm { width: 30px; height: 30px; font-size: 12px; }

.msg { gap: 7px; align-items: flex-start; }
.msg-avatar { margin-top: 1px; }
.msg-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: calc(76% - 37px);
  min-width: 0;
}
.msg.out .msg-stack { align-items: flex-end; }
.msg-name {
  font-size: 10.5px;
  color: #6b7482;
  margin: 0 5px 3px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg.out .msg-name { color: #7d8797; }
.bubble { max-width: 100%; }
.msg.out .bubble { max-width: 100%; }

.bubble.media { padding: 4px 4px 0; }
.bubble.media .msg-meta { padding: 5px 6px 4px; margin-top: 0; }

.msg-img {
  display: block;
  width: 100%;
  max-width: 228px;
  max-height: 280px;
  object-fit: cover;
  border-radius: 13px;
  cursor: zoom-in;
  background: #11151b;
}

.loc-card {
  display: flex;
  gap: 9px;
  align-items: center;
  width: 208px;
  color: inherit;
  text-align: left;
  text-decoration: none;
  padding: 2px 2px 1px;
}
.loc-card:active { opacity: 0.72; }
.loc-pin {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  background: rgba(47, 98, 240, 0.16);
  color: #7fa2ff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg.out .loc-pin { background: rgba(255, 255, 255, 0.18); color: #fff; }
.loc-pin svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.loc-title { font-size: 13.5px; font-weight: 500; }
.loc-sub {
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}
.msg.out .loc-sub { color: #c6d8ff; }

/* 定位拿不到时，位置面板要能手动填坐标。两格并排，窄屏换行而不是缩小字号。 */
.loc-fields { display: flex; gap: 10px; flex-wrap: wrap; }
.loc-fields .field { flex: 1 1 140px; min-width: 0; margin: 10px 0 0; }
.loc-fields input { font-variant-numeric: tabular-nums; }

.voice-card {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 168px;
  padding: 2px 2px 1px;
  color: inherit;
  text-align: left;
}
.voice-play {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  padding-left: 2px;
}
.msg.out .voice-play { background: rgba(255, 255, 255, 0.22); padding-left: 2px; }
.voice-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 20px; color: currentColor; }
.voice-wave i { width: 2px; border-radius: 2px; background: currentColor; opacity: 0.5; }
.voice-dur { font-size: 10.5px; opacity: 0.72; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ composer */

.composer-wrap {
  flex: none;
  position: relative;
  background: #0e1116;
  border-top: 1px solid var(--line);
}

.tray, .emoji-panel, .rec-bar { border-bottom: 1px solid var(--line); }
.tray[hidden], .emoji-panel[hidden], .rec-bar[hidden] { display: none; }
/* 好友闸门落下时整条输入栏收起，只留上面那条说明 */
.composer-wrap[hidden] { display: none; }

.tray {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 12px;
}
.tray-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 64px;
  border-radius: 12px;
  background: var(--surface);
  color: #c7cfdb;
  font-size: 12px;
}
.tray-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tray-btn:active { background: var(--surface-2); }
.tray-btn.primary { background: var(--accent); color: #fff; }

.emoji-panel {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px 10px;
  max-height: 232px;
  overflow-y: auto;
}
.emoji-panel button {
  height: 38px;
  border-radius: 8px;
  font-size: 23px;
  line-height: 1;
}
.emoji-panel button:active { background: var(--surface-2); }

.rec-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}
.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff5a52;
  animation: rec-pulse 1s ease-in-out infinite;
}
@keyframes rec-pulse { 50% { opacity: 0.25; } }
.rec-time { font-size: 13px; font-variant-numeric: tabular-nums; }
.rec-hint { flex: 1; font-size: 11.5px; color: var(--muted); }
.rec-bar .tray-btn {
  height: 32px;
  flex-direction: row;
  padding: 0 14px;
  font-size: 12.5px;
  border-radius: 16px;
}

.composer {
  border-top: 0;
  background: transparent;
}
.composer .cbtn {
  width: 36px;
  height: 36px;
  flex: none;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: #8b95a3;
  display: flex;
  align-items: center;
  justify-content: center;
}
.composer .cbtn svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.composer .cbtn:active { background: var(--surface-2); }
.composer #send-btn { padding: 0 14px; }

#me-account { font-size: 12px; letter-spacing: 0.12em; color: #b6bfcc; }

.full-img { width: 100%; height: auto; border-radius: 10px; display: block; }

.loc-title, .loc-sub { display: block; }
.loc-card { max-width: 100%; }
.avatar-actions { display: flex; gap: 8px; margin-top: 10px; }
.mini-btn {
  height: 30px;
  padding: 0 13px;
  border-radius: 15px;
  background: var(--surface-2);
  color: #c7cfdb;
  font-size: 12px;
}
.mini-btn:active { background: #2a313c; }
.composer input { min-width: 0; }
.bubble.media { white-space: normal; }
.loc-card { white-space: normal; }
.voice-card { white-space: normal; }

/* ============================ 软件使用说明 ============================ */

/* 这页原来是一节一大段，手机上整屏都是字、找不到重点。改成三件事：
   ① 顶部先把最常见的三个卡点一句话给答案；
   ② 正文一句只说一件事，标题带序号块，靠行距分栏而不是靠颜色；
   ③ 颜色只承担一个语义——绿=做得到、橙=有条件/要注意、红=做不到/找不回。
   键位仍是等宽小胶囊，一眼能认出那是按键而不是文字。 */
.help-quick {
  margin: 6px 0 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
}
.help-quick-h {
  margin: 0;
  padding: 9px 12px 8px;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.help-quick-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 9px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.5;
}
.help-quick-row .q-k { flex: 0 0 auto; font-weight: 600; color: #dfe6ef; }
.help-quick-row .q-a { flex: 1 1 170px; min-width: 0; color: #a7b0bd; }

.help-h {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 7px;
  font-size: 14.5px;
  font-weight: 600;
  color: #dbe2ec;
}
.help-n {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #cfe0ff;
  background: rgba(63, 124, 255, 0.16);
}
/* 标题下面那句「为什么」：小一号、灰一档，扫读时可以先跳过。 */
.help-why { margin: 0 0 7px; font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.help-body .sheet-text { margin: 4px 0 6px; }
.help-ul { margin: 0 0 4px; padding-left: 17px; }
.help-ul li { font-size: 13.5px; color: #aab3c0; line-height: 1.62; margin: 0 0 6px; }
.help-ul li:last-child { margin-bottom: 0; }
.help-body b { color: #d7dee8; font-weight: 600; }
/* 三种颜色只用来标「能不能做到」，别的地方不许用，否则又变成一屏花字。 */
.can { color: #34c759; font-weight: 600; }
.cond { color: var(--orange); font-weight: 600; }
.cannot { color: var(--danger); font-weight: 600; }
/* 两条容易搞混的东西并排摆，比连着两个长句子好认。 */
.help-cmp { display: grid; gap: 8px; margin: 0 0 4px; }
.help-cmp > div {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.help-cmp h4 { margin: 0 0 3px; font-size: 13.5px; font-weight: 600; color: #d7dee8; }
.help-cmp p { margin: 0; font-size: 13px; line-height: 1.55; color: #a7b0bd; }
.help-k {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  color: #e4eaf3;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  white-space: nowrap;
}
/* 地址是内容不是标签：只有这一行恢复文本光标，长按能选中复制。 */
.help-addr {
  user-select: text;
  -webkit-user-select: text;
  word-break: break-all;
  color: #c7cfdb;
}
/* 中性告示条：定位拿不到这类「不是你的错，但要告诉你为什么」的话。
   用橙不用红，红色在这套界面里只留给真的做不到的事。 */
.help-warn {
  margin: 10px 0 0;
  padding: 9px 11px;
  border: 1px solid rgba(255, 159, 10, 0.28);
  border-radius: 10px;
  background: rgba(255, 159, 10, 0.1);
  color: #f0c489;
  font-size: 13px;
  line-height: 1.55;
}
a.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
