@view-transition {
  navigation: auto;
}
::view-transition-old(root) {
  animation: none;
  z-index: 1;
}
::view-transition-new(root) {
  animation: vtFadeIn 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
  z-index: 2;
}
@keyframes vtFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

:root,
html[data-theme="light"],
body[data-theme="light"] {
  color-scheme: light;
  --bg: #fafaf7;
  --bg-subtle: #f3f1eb;
  --bg-panel: #f6f4ee;
  --bg-hover: rgba(28, 25, 21, 0.045);
  --bg-active: rgba(28, 25, 21, 0.078);
  --fg: #1b1916;
  --fg-mid: #4e4a43;
  --fg-muted: #78736a;
  --fg-faint: #9c968b;
  --line: rgba(28, 25, 21, 0.11);
  --line-strong: rgba(28, 25, 21, 0.25);
  --accent: #9e2a2b;
  --accent-soft: rgba(158, 42, 43, 0.09);
  --ok: #2a5d4f;
  --link: #225870;
  --amber: #a87724;
  --map-bg: #efede5;
  --map-edge: rgba(28, 25, 21, 0.24);
  --map-node: #26231f;
  --mk-raised: #ffffff;   /* menus, focused controls in Make Atlas sheets */
  --mk-track: #e6e2d8;    /* segmented-control track */
  --mk-well: #f3f1eb;     /* dropdown arrow well */
  --mk-shadow: rgba(28, 25, 21, 0.16);
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-display: "Cinzel", Georgia, serif;
  --font-serif: "Cormorant Garamond", "Noto Serif TC", "Songti TC", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "PingFang TC", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, monospace;
}

html[data-theme="dark"],
body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131518;
  --bg-subtle: #181a1f;
  --bg-panel: #16181d;
  --bg-hover: rgba(236, 230, 216, 0.05);
  --bg-active: rgba(236, 230, 216, 0.088);
  --fg: #ece6d8;
  --fg-mid: #bcb4a3;
  --fg-muted: #8a8375;
  --fg-faint: #635e54;
  --line: rgba(236, 230, 216, 0.1);
  --line-strong: rgba(236, 230, 216, 0.24);
  --accent: #d96d5b;
  --accent-soft: rgba(217, 109, 91, 0.14);
  --ok: #72b899;
  --link: #7da9c9;
  --amber: #d4b06a;
  --map-bg: #111317;
  --map-edge: rgba(236, 230, 216, 0.2);
  --map-node: #dfd8c7;
  --mk-raised: #1e2126;
  --mk-track: #24272d;
  --mk-well: #1b1e23;
  --mk-shadow: rgba(0, 0, 0, 0.45);
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: var(--font-sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

.ico { width: 14px; height: 14px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.ico-sm { width: 12px; height: 12px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.tabula-mark { width: 14px; height: 14px; color: var(--accent); flex-shrink: 0; }
.hidden { display: none !important; }

/* =====================================================================
   FULL-VIEWPORT CURATED DESK (3-PANE WITH ALIGNED 44PX HEADER RULE)
   ===================================================================== */
.ws-app {
  display: grid;
  grid-template-columns: 228px 1fr 372px;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}
html.is-desktop-mac .ws-app {
  grid-template-columns: 248px 1fr 372px;
}
html.is-desktop-mac .ws-brand-row {
  padding-left: 94px;
  -webkit-app-region: drag;
}
html.is-desktop-mac .ws-topbar,
html.is-desktop-mac .ws-ins-hdr {
  -webkit-app-region: drag;
}
html.is-desktop-mac .ws-brand-row a,
html.is-desktop-mac .ws-topbar button,
html.is-desktop-mac .ws-topbar input,
html.is-desktop-mac .ws-topbar .seg,
html.is-desktop-mac .ws-ins-hdr button,
html.is-desktop-mac .ws-ins-hdr a,
html.is-desktop-mac .ins-menu-pop {
  -webkit-app-region: no-drag;
}
@media (max-width: 1040px) {
  .ws-app { grid-template-columns: 204px 1fr; }
  .ws-inspector { display: none; }
}

/* Shared Quiet & Archival Controls */
.quiet-btn {
  width: 28px; height: 28px;
  border: none; background: transparent; color: var(--fg-muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; line-height: 1;
  transition: color 0.12s, background 0.12s;
}
.quiet-btn:hover { color: var(--fg); background: var(--bg-hover); }
.quiet-btn.is-active { color: var(--accent); }
.quiet-btn.is-danger:hover { color: var(--accent); background: var(--accent-soft); }

.kbd-cap {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 21px; padding: 0 6px;
  font-family: var(--font-sans); font-size: 10.5px; font-weight: 500;
  color: var(--fg-muted); background: var(--bg-subtle);
  border: 1px solid var(--line-strong);
  box-shadow: 0 1.5px 0 var(--line-strong);
  flex-shrink: 0;
}

.seg {
  display: inline-flex;
  height: 26px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
}
.seg-btn {
  border: none; border-right: 1px solid var(--line);
  background: transparent; color: var(--fg-muted);
  padding: 0 9px; height: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  font-family: var(--font-sans); font-size: 11.5px; font-weight: 500; letter-spacing: 0.1px;
  cursor: pointer; white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:not(.active):hover { background: var(--bg-hover); color: var(--fg); }
.seg-btn.active { background: var(--fg); color: var(--bg); font-weight: 500; }

.icon-btn {
  width: 26px; height: 26px;
  border: 1px solid var(--line);
  background: transparent; color: var(--fg-muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--fg); background: var(--bg-hover); }
.icon-btn.is-danger:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.btn-primary {
  height: 34px; padding: 0 14px;
  border: 1px solid var(--fg);
  background: var(--fg); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-size: 11.5px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  cursor: pointer; transition: opacity 0.14s;
}
.btn-primary:hover { opacity: 0.86; }

/* =====================================================================
   LEFT SIDEBAR
   ===================================================================== */
.ws-sidebar {
  background: var(--bg-subtle);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  user-select: none;
  overflow: hidden;
}
.ws-brand-row {
  height: 44px; padding: 0 14px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: flex-start;
  flex-shrink: 0;
}
.ws-brand-lockup {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--fg);
}
.ws-brand {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 700;
  letter-spacing: 1.6px; text-transform: uppercase;
  line-height: 1;
}

.ws-nav {
  padding: 12px 10px;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto; flex: 1;
}
.ws-nav-sep { height: 1px; background: var(--line); margin: 10px 4px; }
.ws-nav-btn {
  width: 100%; border: none; border-left: 2px solid transparent;
  background: transparent; cursor: pointer;
  padding: 7px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 13px; color: var(--fg-mid); text-align: left;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.ws-nav-btn:hover { background: var(--bg-hover); color: var(--fg); }
.ws-nav-btn.active {
  background: var(--bg-active); color: var(--fg); font-weight: 600;
  border-left-color: var(--accent);
}
.ws-nav-l { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.ws-nav-l .ico { color: var(--fg-faint); }
.ws-nav-btn.active .ws-nav-l .ico { color: var(--accent); }
.ws-cnt { font-family: var(--font-sans); font-variant-numeric: tabular-nums; font-size: 11px; color: var(--fg-faint); flex-shrink: 0; }

.ws-subnav {
  margin: 2px 0 6px 20px; padding-left: 10px;
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 1px;
}
.ws-subbtn {
  width: 100%; border: none; background: transparent; cursor: pointer;
  padding: 5px 8px; font-size: 12px; color: var(--fg-muted);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  text-align: left; transition: color 0.12s, background 0.12s;
}
.ws-subbtn span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-subbtn:hover { color: var(--fg); background: var(--bg-hover); }
.ws-subbtn.active { color: var(--accent); font-weight: 600; background: var(--bg-hover); }

.ws-side-foot {
  margin-top: auto; height: 40px; padding: 0 10px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.ws-foot-left, .ws-foot-right { display: flex; align-items: center; gap: 2px; }
/* one 16px line-icon set: library actions on the left; help, theme, then settings on the right */
.ws-side-foot .ico { width: 16px; height: 16px; stroke-width: 1.5; stroke-linejoin: round; } /* one soft, rounded line weight for the whole row */
.ws-foot-div { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }
.ws-foot-div:has(+ .hidden) { display: none; } /* no Settings in the web build */

/* =====================================================================
   CENTER CATALOG PANE + F3 HEADER CROSSFADE SEARCH
   ===================================================================== */
.ws-main {
  display: flex; flex-direction: column; overflow: hidden; background: var(--bg);
}
.ws-topbar {
  position: relative;
  height: 44px; padding: 0 18px 0 22px; flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.ws-topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 12px; font-weight: 700;
  letter-spacing: 1.4px; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-toolbar { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.ws-search-overlay {
  position: absolute; inset: 0; z-index: 12;
  padding: 0 14px 0 22px;
  background: var(--bg);
  display: flex; align-items: center; gap: 10px;
  opacity: 0; pointer-events: none;
  transform: translateY(-3px);
  transition: opacity 0.18s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.ws-search-overlay.open {
  opacity: 1; pointer-events: auto; transform: translateY(0);
}
.search-ov-ico { color: var(--fg-muted); }
.ws-search-overlay input {
  flex: 1; border: none; background: transparent; outline: none;
  font-size: 13px; color: var(--fg);
}
.ws-search-overlay input::placeholder { color: var(--fg-faint); }

.ws-toast {
  padding: 8px 22px; font-family: var(--font-sans); font-size: 12px;
  background: var(--bg-subtle); border-bottom: 1px solid var(--line); color: var(--ok);
  flex-shrink: 0;
}
.ws-toast.is-err { color: var(--accent); }

.ws-list-wrap { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
.ws-list { flex: 1; }

.ws-empty {
  padding: 56px 28px; max-width: 440px;
  color: var(--fg-muted); font-size: 13px; line-height: 1.7;
}
.ws-empty strong {
  display: block; font-family: var(--font-serif); font-size: 20px;
  color: var(--fg); margin-bottom: 6px;
}

/* Atlas Rows with Inline Live SVG Plate */
.c-plate-row {
  width: 100%; border: none; border-bottom: 1px solid var(--line);
  background: transparent; cursor: pointer; text-align: left;
  padding: 14px 22px;
  display: grid; grid-template-columns: 112px 1fr auto; gap: 16px; align-items: center;
  border-left: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.c-plate-row:hover { background: var(--bg-hover); }
.c-plate-row.selected { background: var(--bg-active); border-left-color: var(--accent); }
.c-thumb {
  width: 112px; height: 64px;
  background: var(--map-bg); border: 1px solid var(--line);
  overflow: hidden; flex-shrink: 0;
}
.c-thumb svg { width: 100%; height: 100%; display: block; }

.row-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-title {
  font-family: var(--font-serif); font-size: 18px; font-weight: 700;
  line-height: 1.2; color: var(--fg);
}
.row-sub { font-size: 12.5px; color: var(--fg-muted); margin-top: 4px; }
.row-meta-pills {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px;
  font-family: var(--font-sans); font-variant-numeric: tabular-nums; font-size: 11.5px; color: var(--fg-faint);
}

.kind-tag {
  font-family: var(--font-sans); font-size: 9.5px; font-weight: 600; letter-spacing: 0.65px;
  text-transform: uppercase; color: var(--fg-muted);
  border: 1px solid var(--line); padding: 1px 5px; line-height: 1.4;
  white-space: nowrap;
}
.kind-tag.is-domain { color: var(--link); border-color: color-mix(in srgb, var(--link) 35%, transparent); }
.kind-tag.is-source { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

.prog {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-sans); font-variant-numeric: tabular-nums; font-size: 11px; color: var(--fg-muted);
  white-space: nowrap;
}
.prog-bar { width: 48px; height: 3px; background: var(--line); }
.prog-bar > i { display: block; height: 100%; background: var(--ok); }

/* Reference Shelf Rows */
.c-ref-row {
  width: 100%; border: none; border-bottom: 1px solid var(--line);
  background: transparent; cursor: pointer; text-align: left;
  padding: 14px 22px;
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  border-left: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.c-ref-row:hover { background: var(--bg-hover); }
.c-ref-row.selected { background: var(--bg-active); border-left-color: var(--accent); }
.c-ref-acts { display: flex; align-items: center; gap: 4px; }
.c-ref-row .hover-only { opacity: 0.32; transition: opacity 0.12s; }
.c-ref-row:hover .hover-only, .c-ref-row.selected .hover-only { opacity: 1; }

/* =====================================================================
   RIGHT INSPECTOR (ALIGNED 44PX HEADER + QUIET OVERFLOW MENU + SINGLE CTA)
   ===================================================================== */
.ws-inspector {
  border-left: 1px solid var(--line);
  background: var(--bg-panel);
  display: flex; flex-direction: column; overflow: hidden;
}
.ws-ins-hdr {
  position: relative;
  height: 44px; padding: 0 12px 0 18px; flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.ins-kicker {
  font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--accent);
}
.ws-ins-tools { display: flex; align-items: center; gap: 2px; position: relative; }

.ins-menu-pop {
  position: absolute; top: 34px; right: 0; z-index: 30;
  min-width: 152px; padding: 4px 0;
  background: var(--bg); border: 1px solid var(--line-strong);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.16);
}
.ins-menu-item {
  width: 100%; border: none; background: transparent; cursor: pointer;
  padding: 7px 12px; text-align: left; font-size: 12px; color: var(--fg-mid);
  display: flex; align-items: center; gap: 8px;
  transition: background 0.12s, color 0.12s;
}
.ins-menu-item:hover { background: var(--bg-hover); color: var(--fg); }
.ins-menu-item.is-danger:hover { color: var(--accent); background: var(--accent-soft); }
.ins-menu-sep { height: 1px; background: var(--line); margin: 4px 0; }

.ws-ins-body {
  flex: 1; overflow-y: auto; padding: 20px 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.ins-title { margin: 0; font-family: var(--font-serif); font-size: 26px; font-weight: 700; line-height: 1.15; }
.ins-sub { font-size: 13px; color: var(--fg-muted); margin-top: 3px; }
.ins-desc { margin: 0; font-family: var(--font-serif); font-size: 15px; line-height: 1.68; color: var(--fg-mid); }

.map-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--map-bg);
  border: 1px solid var(--line);
  overflow: hidden;
}
.map-frame svg { width: 100%; height: 100%; display: block; }
.map-frame::before, .map-frame::after {
  content: ""; position: absolute; width: 7px; height: 7px; pointer-events: none;
  border-color: var(--line-strong); border-style: solid;
}
.map-frame::before { top: 4px; left: 4px; border-width: 1px 0 0 1px; }
.map-frame::after { bottom: 4px; right: 4px; border-width: 0 1px 1px 0; }

.spec-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.spec-cell {
  padding: 8px 0;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.spec-cell:nth-child(odd) { padding-right: 12px; border-right: 1px solid var(--line); }
.spec-cell:nth-child(even) { padding-left: 12px; }
.spec-cell:nth-child(n+3) { border-top: 1px solid var(--line); }
.spec-cell.is-wide { grid-column: 1 / -1; border-right: none; padding-right: 0; }
.spec-k { font-family: var(--font-sans); font-size: 10px; font-weight: 500; letter-spacing: 0.55px; text-transform: uppercase; color: var(--fg-faint); }
.spec-v { font-family: var(--font-sans); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 500; color: var(--fg); text-align: right; }

.sem-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.sem-dot.primary { background: var(--accent); }
.sem-dot.referenced { border: 1.5px dashed var(--amber); background: transparent; }

.ins-section { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 5px; }
.ins-sec-hdr {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-display); font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--fg-faint);
}
.ins-node-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 6px; margin: 0 -6px;
  font-family: var(--font-serif); font-size: 14.5px; font-weight: 500; color: var(--fg);
  transition: background 0.12s, color 0.12s;
}
.ins-node-link:hover { background: var(--bg-hover); color: var(--accent); }
.ins-node-l { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.ins-node-l span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-node-tag { font-family: var(--font-sans); font-variant-numeric: tabular-nums; font-size: 11px; color: var(--fg-faint); flex-shrink: 0; }

.ws-ins-foot {
  padding: 12px 18px; border-top: 1px solid var(--line);
  background: var(--bg-subtle);
  flex-shrink: 0;
}
.ws-ins-foot:empty { display: none; }
.ws-ins-foot .btn-primary { width: 100%; }

/* Keyboard Shortcuts Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(17, 17, 17, 0.42); backdrop-filter: blur(3px);
  display: grid; place-items: center;
}
.modal-sheet {
  width: 400px; max-width: 92vw;
  background: var(--bg); color: var(--fg);
  border: 1.5px solid var(--fg);
  padding: 18px 20px;
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.24);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.modal-head h3 {
  margin: 0; font-family: var(--font-serif); font-size: 20px; font-weight: 700; color: var(--accent);
}
.sc-list { display: flex; flex-direction: column; }
.sc-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
  font-family: var(--font-serif); font-size: 15px; color: var(--fg-mid);
}
.sc-row:last-child { border-bottom: none; }
.sc-keys { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; }

/* Undo Toast (Bottom Center Inverted Plate) */
.undo-toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 70;
  background: var(--fg); color: var(--bg);
  border-left: 3.5px solid var(--accent);
  padding: 8px 14px;
  display: flex; align-items: center; gap: 14px;
  font-size: 12.5px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}
.undo-btn {
  border: 1px solid currentColor; background: transparent; color: inherit;
  padding: 2px 8px; font-family: var(--font-sans); font-size: 11px; font-weight: 600;
  letter-spacing: 0.5px; text-transform: uppercase; cursor: pointer;
}
.undo-btn:hover { opacity: 0.8; }

/* Drag-and-Drop Overlay */
.drop-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(19, 20, 22, 0.56);
  display: grid; place-items: center;
  pointer-events: none;
}
.drop-box {
  padding: 28px 36px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line-strong); font-size: 14px;
}
.drop-box code { font-family: var(--font-mono); color: var(--accent); }

/* =====================================================================
   MAKE ATLAS (desktop)
   Library rows and inspector states keep the Library's square language;
   the Make Atlas and Settings sheets use the "B2" style: system font,
   grouped rows, soft corners, split-well dropdowns (docs/DESIGN.md §7).
   ===================================================================== */

/* ---- Library: job rows and inspector ---- */
.btn-secondary {
  height: 34px; padding: 0 14px; border: 1px solid var(--fg); background: transparent; color: var(--fg);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-size: 11.5px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  cursor: pointer; white-space: nowrap;
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-primary.sm { height: 26px; padding: 0 10px; font-size: 10.5px; letter-spacing: 1px; }
.ws-ins-foot .btn-secondary { width: 100%; }
.ws-ins-foot .foot-row { display: flex; gap: 8px; margin-top: 8px; }
.ws-ins-foot .foot-row > * { flex: 1; }
.ins-kicker.is-ok { color: var(--ok); }
.kind-tag.is-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.kind-tag.is-alert { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.prog-bar.is-making > i { background: var(--accent); transition: width 0.5s; }
.prog-bar.is-wide { width: 120px; }
.c-thumb.is-pending { background: repeating-linear-gradient(-45deg, var(--map-bg) 0 6px, transparent 6px 12px), var(--bg-subtle); }
.sem-dot.is-done { background: var(--ok); }
.sem-dot.is-active { background: var(--accent); }
.sem-dot.is-wait { border: 1px solid var(--line-strong); }
.sem-dot.is-stopped { border: 1.5px solid var(--accent); }
.stage-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.stage-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-family: var(--font-serif); font-size: 15px; color: var(--fg-mid); }
.stage-row.is-active { color: var(--fg); font-weight: 700; }
.stage-row.is-wait { color: var(--fg-faint); }
.stage-st { margin-left: auto; font-family: var(--font-sans); font-size: 11px; color: var(--fg-muted); font-variant-numeric: tabular-nums; font-weight: 400; }
.stage-st.is-alert { color: var(--accent); }
.notice { border-left: 3.5px solid var(--accent); background: var(--bg); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.notice-t { font-family: var(--font-serif); font-size: 16px; font-weight: 700; color: var(--accent); }
.notice-b { font-size: 12.5px; line-height: 1.6; color: var(--fg-mid); overflow-wrap: anywhere; }
.note { font-size: 12px; line-height: 1.6; color: var(--fg-muted); }
.undo-toast.is-ok { border-left-color: var(--ok); }

/* ---- Sheets (B2) ---- */
.mk-sheet {
  width: 640px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px);
  background: var(--bg); color: var(--fg); font-family: var(--font-system); font-size: 13px;
  border-radius: 10px; box-shadow: 0 0 0 1px var(--line-strong), 0 20px 54px rgba(0, 0, 0, 0.26);
  display: flex; flex-direction: column; overflow: hidden;
}
.mk-sheet.is-wide { width: 900px; }
.mk-head { height: 48px; padding: 0 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; flex-shrink: 0; }
.mk-head-title { font-weight: 600; }
.mk-head-left { justify-self: start; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.mk-back { justify-self: start; border: 0; background: transparent; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.mk-close { justify-self: end; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--bg-active); color: var(--fg-muted); font-size: 14px; line-height: 1; cursor: pointer; }
.mk-close:hover { color: var(--fg); }
.mk-body { padding: 22px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.mk-sheet.is-wide { height: min(740px, calc(100vh - 48px)); }
.mk-body.is-split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: minmax(0, 1fr); gap: 24px; overflow: hidden; }
.mk-body.is-split > .mk-col:first-child { min-height: 0; overflow-y: auto; padding-bottom: 2px; }
.mk-body.is-split > .mk-col:last-child { align-self: start; min-height: 0; max-height: 100%; overflow-y: auto; padding-bottom: 2px; }
.mk-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.mk-h1 { margin: 0; font-family: var(--font-serif); font-size: 30px; font-weight: 700; line-height: 1.1; }
.mk-sub { margin: 4px 0 0; color: var(--fg-muted); line-height: 1.5; }
.mk-label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 0 2px; font-weight: 600; }
.mk-label > span { font-weight: 400; color: var(--fg-muted); }
.mk-group { background: var(--bg-subtle); border-radius: 8px; overflow: hidden; }
.mk-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.mk-row:last-child { border-bottom: 0; }
.mk-row.is-wrap { flex-wrap: wrap; }
.mk-row-k { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mk-row-k small { font-size: 11.5px; color: var(--fg-muted); }
.mk-row-k small.is-alert { color: var(--accent); }
.mk-row-k small.is-ok { color: var(--ok); }
.mk-row-acts { display: flex; gap: 6px; flex-shrink: 0; }
.mk-muted { color: var(--fg-muted); }
.mk-num { font-variant-numeric: tabular-nums; }
.mk-note { margin: 0; font-size: 12px; line-height: 1.55; color: var(--fg-muted); }
.mk-note.is-ok { color: var(--ok); }
.mk-note.is-alert { color: var(--accent); }
.mk-link { border: 0; background: transparent; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: none; }
.mk-link:hover { text-decoration: underline; }

.mk-btn { height: 30px; padding: 0 14px; border-radius: 6px; border: 0; background: var(--bg-active); font: inherit; color: var(--fg); cursor: pointer; white-space: nowrap; }
.mk-btn:hover { background: color-mix(in srgb, var(--fg) 12%, transparent); }
.mk-btn.primary { background: var(--accent); color: #fafaf7; font-weight: 600; padding: 0 16px; }
.mk-btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.mk-btn.quiet { background: transparent; color: var(--fg-muted); }
.mk-btn.quiet:hover { color: var(--fg); background: var(--bg-hover); }
.mk-btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.mk-foot { height: 58px; padding: 0 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-shrink: 0; }
.mk-foot .mk-note { margin-right: auto; }

.mk-seg { display: inline-flex; padding: 2px; border-radius: 6px; background: var(--mk-track); }
.mk-seg button { height: 22px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; font: inherit; font-size: 12px; color: var(--fg-mid); cursor: pointer; white-space: nowrap; }
.mk-seg button.on { background: var(--mk-raised); color: var(--fg); box-shadow: 0 1px 2px var(--mk-shadow); }
.mk-seg.is-block { display: flex; }
.mk-seg.is-block button { flex: 1; height: 26px; }

.mk-choice { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 44px; padding: 8px 12px; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.mk-choice:last-child { border-bottom: 0; }
.mk-choice:hover { background: var(--bg-hover); }
.mk-radio { width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--bg); display: grid; place-items: center; }
.mk-radio.on { border-color: var(--accent); background: var(--accent); }
.mk-radio.on::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #fafaf7; }

.mk-field-group { display: flex; border-radius: 6px; box-shadow: 0 0 0 1px var(--line-strong); overflow: hidden; background: var(--mk-raised); }
.mk-field-group:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.mk-field-group.is-ok { box-shadow: 0 0 0 1px color-mix(in srgb, var(--ok) 60%, transparent); }
.mk-field-group input { flex: 1; min-width: 0; height: 30px; border: 0; padding: 0 10px; font: inherit; color: var(--fg); background: transparent; outline: none; }
.mk-field-group input::placeholder { color: var(--fg-faint); }
.mk-field-group button { border: 0; border-left: 1px solid var(--line); background: var(--bg-subtle); padding: 0 12px; font: inherit; font-weight: 500; color: var(--fg); cursor: pointer; white-space: nowrap; }
.mk-field-group button:disabled { opacity: 0.5; cursor: default; }

/* dropdown button with the arrow in its own well; the menu floats (position: fixed) */
.mk-popup { height: 28px; min-width: 160px; max-width: 100%; padding: 0 0 0 10px; border: 0; border-radius: 6px; background: var(--bg); box-shadow: 0 0 0 1px var(--line-strong), 0 1px 2px var(--mk-shadow); font: inherit; color: var(--fg); display: inline-flex; align-items: center; justify-content: space-between; gap: 10px; overflow: hidden; cursor: pointer; text-align: left; }
.mk-popup.is-block { width: 100%; }
.mk-popup-val { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-popup-val span { color: var(--fg-muted); }
.mk-popup-well { width: 26px; align-self: stretch; border-left: 1px solid var(--line); background: var(--mk-well); display: grid; place-items: center; color: var(--fg-muted); flex-shrink: 0; transition: background 0.12s, color 0.12s; }
.mk-popup:hover { background: var(--mk-raised); }
.mk-popup:hover .mk-popup-well { color: var(--fg); background: var(--bg-active); }
.mk-popup[aria-expanded="true"] { background: var(--mk-raised); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent); }
.mk-popup[aria-expanded="true"] .mk-popup-well { background: var(--accent); color: #fafaf7; border-left-color: transparent; }
.mk-popup[aria-expanded="true"] .mk-popup-well svg { transform: rotate(180deg); }

.mk-menu { position: fixed; z-index: 200; width: 340px; border-radius: 8px; background: var(--mk-raised); color: var(--fg); font-family: var(--font-system); font-size: 13px; box-shadow: 0 0 0 1px var(--line-strong), 0 10px 28px var(--mk-shadow); display: flex; flex-direction: column; overflow: hidden; }
.mk-menu-search { height: 34px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); color: var(--fg-muted); flex-shrink: 0; }
.mk-menu-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: inherit; color: var(--fg); }
.mk-menu-list { padding: 4px; overflow-y: auto; }
.mk-menu-sec { padding: 8px 8px 4px; font-size: 11px; font-weight: 600; color: var(--fg-muted); display: flex; justify-content: space-between; gap: 8px; }
.mk-menu-sec .is-alert { color: var(--accent); font-weight: 400; }
.mk-menu-item { width: 100%; border: 0; background: transparent; border-radius: 5px; padding: 6px 8px; display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 8px; align-items: center; font: inherit; color: var(--fg); text-align: left; cursor: pointer; }
.mk-menu-item:hover, .mk-menu-item.is-active { background: var(--bg-hover); }
.mk-menu-item.is-sel { background: var(--bg-subtle); }
.mk-menu-item:disabled { color: var(--fg-faint); cursor: default; background: transparent; }
.mk-menu-item small { display: block; font-size: 11px; color: var(--fg-muted); }
.mk-menu-item .tick { color: var(--accent); }
.mk-menu-item .aside { font-size: 11.5px; color: var(--fg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mk-menu-item:disabled .aside { color: var(--accent); }
.mk-menu-empty { padding: 14px 10px; font-size: 12px; color: var(--fg-muted); }
.mk-menu-foot { padding: 8px 12px; border-top: 1px solid var(--line); background: var(--bg-subtle); font-size: 11.5px; line-height: 1.5; color: var(--fg-muted); flex-shrink: 0; }

/* source */
.mk-drop { height: 180px; border-radius: 8px; background: var(--bg-subtle); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 0 16px; }
.mk-drop.is-over { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.mk-drop-title { font-family: var(--font-serif); font-size: 21px; font-weight: 700; }
.mk-file-badge { width: 30px; height: 36px; border-radius: 4px; background: var(--bg); box-shadow: 0 0 0 1px var(--line-strong); display: grid; place-items: center; font-size: 9px; font-weight: 700; color: var(--accent); flex-shrink: 0; }
.mk-checks { list-style: none; margin: 0; padding: 0; }
.mk-checks li { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.mk-checks li:last-child { border-bottom: 0; }
.mk-checks svg { color: var(--ok); flex-shrink: 0; }
.mk-checks li.is-warn svg { color: var(--accent); }

/* review: section list */
.mk-sec-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 34px; padding: 6px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.mk-sec-row:last-child { border-bottom: 0; }
.mk-sec-row input { margin: 0; width: 14px; height: 14px; accent-color: var(--accent); }
.mk-sec-row .lbl { color: var(--fg-muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.mk-sec-row .tag { margin-left: 6px; font-size: 11px; color: var(--fg-muted); }
.mk-sec-row.is-off .ttl { color: var(--fg-faint); }
.mk-sec-row .meta { font-size: 12px; color: var(--fg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* settings: stepper, status dots */
.mk-stepper { display: inline-flex; align-items: center; border-radius: 6px; background: var(--mk-track); padding: 2px; }
.mk-stepper button { width: 24px; height: 22px; border: 0; border-radius: 4px; background: transparent; color: var(--fg); font-size: 14px; cursor: pointer; }
.mk-stepper button:hover { background: var(--mk-raised); }
.mk-stepper span { min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }
.mk-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.mk-dot.ok { background: var(--ok); }
.mk-dot.bad { background: var(--accent); }
.mk-dot.none { box-shadow: inset 0 0 0 1px var(--line-strong); }

/* domain review: how the atlas is made */
.mk-steps { list-style: none; margin: 0; padding: 0; }
.mk-steps li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.mk-steps li:last-child { border-bottom: 0; }
.mk-steps .mk-row-k small { line-height: 1.5; margin-top: 2px; }
.mk-step-n { width: 20px; height: 20px; border-radius: 50%; background: var(--mk-track); color: var(--fg-mid); display: grid; place-items: center; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* rows that a choice hides (readings rows when readings are off) */
.mk-row.hidden { display: none; }
/* a segmented control that allows several choices (reading kinds) */
.mk-seg.is-multi { flex-wrap: wrap; }
.mk-seg.is-multi button.on::before { content: "✓ "; color: var(--accent); }
/* scrolling columns: groups keep their height instead of shrinking (and clipping rows) */
.mk-body.is-split > .mk-col > *, .mk-col > .mk-col > * { flex-shrink: 0; }
