:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c1f26;
  --muted: #6b7280;
  --line: #e4e7ec;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --danger: #d33f3f;
  --warn-bg: #fff7e0;
  --warn-ink: #7a5300;
  --error-bg: #fdecec;
  --error-ink: #8a1f1f;
  --info-bg: #eaf1ff;
  --info-ink: #1e4db3;
  --todo-bg: #fff3e0;
  --todo-ink: #a04d00;
  --todo-line: #f0a43a;
  --ok-bg: #e7f6ec;
  --ok-ink: #1f6f3d;
  --ok-line: #6cc08b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }
.mt { margin-top: 12px; }
.mt-sm { margin: 10px 0 0; }
.m0 { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
small { font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
}
.brand { font-weight: 700; color: var(--text); font-size: 16px; }
.brand:hover { text-decoration: none; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 14px; }
.topnav form { margin: 0; display: flex; }

.page { max-width: 1120px; margin: 0 auto; padding: 24px 24px 96px; }
.page:has(.doc-layout) { max-width: 1440px; }
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 20px; }
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-items: start; margin-bottom: 20px; }
.build-card { margin: 0; min-width: 0; }
.build-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.build-card-head a { font-size: 13px; flex: none; }
.build-card input.card-name {
  border: 0;
  background: transparent;
  font-size: 16px;
  font-weight: 650;
  padding: 0;
  width: 100%;
  box-shadow: none;
}
.build-card input.card-name:focus { outline: none; border: 0; box-shadow: none; }
textarea.clip {
  height: 220px;
  max-height: 220px;
  overflow: auto;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.clip-hint { margin: 8px 0 0; }
.crumbs { display: flex; gap: 8px; color: var(--muted); font-size: 13px; margin-bottom: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 4px 0 18px; flex-wrap: wrap; }
.page-head .actions form:last-child { margin-left: 12px; }
.section-title { margin: 28px 0 12px; }
.version-tag {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  font-size: 13px; font-weight: 600; color: var(--info-ink); background: var(--info-bg);
  padding: 2px 8px; border-radius: 999px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card.narrow { max-width: 520px; }
.card h2 { margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { display: block; color: inherit; transition: border-color .15s, transform .15s; }
.tile:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.tile h2 { margin-bottom: 6px; }
.tile p { margin: 0; font-size: 13px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.empty { color: var(--muted); padding: 14px 0; }

input[type=text], input[type=number], input:not([type]), select, textarea {
  font: inherit; color: inherit;
  background: #fff; border: 1px solid #d5d9e0; border-radius: 8px;
  padding: 7px 10px; min-width: 0; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 111, 237, .35); outline-offset: 0; border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--muted); }
label.wide { width: 100%; }
label > input, label > select, label > textarea { color: var(--text); font-size: 15px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { flex: 1; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions .spacer { flex: 1; }
.actions.sticky {
  position: sticky; bottom: 0; margin: 12px -8px 0; padding: 12px 8px;
  background: linear-gradient(to bottom, rgba(246, 247, 249, 0), var(--bg) 30%);
}

button, .button {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  padding: 8px 14px; border-radius: 8px; line-height: 1.3; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .button:hover { filter: brightness(.95); text-decoration: none; }
button:disabled { opacity: .55; cursor: default; }
button.secondary, .button.secondary { background: var(--info-bg); color: var(--info-ink); border-color: transparent; }
button.ghost, .button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.danger, .button.danger { color: var(--danger); }
button.danger:not(.ghost) { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small { padding: 5px 10px; font-size: 13px; }

.notice { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; background: var(--info-bg); color: var(--info-ink); }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice.error { background: var(--error-bg); color: var(--error-ink); }
.notice ul { margin: 0; padding-left: 18px; }
.error-text { color: var(--danger); }

/* 登录与账户 */
.login-card { margin: 48px auto 0; }
.login-card h1 { margin-bottom: 6px; }
.login-card > p { margin: 0 0 16px; }
.passkey-block button { width: 100%; justify-content: center; padding: 11px 14px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; font-size: 13px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.list td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list td.right { text-align: right; }
table.list form { margin: 0; display: inline-flex; }

/* 模板结构折叠块 */
details.structure summary { cursor: pointer; font-weight: 600; }
.structure-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 14px; }
.structure-group h3 { margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font-size: 12.5px; }
.field-list { margin: 0; padding-left: 16px; font-size: 13.5px; }

/* 向导 */
.step h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.step-no {
  display: inline-flex; width: 24px; height: 24px; border-radius: 50%; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 700;
}
.sub-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; background: #fafbfc; }
.row { display: flex; gap: 8px; align-items: center; }
.row.head { margin-bottom: 10px; }
.row.head input { flex: 1; font-weight: 600; }
.row select { width: auto; min-width: 110px; }
.field-rows { display: flex; flex-direction: column; gap: 8px; }
.field-row { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.field-row .row input { flex: 1; }
.options-wrap { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.options-wrap textarea { font-size: 14px; }

/* 标签、徽标、进度 */
.tags { display: inline-flex; flex-wrap: wrap; gap: 6px; margin: 0; vertical-align: middle; }
.tag {
  display: inline-block; font-size: 12px; font-weight: 600; line-height: 1.4;
  padding: 1px 8px; border-radius: 999px; background: var(--info-bg); color: var(--info-ink);
}
.badge {
  display: inline-block; font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap;
  padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted);
}
.badge.todo, .progress.todo { background: var(--todo-bg); color: var(--todo-ink); }
.badge.ok, .progress.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.progress { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.todo-ink { color: var(--todo-ink); }
.arrow { color: var(--muted); margin: 0 4px; }

/* 角色面板：左右两列位置卡，中间角色卡，列表组横跨底部 */
.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 1.15fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.ring-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.span-all { grid-column: 1 / -1; }
.panel-grid > .card { margin-bottom: 0; }
@media (max-width: 900px) {
  .panel-grid { grid-template-columns: 1fr; }
  .panel-grid > .hero { order: -1; }
}

.hero { padding: 20px 22px; }
.hero-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.hero-name { font-size: 22px; margin-bottom: 6px; }
.stat-title {
  margin: 16px 0 6px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; letter-spacing: .04em; color: var(--muted); text-transform: uppercase;
}
.hero .stat-title:first-of-type { border-top: 0; padding-top: 6px; }
.notes { margin: 0; white-space: pre-wrap; font-size: 14px; line-height: 1.6; }

/* 通用属性置顶一整行，保存钉在行尾 */
.stats-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: nowrap; align-items: flex-start; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 14px; margin-bottom: 14px;
}
.stats-scroll {
  display: flex; flex-wrap: nowrap; gap: 16px 22px; align-items: flex-start;
  flex: 1; min-width: 0; overflow-x: auto;
}
.stat-cluster { flex: 0 0 auto; }
.stat-cluster.stat-name { min-width: 88px; font-size: 18px; font-weight: 700; padding-top: 14px; }
.stat-cluster h3 {
  cursor: pointer; margin: 0 0 4px; font-size: 12px; font-weight: 600;
  letter-spacing: .04em; color: var(--muted); text-transform: uppercase; white-space: nowrap;
}
.stats-bar .stat-cluster:not(.is-on) .edit-line:has(.tap-view > .muted) { display: none; }
.stat-cluster .edit-line {
  display: grid; grid-template-columns: max-content minmax(3em, auto); gap: 1px 8px;
  align-items: baseline; margin-bottom: 1px;
}
.stat-cluster .edit-label { font-size: 12px; white-space: nowrap; }
.stat-cluster .tap-view { max-width: 16em; overflow-wrap: anywhere; }
.save-cluster { flex: 0 0 auto; display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.save-cluster button { justify-content: center; }
.save-hint { font-size: 12px; color: var(--muted); text-align: center; }

/* 点击即编辑 */
.tap { min-height: 1.5em; }
.tap-view { cursor: text; border-radius: 6px; padding: 2px 4px; margin: 0 -4px; }
.tap-view:hover { background: rgba(47, 111, 237, .06); }
.tap:not(.is-on) .tap-edit { display: none; }
.tap.is-on .tap-view { display: none; }
.tap-notes .tap-view { min-height: 8em; }
.tap-notes textarea { min-height: 10em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.55; }

.slot {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px 12px; border-left-width: 3px; border-left-color: #9aa8bd;
}
.slot.unmet { border-left-color: var(--todo-line); }
.slot.blank { border-left-color: var(--line); border-style: dashed; box-shadow: none; }
.slot.edit { border-left-color: var(--accent); border-style: solid; }
.slot-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.slot-title { font-weight: 700; font-size: 14px; cursor: pointer; }
.slot:not(.is-on) .edit-line:has(.tap-view > .muted) { display: none; }
.slot-edit { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.slot-head:hover .slot-edit { color: var(--accent); }

.lines { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; font-size: 13.5px; }
.lines .line { display: contents; }
.lines dt { color: var(--muted); white-space: nowrap; }
.lines dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.lines .line.unmet dd { color: var(--todo-ink); }
.lines .line.unmet dd b { color: var(--todo-ink); font-weight: 700; }
.edit-line.unmet .tap-view { color: var(--todo-ink); }
.edit-line.unmet .tap-view b { font-weight: 700; }

/* 列表组与对比表 */
table.matrix th.row-name { color: var(--text); font-weight: 600; white-space: nowrap; width: 1%; }
table.matrix td.unmet { color: var(--todo-ink); font-weight: 600; }
.table-wrap { overflow-x: auto; max-width: 100%; padding: 8px 12px; -webkit-overflow-scrolling: touch; }
.roster-table th, .roster-table td { white-space: nowrap; }
.roster-table thead th:first-child, .roster-table th.row-name {
  position: sticky; left: 0; background: var(--card); z-index: 1;
  box-shadow: 6px 0 8px -6px rgba(20, 28, 45, .12);
}
.roster-table th.row-name .tags { margin-left: 6px; display: flex; flex-wrap: wrap; }

/* 阵容总览 */
.roster-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.view-toggle a { padding: 5px 12px; font-size: 13px; color: var(--muted); }
.view-toggle a.on { background: var(--accent); color: var(--accent-ink); }
.view-toggle a:hover { text-decoration: none; }
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; margin-bottom: 20px; }
.roster-card { padding: 16px 18px 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.roster-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.roster-head .tags { margin-left: 8px; }
.roster-name { font-size: 17px; font-weight: 700; color: var(--text); }
.chips-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 6px 12px; }
.chip-slot { display: grid; gap: 1px; font-size: 13px; padding: 4px 0 5px; border-bottom: 1px dashed var(--line); min-width: 0; }
.chip-name { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-text { min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
.chip-slot.unmet .chip-text { color: var(--todo-ink); font-weight: 600; }
.chip-slot.blank .chip-text { color: var(--muted); }
.roster-foot { display: flex; gap: 14px; font-size: 13px; margin-top: auto; padding-top: 4px; }

/* 字段竖排 */
.edit-lines { display: flex; flex-direction: column; gap: 8px; }
.edit-line { display: flex; flex-direction: column; gap: 3px; }
.edit-label { font-size: 12.5px; color: var(--muted); }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: center; }
.pair.stack { grid-template-columns: 1fr; }
.pair.stack .arrow { display: none; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 8px; padding-top: 2px; }
.checks-hint { width: 100%; font-size: 12px; color: var(--muted); }
.check { flex-direction: row; align-items: center; gap: 4px; color: var(--text); font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.check input { width: auto; margin: 0; }
.slot-table { display: flex; flex-direction: column; gap: 6px; overflow-x: auto; --cols: 110px 1fr; }
.slot-row { display: grid; grid-template-columns: var(--cols); gap: 10px; align-items: start; min-width: fit-content; }
.slot-cell > input, .slot-cell > select { max-width: 480px; }
.slot-row.header { color: var(--muted); font-size: 13px; padding: 0 0 2px; border-bottom: 1px solid var(--line); }
.slot-name { font-weight: 600; padding-top: 7px; }
.build-form .hero label.wide { margin-bottom: 4px; }
.build-form .hero .stat-title { margin-top: 14px; }

.doc-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 800px) { .doc-layout { grid-template-columns: 1fr; } }
.history { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.history h2 { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.history ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.history li a { display: block; padding: 4px 6px; border-radius: 6px; color: var(--text); font-size: 13px; }
.history li.on a { background: var(--info-bg); color: var(--info-ink); }
.history li a:hover { text-decoration: none; background: var(--bg); }
.doc-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .doc-grid { grid-template-columns: 1fr; } }
.doc-view { padding: 16px 20px; margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; margin: 0 0 12px; }
.legend span { font-weight: 600; }

/* 三色：骨架与手写黑色，快速填充青色，AI 紫色 */
.src-user, .src-template { color: var(--text); }
.src-fill { color: #0b7285; }
.src-ai { color: #5b4fcf; }
.sep { color: var(--muted); margin: 0 6px; }

.md { font-size: 14px; line-height: 1.6; color: var(--text); }
.md h1, .md h2, .md h3, .md p { margin: 0; color: var(--text); }
.md h1 { font-size: 22px; margin-bottom: 4px; }
.md h2 { font-size: 16px; margin-top: 14px; }
.md h3 { font-size: 14px; margin-top: 8px; }
.md .lbl { color: var(--text); }
.md-li { margin: 0; overflow-wrap: anywhere; }
.md-li::before { content: "• "; color: var(--muted); }
.md-li-1 { padding-left: 16px; }
.md-li-2 { padding-left: 32px; }
.md-li-3 { padding-left: 48px; }
.md-li-4 { padding-left: 64px; }
.md-blank { height: 8px; }
textarea[data-md] { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.55; }

.preset-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.preset-list li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.preset-list li a { font-weight: 600; }
.m0 { margin: 0; }

.note {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 4px 4px 10px;
  margin: 0 0 16px;
  min-height: 42vh;
}
.note input.note-title {
  border: 0;
  background: transparent;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -.02em;
  padding: 14px 16px 2px;
  width: 100%;
  box-shadow: none;
}
.note input.note-title:focus { outline: none; border: 0; box-shadow: none; }
.note-read h1,
.note .vditor-ir h1 { display: none; }
.page-head:not(:has(h1)) { justify-content: flex-end; }
.note-read { min-height: 42vh; padding: 6px 16px 28px; cursor: text; }
.note-load {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 36px;
  background: var(--card);
}
.load-track { width: min(220px, 70%); height: 3px; border-radius: 99px; background: var(--line); overflow: hidden; }
.load-bar { width: 40%; height: 100%; border-radius: 99px; background: var(--accent); animation: note-load .8s ease-in-out infinite; }
@keyframes note-load { from { transform: translateX(-120%); } to { transform: translateX(280%); } }
.note [data-fast-note] { flex: 1; min-height: 0; overflow: auto; width: 100%; }
.note .ProseMirror {
  outline: none;
  box-sizing: border-box;
  width: 100%;
  min-height: 100%;
  padding: 4px 16px 28px;
  font-size: 15px;
  line-height: 1.65;
}
.note .ProseMirror h1 { display: none; }
.note .ProseMirror h2 { font-size: 16px; margin: 14px 0 4px; }
.note .ProseMirror h3 { font-size: 14px; margin: 10px 0 2px; }
.note .ProseMirror p { margin: 4px 0; }
.note .ProseMirror ul,
.note .ProseMirror ol { margin: 2px 0; padding-left: 1.3em; }
.note .ProseMirror li { margin: 1px 0; }
.note .ProseMirror li p { margin: 0; }
.note-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.note:not(.is-editing):not(.is-ro) .note-write,
.note:not(.is-editing) .note-actions { display: none; }
.note-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; min-width: 0; }
.note.is-ro .note-write,
.note.is-opening .note-write {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 0;
}
.note.is-opening .note-read {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--card);
  overflow: auto;
}
.note.is-ro:not(.is-opening) .note-read { display: none; }
.note [data-note] { width: 100%; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.note .vditor,
.note .vditor-content,
.note .vditor-ir { width: 100% !important; max-width: none; min-width: 0; }
.note .vditor-ir pre.vditor-reset[contenteditable="false"] { opacity: 1; cursor: text; }
.note .vditor-ir .vditor-reset > h1:before,
.note .vditor-ir .vditor-reset > h2:before,
.note .vditor-ir .vditor-reset > h3:before,
.note .vditor-ir .vditor-reset > h4:before,
.note .vditor-ir .vditor-reset > h5:before,
.note .vditor-ir .vditor-reset > h6:before { content: none; display: none; }
textarea.note-source {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.note-actions { display: flex; align-items: center; gap: 10px; padding: 2px 12px 4px; }
.note .vditor { border: 0; }
.note .vditor-toolbar,
.note .vditor-counter { display: none; }
.note .vditor-ir,
.note .vditor-content { min-height: 42vh; }
.note .vditor-reset {
  font-family: inherit !important;
  font-size: 15px !important;
  line-height: 1.65 !important;
  padding: 2px 16px 24px !important;
  background: transparent !important;
}

dialog.modal {
  border: 0;
  padding: 0;
  width: min(720px, calc(100vw - 32px));
  max-height: 80vh;
  overflow: auto;
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(16, 24, 40, .2);
}
dialog.modal.compact { width: min(420px, calc(100vw - 32px)); }
dialog.modal .modal-form { display: flex; flex-direction: column; gap: 12px; padding: 0 16px 16px; }
dialog.modal::backdrop { background: rgba(16, 24, 40, .45); }
dialog.modal .note {
  min-height: 0;
  margin: 0;
  border: 0;
  box-shadow: none;
}
dialog.modal .vditor-content { max-height: 52vh; overflow: auto; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 0;
}
.preset-line { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 2px 0 18px; }
.quiet { margin: 8px 0 0; }
.history-foot { margin: 12px 0 0; font-size: 13px; }

/* 角色页锁在一屏里，正文和历史各自在容器内滚动 */
html:has(body.fit) { height: 100%; overflow: hidden; }
body.fit {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.fit .topbar { flex: none; }
body.fit .page {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding-bottom: 16px;
}
body.fit .page > * { flex: none; }
body.fit .doc-layout {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
}
body.fit .history {
  min-height: 0;
  overflow: auto;
}
body.fit .doc-main {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.fit .note {
  flex: 1;
  min-height: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.fit .note-title,
body.fit .note-actions,
body.fit .legend { flex: none; }
body.fit .note-body,
body.fit .note-read,
body.fit .note-write {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
body.fit .note .vditor {
  height: auto !important;
  min-height: 0 !important;
  border: 0;
}
body.fit .note .vditor-ir,
body.fit .note .vditor-content { min-height: 0 !important; }
@media (max-width: 800px) {
  body.fit .doc-layout { grid-template-rows: minmax(0, 30%) minmax(0, 1fr); }
}
