/* Soma Studio — shell and components. Tokens only; no hex values here. */

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* Titlebar ---------------------------------------------------------------- */
.titlebar {
  height: var(--titlebar-h);
  flex: 0 0 var(--titlebar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  background: var(--titlebar);
  border-bottom: 1px solid var(--line);
  user-select: none;
}
.title-left, .title-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.title-left strong { font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.title-left .workspace-name {
  color: var(--muted);
  font-size: 11.5px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-solid));
}
.command {
  flex: 0 1 560px;
  margin: 0 auto;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input);
  color: var(--faint);
  font-size: 11.5px;
}
.command span { flex: 1; text-align: left; }
.icon-btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.icon-btn.small { width: 22px; height: 22px; }
.engine-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--faint);
  white-space: nowrap;
}
.verify-chip {
  height: 20px;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 9.5px;
  color: var(--faint);
  white-space: nowrap;
}
.verify-chip.ok { color: var(--green); border-color: var(--green); background: var(--green-soft); }
.verify-chip.bad { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.title-action {
  height: 22px;
  padding: 0 7px;
  font-size: 10px;
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}
.title-action:hover { background: var(--panel-2); border-color: var(--accent-line); color: var(--ink); }
.statusbar .font-probe { height: 18px; line-height: 16px; padding: 0 6px; font-size: 9.5px; }
.font-probe {
  font-size: 10.5px;
  line-height: 18px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--faint);
  white-space: nowrap;
  cursor: default;
}
.font-probe.ok { color: var(--green); border-color: var(--green); background: var(--green-soft); }
.font-probe.warn { color: var(--amber); border-color: var(--amber); background: var(--amber-soft); }
.font-probe.bad { color: var(--red); border-color: var(--red); background: var(--red-soft); }
@media (max-width: 1180px) {
  .font-probe { display: none; }
}
.dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: var(--faint);
}
.dot.ok { background: var(--green); }
.dot.warn { background: var(--amber); }
.dot.bad { background: var(--red); }

/* Body ------------------------------------------------------------------- */
.body { flex: 1; min-height: 0; display: flex; position: relative; }

/* Sidebar ---------------------------------------------------------------- */
.sidebar {
  width: 216px;
  flex: 0 0 216px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--side);
  border-right: 1px solid var(--line);
}
.sidebar.collapsed { display: none; }
.side-head {
  height: var(--chrome-h);
  flex: 0 0 var(--chrome-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px 0 12px;
  border-bottom: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 750;
  color: var(--faint);
}
.side-head .fill { flex: 1; }
.nav { flex: 1; overflow-y: auto; padding: 8px 6px 12px; }
.nav-group { margin-bottom: 10px; }
.nav-title {
  display: block;
  padding: 5px 8px 4px;
  font-size: 10px;
  font-weight: 750;
  color: var(--faint);
}
.nav-item {
  width: 100%;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  text-align: left;
}
.nav-item:hover { background: var(--panel-2); color: var(--ink); }
.nav-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--ink);
}
.nav-item .nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-item .nav-meta {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.nav-empty { padding: 4px 8px; font-size: 11px; color: var(--faint); }
.side-foot {
  padding: 9px 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 10.5px;
  color: var(--faint);
}
.side-foot .mono { font-size: 10px; }

/* Main / tabs ------------------------------------------------------------ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tabs {
  height: var(--chrome-h);
  flex: 0 0 var(--chrome-h);
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 0 8px;
  background: var(--titlebar);
  border-bottom: 1px solid var(--line);
}
.tab-scroll {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-scroll::-webkit-scrollbar { display: none; }
.tab {
  height: 25px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 7px 0 10px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  background: transparent;
}
.tab:hover { background: var(--panel-2); color: var(--ink-2); }
.tab.active {
  height: 26px;
  top: 1px;
  position: relative;
  background: var(--bg);
  border-color: var(--line);
  color: var(--ink);
}
.tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 1px;
  background: var(--accent);
}
.tab-label {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab-dirty {
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  border-radius: 50%;
  background: var(--amber);
}
.tab-close {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  display: none;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--faint);
}
.tab:hover .tab-close, .tab.active .tab-close { display: grid; }
.tab-close:hover { background: var(--elevated); color: var(--ink); }
.tab-add {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  margin-bottom: 2px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--faint);
  font-size: 16px;
}
.tab-add:hover { background: var(--panel-2); color: var(--ink); }
.tabs-fill { flex: 1; }

/* Breadcrumb ------------------------------------------------------------- */
.breadcrumb {
  height: var(--breadcrumb-h);
  flex: 0 0 var(--breadcrumb-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 11px;
  background: var(--side);
  white-space: nowrap;
}
.crumb { color: var(--faint); }
.crumb strong { color: var(--ink-2); font-weight: 600; }
.crumb-sep { color: var(--line-2); }
.crumb-fill { flex: 1; }
.mode-switch {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 1px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--input);
}
.mode-btn {
  height: 21px;
  padding: 0 8px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}
.mode-btn:hover { color: var(--ink); background: var(--panel-2); }
.mode-btn.active { color: var(--on-accent); background: var(--accent-solid); font-weight: 650; }
.mode-btn:disabled { opacity: .45; cursor: not-allowed; }
.page-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.page-btn {
  height: 22px;
  min-width: 22px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--input);
  color: var(--muted);
  font-size: 11px;
}
.page-btn:hover:not(:disabled) { color: var(--ink); border-color: var(--line-2); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-input, .zoom-select {
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--input);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 0 4px;
}
.page-input { width: 42px; text-align: center; }
.zoom-select { padding: 0 2px; }
.breadcrumb .chip {
  height: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 9.5px;
  color: var(--muted);
}
.breadcrumb .chip.warn { border-color: var(--amber); color: var(--amber); background: var(--amber-soft); }
.breadcrumb .chip.bad { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.breadcrumb .chip.ok { border-color: var(--green); color: var(--green); background: var(--green-soft); }

/* Content / workspace ---------------------------------------------------- */
.content { flex: 1; min-height: 0; overflow: hidden; }
.workspace { height: 100%; min-height: 0; display: flex; }
.pane {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.pane-head {
  height: 29px;
  flex: 0 0 29px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
}
.pane-head .fill { flex: 1; }
.proof-controls { display: flex; align-items: center; gap: 4px; margin-left: 4px; }
.proof-controls .page-btn, .proof-controls .page-input, .proof-controls .zoom-select { height: 21px; }
@media (max-width: 1500px) {
  .proof-controls .zoom-select { display: none; }
}
.pane-head .badge {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  font-weight: 400;
}
.pane-body { flex: 1; min-height: 0; overflow: auto; }
.split-resizer {
  width: var(--resizer-w);
  flex: 0 0 var(--resizer-w);
  cursor: col-resize;
  position: relative;
  touch-action: none;
}
.split-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 1px;
  background: var(--line);
}
.split-resizer:hover::after, .split-resizer.dragging::after { background: var(--accent); }
.split-resizer[hidden] { display: none; }

/* Diagnostic page -------------------------------------------------------- */
.doc-page {
  height: 100%;
  overflow: auto;
  padding: 20px 22px 26px;
  container-type: inline-size;
}
.doc-page h1 { margin: 0 0 6px; font-size: 19px; letter-spacing: -.02em; }
.doc-page .lead { margin: 0 0 16px; color: var(--muted); font-size: 12px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 700; }
.panel-head p { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.panel-body { padding: 13px; }
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.kv {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  min-width: 0;
}
.kv .k { font-size: 9.5px; color: var(--faint); font-weight: 700; }
.kv .v {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table-wrap { overflow: auto; }
table.compact {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
table.compact th {
  text-align: left;
  font-size: 9.5px;
  color: var(--faint);
  background: var(--panel-2);
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.compact td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: middle;
}
table.compact tr:last-child td { border-bottom: 0; }
table.compact tbody tr:hover td { background: var(--panel-2); }
table.compact td.num, table.compact th.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 9.5px;
  font-weight: 700;
  white-space: nowrap;
}
.pill.ok { color: var(--green); background: var(--green-soft); border-color: var(--green); }
.pill.warn { color: var(--amber); background: var(--amber-soft); border-color: var(--amber); }
.pill.bad { color: var(--red); background: var(--red-soft); border-color: var(--red); }
.pill.info { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }

/* Editor ----------------------------------------------------------------- */
.editor-wrap { position: relative; height: 100%; min-height: 0; background: var(--bg); }
.source-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 10px 14px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  tab-size: 4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-x: hidden;
  overflow-y: auto;
}
.source-input:focus { background: var(--bg); }
.source-readonly { opacity: .85; }

/* Proof ------------------------------------------------------------------ */
.proof-scroll {
  height: 100%;
  overflow: auto;
  background: var(--canvas);
  padding: 24px;
}
.proof-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  min-height: 100%;
}
.page-slot {
  position: relative;
  flex: 0 0 auto;
  background: var(--paper);
  box-shadow: var(--page-shadow);
  border: 1px solid var(--paper-edge);
}
.page-scale {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
}
.page-host { position: relative; width: 100%; height: 100%; }
.page-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  background: var(--paper);
}
.proof-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
}

/* Live loupe ------------------------------------------------------------- */
.live-wrap {
  height: 100%;
  overflow: auto;
  background: var(--canvas);
  padding: 20px;
}
.live-sheet {
  position: relative;
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  box-shadow: var(--page-shadow);
  transform-origin: top left;
}
.live-atom {
  position: absolute;
  white-space: pre;
  color: var(--ink);
}
.live-line-guide {
  position: absolute;
  border-top: 1px dashed var(--trim-zone);
}
.live-flag {
  position: absolute;
  right: -3px;
  width: 3px;
  border-radius: 2px;
}
.live-flag.overfull { background: var(--flag-overfull); }
.live-flag.emergency { background: var(--flag-emergency); }
.live-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 10px;
}
.live-status .fill { flex: 1; }
.live-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 24px;
}

/* Inspect ---------------------------------------------------------------- */
.inspect { display: flex; height: 100%; min-height: 0; }
.inspect-canvas { flex: 1 1 0; min-width: 0; min-height: 0; }
.inspect-side {
  flex: 0 0 46%;
  min-width: 320px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--side);
  border-left: 1px solid var(--line);
}
.inspect-head {
  height: 29px;
  flex: 0 0 29px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 700;
  color: var(--faint);
}
.inspect-head .fill { flex: 1; }
.inspect-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.inspect-tab {
  height: 24px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
}
.inspect-tab:hover { color: var(--ink); background: var(--panel-2); }
.inspect-tab.active { color: var(--ink); background: var(--panel-2); border-color: var(--line); }
.inspect-body { flex: 1; min-height: 0; overflow: auto; }
.line-table { font-size: 10.5px; }
.line-table th { padding: 6px 7px; }
.line-table td { padding: 5px 7px; }
.line-table tr.selected td { background: var(--accent-soft); }
.line-table tr.clickable { cursor: pointer; }
.ratio-cell { position: relative; min-width: 70px; }
.ratio-bar {
  position: absolute;
  top: 50%;
  height: 5px;
  border-radius: 3px;
  transform: translateY(-50%);
  background: var(--accent-line);
  opacity: .7;
}
.ratio-bar.negative { background: var(--amber); }
.flag-list { display: flex; gap: 3px; flex-wrap: wrap; }
.mini-flag {
  font-size: 8.5px;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.mini-flag.bad { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.mini-flag.warn { color: var(--amber); border-color: var(--amber); background: var(--amber-soft); }
.mini-flag.info { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  padding: 10px;
}
.stat {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 9px;
  background: var(--panel-2);
}
.stat .k { font-size: 9px; color: var(--faint); font-weight: 700; }
.stat .v { font-family: var(--mono); font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.histogram {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.hist-bar {
  flex: 1;
  min-width: 3px;
  background: var(--accent-line);
  border-radius: 2px 2px 0 0;
  opacity: .8;
}
.hist-bar.hot { background: var(--amber); }
.hist-axis { display: flex; justify-content: space-between; padding: 0 12px 10px; font-family: var(--mono); font-size: 9px; color: var(--faint); }
.params { padding: 10px 12px; }
.params dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; }
.params dt { color: var(--muted); font-size: 10.5px; }
.params dd { margin: 0; font-family: var(--mono); font-size: 10.5px; color: var(--ink); text-align: right; }
.params .note { margin-top: 12px; padding: 8px 9px; border: 1px solid var(--amber); background: var(--amber-soft); color: var(--amber); border-radius: 5px; font-size: 10px; }

/* Compare ---------------------------------------------------------------- */
.compare { display: flex; height: 100%; min-height: 0; }
.compare-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.compare-col:last-child { border-right: 0; }
.compare-body { flex: 1; overflow: auto; padding: 14px; }
.compare-line {
  display: flex;
  gap: 10px;
  padding: 3px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
}
.compare-line:hover { background: var(--panel-2); }
.compare-line.diff { background: var(--amber-soft); }
.compare-line .n { width: 22px; color: var(--faint); text-align: right; flex: 0 0 22px; }
.compare-line .t { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.compare-summary { padding: 10px 12px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }

/* AI dock ---------------------------------------------------------------- */
.ai-dock {
  width: 0;
  flex: 0 0 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--side);
  border-left: 1px solid transparent;
}
.ai-dock.open { width: 420px; flex: 0 0 420px; border-left-color: var(--line); }
.ai-header {
  height: var(--chrome-h);
  flex: 0 0 var(--chrome-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--titlebar);
  white-space: nowrap;
}
.ai-header strong { font-size: 11.5px; font-weight: 700; }
.ai-header select {
  width: auto;
  min-width: 150px;
  max-width: 210px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--input);
  color: var(--ink);
  font-size: 11px;
}
.ai-fill { flex: 1; }
.ai-stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ai-empty {
  margin: auto 0;
  text-align: center;
  color: var(--muted);
  padding: 24px 12px;
}
.ai-empty .mark {
  width: 40px;
  height: 40px;
  margin: 0 auto 8px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--on-accent);
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-solid));
}
.ai-empty strong { display: block; font-size: 15px; color: var(--ink); margin-bottom: 4px; }
.ai-empty p { margin: 0; font-size: 11.5px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.suggestion {
  padding: 3px 9px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
}
.msg { max-width: 96%; }
.msg.user { align-self: flex-end; }
.msg-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 9.5px;
  color: var(--faint);
}
.msg-head .badge {
  padding: 0 5px;
  border: 1px solid var(--amber);
  border-radius: 999px;
  color: var(--amber);
  background: var(--amber-soft);
  font-weight: 700;
}
.msg-body {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.msg.assistant .msg-body { background: var(--panel-2); border-top-left-radius: 3px; }
.msg.user .msg-body { background: var(--bubble-user); border-color: var(--accent-line); }
.ai-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 11px 12px;
  border-top: 1px solid var(--line);
  background: var(--titlebar);
}
.ai-composer textarea {
  width: 100%;
  min-height: 98px;
  max-height: 220px;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--input);
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.7;
  resize: vertical;
}
.ai-composer-row { display: flex; align-items: center; gap: 8px; }
.ai-composer-row .hint { flex: 1; font-size: 9.5px; color: var(--faint); }
.primary {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--accent-solid);
  border-radius: 6px;
  background: var(--accent-solid);
  color: var(--on-accent);
  font-weight: 650;
}
.primary:hover { background: var(--accent-solid-hover); }
.primary:disabled { opacity: .55; cursor: not-allowed; }
.ghost {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink-2);
}
.ghost:hover { border-color: var(--accent-line); color: var(--ink); }
.mini {
  height: 25px;
  padding: 0 8px;
  border: 1px solid var(--accent-line);
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
}

/* Markdown in AI --------------------------------------------------------- */
.md { overflow-wrap: anywhere; }
.md p { margin: 0 0 8px; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 {
  margin: 12px 0 6px;
  line-height: 1.4;
  color: var(--ink);
  font-weight: 700;
}
.md h1 { font-size: 16px; }
.md h2 { font-size: 14.5px; }
.md h3 { font-size: 13.5px; }
.md h4 { font-size: 13px; }
.md ul, .md ol { margin: 6px 0 9px; padding-left: 18px; }
.md li { margin: 2px 0; }
.md code { font-size: 11px; background: var(--code-bg); padding: 1px 4px; border-radius: 4px; }
.md pre { margin: 8px 0; padding: 9px 11px; font-size: 10.5px; line-height: 1.6; background: var(--pre-bg); }
.md pre code { background: transparent; padding: 0; }
.md blockquote { margin: 8px 0; padding: 2px 0 2px 10px; border-left: 2px solid var(--accent-line); color: var(--muted); }
.md table { width: 100%; min-width: 0; margin: 8px 0; border-collapse: collapse; font-size: 11px; }
.md th, .md td { padding: 5px 7px; border: 1px solid var(--line); text-align: left; vertical-align: top; white-space: normal; }
.md th { background: var(--panel-2); color: var(--muted); font-size: 9.5px; font-weight: 700; }
.md a { color: var(--accent-2); text-decoration: underline; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

/* Status bar ------------------------------------------------------------- */
.statusbar {
  height: var(--statusbar-h);
  flex: 0 0 var(--statusbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  background: var(--titlebar);
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 10.5px;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}
.statusbar .mono { font-size: 10px; font-variant-numeric: tabular-nums; }
.status-fill { flex: 1; }
.status-item { display: inline-flex; align-items: center; gap: 5px; }
.status-mode { color: var(--ink-2); font-weight: 700; }

/* Resizers --------------------------------------------------------------- */
.resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--resizer-w);
  z-index: 25;
  cursor: col-resize;
  touch-action: none;
}
.sidebar > .resizer { right: 0; }
.ai-dock > .resizer { left: 0; }
.resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 1px;
  background: transparent;
}
.resizer:hover::after, .resizer.dragging::after { background: var(--accent); }

/* Palette ---------------------------------------------------------------- */
.palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: start center;
  padding-top: 12vh;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(2px);
}
.palette {
  width: min(640px, calc(100vw - 32px));
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  box-shadow: var(--shadow-menu);
  overflow: hidden;
}
.palette-input {
  height: 44px;
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}
.palette-input input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}
.palette-list { flex: 1; overflow-y: auto; padding: 5px; }
.palette-group {
  padding: 7px 9px 4px;
  font-size: 9.5px;
  font-weight: 750;
  color: var(--faint);
}
.palette-row {
  width: 100%;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
}
.palette-row:hover, .palette-row.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--ink);
}
.palette-row .icon { width: 16px; color: var(--faint); text-align: center; }
.palette-row .label { flex: 1; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-row .hint { font-size: 10.5px; color: var(--faint); }
.palette-foot {
  height: 28px;
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  color: var(--faint);
}

/* Banners, empty states, toasts ------------------------------------------ */
.banner {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 10px 12px 0;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.banner .fill { flex: 1; }
.banner.info { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.banner.warn { color: var(--amber); background: var(--amber-soft); border-color: var(--amber); }
.banner.bad { color: var(--red); background: var(--red-soft); border-color: var(--red); }
.banner.ok { color: var(--green); background: var(--green-soft); border-color: var(--green); }
.empty-state {
  height: 100%;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}
.empty-state .mark {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--on-accent);
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-solid));
  margin-bottom: 4px;
}
.empty-state strong { font-size: 15px; color: var(--ink); font-weight: 700; }
.empty-state span { font-size: 11.5px; }
.empty-actions { display: flex; gap: 8px; margin-top: 8px; }
.empty-actions .primary, .empty-actions .ghost { height: 28px; padding: 0 12px; }
.toasts {
  position: fixed;
  right: 16px;
  bottom: 36px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: 420px;
  padding: 9px 12px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: var(--shadow-menu);
  color: var(--ink-2);
  font-size: 11.5px;
}
.toast.bad { border-color: var(--red); color: var(--red); }
.toast.ok { border-color: var(--green); color: var(--green); }

/* Focus and motion ------------------------------------------------------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-soft);
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Responsive ------------------------------------------------------------- */
@media (max-width: 1500px) {
  .inspect-side { flex-basis: 50%; }
}
@media (max-width: 1280px) {
  .ai-dock.open {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 30;
    width: 420px !important;
    flex-basis: 420px !important;
    box-shadow: var(--shadow-dock);
  }
}
@media (max-width: 1180px) {
  .workspace { flex-direction: column; }
  .split-resizer { display: none; }
  .inspect { flex-direction: column; }
  .inspect-side { flex: 0 0 46%; width: 100%; min-width: 0; border-left: 0; border-top: 1px solid var(--line); }
  .compare { flex-direction: column; }
  .compare-col { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 980px) {
  .sidebar { display: none; }
  .sidebar-toggle { display: none; }
  .mode-switch .mode-btn { padding: 0 6px; }
}
@media (max-width: 760px) {
  .ai-dock.open {
    position: absolute;
    inset: 0;
    width: 100% !important;
    flex-basis: 100% !important;
  }
  .doc-page { padding: 14px 12px 20px; }
  .breadcrumb { gap: 4px; padding: 0 8px; }
  .mode-switch .mode-btn[data-mode="compare"] { display: none; }
  .page-controls .zoom-select { display: none; }
  .title-left .workspace-name { display: none; }
  .statusbar { gap: 8px; }
  .statusbar .optional { display: none; }
}
@media (max-width: 520px) {
  .command { display: none; }
  .inspect-side { flex-basis: 52%; }
}
@container (max-width: 900px) {
  .doc-page .kv-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}
