/* MultiView — interface styles */
:root {
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --radius: 8px;
  --gap: 6px;
  --hit: #ffe066;
  --hit-cur: #ff9f1c;
  --add: rgba(34, 197, 94, .16);
  --add-strong: rgba(34, 197, 94, .42);
  --del: rgba(239, 68, 68, .14);
  --del-strong: rgba(239, 68, 68, .40);
  --chg: rgba(234, 179, 8, .10);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111318;
  --bg2: #181b22;
  --panel: #1d2029;
  --raise: #252936;
  --line: #2c313d;
  --line2: #3a4050;
  --text: #e7e9ef;
  --muted: #8f97a8;
  --accent: #7c83ff;
  --accent-ink: #fff;
  --hover: rgba(255, 255, 255, .07);
  --shadow: 0 12px 40px rgba(0, 0, 0, .5);
  --pdf-bg: #2f323a;
  --img-bg: #22252d;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #eceef3;
  --bg2: #f8f9fb;
  --panel: #ffffff;
  --raise: #ffffff;
  --line: #d8dbe3;
  --line2: #c5c9d3;
  --text: #1c2130;
  --muted: #646c7e;
  --accent: #4f57e6;
  --accent-ink: #fff;
  --hover: rgba(20, 30, 60, .06);
  --shadow: 0 12px 40px rgba(20, 30, 60, .18);
  --pdf-bg: #d5d8df;
  --img-bg: #e6e8ee;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 13px/1.4 var(--font);
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}
input, select, textarea, button { font: inherit; color: inherit; }
input, textarea { user-select: text; }
button { cursor: pointer; }
button:disabled { cursor: default; }
kbd {
  font: 11px var(--mono);
  padding: 1px 5px;
  border: 1px solid var(--line2);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  white-space: nowrap;
}
.ic { display: block; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- Buttons & inputs ---------- */
.ibtn {
  width: 26px; height: 26px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
}
.ibtn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.ibtn:disabled { opacity: .3; }
.ibtn.has { color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--line2); border-radius: 7px;
  background: var(--raise); color: var(--text);
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
select {
  height: 26px; padding: 0 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  outline: none;
}
select:focus, .txt:focus, .num:focus { border-color: var(--accent); }
.txt, .num {
  height: 30px; padding: 0 10px; width: 100%;
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px; outline: none;
}
.num { width: 90px; }
.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.seg button {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; min-width: 24px; padding: 0 8px;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
}
.seg button:hover { color: var(--text); background: var(--hover); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* ---------- Top bar ---------- */
#topbar {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 7px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 8px; flex: none; }
.brand b { font-size: 14px; letter-spacing: .2px; }
.logo { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 18px; height: 18px; }
.logo i { border-radius: 2px; background: #f97316; }
.logo i:nth-child(2) { background: #3b82f6; }
.logo i:nth-child(3) { background: #22c55e; }
.logo i:nth-child(4) { background: #eab308; }
.tb-group { display: flex; align-items: center; gap: 6px; flex: none; }
.tb-label { color: var(--muted); font-size: 12px; }
.ws-sel { height: 30px; max-width: 170px; font-weight: 600; }
.arrpic { display: flex; flex-direction: column; gap: 2px; width: 20px; height: 14px; }
.arrrow { flex: 1; display: flex; gap: 2px; }
.arrrow i { flex: 1; border-radius: 1.5px; background: currentColor; opacity: .85; }
.search { flex: 1; min-width: 260px; display: flex; align-items: center; gap: 6px; }
.qwrap {
  flex: 1; min-width: 0; display: flex; align-items: center;
  height: 32px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.qwrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.q { flex: 1; min-width: 0; height: 100%; padding: 0 10px; border: 0; outline: 0; background: transparent; }
.q::-webkit-search-cancel-button { display: none; }
.find-nav { display: flex; align-items: center; gap: 1px; padding-right: 3px; }
.find-total { font-size: 12px; color: var(--muted); padding: 0 6px; white-space: nowrap; }
.find-total.none { color: #ef4444; }
.go { height: 32px; }
.tools { gap: 6px; }
.tbtn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--text);
  white-space: nowrap;
}
.tbtn:hover { background: var(--hover); }
.tbtn.kb.on { background: #16a34a; border-color: #16a34a; color: #fff; }
.tbtn.kb.on kbd { background: rgba(0,0,0,.2); border-color: rgba(255,255,255,.4); color: #fff; }
@media (max-width: 1480px) {
  .tools .tbtn span, .tb-label { display: none; }
  .tools .tbtn.kb span { display: inline; }
}
@media (max-width: 1250px) {
  .brand b, .tools .tbtn kbd { display: none; }
  .mode span { display: none; }
}

/* ---------- Stage & panels ---------- */
#stage { flex: 1; min-height: 0; display: flex; }
#grid { flex: 1; position: relative; margin: var(--gap); min-width: 0; }
#stage.dragging, #stage.dragging * { user-select: none !important; }
#stage.dragging .pbody, #stage.dragging webview { pointer-events: none; }
#stage.col-resize, #stage.col-resize * { cursor: col-resize !important; }
#stage.row-resize, #stage.row-resize * { cursor: row-resize !important; }

.panel {
  --pc: #7c83ff;
  position: absolute;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--pc);
  border-radius: var(--radius);
  overflow: hidden;
  container-type: inline-size;
  container-name: panel;
  transition: box-shadow .15s;
}
.panel.off { visibility: hidden; pointer-events: none; left: -20000px !important; }
.panel.focused { box-shadow: 0 0 0 1px color-mix(in srgb, var(--pc) 70%, transparent), 0 4px 18px rgba(0,0,0,.18); }
.panel.maxed { z-index: 3; }

.phead {
  position: relative;
  flex: none;
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px 6px;
  padding: 4px 6px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
}
.ph-id { order: 0; display: flex; align-items: center; gap: 6px; min-width: 0; flex: 0 1 auto; }
.ph-tools { order: 1; display: flex; align-items: center; gap: 1px; margin-left: auto; flex: none; }
.ph-break { order: 2; flex-basis: 100%; height: 0; }
.ph-nav { order: 3; display: flex; align-items: center; flex: none; }
.ph-addr { order: 4; flex: 1 1 160px; min-width: 0; display: flex; align-items: center; gap: 4px; }
@container panel (min-width: 760px) {
  .ph-break { display: none; }
  .ph-nav { order: 1; }
  .ph-addr { order: 2; }
  .ph-tools { order: 3; margin-left: 0; }
}
@container panel (max-width: 560px) { .zoom { display: none !important; } }
@container panel (max-width: 360px) { .pnum { display: none; } .psync { width: 70px; } }
.panel:not(.is-web) .ph-nav { display: none; }

.pdot { width: 13px; height: 13px; flex: none; border-radius: 50%; border: 0; padding: 0; background: var(--pc); box-shadow: 0 0 0 2px color-mix(in srgb, var(--pc) 30%, transparent); }
.pnum { font: 600 11px var(--mono); color: var(--muted); }
.pname {
  field-sizing: content; min-width: 6ch; max-width: 22ch;
  height: 24px; padding: 0 4px;
  border: 1px solid transparent; border-radius: 5px; background: transparent;
  font-weight: 600; outline: none; text-overflow: ellipsis;
}
.pname:hover { border-color: var(--line); }
.pname:focus { border-color: var(--accent); background: var(--bg); }
.pname::placeholder { color: var(--text); opacity: .9; }
.kbbadge, .findbadge {
  font: 600 11px var(--mono); padding: 1px 6px; border-radius: 10px; white-space: nowrap;
}
.kbbadge { background: color-mix(in srgb, var(--pc) 22%, transparent); color: var(--text); border: 1px solid color-mix(in srgb, var(--pc) 55%, transparent); }
.findbadge { background: var(--hit); color: #111; }
.findbadge.none { background: color-mix(in srgb, #ef4444 25%, transparent); color: var(--text); }
.kbbadge:empty, .findbadge:empty { display: none; }
.kindic { color: var(--muted); display: flex; padding-left: 2px; }
.paddr {
  flex: 1; min-width: 0; height: 26px; padding: 0 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; outline: none;
  font-size: 12.5px; color: var(--muted); text-overflow: ellipsis;
}
.paddr:focus { color: var(--text); border-color: var(--accent); }
.zoom { display: flex; align-items: center; }
.zoomlbl { width: 42px; height: 24px; border: 0; background: transparent; color: var(--muted); font-size: 11.5px; border-radius: 5px; }
.zoomlbl:hover { background: var(--hover); color: var(--text); }
.psync { height: 24px; font-size: 12px; margin: 0 2px; }
.panel[data-sync="off"] .psync { color: var(--muted); border-style: dashed; }
.panel:not([data-sync="off"]) .psync { border-color: color-mix(in srgb, var(--pc) 55%, var(--line)); }

.panel.loading .phead::after {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 2px; width: 35%;
  background: var(--pc); animation: load 1.1s ease-in-out infinite;
}
@keyframes load { 0% { left: -35%; } 100% { left: 100%; } }

.pbody { flex: 1; position: relative; min-height: 0; background: var(--panel); }
.view { position: absolute; inset: 0; outline: none; }
webview { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.view-banner {
  position: absolute; left: 10px; right: 10px; top: 10px; z-index: 2;
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 8px 12px; border-radius: 8px; background: #7c2d12; color: #fff; box-shadow: var(--shadow);
}
.drop-hint {
  display: none; position: absolute; inset: 8px; z-index: 5; pointer-events: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 8px;
  border: 2px dashed var(--pc); border-radius: 10px;
  background: color-mix(in srgb, var(--pc) 14%, transparent);
  font-weight: 600; color: var(--text);
}
.panel.drop .drop-hint { display: flex; }

/* Notes */
.pnotes { display: none; flex: none; flex-direction: column; height: 28%; min-height: 60px; border-top: 1px solid var(--line); background: var(--bg2); }
.panel.notes-open .pnotes { display: flex; }
.notes-grip { height: 7px; cursor: row-resize; flex: none; position: relative; }
.notes-grip::after { content: ""; position: absolute; left: 50%; top: 2px; width: 36px; height: 3px; margin-left: -18px; border-radius: 2px; background: var(--line2); }
.notes-ta { flex: 1; resize: none; border: 0; outline: 0; padding: 4px 12px 10px; background: transparent; line-height: 1.5; }

/* Gutters */
.gutter { position: absolute; z-index: 4; border-radius: 3px; transition: background .12s; }
.gutter.v { cursor: col-resize; }
.gutter.h { cursor: row-resize; }
.gutter:hover { background: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ---------- Master scrollbar ---------- */
#master {
  flex: none; width: 34px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 0;
  background: var(--bg2); border-left: 1px solid var(--line);
}
body.kb-on #master { box-shadow: inset 2px 0 0 #16a34a; }
.m-track {
  flex: 1; width: 10px; position: relative; border-radius: 6px;
  background: var(--line); cursor: pointer; touch-action: none;
}
.m-thumb {
  position: absolute; left: -7px; top: 0; width: 24px; height: 58px;
  border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.3); cursor: grab;
}
#master.active .m-thumb { cursor: grabbing; filter: brightness(1.12); }
.m-pct { font: 700 10px var(--mono); writing-mode: vertical-rl; transform: rotate(180deg); }
.m-dots { display: flex; flex-direction: column; gap: 5px; align-items: center; }
.m-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--pc); border: 2px solid var(--pc); cursor: pointer; display: inline-block; flex: none; }
.m-dot.off { background: transparent; opacity: .6; }

/* ---------- Local viewers ---------- */
.local .sc { position: absolute; inset: 0; overflow: auto; user-select: text; }
.local .content { min-height: 100%; }
.view-msg {
  height: 100%; min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px; text-align: center; color: var(--muted);
}
.view-msg h3 { margin: 4px 0 0; color: var(--text); font-size: 15px; }
.view-msg p { margin: 0; max-width: 440px; }
.view-msg code { font: 12px var(--mono); word-break: break-all; }
.empty { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; user-select: none; }
.empty-title { font-size: 15px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 560px; }
.chip { height: 28px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line2); background: var(--bg); }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.recent { display: flex; flex-direction: column; gap: 3px; align-items: stretch; min-width: 240px; max-width: 420px; }
.recent-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 0; border-radius: 6px; background: transparent; text-align: left; color: var(--text); overflow: hidden; }
.recent-item span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item:hover { background: var(--hover); }

.paper {
  max-width: 860px; margin: 22px auto 60px; padding: 56px 68px;
  background: #fff; color: #1f2328; border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,.2), 0 6px 24px rgba(0,0,0,.12);
  font: 15px/1.6 Calibri, "Segoe UI", system-ui, sans-serif; user-select: text;
}
.docx .sc { background: var(--pdf-bg); }
.paper img { max-width: 100%; height: auto; }
.paper table { border-collapse: collapse; margin: 10px 0; }
.paper td, .paper th { border: 1px solid #c9ccd3; padding: 4px 8px; vertical-align: top; }
.paper h1, .paper h2, .paper h3 { line-height: 1.25; }
.paper.md { background: var(--panel); color: var(--text); box-shadow: none; padding: 28px 40px; margin-top: 0; font: 14.5px/1.65 var(--font); }
.paper.md code { font: 12.5px var(--mono); background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.paper.md pre { background: var(--bg); padding: 12px; border-radius: 8px; overflow: auto; }
.paper.md pre code { background: none; padding: 0; }
.paper.md blockquote { margin: 0; padding-left: 14px; border-left: 3px solid var(--line2); color: var(--muted); }
.paper.md td, .paper.md th { border-color: var(--line); }
.paper a { color: #2563eb; }
.paper.md a { color: var(--accent); }

.code { display: flex; min-width: max-content; min-height: 100%; font: 12.5px/1.55 var(--mono); }
.code pre { margin: 0; padding: 10px 14px; user-select: text; }
.code .ln { position: sticky; left: 0; text-align: right; color: var(--muted); background: var(--bg2); border-right: 1px solid var(--line); padding: 10px 10px; user-select: none; opacity: .8; }
.code .src { tab-size: 4; white-space: pre; }

.table-wrap { display: inline-block; min-width: 100%; }
.grid-table { border-collapse: separate; border-spacing: 0; font-size: 12.5px; user-select: text; }
.grid-table th, .grid-table td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 3px 9px; white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.grid-table thead th { position: sticky; top: 0; z-index: 2; background: var(--bg2); color: var(--muted); font-weight: 600; font-size: 11px; }
.grid-table .rn { position: sticky; left: 0; z-index: 1; background: var(--bg2); color: var(--muted); text-align: right; font-size: 11px; min-width: 38px; }
.grid-table thead .rn { z-index: 3; }
.grid-table tr.first td:not(.rn) { font-weight: 600; background: color-mix(in srgb, var(--accent) 7%, transparent); }
.grid-table tbody tr:hover td:not(.rn) { background: var(--hover); }
.note { padding: 10px; color: var(--muted); font-size: 12px; }
.view.sheet:has(.sheet-tabs:not([hidden])) .sc { bottom: 32px; }
.sheet-tabs {
  position: absolute; left: 0; right: 0; bottom: 0; height: 32px;
  display: flex; gap: 2px; padding: 0 6px; align-items: center; overflow-x: auto;
  background: var(--bg2); border-top: 1px solid var(--line);
}
.stab { height: 24px; padding: 0 12px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); white-space: nowrap; }
.stab:hover { background: var(--hover); color: var(--text); }
.stab.on { background: var(--panel); color: var(--text); box-shadow: inset 0 -2px 0 var(--pc); }

.image .sc { background: var(--img-bg); }
.image .content { display: flex; align-items: flex-start; justify-content: center; padding: 12px; min-width: max-content; }
.image img { display: block; background: repeating-conic-gradient(#8883 0 25%, transparent 0 50%) 0 0 / 16px 16px; }
.image img.fit { max-width: 100%; height: auto; }
.image .content:has(img.fit) { min-width: 0; }

.pdf .pdf-sc { background: var(--pdf-bg); }
.pdfViewer .page { box-shadow: 0 1px 4px rgba(0,0,0,.25); border: 0; margin: 10px auto; }

.seg.float { position: absolute; top: 8px; right: 18px; z-index: 3; box-shadow: var(--shadow); }

mark.mv-hit { background: var(--hit); color: #111; border-radius: 2px; padding: 0; }
mark.mv-hit.cur { background: var(--hit-cur); outline: 2px solid var(--hit-cur); }

/* ---------- Menus, modals, toasts ---------- */
.popmenu {
  position: fixed; z-index: 300; min-width: 230px; max-width: 360px; max-height: 80vh; overflow: auto;
  padding: 5px; border-radius: 10px; background: var(--raise); border: 1px solid var(--line2); box-shadow: var(--shadow);
}
.mi { width: 100%; display: flex; align-items: center; gap: 9px; padding: 6px 9px; border: 0; border-radius: 6px; background: transparent; text-align: left; }
.mi:hover:not(:disabled) { background: var(--hover); }
.mi:disabled { opacity: .4; }
.mi span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi.danger { color: #ef4444; }
.mi-ic { width: 14px; color: var(--muted); display: flex; }
.mi-hint { margin-left: auto; color: var(--muted); font-size: 11.5px; padding-left: 12px; }
.sep { height: 1px; margin: 4px 6px; background: var(--line); }
.swatches { display: flex; gap: 7px; padding: 7px 9px; }
.sw { width: 20px; height: 20px; border-radius: 50%; border: 0; padding: 0; }
.sw.on { box-shadow: 0 0 0 2px var(--raise), 0 0 0 4px var(--text); }

.m-back { position: fixed; inset: 0; z-index: 200; background: rgba(8, 10, 16, .5); display: flex; align-items: center; justify-content: center; padding: 24px; user-select: none; }
.modal { display: flex; flex-direction: column; min-width: 380px; max-width: 92vw; max-height: 92vh; background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; box-shadow: var(--shadow); }
.modal.wide { width: 960px; }
.modal.full { width: calc(100vw - 48px); height: calc(100vh - 48px); max-width: none; max-height: none; }
.m-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.m-title { font-size: 14px; font-weight: 600; }
.m-body { flex: 1; min-height: 0; overflow: auto; padding: 16px; user-select: text; }
.modal.full .m-body { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.m-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 16px 14px; }
.m-body p { margin: 0 0 4px; }

#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { max-width: 640px; padding: 9px 16px; border-radius: 9px; background: #1f2430; color: #f2f4f8; box-shadow: var(--shadow); border: 1px solid #333a48; transition: opacity .3s, transform .3s; }
.toast.warn { background: #78350f; border-color: #92400e; }
.toast.out { opacity: 0; transform: translateY(6px); }
.fatal { position: fixed; inset: 20px; z-index: 999; padding: 16px; background: #450a0a; color: #fff; overflow: auto; white-space: pre-wrap; border-radius: 10px; }

/* ---------- Differences ---------- */
.diff, .swipe { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.diff-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.diff-bar .side { display: flex; align-items: center; gap: 6px; }
.diff-bar .side span { font-size: 12px; color: var(--muted); }
.diff-bar select { height: 30px; max-width: 280px; }
.diff-bar .spacer { flex: 1; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; cursor: pointer; }
.pg { width: 64px; height: 30px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; }
.diff-stats { display: flex; gap: 14px; align-items: center; padding: 8px 16px; font-size: 12.5px; border-bottom: 1px solid var(--line); }
.st { font-weight: 600; }
.st.add { color: #16a34a; } .st.del { color: #dc2626; } .st.chg { color: #ca8a04; }
.diff-out { flex: 1; min-height: 0; overflow: auto; position: relative; }
.diff-loading { padding: 40px; text-align: center; color: var(--muted); }
.diff-head { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr 1fr; background: var(--bg2); border-bottom: 1px solid var(--line); font-weight: 600; }
.dh { padding: 7px 14px 7px 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dh.b { border-left: 1px solid var(--line); }
.diff-grid { font: 12.5px/1.55 var(--mono); }
.drow { display: grid; grid-template-columns: 46px 1fr 46px 1fr; }
.dln { text-align: right; padding: 1px 8px; color: var(--muted); background: var(--bg2); user-select: none; font-size: 11px; line-height: 19px; }
.dtxt { padding: 1px 10px; white-space: pre-wrap; word-break: break-word; min-width: 0; }
.dtxt.r { border-left: 1px solid var(--line); }
.drow.add .dtxt.r { background: var(--add); }
.drow.add .dtxt.l, .drow.del .dtxt.r { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--hover) 6px 7px); }
.drow.del .dtxt.l { background: var(--del); }
.drow.chg .dtxt { background: var(--chg); }
.drow ins { background: var(--add-strong); text-decoration: none; border-radius: 2px; }
.drow del { background: var(--del-strong); text-decoration: line-through; text-decoration-color: rgba(220,38,38,.7); border-radius: 2px; }
.drow.cur { outline: 2px solid var(--accent); outline-offset: -1px; }
.drow.fold { display: block; }
.dfold { text-align: center; padding: 3px; color: var(--muted); background: var(--bg2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; font-family: var(--font); font-size: 12px; }
.dfold:hover { color: var(--accent); }

/* ---------- Swipe ---------- */
.sw-hint { padding: 6px 16px; }
.range { width: 200px; accent-color: var(--accent); }
.sw-stage { flex: 1; min-height: 0; overflow: auto; padding: 16px; background: var(--img-bg); }
.sw-stack { position: relative; width: 100%; max-width: 1400px; margin: 0 auto; touch-action: none; }
.sw-stack.busy { opacity: .5; }
.sw-stack[data-mode="swipe"] { cursor: ew-resize; }
.sw-a { display: block; width: 100%; height: auto; }
.sw-b { position: absolute; left: 0; top: 0; width: 100%; height: auto; }
.sw-stack[data-mode="difference"] .sw-b { mix-blend-mode: difference; }
.sw-handle { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); pointer-events: none; }
.sw-handle span { position: absolute; top: 90px; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; background: #fff; color: #111; display: flex; align-items: center; justify-content: center; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.sw-stack:not([data-mode="swipe"]) .sw-handle { display: none; }
.sw-lab { position: absolute; top: 8px; padding: 2px 10px; border-radius: 10px; background: var(--pc, #333); color: #fff; font-size: 12px; font-weight: 600; box-shadow: 0 1px 6px rgba(0,0,0,.35); pointer-events: none; }
.sw-lab.a { left: 8px; } .sw-lab.b { right: 8px; }
.sw-stack[data-mode="side"] { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: none; }
.sw-stack[data-mode="side"] .sw-b { position: static; }
.sw-stack[data-mode="side"] .sw-lab.b { right: auto; left: calc(50% + 15px); }

/* ---------- Settings ---------- */
.settings { display: grid; grid-template-columns: 170px 1fr; gap: 16px; min-height: 420px; }
.set-tabs { display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line); padding-right: 12px; }
.set-tabs button { text-align: left; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.set-tabs button:hover { background: var(--hover); color: var(--text); }
.set-tabs button.on { background: var(--hover); color: var(--text); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.set-pane { max-height: 68vh; overflow: auto; padding-right: 6px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.set-label { font-weight: 600; }
.set-hint { color: var(--muted); font-size: 12.5px; line-height: 1.55; margin: 2px 0 8px; }
.set-hint kbd { font-size: 10.5px; }
.keygrid { display: grid; grid-template-columns: 150px 120px 120px; gap: 6px 10px; align-items: center; }
.kh { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.kp { display: flex; align-items: center; gap: 8px; }
.keycap { height: 30px; font: 600 13px var(--mono); border: 1px solid var(--line2); border-bottom-width: 3px; border-radius: 7px; background: var(--raise); }
.keycap.listening { border-color: var(--accent); color: var(--accent); animation: pulse 1s infinite; font: 12px var(--font); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); } }
.sites { display: flex; flex-direction: column; gap: 5px; }
.site-row { display: grid; grid-template-columns: 120px 150px 1fr 190px 58px; gap: 6px; align-items: center; }
.site-row .txt { height: 28px; font-size: 12.5px; }
.site-row.head { font-size: 11.5px; color: var(--muted); }
.site-btns { display: flex; }
.shortcuts { display: flex; flex-direction: column; }
.sc-row { display: grid; grid-template-columns: 300px 1fr; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: center; }
.sc-row kbd { justify-self: start; white-space: normal; }

/* ---------- Browser demo ---------- */
.view.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.frame-note {
  position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 2;
  display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px;
  border-radius: 8px; background: var(--raise); border: 1px solid var(--line2); box-shadow: var(--shadow);
  font-size: 12px; color: var(--muted);
}
.frame-note span { flex: 1; }
