:root {
  --bg: #f5f6f8;
  --panel: #fff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e3e6eb;
  --accent: #2f6fde;
  --accent-ink: #fff;
  --ok: #16794a;
  --err: #b42318;
  --warn: #b54708;
  --sans: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 var(--sans);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, .btn, input, select, textarea {
  font: inherit;
  color: var(--ink);
}
input, select, textarea {
  padding: 6px 8px;
  border: 1px solid #cfd4dc;
  border-radius: 6px;
  background: #fff;
}
button, .btn {
  appearance: none;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid #cfd4dc;
  background: #fff;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
}
button:hover, .btn:hover { border-color: #a8a29e; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.active { background: #2d3546; color: #fff; border-color: transparent; }
h1 { font-size: 20px; margin: 0 0 16px; font-weight: 600; }
.mute, .sub { color: var(--muted); }
.sub { margin: 0 0 12px; font-size: 13px; }
.err-text { color: var(--err); }

.top {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  padding-top: var(--safe-t);
  height: calc(52px + var(--safe-t));
  background: #1d2330;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.top .brand { color: #fff; font-weight: 600; white-space: nowrap; text-decoration: none; }
.top .brand:hover { color: #fff; text-decoration: none; }
.top .brand-short { display: none; }
.nav-menu { display: flex; gap: 4px; align-items: center; }
.nav-menu a {
  color: #c9d1e0; padding: 6px 10px; border-radius: 6px; text-decoration: none; white-space: nowrap;
}
.nav-menu a.on, .nav-menu a:hover { color: #fff; background: #2d3546; text-decoration: none; }
.tablewrap { overflow-x: auto; }
.cos { width: 100%; border-collapse: collapse; }
.cos th, .cos td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.cos th { background: #f0f2f5; font-weight: 600; white-space: nowrap; }
.cos td.act { text-align: right; white-space: nowrap; }
.cos td.act button { margin-left: 6px; }
.top .ver {
  font: 600 12px/1.4 var(--mono);
  color: #c9d1e0;
  padding: 2px 8px;
  border: 1px solid #3a4558;
  border-radius: 999px;
  white-space: nowrap;
}
.top .me { display: flex; gap: 12px; align-items: center; margin-left: auto; color: #c9d1e0; white-space: nowrap; }
.top .me a, .top .me button {
  color: #c9d1e0;
  background: none;
  border: none;
  padding: 6px 0;
  border-radius: 0;
  cursor: pointer;
  font: inherit;
}
.top .me a:hover, .top .me button:hover { color: #fff; text-decoration: none; }
.search { position: relative; margin-bottom: 14px; }
.search input { width: 100%; padding: 8px 10px; outline: none; }
.search input:focus { border-color: var(--accent); }
.main { max-width: 1280px; margin: 0 auto; padding: 20px; }
main.narrow { max-width: 420px; padding-top: 10vh; }
.dash { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.agent-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 14px; }
.agent-row a.btn { text-decoration: none; white-space: nowrap; }
.guide { padding: 0 14px 14px; }
.guide-p { margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.guide h2 { margin: 14px 0 6px; font-size: 15px; }
#agentGuide h2 { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.cmd {
  width: 100%; margin: 0 0 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px;
  background: #f0f2f5; color: var(--ink); font: 12px/1.55 var(--mono); white-space: pre-wrap; word-break: break-all;
}
.guide table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0 10px; }
.guide th, .guide td { border-top: 1px solid var(--line); padding: 6px 8px 6px 0; text-align: left; vertical-align: top; }
.guide th { color: var(--muted); font-weight: 700; }
.guide input, .guide select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; max-width: 100%; }
.guide .setup { display: flex; flex-direction: column; gap: 8px; }
.company { border-top: 1px solid var(--line); }
.company .newbar { padding: 0 14px 10px; }
.wizard { padding: 16px; }
.pips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.pip { padding: 4px 10px; border-radius: 999px; background: #eef1f5; color: var(--muted); font-size: 12px; }
.pip.on { background: var(--accent); color: #fff; }
.pip.done { background: #e7f6ee; color: var(--ok); }
.wizard h2 { margin: 0 0 8px; font-size: 18px; }
.wizard .fields { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.wizard label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.wizard input, .wizard select { max-width: 100%; }
.wizard .choices { display: flex; flex-direction: column; gap: 8px; }
.wizard .choices label { flex-direction: row; align-items: center; color: var(--ink); }
.wizard-nav { display: flex; gap: 8px; margin-top: 16px; }
.wizard table { width: 100%; border-collapse: collapse; }
.wizard th, .wizard td { border-top: 1px solid var(--line); padding: 8px 8px 8px 0; text-align: left; vertical-align: middle; }
.wizard th { color: var(--muted); font-size: 12px; font-weight: 600; }
.card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 16px; }
.card-head, .panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600; background: #f0f2f5;
}
.card-head .count { color: var(--muted); font-weight: 600; }
.spacer { flex: 1; }
.more { padding: 3px 8px; }
.none, .empty, .error { padding: 16px; color: var(--muted); }
.error { color: var(--err); }
.item, .row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  padding: 10px 14px; border-top: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.item:hover, a.row:hover { background: #f7f8fa; }
.item .t, .row .name { font-weight: 650; }
.item .p, .meta { color: var(--muted); font-size: 12px; }
.item .r { color: var(--muted); font-size: 12px; text-align: right; }
.item.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.tag { display: inline-block; padding: 0 8px; border-radius: 10px; font-size: 12px; background: #eef1f5; color: var(--muted); }
.tag.dirty { background: #fef4e6; color: var(--warn); }
.tag.saved, .tag.ok { background: #e7f6ee; color: var(--ok); }
.people { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 3px 8px; font-size: 12px; font-weight: 650;
}
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, #78716c); }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.live.off { background: #d6d3d1; }
.crumb { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; color: var(--muted); font-family: var(--mono); font-size: 13px; }
.crumb a { text-decoration: none; }
.tools { display: flex; gap: 8px; margin: 8px 0; }
.newbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.newbar input { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 180px; }
.msg { color: var(--err); font-size: 13px; }
.badge { display: inline-block; min-width: 36px; margin-right: 8px; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: 700; color: #fff; text-align: center; }
.badge.dir { background: var(--accent); }
.badge.md { background: #44403c; }
.badge.file { background: #a8a29e; }
.row.head { color: var(--muted); font-size: 12px; font-weight: 700; }
.row { grid-template-columns: 1fr 90px 160px; }
.mark { background: #fef3c7; }

body.login-page {
  min-height: 100vh;
  background: #1d2330 url("/login-bg.jpg") center / cover no-repeat;
}
.login-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr minmax(300px, 400px);
  gap: 48px;
  align-items: center;
  width: min(1040px, calc(100% - 64px));
  margin: 0 auto;
  padding: 48px 0;
}
.login-intro {
  color: #f8fafc;
  max-width: 420px;
  padding: 8px 4px;
  text-shadow: 0 1px 2px rgba(15, 23, 42, .45);
}
.login-mark { margin: 0 0 14px; font-size: 64px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.login-intro h2 { margin: 0 0 6px; font-size: 32px; font-weight: 600; line-height: 1.25; }
.login-en { margin: 0 0 18px; font-size: 16px; font-weight: 500; letter-spacing: 0.04em; line-height: 1.4; color: rgba(248, 250, 252, .82); }
.login-note { margin: 0; font-size: 20px; font-weight: 500; line-height: 1.5; }
.login-box {
  background: #fff;
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 12px;
  padding: 32px 28px 28px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .28);
}
.login-box h1 { margin: 0 0 20px; font-size: 20px; text-align: left; }
.login-box form { display: flex; flex-direction: column; }
.login-box label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}
.login-box input { width: 100%; height: 42px; margin: 0; padding: 0 12px; }
.login-box .err-text { margin: -4px 0 12px; }
.login-box .err-text:empty { display: none; }
.login-box button { width: 100%; height: 42px; margin-top: 4px; }
@media (max-width: 800px) {
  .login-layout { grid-template-columns: 1fr; width: min(400px, calc(100% - 32px)); padding: 32px 0; }
  .login-intro { display: none; }
}

.tabs {
  display: flex; gap: 2px; align-items: flex-end; overflow-x: auto;
  padding: 6px 8px 0; padding-top: calc(6px + var(--safe-t));
  background: #1d2330; border-bottom: 1px solid #3a4558;
}
.tab {
  display: flex; align-items: center; gap: 6px; max-width: 220px; min-width: 96px;
  padding: 7px 8px 7px 10px; border-radius: 8px 8px 0 0; color: #c9d1e0; cursor: pointer;
}
.tab .x { color: #c9d1e0; }
.tab.on { background: var(--panel); color: var(--ink); font-weight: 600; }
.tab .nm { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tab .st { width: 8px; height: 8px; border-radius: 50%; }
.tab .st.dirty { background: var(--warn); }
.tab .st.ai { background: var(--ok); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.tab .x { border: 0; background: transparent; color: var(--muted); padding: 0 4px; font-size: 16px; }
.frames { position: relative; height: calc(100vh - 42px); }
.frames iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: none; background: var(--bg); }
.frames iframe.on { display: block; }

.editor-top {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  height: auto; min-height: 52px;
  padding: 8px 12px; padding-top: calc(8px + var(--safe-t));
  background: #fff; color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.editor-top button, .editor-top .btn { color: var(--ink); background: #fff; border: 1px solid #cfd4dc; padding: 6px 14px; border-radius: 6px; }
.editor-top button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.editor-top button.active { background: #2d3546; color: #fff; border-color: transparent; }
.editor-top .path { flex: 1 1 180px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.editor-top .path strong { color: var(--ink); }
.status { font-size: 12px; color: var(--muted); min-width: 6em; text-align: right; }
.status.dirty { color: var(--warn); }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.layout { display: flex; min-height: calc(100vh - 52px); }
.nav {
  flex: 0 0 260px; display: none; flex-direction: column;
  border-right: 1px solid var(--line); background: var(--panel); min-height: 0;
}
.layout.nav-open .nav { display: flex; }
.nav-head, .nav-filter-wrap { padding: 8px 10px; }
.nav-head { display: flex; align-items: center; gap: 6px; font-weight: 700; border-bottom: 1px solid var(--line); }
.nav-head span { flex: 1; }
.nav-filter { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.nav-legend { padding: 0 12px 6px; color: var(--muted); font-size: 12px; }
.nav-tree { overflow: auto; padding: 4px 6px 20px; font-size: 13px; }
.nav-row {
  display: flex; align-items: center; gap: 4px; padding: 3px 6px;
  padding-left: calc(6px + var(--d, 0) * 14px);
  border-radius: 6px; color: inherit; text-decoration: none; cursor: pointer;
}
.nav-row:hover { background: #f5f5f4; }
.nav-row.cur { background: var(--accent); color: var(--accent-ink); }
.nav-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd { padding: 0 4px; border-radius: 6px; color: #fff; font-size: 10px; font-style: normal; }
.bd.new { background: var(--ok); }
.bd.mod { background: #d97706; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(28,25,23,.35); z-index: 30; }
.wrap { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr; min-height: calc(100vh - 52px); }
.wrap.split { grid-template-columns: 1fr 1fr; }
.wrap.edit-only .pane.preview, .wrap:not(.split):not(.edit-only) .pane.edit { display: none; }
.pane { min-width: 0; overflow: auto; }
.pane.edit { background: var(--panel); border-right: 1px solid var(--line); }
.ed-box { position: relative; min-height: 100%; }
.ed-text, .ed-mirror {
  margin: 0; padding: 16px 16px 48px calc(var(--ln-w, 3ch) + 22px);
  font-family: var(--mono); font-size: 14px; line-height: 1.55;
  tab-size: 4; white-space: pre-wrap; overflow-wrap: anywhere;
}
.ed-text {
  position: relative; display: block; width: 100%; border: 0; resize: none; overflow: hidden;
  background: transparent; color: var(--ink); caret-color: var(--ink); outline: none;
}
.ed-mirror { position: absolute; inset: 0; color: transparent; pointer-events: none; }
.ed-mirror .ln { position: relative; }
.ed-mirror .ln::before {
  content: attr(data-n); position: absolute; right: calc(100% + 10px); width: var(--ln-w, 3ch);
  text-align: right; color: #a8a29e;
}
.ed-mirror .ln.mk { background: var(--mk); box-shadow: inset 3px 0 0 var(--c); }
.rc { border-left: 2px solid var(--c); margin-left: -1px; }
.rc b {
  position: absolute; transform: translateY(-1.1em); background: var(--c); color: #fff;
  font: 600 11px/1.4 var(--sans); padding: 0 4px; border-radius: 4px; white-space: nowrap;
}
.rsel { background: var(--sel); }
.preview-inner { padding: 8px 22px 48px; }
.markdown-body { font-size: 16px; line-height: 1.65; }
.markdown-body pre { background: #f5f5f4; padding: 12px; overflow: auto; border-radius: 8px; }
.markdown-body code { font-family: var(--mono); font-size: .92em; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { line-height: 1.25; }
.hist {
  position: fixed; inset: 0; z-index: 40; background: rgba(28,25,23,.45);
  display: flex; align-items: stretch; justify-content: center; padding: 24px;
}
.hist-box { background: var(--panel); width: min(1100px, 100%); border-radius: 12px; display: flex; flex-direction: column; min-height: 0; }
.hist-head, .hist-sum { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.hist-head select { max-width: 280px; }
.hist-body { display: grid; grid-template-columns: 280px 1fr; min-height: 0; flex: 1; }
.hist-list { overflow: auto; border-right: 1px solid var(--line); }
.hv { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 8px 10px; }
.hv.on { background: #eef4ff; }
.hv.base { box-shadow: inset 3px 0 0 var(--accent); }
.hv-top { display: flex; gap: 6px; align-items: center; font-weight: 700; }
.hv time, .hv-by, .hv-au { color: var(--muted); font-size: 12px; font-weight: 500; }
.note { margin-left: auto; font-size: 11px; color: var(--accent); }
.hist-view { overflow: auto; font-family: var(--mono); font-size: 13px; line-height: 1.45; padding: 8px 0 24px; }
.dl { display: grid; grid-template-columns: var(--nw, 4ch) var(--nw, 4ch) 1.2em 1fr; gap: 8px; padding: 0 12px; white-space: pre-wrap; }
.dl.del { background: #fef2f2; }
.dl.add { background: #f0fdf4; }
.dl .no, .dl .sg { color: var(--muted); }
.dl del { background: #fecaca; text-decoration: none; }
.dl ins { background: #bbf7d0; text-decoration: none; }
.n-add { color: var(--ok); font-weight: 700; }
.n-del { color: var(--err); font-weight: 700; }
.dl-fold { margin: 4px 12px; }
.sheet { border: 0; border-radius: 12px; padding: 0; width: min(880px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto; }
.sheet::backdrop { background: rgba(28, 25, 23, .45); }
.sheet-head, .sheet-nav { display: flex; gap: 8px; align-items: center; padding: 12px 14px; }
.sheet-head { border-bottom: 1px solid var(--line); }
.sheet-nav { border-top: 1px solid var(--line); }
.sheet-body { padding: 12px 14px; overflow: auto; max-height: 60vh; }
.sheet-row { display: grid; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
.sheet-row input, .sheet-row textarea { width: 100%; }
.sheet-row textarea { min-height: 64px; }
.opt { display: flex; gap: 8px; align-items: center; margin: 4px 0; }
.layout.ai-open .ai { display: flex; }
.ai {
  position: relative;
  flex: 0 0 var(--review-w, 420px); width: var(--review-w, 420px);
  display: none; flex-direction: column; min-width: 0; min-height: 0;
  border-left: 1px solid var(--line); background: var(--panel);
}
.ai.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.rev-w {
  position: absolute; z-index: 4; left: -5px; top: 0; bottom: 0; width: 10px;
  cursor: col-resize; touch-action: none;
}
.rev-w::after { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; }
.rev-w:hover::after, .rev-w.on::after { background: var(--accent); }
.chat-h {
  flex: 0 0 8px; margin: -4px 0; position: relative; z-index: 3;
  cursor: ns-resize; touch-action: none;
  display: flex; align-items: center; justify-content: center;
}
.chat-h::before { content: ""; width: 36px; height: 3px; border-radius: 2px; background: #d6d3d1; }
.chat-h:hover::before, .chat-h.on::before { background: var(--accent); }
.ai-head, .ai-form, .ai-actions, .ai-pub, .usage-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ai-head { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.ai-head select { max-width: 140px; padding: 2px 6px; }
.ai-head small { font-weight: 500; color: var(--muted); }
.ai-head small.on { color: var(--ok); }
.ai-head small.off { color: var(--err); }
.ai-head .zoom { padding: 3px 0; width: 24px; font-weight: 700; }
.ai-status { padding: 6px 10px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); }
.ai-status.err { color: var(--err); }
.ai-files { margin-top: 6px; color: var(--muted); font-size: 12px; }
.ai-actions .hint { flex: 1; color: var(--muted); font-size: 12px; }
.ai-pub { padding: 8px 10px; border-top: 1px solid var(--line); }
.ai-pub .st { color: var(--muted); font-size: 12px; }
.ai-pub pre { flex: 1 1 100%; max-height: 160px; overflow: auto; margin: 0; }
.usage { position: fixed; inset: 0; z-index: 50; background: rgba(28,25,23,.45); display: flex; align-items: center; justify-content: center; padding: 24px; }
.usage-box { background: #fff; width: min(560px, 100%); border-radius: 12px; }
.usage-head { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.usage-body { padding: 14px; }
.usage-body table { width: 100%; border-collapse: collapse; }
.usage-body td, .usage-body th { border-top: 1px solid var(--line); padding: 6px 8px 6px 0; text-align: left; }
.ai-issues {
  flex: 0 0 auto; height: var(--issues-h, 180px); overflow: auto;
  padding: 10px 12px 2px;
}
.ai-issues:empty, .ai-issues:empty + .issues-h { display: none; }
.ai-issues .issue {
  display: block; width: 100%; text-align: left;
  margin: 0 0 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-left: 3px solid var(--rev-c, #b45309);
  border-radius: 8px; background: #fff; color: inherit; cursor: pointer;
}
.ai-issues .issue[data-kind="conflict"] { --rev-c: #b91c1c; }
.ai-issues .issue[data-kind="inconsistent"] { --rev-c: #b45309; }
.ai-issues .issue[data-kind="omission"] { --rev-c: #1d4ed8; }
.ai-issues .issue.on { background: #fff7ed; }
.ai-issues .issue b { display: block; font-size: 13px; }
.ai-issues .issue .loc { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; }
.ai-issues .issue p { margin: 4px 0 0; font-size: 12.5px; }
.ai-log, .ai-issues { zoom: var(--ai-zoom, 1); }
.ai-log { flex: 1; overflow: auto; padding: 10px; }
.ai-msg { margin: 0 0 10px; }
.ai-msg .thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.ai-msg .thumbs img { max-width: 140px; max-height: 100px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: zoom-in; }
.ai-ask { margin-top: 8px; padding: 8px; border: 1px solid var(--accent); border-radius: 8px; background: var(--bg, #fafaf9); }
.ai-ask .q { margin: 6px 0 4px; font-size: 13px; }
.ai-ask .q b { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 4px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 500; }
.ai-ask .opts { display: flex; flex-direction: column; gap: 4px; }
.ai-ask .opt { display: block; width: 100%; text-align: left; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.ai-ask .opt small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.ai-ask .opt.on { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.ai-ask .other { display: flex; gap: 6px; margin-top: 8px; }
.ai-ask .other input { flex: 1; min-width: 0; }
.ai-ask.done { border-color: var(--line); opacity: .7; }
.ai-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.ai-imgs[hidden] { display: none; }
.ai-img { position: relative; width: 64px; height: 64px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.ai-img img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.ai-img button, .ai-file button.x {
  position: absolute; top: 2px; right: 2px; padding: 0 5px; border-radius: 8px;
  background: rgba(0,0,0,.6); color: #fff; border: 0; font: 600 11px/16px var(--sans);
}
.ai-file {
  position: relative; display: flex; align-items: center; max-width: 220px; min-height: 32px;
  padding: 6px 22px 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
  color: var(--ink); font-size: 12px; text-decoration: none;
}
.ai-file .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-light {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.75); cursor: zoom-out;
}
.ai-light img { max-width: 94vw; max-height: 94vh; background: #fff; }
#aiSend.busy { display: inline-flex; align-items: center; gap: 6px; }
.ai-spin {
  width: 12px; height: 12px; box-sizing: border-box;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: ai-spin .8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
.msi-dlg {
  position: fixed; inset: 0; z-index: 62; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(28,25,23,.38);
}
.msi-dlg[hidden] { display: none; }
.msi-box { width: min(420px, 100%); background: #fff; border-radius: 12px; padding: 16px 18px 14px; }
.msi-box h3 { margin: 0 0 6px; }
.msi-bar { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.ai-msg b { display: block; font-size: 12px; color: var(--muted); }
.ai-msg.me { background: #eef4ff; border-radius: 8px; padding: 6px 8px; }
.ai-form { padding: 8px 10px 12px; border-top: 1px solid var(--line); flex-direction: column; align-items: stretch; }
.ai-form textarea { width: 100%; height: var(--ai-h, 84px); min-height: 52px; resize: none; font-size: calc(13px * var(--ai-zoom, 1)); }
.ai-q { font-weight: 700; margin-bottom: 6px; }
#aiChoice { padding: 0 10px 8px; display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 640px) {
  .top { flex-wrap: wrap; height: auto; min-height: 52px; gap: 8px; padding: 8px 12px; padding-top: calc(8px + var(--safe-t)); }
  .top .brand-full { display: none; }
  .top .brand-short { display: inline; }
  .top .me { flex: 1 1 100%; flex-wrap: wrap; margin-left: 0; padding-top: 4px; border-top: 1px solid #3a4558; }
  .nav-menu { order: 3; flex: 1 1 100%; flex-wrap: wrap; padding-bottom: 8px; }
  .editor-top { border-top: 0; background: #fff; color: var(--ink); }
}
@media (max-width: 800px) {
  .dash { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; }
  .nav {
    position: fixed; z-index: 35; top: 0; bottom: 0; left: 0; width: min(86vw, 320px);
    box-shadow: 8px 0 24px rgba(0,0,0,.12);
  }
  .layout.nav-open .scrim { display: block; }
  .hist { padding: 0; }
  .hist-body { grid-template-columns: 1fr; }
  .hist-list { max-height: 30vh; }
  .wrap.split { grid-template-columns: 1fr; }
  .layout.ai-open .ai {
    position: fixed; z-index: 34; left: 0; right: 0; bottom: 0; height: 62vh; width: auto;
    flex: none; border-left: 0; border-top: 1px solid var(--line);
  }
  .rev-w { display: none; }
}
