/* 依依控制台 · 样式
 * 一个文件、零构建。改这里不用重启进程，刷新页面就能看到。
 */

:root {
  --bg: #0e0f13;
  --panel: #16181f;
  --panel-2: #1b1e26;
  --panel-3: #0f1116;
  --line: #262a34;
  --line-soft: #1e222a;
  --text: #e8eaf0;
  --text-2: #b9bfcc;
  --muted: #8a92a3;
  --dim: #656d7d;
  --accent: #e0a0a8;
  --accent-dim: rgba(224, 160, 168, .14);
  --accent-2: #9ec9b4;
  --warn: #e5b567;
  --bad: #e07878;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .28), 0 10px 30px -18px rgba(0, 0, 0, .8);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.62 -apple-system, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  display: flex;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration-color: rgba(224, 160, 168, .35); }
a:hover { text-decoration-color: var(--accent); }
code, pre, .mono { font-family: var(--mono); }
code { font-size: .92em; background: #ffffff0a; padding: 1px 5px; border-radius: 5px; }
pre code { background: none; padding: 0; }
/* 长 URL、长 token 不能把窄屏顶出横向滚动 */
code, .desc, .kv dd { overflow-wrap: anywhere; }
::selection { background: var(--accent-dim); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2f3a; border-radius: 99px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #363c49; }

/* ---------------- 侧栏 ---------------- */

nav {
  width: 236px; flex: 0 0 236px;
  display: flex; flex-direction: column; gap: 18px;
  padding: 22px 14px 18px;
  border-right: 1px solid var(--line-soft);
  background:
    radial-gradient(130% 55% at 0% 0%, #191c24 0%, rgba(14, 15, 19, 0) 62%),
    #0b0c10;
}
nav .brand {
  font-size: 17px; letter-spacing: 3px; padding: 2px 10px 0; font-weight: 600;
}
nav .brand::before {
  content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 9px;
  border-radius: 50%; background: var(--accent); vertical-align: middle;
  box-shadow: 0 0 10px 1px rgba(224, 160, 168, .55);
}
nav .brand small {
  display: block; color: var(--dim); font-size: 10px; letter-spacing: 2.4px;
  margin: 6px 0 0 15px; font-weight: 400;
}
nav .nav-group { display: flex; flex-direction: column; gap: 2px; }
nav .nav-label {
  font-size: 10px; letter-spacing: .18em; color: var(--dim);
  padding: 0 11px 6px; text-transform: uppercase; font-weight: 500;
}
nav button {
  position: relative; display: flex; align-items: center; gap: 10px;
  text-align: left; background: none; border: 0; color: var(--muted);
  padding: 9px 11px; border-radius: 9px; cursor: pointer; font: inherit;
  font-size: 13.5px; transition: background .15s, color .15s;
}
nav button i {
  font-style: normal; width: 16px; text-align: center; font-size: 13px;
  opacity: .75; flex: 0 0 16px;
}
nav button:hover { background: #ffffff08; color: var(--text-2); }
nav button.on {
  color: #f1d5d9;
  background: linear-gradient(90deg, rgba(224, 160, 168, .16), rgba(224, 160, 168, .03));
  box-shadow: inset 0 0 0 1px rgba(224, 160, 168, .16);
}
nav button.on i { opacity: 1; }
nav button.on::before {
  content: ''; position: absolute; left: 0; top: 9px; bottom: 9px;
  width: 2px; border-radius: 2px; background: var(--accent);
}
nav .foot {
  margin-top: auto; font-size: 11px; color: #4f5666; padding: 12px 11px 0;
  line-height: 1.6; border-top: 1px solid var(--line-soft);
}

/* ---------------- 主区 ---------------- */

main { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 30px 70px; scroll-behavior: smooth; overscroll-behavior: contain; }

header.top {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: center; gap: 10px;
  max-width: 1080px; margin: 0 auto 22px;
  padding: 20px 0 14px;
  background: linear-gradient(180deg, var(--bg) 72%, rgba(14, 15, 19, 0));
  backdrop-filter: blur(6px);
}
header.top h1 { font-size: 19px; margin: 0; font-weight: 600; letter-spacing: .5px; }
header.top .desc { margin: 0; color: var(--dim); font-size: 12px; font-family: var(--mono); }
header.top .spacer { flex: 1; }

.pill {
  font-size: 11.5px; padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.pill.ok { color: var(--accent-2); border-color: #2c4a3d; background: #14211b; }
.pill.bad { color: var(--bad); border-color: #4a2c2c; background: #211616; }
.pill.warn { color: var(--warn); border-color: #4a3e2c; background: #211d14; }

section.page { display: none; max-width: 1080px; margin: 0 auto; }
section.page.on { display: block; animation: fade .22s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------- 卡片 ---------------- */

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(224px, 1fr)); }
.card {
  position: relative; background: linear-gradient(180deg, #171a21, #14161c);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; transition: border-color .15s, transform .15s;
}
.card:hover { border-color: #2f3542; }
.card h3 {
  margin: 0 0 10px; font-size: 11px; color: var(--dim); font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase;
}
.card .big { font-size: 25px; font-weight: 600; line-height: 1.25; letter-spacing: -.2px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 5px; }
.card.hint { border-color: #3a3038; background: linear-gradient(180deg, #1b1619, #171316); }
.card.hint b { color: var(--accent); }

/* ---------------- 面板 ---------------- */

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.panel > h2, .panel .section-head h2 {
  margin: 0 0 6px; font-size: 15.5px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.panel .desc { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; line-height: 1.7; }
.panel .desc:last-child { margin-bottom: 0; }
.panel.hint { border-color: #3a3038; background: linear-gradient(180deg, #1a1518, #161316); }
.panel > h3 { font-size: 13px; margin: 20px 0 6px; color: var(--text-2); }

/* 分段：一个面板里放几块不同的设置 */
.section + .section {
  margin-top: 26px; padding-top: 26px; border-top: 1px dashed var(--line-soft);
}
.section-head { margin-bottom: 16px; }
.section-head h2 { margin: 0 0 6px; font-size: 14.5px; font-weight: 600; }
.section-head .desc { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.7; }

/* ---------------- 表单 ---------------- */

.form-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.form-grid + .form-grid, .form-grid + .check-grid, .check-grid + .form-grid { margin-top: 16px; }
.form-grid.col-2 { grid-template-columns: 1fr 1fr; }
.form-grid.col-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid .span-2 { grid-column: span 2; }

label.field, .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
label.field > span, .field > span {
  font-size: 12px; color: var(--text-2); font-weight: 500;
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 4px 8px; flex-wrap: wrap;
}
label.field > span small, .field > span small {
  color: var(--dim); font-weight: 400; font-size: 11px; text-align: right;
}
label.field .hint, .field .hint { margin: 0; }

input[type=text], input[type=password], input[type=number], input[type=search],
input[type=time], input[type=datetime-local], textarea, select {
  width: 100%; background: var(--panel-3); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; font-size: 13.5px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
  min-width: 0;
}
input[type=text]:hover, input[type=password]:hover, input[type=number]:hover,
input[type=search]:hover, input[type=time]:hover, input[type=datetime-local]:hover,
textarea:hover, select:hover { border-color: #2f3542; }
input:focus, textarea:focus, select:focus {
  border-color: #6d5b62; background: #0c0e12;
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder, textarea::placeholder { color: #4e5666; }
textarea { resize: vertical; min-height: 74px; line-height: 1.62; }
textarea.mono { font-family: var(--mono); font-size: 12.5px; }
select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, #6a7285 50%), linear-gradient(135deg, #6a7285 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px;
  background: none; border: 0; padding: 0; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 99px; background: linear-gradient(90deg, #3a3037, #22262e);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; margin-top: -5.5px;
  border-radius: 50%; background: var(--accent); border: 0;
  box-shadow: 0 0 0 3px rgba(224, 160, 168, .16);
}
.mood-value {
  display: inline-block; min-width: 18px; text-align: center; color: var(--accent);
  font-family: var(--mono); font-size: 12px; background: var(--accent-dim);
  border-radius: 5px; padding: 0 5px;
}

/* 开关：一行一块，点整行都能切换 */
.check-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
.check-grid.col-2 { grid-template-columns: 1fr 1fr; }
label.check {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  font-size: 13px; color: var(--text-2); line-height: 1.55;
  padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--panel-3); transition: border-color .15s, background .15s;
}
label.check:hover { border-color: #2f3542; }
label.check:has(input:checked) { border-color: #4d3a40; background: #17131a; color: var(--text); }
label.check input {
  width: 15px; height: 15px; margin: 2px 0 0; flex: 0 0 15px;
  accent-color: var(--accent); cursor: pointer;
}
label.check small { display: block; color: var(--dim); font-size: 11.5px; margin-top: 3px; }
label.check.oneline { align-items: center; }
label.check.oneline input { margin-top: 0; }
.check-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.check-inline label.check { padding: 6px 10px; }

/* ---------------- 按钮 ---------------- */

button.act {
  background: linear-gradient(180deg, #e6abb3, var(--accent)); color: #231518;
  border: 0; border-radius: var(--radius-sm);
  padding: 10px 19px; font-size: 13.5px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: filter .15s, transform .06s;
  box-shadow: 0 1px 0 #ffffff2e inset, 0 6px 16px -10px rgba(224, 160, 168, .9);
}
button.act:hover { filter: brightness(1.07); }
button.act:active { transform: translateY(1px); }
button.act:disabled { opacity: .5; cursor: default; filter: grayscale(.25); }
button.ghost {
  background: #ffffff05; color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 16px; font-size: 13px;
  font-family: inherit; cursor: pointer; transition: border-color .15s, background .15s;
}
button.ghost:hover { border-color: #3d4350; background: #ffffff0a; }
button.ghost:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid rgba(224, 160, 168, .5); outline-offset: 1px;
}

.actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.msg { font-size: 12.5px; color: var(--muted); }
.msg.good { color: var(--accent-2); }
.msg.bad { color: var(--bad); }
.msg.warn { color: var(--warn); }

/* 保存条：每个设置表单底部，滚到哪儿都能看见存没存上 */
.save-bar {
  position: sticky; bottom: -1px; z-index: 3;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 24px -22px -20px; padding: 14px 22px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  background: linear-gradient(180deg, rgba(22, 24, 31, .55), rgba(22, 24, 31, .97));
  backdrop-filter: blur(8px);
}
.save-bar .msg { margin-left: 2px; }

/* ---------------- 线路 ---------------- */

.routes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
/* 每行的宽度分配按 data-route 来（routeRow() 只写 data-route，不写 inline 宽度），
   这样窄屏才能整体收成一条竖排。 */
.route-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--panel-3);
}
.route-row > input { flex: 1 1 140px; min-width: 0; font-size: 13px; padding: 8px 10px; }
.route-row > input[data-route="rate"] { flex: 0 1 84px; }
.route-row > select { flex: 0 0 auto; width: auto; min-width: 84px; font-size: 13px; padding: 8px 10px; }
.route-row > button {
  flex: 0 0 auto; align-self: center; padding: 6px 9px; font-size: 12px;
  line-height: 1; min-width: 30px;
}
.route-row > button[data-move="up"] { margin-left: auto; }
.route-row > button[data-remove] { color: var(--bad); }
.route-row > button[data-remove]:hover { border-color: #5a3232; background: #211616; }
.route-row:focus-within { border-color: #3a4150; }

/* ---------------- 代码块 / 表格 ---------------- */

pre.block {
  background: #0a0b0e; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px; white-space: pre-wrap; word-break: break-word;
  font-size: 12.5px; line-height: 1.72; margin: 0; color: #cdd2dd;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th {
  color: var(--dim); font-weight: 500; font-size: 11px;
  letter-spacing: .08em; text-transform: uppercase;
}
tbody tr:hover { background: #ffffff04; }
tbody tr:last-child td { border-bottom: 0; }
td.time { color: var(--muted); font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }

/* 最近发出的消息：桌面上是三列表，窄屏下面在 @media 里折成一张张卡片 */
table.sends { table-layout: fixed; }
table.sends th:nth-child(1), table.sends td:nth-child(1) { width: 84px; }
table.sends th:nth-child(2), table.sends td:nth-child(2) { width: 30%; }
table.sends td { overflow-wrap: anywhere; }
table.sends .bubble { display: inline; }
table.sends td.msg { color: var(--muted); text-align: center; padding: 16px 8px; }
.bubble { display: inline-block; background: #232028; border-radius: 8px; padding: 2px 8px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 14px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.au { color: var(--dim); }

ul.problems { margin: 10px 0 0; padding-left: 18px; color: var(--warn); font-size: 13px; }
ul.problems li { margin: 3px 0; }

/* ---------------- 预设 ---------------- */

.presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.preset {
  text-align: left; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 13px 15px; cursor: pointer; color: var(--text);
  font-size: 14px; font-weight: 600; font-family: inherit;
  transition: border-color .15s, background .15s, transform .12s;
}
.preset:hover { border-color: #4a4450; background: #202127; transform: translateY(-1px); }
.preset span { display: block; margin-top: 6px; font-size: 12px; font-weight: 400; color: var(--muted); line-height: 1.6; }

/* ---------------- 列表 ---------------- */

.memories { list-style: none; margin: 0; padding: 0; }
.memories li {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
  padding: 10px 2px; border-bottom: 1px solid var(--line-soft);
  font-size: 13px; line-height: 1.6;
}
.memories li:last-child { border-bottom: 0; }
.memories li > span, .memories li > div { flex: 1 1 240px; min-width: 0; }
.memories time { color: var(--dim); font-size: 11.5px; white-space: nowrap; flex: 0 0 92px; font-family: var(--mono); }
.memories .empty { display: block; color: var(--dim); font-size: 13px; padding: 12px 2px; border: 0; }
.memories button { font-size: 12px; padding: 4px 10px; }
.memories .row-actions { display: flex; gap: 6px; white-space: nowrap; flex: 0 0 auto; margin-left: auto; }
.memories input[type=text] { padding: 6px 9px; font-size: 13px; }
/* 她的日记与留话：一条一段，别让长句挤成一行看不完。 */
#diary-list li, #memo-list li { display: block; }
#diary-list li b, #memo-list li b { display: block; color: var(--dim); font-weight: 500; font-size: 11.5px; font-family: var(--mono); margin-bottom: 3px; }
#diary-list .memo-line, #memo-list .memo-line { display: block; white-space: pre-wrap; }
#person-facts li { display: block; }
#person-facts li p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
#doctor-list li { display: block; }
#doctor-list li strong { font-weight: 600; }

.memory-add { display: flex; gap: 10px; align-items: flex-end; margin: 10px 0 6px; }
.memory-add label.field { flex: 1; margin-bottom: 0; }
.hint { color: var(--dim); font-size: 12px; font-weight: 400; }

/* 表达学习里的「查看原话来源」折叠 */
.memories details { flex: 1 1 100%; margin-top: 6px; }
.memories summary {
  cursor: pointer; color: var(--dim); font-size: 12px; list-style: none;
  padding: 2px 0; user-select: none;
}
.memories summary::-webkit-details-marker { display: none; }
.memories summary::before { content: '▸ '; }
.memories details[open] summary::before { content: '▾ '; }
.memories summary:hover { color: var(--text-2); }
.memories details p {
  margin: 4px 0 0 14px; color: var(--muted); font-size: 12px;
  font-family: var(--mono); line-height: 1.6; word-break: break-word;
}

/* 体检：✗ 红、⚠ 黄，建议和故障一眼分开 */
#doctor-count.good { color: var(--accent-2); }
#doctor-count.warn { color: var(--warn); }
#doctor-count.bad { color: var(--bad); }
#doctor-list li.warn strong { color: var(--warn); }
#doctor-list li.bad strong { color: var(--bad); }

/* ---------------- 日志 ---------------- */

.log-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.log-tools select { width: auto; min-width: 120px; padding: 7px 30px 7px 10px; font-size: 13px; }
.log-tools input[type=search] { flex: 1 1 180px; min-width: 130px; padding: 7px 10px; font-size: 13px; }
.log-tools button { padding: 7px 14px; font-size: 12.5px; }

.log {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
  background: #0a0b0e; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; height: min(58vh, 520px); overflow-y: auto;
}
.log div { white-space: pre-wrap; word-break: break-word; }
.log .t { color: #565d6d; }
.log .info { color: #c7cbd6; }
.log .warn { color: var(--warn); }
.log .error { color: var(--bad); }

/* 口令门在 app.js 里是 createElement + inline style 拼出来的（position:fixed 那一坨），
   这里只管把卡片本身收进屏幕：320px 的窄屏上固定 340px 会顶出边框。 */
#token-gate { padding: 20px; }
#token-gate .panel { max-width: 100%; margin-bottom: 0; }
#token-gate .panel h2 { margin-top: 0; }
#token-gate input { width: 100%; margin-top: 12px; }
#token-gate button.act { width: 100%; }

/* ---------------- 窄屏 ---------------- */

@media (max-width: 1080px) {
  .form-grid.col-3 { grid-template-columns: 1fr 1fr; }
}

/* 平板竖屏：侧栏收窄一点，正文别被挤成一条 */
@media (max-width: 900px) {
  nav { width: 196px; flex-basis: 196px; padding-left: 10px; padding-right: 10px; }
  main { padding-right: 22px; padding-left: 22px; }
}

@media (max-width: 720px) {
  /* 整页只有 main 一个滚动条：body 定死高度，nav 是它的兄弟，
     所以 nav 天然一直留在顶上，不用 sticky，也不会跟顶栏打架。 */
  body { flex-direction: column; overflow: hidden; }

  /* 导航压成一条横向滑动的标签带：九个标签换行要吃掉三行高度，
     而设置页本来就很长。右缘渐隐是为了让人看出「后面还有」。 */
  nav {
    width: auto; flex: 0 0 auto;
    flex-direction: row; align-items: center; flex-wrap: nowrap;
    gap: 2px; padding: 7px 8px;
    padding-top: calc(7px + env(safe-area-inset-top));
    border-right: 0; border-bottom: 1px solid var(--line);
    background: #0c0d11; z-index: 7;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent 100%);
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent 100%);
  }
  nav::-webkit-scrollbar { display: none; }
  nav .brand, nav .foot, nav .nav-label { display: none; }
  /* 分组解散，九个标签排成一条 */
  nav .nav-group { display: contents; }
  nav button {
    flex: 0 0 auto; white-space: nowrap;
    padding: 8px 13px; font-size: 13px; border-radius: 999px;
    background: #ffffff06;
  }
  nav button i { display: none; }
  nav button.on::before { display: none; }
  nav button.on {
    color: #f4dade;
    background: linear-gradient(90deg, rgba(224, 160, 168, .26), rgba(224, 160, 168, .1));
    box-shadow: inset 0 0 0 1px rgba(224, 160, 168, .22);
  }

  main { padding: 0 12px calc(40px + env(safe-area-inset-bottom)); }
  header.top { position: static; padding: 12px 0 8px; margin-bottom: 12px; flex-wrap: wrap; gap: 6px; }
  header.top h1 { font-size: 16px; }
  header.top .desc { display: none; }

  .panel { padding: 14px; border-radius: 12px; margin-bottom: 12px; }
  .panel > h2, .panel .section-head h2 { font-size: 14px; }
  .panel .desc, .section-head .desc { font-size: 12px; line-height: 1.65; margin-bottom: 12px; }
  .section + .section { margin-top: 20px; padding-top: 20px; }
  .section-head { margin-bottom: 12px; }

  /* 概览那六张数字卡：手机上排两列，一列排下来要滑四屏才见到正文。
     只收窄 .grid 里的卡——连接页那个「协议端那边这样填」的小卡片标题不是数字标题，
     跟着缩到 10px 就看不见了。 */
  .grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .grid .card { padding: 12px 13px; border-radius: 12px; }
  .grid .card h3 { font-size: 10px; margin-bottom: 6px; letter-spacing: .08em; }
  .grid .card .big { font-size: 19px; }
  .grid .card .sub { font-size: 11px; margin-top: 3px; }
  pre.block { padding: 11px 12px; font-size: 12px; }

  /* 保存条在手机上不再浮在表单上方：它是表单的最后一行，跟着内容滚走 */
  .save-bar {
    position: static;
    flex-direction: column; align-items: stretch; gap: 8px;
    margin: 18px -14px -14px; padding: 12px 14px;
    border-radius: 0 0 12px 12px;
  }
  .save-bar button.act { width: 100%; }
  .save-bar .msg { margin: 0; text-align: center; }
  .form-grid.col-2, .form-grid.col-3, .form-grid .span-2 { grid-template-columns: 1fr; grid-column: auto; }
  .check-grid.col-2 { grid-template-columns: 1fr; }
  .route-row { gap: 8px; }
  .route-row > input { flex: 1 1 100%; }
  .route-row > button[data-move="up"] { margin-left: 0; }
  .memories time { flex: 0 0 100%; }
  .log { height: 60vh; }
  .actions .msg { flex: 1 1 100%; }

  /* 「亲手记一条」这种输入框 + 按钮并排的，窄屏改成上下两行，按钮撑满 */
  .memory-add { flex-direction: column; align-items: stretch; gap: 8px; }
  .memory-add button { width: 100%; }
  /* 日志工具栏那几个按钮在窄屏换行就行，别硬挤成一条 */
  .log-tools select, .log-tools input[type=search] { flex: 1 1 100%; min-width: 0; width: 100%; }
  .log-tools button { flex: 1 1 0; }
  .log-tools .msg { flex: 1 1 100%; }
  /* 预设卡片窄屏一行一个，别留半格 */
  .presets { grid-template-columns: 1fr; }

  /* 输入框字号别低于 16px：低于这个数，Android WebView 一点就自动放大整个页面 */
  input[type=text], input[type=password], input[type=number], input[type=search],
  input[type=time], input[type=datetime-local], textarea, select { font-size: 16px; }
  /* 下拉和输入在手指下稍微高一点好点 */
  input[type=text], input[type=password], input[type=number], input[type=search],
  input[type=time], input[type=datetime-local], select { padding: 10px 12px; }
  button.act, button.ghost { padding: 11px 18px; }
  .save-bar button.act { flex: 1 1 auto; }

  /* 最近发出的消息：三列表塞不进手机，改成一行一条 */
  table.sends, table.sends tbody, table.sends tr, table.sends td { display: block; width: auto; }
  table.sends thead { display: none; }
  table.sends tbody tr {
    padding: 10px 0; border-bottom: 1px solid var(--line-soft);
  }
  table.sends tbody tr:last-child { border-bottom: 0; }
  table.sends td {
    border: 0; padding: 0; white-space: normal; overflow-wrap: anywhere;
  }
  /* 桌面上那两列宽度（84px / 30%）选择器比上面这条更具体，会盖掉 width:auto，
     窄屏下得点名改回来，否则时间和会话两行被挤成一条细柱。 */
  table.sends td:nth-child(1), table.sends td:nth-child(2) { width: auto; }
  table.sends td.time { font-size: 11px; margin-bottom: 4px; }
  table.sends td:nth-child(2) {
    color: var(--dim); font-size: 11.5px; font-family: var(--mono);
    margin-bottom: 6px;
  }
  table.sends td:nth-child(3) { font-size: 13px; line-height: 1.6; }
  table.sends .bubble { display: inline; background: none; padding: 0; }
  table.sends td.msg { text-align: left; padding: 4px 0; }

  /* 面板里剩下的 <dl class="kv"> 在窄屏把标签压窄一点 */
  .kv { grid-template-columns: 74px 1fr; gap: 8px 10px; font-size: 12.5px; }
}

/* ---------------- 能力 ---------------- */

/* 一张能力卡就是一行 .check：这里只补 .check 自己处理不了的三件事——
   组与组之间的距离、组标题的样式、锁定项（input:disabled）的灰。 */
.ability-group + .ability-group { margin-top: 22px; }
.ability-group-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 10px; font-size: 12.5px; font-weight: 600;
  color: var(--text-2); letter-spacing: .06em;
}
.ability-group-title::before {
  content: ''; width: 3px; height: 12px; border-radius: 2px;
  background: var(--accent); opacity: .7;
}
.ability-actions { margin-top: 18px; }
/* 标题吃掉整张卡剩下的宽度，描述和说明跟在下面；点哪儿都能拨。 */
label.check.ability > span {
  flex: 1 1 auto; min-width: 0;
  color: var(--text); font-weight: 600;
}
label.check.ability > span small { font-weight: 400; }
label.check.ability:has(input:disabled) { opacity: .68; cursor: default; }
label.check.ability:has(input:disabled):hover { border-color: var(--line-soft); }
label.check.ability input:disabled { cursor: default; }
/* 锁定的原因：跟描述同一行排版，但用警告色，别让人以为是普通说明 */
label.check.ability small.ability-note { color: var(--warn); }
label.check.ability small.ability-note::before { content: '· '; }
