:root {
  --bg: #0f1720;
  --bg2: #152030;
  --panel: #1a2736;
  --panel2: #213044;
  --ink: #e8eef5;
  --muted: #8fa3b8;
  --line: #2c3f55;
  --teal: #2a9d8f;
  --teal-dim: #1a5c55;
  --amber: #d4a017;
  --ok: #3dba7a;
  --bad: #e07070;
  --navy: #0c1520;
  --shadow: 0 12px 32px rgba(0, 0, 0, .35);
  --chrome-muted: #9db4cc;
}
html[data-font="avenir"], html[data-font="avenir"] body {
  font-family: "Avenir Next", "Segoe UI", -apple-system, sans-serif;
}
html[data-font="segoe"], html[data-font="segoe"] body {
  font-family: "Segoe UI", "Avenir Next", -apple-system, sans-serif;
}
html[data-font="system"], html[data-font="system"] body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; text-align: left; }
body {
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a3a4a 0%, transparent 55%),
    radial-gradient(900px 500px at 90% 0%, #1a2a40 0%, transparent 50%),
    var(--bg);
  min-height: 100%;
  text-align: left;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 22px;
  min-height: 64px;
  height: auto;
  overflow: visible;
  background: linear-gradient(90deg, var(--navy), #152536 55%, #163042);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  flex: 0 0 auto;
  min-width: max-content;
  overflow: hidden;
  text-align: left;
}
.logo-slot {
  display: block;
  flex: 0 0 34px;
  width: 34px;
  height: 26px;
  overflow: hidden;
}
.brand .logo {
  display: block;
  height: 26px;
  width: auto;
  max-height: 26px;
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .4));
}
.brand-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0;
}
.brand h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: .01em; color: #fff; text-align: left; white-space: nowrap; }
.brand p { margin: 2px 0 0; font-size: 11px; color: #9db4cc; text-align: left; white-space: nowrap; }
.chrome {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px 12px;
  flex: 1 1 auto;
  min-width: 0;
}
.look {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--chrome-muted);
  white-space: nowrap;
}
.look select {
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  color: #fff;
  background-color: rgba(255, 255, 255, .08);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23ffffff' d='M1 1l4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 10px 6px;
  border: 1px solid #4d7394;
  border-radius: 6px;
  padding: 4px 22px 4px 8px;
}
.page-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 4px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
}
.zoom-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.zoom-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .16); }
.zoom-btn:disabled { opacity: .35; cursor: default; }
#pageZoomPct {
  color: #fff;
  min-width: 2.8rem;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.top-actions .btn.ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, .35);
}
.top-actions .btn.ghost:hover {
  border-color: rgba(255, 255, 255, .55);
  background: rgba(255, 255, 255, .1);
}
.note-bar {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(42, 157, 143, .1);
  border: 1px solid var(--teal-dim);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
html[data-theme="day"] {
  --bg: #eef2f6;
  --bg2: #ffffff;
  --panel: #ffffff;
  --panel2: #f4f7fa;
  --ink: #1c2430;
  --muted: #667085;
  --line: #d7dee6;
  --teal-dim: #9ad4cc;
  --navy: #10263d;
  --shadow: 0 10px 30px rgba(16, 38, 61, .08);
}
html[data-theme="day"] body {
  background: var(--bg);
  color: var(--ink);
}
html[data-theme="day"] .item.on { background: #e8f4f2; }
html[data-theme="day"] .result { background: #eef7f5; }
html[data-theme="day"] .result.bad { background: #fdecec; }
html[data-theme="day"] .result.warn { background: #fff6e6; }
html[data-theme="day"] table.data th { background: #eef3f8; }
html[data-theme="day"] .note-bar { background: #e8f4f2; color: #1c2430; }
html[data-theme="day"] .tree-toggle.top .tree-label { color: #33404f; }
html[data-theme="day"] .tree-toggle.sub .tree-label { color: #4a5563; }
html[data-theme="day"] .item strong { color: #1c2430; }
html[data-theme="day"] h3 { color: #1a3a58; }
html[data-density="compact"] .btn { padding: 6px 10px; font-size: 12px; }
html[data-density="compact"] .item { padding: 6px 8px; }
html[data-density="compact"] .panel { padding: 14px 16px; }
html[data-density="compact"] .field { margin-bottom: 8px; }
html[data-density="compact"] .top { padding: 8px 16px; min-height: 56px; }
html[data-density="compact"] .rail header { padding: 10px 12px 8px; }

.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 22px 48px;
  transform-origin: top center;
}

h2, h3, .panel-kicker, .lede, .field, .field span, .tree-label,
.item, .item strong, .item em, .rail header h3, .rail header p,
.env strong, .env span, .result .lbl, .muted, .empty, table.data th {
  text-align: left;
}
h2 { margin: 0 0 8px; font-size: 22px; font-weight: 700; }
h3 { margin: 0 0 8px; font-size: 15px; font-weight: 700; color: #cfe0f0; }
.lede { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 62ch; word-spacing: .06em; }

@media (max-width: 720px) {
  .top { flex-wrap: wrap; height: auto; padding: 12px 16px; }
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  min-height: 70vh;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  word-spacing: .2em;
  text-transform: uppercase;
  color: var(--teal);
  text-align: left;
}

.tree-group { margin: 4px 0 10px; text-align: left; }
.tree-sub { margin: 2px 0; text-align: left; }
.tree-children { padding-left: 6px; text-align: left; }
.tree-children.leaf { padding-left: 10px; }

.tree-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 8px 8px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}
.tree-toggle .tree-label {
  flex: 1 1 auto;
  text-align: left;
}
.tree-toggle:hover { background: rgba(255,255,255,.04); }
.tree-toggle.top {
  margin-top: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
}
.tree-toggle.top .tree-label {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .04em;
  word-spacing: .2em;
  text-transform: uppercase;
  color: #c5d6e6;
}
.tree-toggle.sub .tree-label {
  font-size: 11px;
  font-weight: 650;
  color: #b7c9da;
}
.tree-toggle .chev {
  flex: 0 0 10px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 7px;
  border-color: transparent transparent transparent var(--muted);
  transition: transform .15s ease;
}
.tree-toggle.open .chev {
  transform: rotate(90deg);
}

.rail-empty {
  margin: 4px 10px 12px;
  font-size: 12px;
  color: var(--muted);
}

.rail, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.rail { overflow: hidden; display: flex; flex-direction: column; max-height: calc(100vh - 120px); }
.rail header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.rail header h3 { text-align: left; }
.rail header p { margin: 4px 0 0; font-size: 12px; color: var(--muted); text-align: left; word-spacing: .1em; }
.rail-body { overflow: auto; padding: 8px; flex: 1; text-align: left; }

.item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 10px 10px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}
.item:hover { background: rgba(255,255,255,.04); }
.item.on { background: rgba(42, 157, 143, .14); box-shadow: inset 3px 0 0 var(--teal); }
.item strong { display: block; font-size: 13px; font-weight: 600; color: #eef4fa; text-align: left; }
.item em { display: block; font-style: normal; font-size: 11px; color: var(--muted); margin-top: 3px; text-align: left; }
.item.val-item em { white-space: normal; line-height: 1.35; }

.panel { padding: 20px 22px 24px; min-width: 0; text-align: left; }
.meta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px 14px;
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: left;
}
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(42, 157, 143, .16);
  color: #7dd3c7;
  font-size: 11px;
  font-weight: 700;
}

.field { margin: 0 0 14px; text-align: left; }
.field span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  word-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  text-align: left;
}
.formula, .input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  padding: 12px 14px;
  font: inherit;
}
.formula {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 15px;
  min-height: 72px;
  line-height: 1.45;
  resize: vertical;
}
.input { font-size: 14px; }
.inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.actions { display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: flex-start; gap: 8px; margin: 12px 0 8px; }
.btn {
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  text-align: left;
}
.btn:hover { border-color: #4a6684; }
.btn.teal { background: var(--teal); border-color: var(--teal); color: #062a28; }
.btn.ghost { background: transparent; }

.result {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #0c1f2a;
  border: 1px solid var(--teal-dim);
}
.result.bad { background: #2a1414; border-color: #5a2a2a; }
.result.warn { background: #2a2210; border-color: #6a5420; }

.msg {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
}
.msg strong { display: inline-block; margin-right: 8px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.msg.error { background: rgba(224, 112, 112, .12); border: 1px solid #6a3030; color: #f0b4b4; }
.msg.warn { background: rgba(212, 160, 23, .12); border: 1px solid #6a5420; color: #e6c35a; }
.msg .sev { font-weight: 700; }

.path-insert {
  border: 0;
  background: transparent;
  color: #9ed7cf;
  font: inherit;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 0;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.path-insert:hover { color: #c8f0ea; }
.path-hint { font-size: 11px; color: #6f8aa0; }

.attach-filter { display: flex; gap: 6px; padding: 4px 8px 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}
.chip.on { background: rgba(42, 157, 143, .16); border-color: var(--teal-dim); color: #7dd3c7; }

.preset-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }

.review-chip.bad { background: rgba(224, 112, 112, .18); color: #f0b4b4; }
.result .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; text-align: left; }
.result .val { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; text-align: left; }
.result .resolved { margin-top: 8px; font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; text-align: left; }

.lib-block {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.lib-list { margin: 0; padding: 0; list-style: none; }
.lib-list li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(44, 63, 85, .55);
  font-size: 13px;
}
.lib-list li:last-child { border-bottom: 0; }
.lib-list code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #9ed7cf;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 220px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data th {
  position: sticky;
  top: 0;
  background: #1c2d40;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  z-index: 1;
}
table.data tr:hover td { background: rgba(255,255,255,.03); }
table.data td.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.pk { color: var(--amber); font-weight: 700; font-size: 11px; }
.muted { color: var(--muted); }
.empty { padding: 24px; color: var(--muted); font-size: 14px; }

.search {
  width: 100%;
  margin-top: 8px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
}

.review-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
  background: rgba(143, 163, 184, .18);
  color: #b7c9da;
}
.review-chip.ok { background: rgba(61, 186, 122, .18); color: #7ddeb0; }
.review-chip.warn { background: rgba(212, 160, 23, .2); color: #e6c35a; }

.rail-review-h {
  margin: 10px 8px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.rail-review-h em {
  font-style: normal;
  margin-left: 6px;
  color: #9db4cc;
}

.source-box {
  width: 100%;
  min-height: 180px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  padding: 12px 14px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 320px;
}

.ai-form, .prepare-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  justify-items: stretch;
  gap: 12px 16px;
  max-width: 720px;
  text-align: left;
}
.ai-form .wide, .prepare-form .wide { grid-column: 1 / -1; text-align: left; }
.ai-form select, .prepare-form select,
.ai-form input, .prepare-form input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  text-align: left;
}

.env-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  margin: 16px 0 8px;
  text-align: left;
}
.env {
  flex: 1 1 120px;
  min-width: 110px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg2);
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.env.on { border-color: var(--teal-dim); }
.env.is-this { box-shadow: inset 0 0 0 1px var(--teal); background: #0c1f2a; }
.env strong { display: block; font-size: 13px; margin-bottom: 6px; text-align: left; }
.env span { display: block; font-size: 11px; color: var(--muted); line-height: 1.4; text-align: left; }
.env .btn { margin-top: 10px; text-align: left; }
.env-arrow {
  align-self: center;
  color: var(--muted);
  font-style: normal;
  font-size: 14px;
}

.cand-list { margin: 0; padding: 0; list-style: none; max-width: 720px; text-align: left; }
.cand-list li {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(44, 63, 85, .55);
  font-size: 13px;
  text-align: left;
}
.cand-list li:last-child { border-bottom: 0; }
.cand-list label { display: flex; gap: 10px; align-items: flex-start; justify-content: flex-start; cursor: pointer; text-align: left; }
.cand-list strong, .cand-list em { text-align: left; }
.cand-list em { display: block; font-style: normal; color: var(--muted); font-size: 11px; margin-top: 2px; }

.release-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  margin-bottom: 12px;
}
.release-card h3 { margin: 0 0 6px; }
.btn.small { padding: 6px 10px; font-size: 12px; }

@media (max-width: 720px) {
  .ai-form, .prepare-form { grid-template-columns: 1fr; }
}

/* Empty right panel — Coras Engine picture, no editor chrome */
.engine-empty {
  text-align: left;
  padding: 8px 0 4px;
}
.engine-empty .panel-kicker { margin-bottom: 8px; }
.engine-empty h2 { margin: 0 0 6px; }
.engine-empty .lede {
  max-width: 62ch;
  margin-bottom: 16px;
}
.engine-picture {
  display: block;
  width: 100%;
  max-width: 1080px;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f4f7f9;
  box-shadow: var(--shadow);
}

.coras-frame-wrap {
  position: relative;
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  min-height: 520px;
}
.coras-frame-wrap iframe {
  display: block;
  width: 100%;
  height: min(70vh, 780px);
  border: 0;
  background: #fff;
}
.coras-frame-wrap.is-down { min-height: 0; }
.coras-down {
  margin: 0;
  padding: 16px 18px;
  background: #2a1414;
  border: 0;
  color: #f0b4b4;
  font-size: 14px;
  line-height: 1.45;
}
html[data-theme="day"] .coras-down {
  background: #fdecec;
  color: #7a2020;
}
.principals-nav { margin: 2px 0 6px; }
.principal-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #dce6f1;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}
.principal-row:hover { background: rgba(255,255,255,.05); }
.principal-row.on {
  background: rgba(46, 108, 164, .35);
  color: #fff;
  font-weight: 650;
}
.principal-row .navicon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: #cfe0f2;
}
.principal-row.on .navicon { color: #fff; }
.principal-name { font-size: 13px; }
.principal-forms { padding-left: 26px; }
.principal-forms .form-leaf { padding: 7px 10px; }
.principal-forms .form-leaf strong { font-size: 13px; }
.principal-forms .form-leaf em { display: none; }
html[data-theme="day"] .principal-row { color: #23405a; }
html[data-theme="day"] .principal-row.on { background: #2e6ca4; color: #fff; }
html[data-theme="day"] .principal-row .navicon { color: #2e6ca4; }
html[data-theme="day"] .principal-row.on .navicon { color: #fff; }

.form-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
}
.form-detail-head h2 { margin: 0; }
.form-design {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
  gap: 14px;
  align-items: start;
}
.form-stage { min-width: 0; }
.form-stage > .muted { margin: 8px 0 0; }
@media (max-width: 860px) {
  .form-design { grid-template-columns: 1fr; }
}
.field-val-panel {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px 12px;
  min-height: 220px;
  max-height: min(88vh, 980px);
  overflow: auto;
  position: sticky;
  top: 76px;
  word-spacing: .08em;
}
.field-val-panel h3 { margin: 0 0 6px; font-size: 16px; word-spacing: .08em; }
.field-val-panel .lede {
  max-width: none;
  margin-bottom: 12px;
  word-spacing: .08em;
}
.field-val-panel .muted { word-spacing: .08em; line-height: 1.45; }
.field-val-panel .rule-summary strong { word-spacing: .2em; }
.field-val-panel .pattern-chip,
.field-val-panel .sev-btn,
.field-val-panel .btn { word-spacing: .1em; }
.note-bar { word-spacing: .08em; }
.pattern-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}
.pattern-chip {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.pattern-chip.on { background: rgba(42, 157, 143, .2); border-color: var(--teal); color: #7dd3c7; }
.sev-row { display: flex; gap: 8px; margin: 8px 0 10px; }
.sev-btn {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 8px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.sev-btn.on.bad { background: rgba(224, 112, 112, .16); border-color: #8a4040; color: #f0b4b4; }
.sev-btn.on.warn { background: rgba(212, 160, 23, .16); border-color: #8a6a20; color: #e6c35a; }
.compare-row { display: flex; gap: 8px; align-items: center; }
.compare-row select, .field-val-panel input, .field-val-panel select {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
}
.compare-toggle { display: flex; gap: 6px; margin: 0 0 8px; }
.field-pick {
  position: relative;
  flex: 1 1 180px;
  min-width: 180px;
}
.field-pick-btn,
.field-pick-search,
.field-pick-item {
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: normal;
  word-spacing: normal;
}
.field-pick-btn {
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 6px 8px;
  cursor: pointer;
}
.field-pick.open .field-pick-btn {
  border-color: var(--teal);
}
.field-pick-pop {
  display: none;
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 240px;
  max-height: 280px;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.field-pick.open .field-pick-pop {
  display: flex;
}
.field-pick-search {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 10px;
}
.field-pick-search:focus {
  outline: none;
}
.field-pick-list {
  overflow: auto;
  padding: 4px 0 6px;
}
.field-pick-group-label {
  margin: 6px 10px 4px;
  font: inherit;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-pick-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 6px 10px;
  cursor: pointer;
}
.field-pick-item:hover,
.field-pick-item.on {
  background: rgba(42, 157, 143, .12);
}
.field-pick-tick {
  margin-left: auto;
  color: var(--teal);
  font-weight: 700;
}
.field-pick-empty {
  margin: 8px 10px;
}
.rule-summary {
  margin: 4px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(42, 157, 143, .1);
  border: 1px solid rgba(42, 157, 143, .25);
}
.rule-summary strong { display: block; font-size: 11px; letter-spacing: .04em; word-spacing: .2em; text-transform: uppercase; color: var(--teal); }
.rule-summary p { margin: 6px 0 0; font-size: 14px; line-height: 1.4; }
.show-rule { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.show-rule summary { cursor: pointer; }
.show-rule code { display: block; margin-top: 8px; font-size: 12px; word-break: break-all; color: var(--ink); }
.field-val-existing { margin: 8px 0; }
.cond-block { margin: 0 0 12px; }
.cond-label {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.cond-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 0 0 8px;
}
.cond-row select, .cond-row .cond-val {
  width: auto;
  min-width: 0;
  flex: 1 1 72px;
  padding: 6px 8px;
}
.cond-row .btn.small { flex: 0 0 auto; }
.cond-and { color: var(--muted); font-size: 12px; }
.cond-join {
  display: flex;
  justify-content: flex-start;
  margin: 0 0 8px 2px;
}
.cond-join select {
  width: auto;
  min-width: 72px;
  padding: 4px 8px;
  font-weight: 600;
  letter-spacing: .04em;
}
.cond-hint { margin: 8px 0 0; font-size: 12px; }
.formula-line-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.formula-line-head > span { margin-bottom: 0; }
.formula-line-actions { display: flex; gap: 6px; flex-shrink: 0; }
.formula-line input.cond-formula {
  width: 100%;
  min-height: 0;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.field-fn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}
.field-fn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  font-size: 11px;
  letter-spacing: .04em;
  cursor: pointer;
}
.field-fn:hover {
  border-color: var(--teal);
  color: #7dd3c7;
}
.field-fn-hint {
  flex: 1 1 100%;
  margin: 2px 0 0;
  font-size: 12px;
}
.cond-row .field-pick {
  flex: 1 1 180px;
  min-width: 180px;
}
.test-block {
  margin: 4px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
}
details.test-cases {
  margin: 4px 0 12px;
  padding: 8px 12px 10px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 13px;
}
details.test-cases > summary {
  cursor: pointer;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 0;
}
details.test-cases[open] > summary { margin-bottom: 10px; }
.test-plan { margin: 10px 0 0; }
.test-plan ul { margin: 6px 0 0; padding-left: 18px; }
.test-plan li { margin: 0 0 4px; font-size: 12.5px; }
.test-plan li.ok { color: var(--ok); }
.test-plan li.bad { color: var(--bad); }
.test-plan-meta { margin: 0; font-size: 12.5px; color: var(--ink); }
.test-plan-empty { margin: 8px 0 0; }
.test-lede { margin: 0 0 10px; font-size: 12.5px; }
.test-case {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg2);
  border: 1px solid var(--line);
}
.test-case-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
}
.test-case-head strong { font-size: 12px; letter-spacing: .03em; }
.test-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 8px;
}
.test-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.test-last { margin: 0 0 4px; font-size: 12.5px; color: var(--muted); }
.test-last.ok { color: var(--ok); }
.test-last.bad { color: var(--bad); }
.test-gate { margin: 0; font-size: 12.5px; color: var(--muted); }
.test-actual { display: block; margin-top: 6px; font-size: 12.5px; }
.test-actual.ok { color: var(--ok); }
.test-actual.bad { color: var(--bad); }
.field-val-panel .btn:disabled,
.field-val-panel .btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
}
.btn.saved,
.field-val-panel .btn.saved:disabled,
.field-val-panel .btn.saved[disabled] {
  background: var(--panel2);
  border-color: var(--line);
  color: var(--muted);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .28);
  opacity: 1;
  cursor: default;
  pointer-events: none;
}
.btn.saved:hover {
  border-color: var(--line);
}
html[data-theme="day"] .btn.saved,
html[data-theme="day"] .field-val-panel .btn.saved:disabled,
html[data-theme="day"] .field-val-panel .btn.saved[disabled] {
  background: #e6ebf0;
  border-color: #c5ced8;
  color: #6b7787;
  box-shadow: inset 0 2px 4px rgba(16, 38, 61, .16);
}
.editor-guide {
  margin: 0 0 12px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
}
.editor-guide summary {
  cursor: pointer;
  list-style: none;
  display: grid;
  grid-template-columns: 14px 1fr;
  column-gap: 6px;
  row-gap: 1px;
  align-items: baseline;
  padding: 2px 0;
}
.editor-guide summary::-webkit-details-marker { display: none; }
.editor-guide summary::before {
  content: "▸";
  grid-column: 1;
  grid-row: 1;
  color: var(--muted);
  font-size: 11px;
}
.editor-guide[open] summary::before { content: "▾"; }
.editor-guide-title {
  grid-column: 2;
  grid-row: 1;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
}
.editor-guide-sub {
  grid-column: 2;
  grid-row: 2;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.editor-guide-body {
  margin-top: 10px;
  text-align: left;
}
.editor-guide-body h3 {
  margin: 14px 0 4px;
  font-size: 13px;
  color: var(--ink);
}
.editor-guide-body p, .editor-guide-body li {
  margin: 0 0 8px;
  line-height: 1.45;
  font-size: 12px;
  color: var(--ink);
}
.editor-guide-body ol {
  margin: 0 0 8px;
  padding-left: 1.3em;
}
.editor-guide-body a { color: var(--teal); }
.editor-guide-body .lede {
  margin-bottom: 10px;
  font-size: 12px;
}
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 14, 22, .55);
  padding: 24px;
}
.confirm-dialog {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 18px 18px 14px;
}
.confirm-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
}
.confirm-body {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.45;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
