:root {
  color-scheme: light;
  --canvas: oklch(97.3% 0.007 290);
  --surface: oklch(99.7% 0.002 290);
  --ink: oklch(25% 0.037 285);
  --muted: oklch(49% 0.028 285);
  --subtle: oklch(53% 0.025 285);
  --line: oklch(90.9% 0.014 285);
  --accent: oklch(52% 0.20 277);
  --accent-strong: oklch(45% 0.19 277);
  --accent-soft: oklch(94.9% 0.028 276);
  --rail: oklch(24% 0.041 283);
  --rail-ink: oklch(93% 0.018 283);
  --rail-muted: oklch(76% 0.029 282);
  --rail-line: oklch(36% 0.045 282);
  --danger: oklch(46% 0.17 24);
  --danger-soft: oklch(95.3% 0.020 24);
  --radius: 12px;
  --gutter: clamp(24px, 3.4vw, 54px);
  --body-font: "Aptos", "Hiragino Sans GB", "PingFang SC", "Microsoft YaHei", sans-serif;
  --display-font: "Avenir Next", "Hiragino Sans GB", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-family: var(--body-font);
  background: var(--canvas);
  color: var(--ink);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; font-size: 1rem; line-height: 1.55; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p, ul { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.entry {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: start;
  justify-items: center;
  padding: clamp(32px, 11vh, 104px) var(--gutter) 32px;
}
.entry-inner {
  display: grid;
  width: min(100%, 27rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.entry-brand { padding: 20px 26px; background: var(--rail); color: var(--rail-ink); }
.entry-panel { display: grid; gap: 20px; padding: clamp(20px, 5vw, 26px); }
.entry-panel h1 { font: 700 1.625rem/1.25 var(--display-font); }
.entry-panel form { display: grid; gap: 16px; }
.entry-panel p[role="status"] { color: var(--muted); font-size: 0.9375rem; }
.entry-panel [type="submit"] { margin-top: 4px; }
.entry-panel .field input[required], .entry-panel button { min-height: 44px; }

.shell { display: grid; min-height: 100vh; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 48px;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  padding: 29px 16px 20px;
  background: var(--rail);
  color: var(--rail-ink);
}
.brand { display: flex; align-items: center; gap: 12px; padding-inline: 11px; align-self: start; }
.brand-mark {
  position: relative;
  display: block;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid oklch(78% 0.12 282);
  border-radius: 10px;
  background: oklch(66% 0.17 279);
}
.brand-mark::before, .brand-mark::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  border: 2px solid oklch(98% 0.01 278);
  border-radius: 3px;
  transform: rotate(-12deg);
}
.brand-mark::before { left: 8px; top: 8px; }
.brand-mark::after { right: 8px; bottom: 8px; }
.brand-name { display: block; font-weight: 650; font-size: 1.125rem; letter-spacing: 0.05em; line-height: 1.2; white-space: nowrap; }
.brand-name small { display: block; margin-top: 4px; color: var(--rail-muted); font-size: 0.75rem; font-family: var(--display-font); font-weight: 500; letter-spacing: 0.045em; }

.navigation { display: grid; gap: 5px; }
.navigation a {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  white-space: nowrap;
  color: var(--rail-muted);
  font-size: 0.9375rem;
  font-weight: 540;
}
.navigation a[aria-current="page"] { background: oklch(35% 0.072 282); border-color: oklch(42% 0.078 282); color: oklch(94% 0.037 282); }
.navigation a:focus-visible, .brand:focus-visible { outline-color: oklch(84% 0.12 282); }
@media (hover: hover) {
  .navigation a:not([aria-current]):hover { background: oklch(31% 0.046 282); color: var(--rail-ink); }
}
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--rail-line); padding: 15px 12px 2px; }
.connection { display: inline-flex; align-items: center; gap: 8px; color: var(--rail-muted); font-size: 0.8125rem; }
.connection::before { width: 7px; height: 7px; border-radius: 50%; background: oklch(78% 0.13 157); content: ""; }
.state-loading::before { background: oklch(83% 0.13 83); }
.state-error::before { background: oklch(76% 0.17 25); }

.glyph { position: relative; display: inline-block; width: 18px; height: 18px; flex: 0 0 18px; color: currentColor; }
.glyph::before, .glyph::after { position: absolute; display: block; content: ""; }
.glyph-overview::before { inset: 2px; background: repeating-linear-gradient(90deg, currentColor 0 5.7px, transparent 5.7px 8.3px); mask-image: linear-gradient(currentColor 0 41%, transparent 41% 59%, currentColor 59%); border-radius: 2px; }
.glyph-sources::before, .glyph-sources::after { width: 9px; height: 5px; border: 1.4px solid currentColor; border-radius: 8px; transform: rotate(-43deg); }
.glyph-sources::before { top: 4px; right: 1px; }
.glyph-sources::after { bottom: 4px; left: 1px; }
.glyph-nodes::before { inset: 3px; border: 1.4px solid currentColor; transform: rotate(30deg) skewY(15deg); border-radius: 3px; }
.glyph-nodes::after { width: 4px; height: 4px; border-radius: 100%; background: currentColor; top: 7px; left: 7px; }
.glyph-groups::before { inset: 2px 2px 5px 5px; border: 1.4px solid currentColor; border-radius: 3px; }
.glyph-groups::after { inset: 7px 7px 2px 2px; border: solid currentColor; border-width: 0 0 1.4px 1.4px; border-radius: 0 0 0 3px; }
.glyph-rules::before { width: 14px; height: 1.4px; top: 4px; left: 2px; background: currentColor; box-shadow: 0 4px currentColor, 0 8px currentColor; }
.glyph-rules::after { width: 3px; height: 3px; top: 3px; left: 11px; border-radius: 100%; background: currentColor; box-shadow: -6px 4px currentColor, -1px 8px currentColor; }
.glyph-profiles::before { inset: 2px 4px 2px 3px; border: 1.4px solid currentColor; border-radius: 2px; }
.glyph-profiles::after { height: 1.4px; width: 5px; left: 6px; top: 7px; background: currentColor; box-shadow: 0 3px currentColor; }
.glyph-terminal::before { inset: 3px 1px; border: 1.4px solid currentColor; border-radius: 3px; }
.glyph-terminal::after { width: 8px; height: 1.4px; left: 5px; top: 9px; background: currentColor; }
.glyph-plus::before, .glyph-plus::after { background: currentColor; border-radius: 1px; }
.glyph-plus::before { width: 12px; height: 1.5px; left: 3px; top: 8px; }
.glyph-plus::after { width: 1.5px; height: 12px; left: 8px; top: 3px; }
.glyph-search::before { inset: 1px 5px 5px 1px; border: 1.6px solid currentColor; border-radius: 50%; }
.glyph-search::after { height: 1.6px; width: 6px; background: currentColor; transform: rotate(45deg); left: 10px; top: 13px; border-radius: 1px; }
.glyph-eye::before, .glyph-eye-off::before { inset: 3px; border: 1.4px solid currentColor; border-radius: 75% 15%; transform: rotate(45deg); }
.glyph-eye::before { background: radial-gradient(circle, currentColor 1.8px, transparent 2px); }
.glyph-eye-off::before { background: currentColor; mask-image: linear-gradient(90deg, #000 34%, transparent 34% 66%, #000 66%); }
.glyph-eye-off::after { width: 18px; height: 1.5px; left: 0; top: 8.25px; background: currentColor; border-radius: 1px; transform: rotate(-45deg); }

.workspace { min-width: 0; }
.topbar {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 0.875rem;
}
.breadcrumb, .client-label { display: flex; align-items: center; gap: 9px; }
.breadcrumb a, .client-label { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-divider { color: var(--subtle); }
.client-label { font-family: var(--display-font); font-weight: 580; white-space: nowrap; }
.client-label .glyph { color: var(--accent); }
.session-account { display: flex; align-items: center; gap: 8px; min-width: 0; }
.session-username { min-width: 0; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

.view { max-width: 1430px; margin-inline: auto; padding: 36px var(--gutter) 56px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-heading h1 { font-size: 2.375rem; line-height: 1.16; letter-spacing: 0.005em; font-family: var(--display-font); font-weight: 700; overflow-wrap: anywhere; }
.page-heading h1:focus { outline: none; }
.page-heading p { margin-top: 9px; color: var(--muted); }
.panel h2 { font-size: 1.125rem; font-weight: 650; font-family: var(--display-font); }

.button {
  display: inline-flex;
  min-height: 42px;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.button:hover { border-color: oklch(77% 0.05 278); background: var(--accent-soft); color: var(--accent-strong); }
.button-primary { background: var(--accent); color: oklch(99.5% 0.006 282); border-color: var(--accent); }
.button-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: oklch(99.5% 0.006 282); }
.button-quiet { background: transparent; border-color: transparent; }
.button-quiet:hover { border-color: transparent; }
.button-danger { color: var(--danger); }
.button-danger:hover { color: var(--danger); background: var(--danger-soft); }
.button:disabled { background: var(--canvas); border-color: var(--line); color: var(--muted); opacity: 0.7; }
.button-icon { padding-inline: 8px; min-width: 36px; min-height: 36px; }
.text-link { color: var(--accent-strong); font-size: 0.875rem; font-weight: 620; }
.text-link:hover { text-decoration: underline; text-underline-offset: 4px; }

.diagram {
  display: grid;
  grid-template-columns: minmax(210px, 0.83fr) minmax(320px, 1.35fr);
  position: relative;
  gap: 24px;
  align-items: center;
  min-height: 230px;
  padding: clamp(24px, 3vw, 42px);
  isolation: isolate;
  overflow: hidden;
  border: 1px solid oklch(87% 0.038 280);
  border-radius: var(--radius);
  background: oklch(94.4% 0.031 282);
}
.diagram::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background-image: radial-gradient(oklch(78% 0.071 281 / 0.64) 1px, transparent 1.15px);
  background-size: 15px 15px;
  mask-image: linear-gradient(to right, transparent 28%, currentColor 72%);
}
.diagram h2 { font-family: var(--display-font); font-size: 1.625rem; font-weight: 700; line-height: 1.32; }
.diagram p { margin-top: 12px; color: oklch(42% 0.047 284); }
.diagram-flow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(8px, 1.45vw, 22px); position: relative; align-items: center; }
.diagram-flow::before { content: ""; position: absolute; inset-inline: 18%; top: 50%; border-top: 1px dashed oklch(63% 0.10 279); z-index: -1; }
.diagram-step {
  display: grid;
  min-width: 0;
  min-height: 106px;
  align-content: center;
  justify-items: center;
  gap: 6px;
  padding: 10px 5px;
  border-radius: 9px;
  border: 1px solid oklch(85.5% 0.042 280);
  background: oklch(98% 0.021 282);
  text-align: center;
  font-size: 0.875rem;
  font-weight: 650;
}
.diagram-step:hover { border-color: var(--accent); color: var(--accent-strong); }
.diagram-step .glyph { color: var(--accent); width: 26px; height: 26px; padding: 4px; border: 4px solid transparent; border-radius: 7px; background: var(--accent-soft); }
.diagram-step small { color: var(--muted); font-weight: 500; font-size: 0.75rem; }

.ledger { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-block: 22px 34px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.ledger-item { min-width: 0; padding: 14px clamp(13px, 2vw, 26px); }
.ledger-item + .ledger-item { border-inline-start: 1px solid var(--line); }
.ledger-item:hover { background: var(--accent-soft); }
.ledger-item:first-child { border-start-start-radius: inherit; border-end-start-radius: inherit; }
.ledger-item:last-child { border-start-end-radius: inherit; border-end-end-radius: inherit; }
.ledger-key { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 0.875rem; }
.ledger-key .glyph { color: var(--accent); }
.ledger-value { display: block; margin-top: 2px; font-family: var(--display-font); font-size: 1.75rem; font-weight: 630; font-variant-numeric: tabular-nums; line-height: 1.25; }
.overview-panels { display: grid; grid-template-columns: minmax(0, 1.38fr) minmax(0, 1fr); gap: 20px; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-list { list-style: none; padding: 0; }
.panel-list li + li { border-top: 1px solid var(--line); }
.panel-row { display: flex; min-height: 64px; align-items: center; gap: 10px; padding: 10px 17px; }
.panel-row:hover { background: var(--accent-soft); }
.panel-row .glyph { color: var(--accent); }
.panel-row strong { min-width: 0; overflow-wrap: anywhere; }
.panel-row span:last-child { flex: 0 0 auto; margin-left: auto; color: var(--muted); font-size: 0.8125rem; }
.panel-row strong { font-size: 0.9375rem; font-weight: 600; }
.empty { display: grid; gap: 8px; justify-items: start; padding: 25px 19px; }
.empty h3 { font-size: 1rem; font-weight: 640; }
.empty p { color: var(--muted); font-size: 0.875rem; }
.empty .text-link { margin-top: 5px; }
.empty-wide .empty { padding: 30px 24px; }
.loading { color: var(--muted); padding-block: 14px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 630; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td:first-child { max-width: 340px; font-weight: 610; overflow-wrap: anywhere; }
td .muted { margin-top: 2px; font-weight: 400; }
td .button { min-height: 34px; padding: 4px 8px; }
tr:hover td { background: color-mix(in oklch, var(--accent-soft), var(--surface) 65%); }
.table-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 3px; }
.align-end { text-align: right; }
.muted { color: var(--muted); }
.protocol { color: var(--accent-strong); font-family: var(--display-font); font-weight: 620; white-space: nowrap; }
.date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.source-update-status { display: grid; gap: 3px; min-width: 155px; }
.source-update-status small { color: var(--muted); line-height: 1.45; }
.source-update-status .source-update-notice { color: var(--danger); }
.source-node-count { display: inline-flex; align-items: center; min-width: 24px; min-height: 24px; font-variant-numeric: tabular-nums; text-decoration: underline; text-underline-offset: 4px; }
.source-traffic, .source-plan-expiring, .source-plan-expired { margin-top: 2px; font-size: 0.8125rem; font-weight: 500; }
.source-traffic { color: var(--accent-strong); }
.source-plan-expiring { color: oklch(43% 0.10 62); }
.source-plan-expired { color: var(--danger); }
.node-search { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.node-search-status { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.source-node-entry { display: flex; align-items: center; gap: 7px; }
.source-node-entry .button { flex: 0 0 auto; }
.source-node-entry .button[aria-disabled="true"] { cursor: wait; color: var(--muted); }
.node-name-with-score { min-width: 0; }
.node-name-with-score .node-reading { margin-inline-start: 7px; }
.node-reading { font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.node-history-trigger { padding: 3px 0; border: 0; background: none; color: inherit; text-align: start; }
.node-history-trigger:hover, .node-history-trigger[aria-expanded="true"] { text-decoration: underline; text-underline-offset: 3px; }
.node-reading-score { display: inline-block; padding: 3px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-strong); font-weight: 620; white-space: nowrap; }
.node-reading-pending { color: var(--muted); font-weight: 500; white-space: nowrap; }
.node-reading-ip { overflow-wrap: anywhere; }
.node-exit small { display: block; font-size: 0.75rem; }
.node-history {
  position: fixed;
  inset: auto;
  width: min(21rem, calc(100vw - 16px));
  max-height: min(60dvh, 26rem);
  overflow: auto;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 24px oklch(20% 0.045 282 / 0.15);
  font-size: 0.8125rem;
  font-weight: 500;
}
.node-history strong { display: block; margin-bottom: 4px; font-size: 0.875rem; font-weight: 640; }
.node-history ul { list-style: none; padding: 0; }
.node-history li { display: flex; gap: 2px 10px; flex-wrap: wrap; justify-content: space-between; padding: 5px 0; }
.node-history li + li { border-top: 1px solid var(--line); }
.node-history li span { min-width: 0; overflow-wrap: anywhere; }
.node-history time { color: var(--muted); font-variant-numeric: tabular-nums; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters select { width: auto; max-width: 100%; }
.search-input { display: flex; position: relative; align-items: center; }
.search-input .glyph { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search-input input[type="search"] { padding-inline-start: 36px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.875rem; }
.pagination .button { min-height: 34px; padding: 4px 8px; }

.editor { max-width: 1020px; padding: clamp(17px, 3vw, 27px); }
.editor form, .editor > section { display: grid; gap: 19px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span:first-child, legend { font-size: 0.9375rem; font-weight: 620; }
.field small { color: var(--muted); font-size: 0.8125rem; }
.name-suggestions { max-height: min(35vh, 14rem); overflow: auto; margin-top: 5px; padding: 4px; list-style: none; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.name-suggestions li { min-height: 36px; padding: 7px 9px; border-radius: 4px; overflow-wrap: anywhere; cursor: pointer; }
.name-suggestions li:hover, .name-suggestions [aria-selected="true"] { background: var(--accent-soft); color: var(--accent-strong); }
input:not([type="checkbox"]):not([type="radio"]), textarea, select {
  width: 100%;
  min-height: 41px;
  padding: 8px 10px;
  border: 1px solid oklch(83.5% 0.020 285);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}
textarea { resize: vertical; min-height: 118px; overflow-wrap: anywhere; }
select { appearance: none; padding-right: 31px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 14px center, right 9px center; background-size: 5px 5px; background-repeat: no-repeat; }
input::placeholder, textarea::placeholder { color: var(--subtle); }
input[type="radio"], input[type="checkbox"] { inline-size: 16px; block-size: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
fieldset { padding: 0; margin: 0; min-width: 0; border: 0; }
legend { margin-bottom: 7px; }
.choice-group { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: flex; align-items: center; gap: 8px; min-height: 42px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; cursor: pointer; overflow-wrap: anywhere; font-size: 0.875rem; }
.choice:has(input:checked) { border-color: oklch(76% 0.085 279); background: var(--accent-soft); color: var(--accent-strong); }
.choice small { color: var(--muted); }
.source-file-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.form-note { margin-block: 0 7px; color: var(--muted); font-size: 0.875rem; }
.form-error { border: 1px solid oklch(85% 0.055 25); color: var(--danger); background: var(--danger-soft); border-radius: 6px; padding: 8px 11px; font-size: 0.875rem; overflow-wrap: anywhere; }
.group-node-filters { margin-bottom: 8px; }
.group-node-renaming { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; margin-block: 8px; }
.group-node-renaming .field { flex: 1 1 210px; max-width: 360px; }
.group-node-results { margin-block: 8px; }
.group-node-list { display: grid; gap: 6px; padding: 0; list-style: none; }
.group-node-choice > input { flex: 0 0 auto; }
.group-node-choice > span { display: grid; gap: 2px; min-width: 0; }
.group-missing { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 0.875rem; }

.rule-list, .order-list { display: grid; gap: 7px; padding: 0; list-style: none; margin: 8px 0 11px; }
.rule-row { display: grid; grid-template-columns: 25px minmax(126px, 0.85fr) minmax(100px, 1.35fr) auto; align-items: end; gap: 7px; }
.rule-ordinal { align-self: end; margin-bottom: 9px; text-align: center; color: var(--muted); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.rule-row .field > span:first-child { font-size: 0.8125rem; font-weight: 550; }
.rule-no-resolve { display: flex; align-items: center; gap: 8px; grid-column: 2 / -1; width: fit-content; min-height: 26px; font-size: 0.8125rem; cursor: pointer; }
.rule-origin { grid-column: 2 / -1; color: var(--muted); font-size: 0.8125rem; overflow-wrap: anywhere; }
.rule-batch { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--canvas); }
.rule-batch > div:first-child { display: grid; gap: 2px; min-width: 0; }
.rule-batch strong { font-size: 0.875rem; }
.rule-batch .reorder-actions { flex: 0 0 auto; }
.rule-editor-tools { display: grid; gap: 8px; margin-block: 10px 12px; }
.rule-editor-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.preset-sources { margin-top: 20px; }
.preset-sources .panel-heading { flex-wrap: wrap; }
.preset-sources-status { padding: 15px 18px; }
.preset-source + .preset-source { border-top: 1px solid var(--line); }
.preset-source > summary { padding: 12px 18px; font-size: 0.9375rem; font-weight: 620; overflow-wrap: anywhere; cursor: pointer; }
.preset-source > summary::marker { color: var(--accent-strong); }
.preset-source > summary:hover { background: var(--accent-soft); }
.preset-source-count { margin-inline-start: 9px; font-weight: 500; white-space: nowrap; }
.preset-source-link { padding: 0 18px 8px; }
.preset-source th, .preset-source td { padding-inline: 18px; }
.preset-source .source-preview-controls { padding: 10px 18px; border-top: 1px solid var(--line); }
.rule-import { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; }
.rule-import > summary { min-height: 24px; color: var(--accent-strong); font-size: 0.9375rem; font-weight: 620; cursor: pointer; }
.rule-import-content { display: grid; gap: 12px; min-width: 0; margin-top: 10px; }
.rule-import-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 10px; }
.rule-import-grid .field > span:first-child { overflow-wrap: anywhere; }
.rule-import-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rule-import-actions .form-note { margin: 0; }
.rule-import-notes:empty { display: none; }
.rule-import-sample-details summary { color: var(--accent-strong); font-size: 0.875rem; cursor: pointer; }
.rule-import-sample { max-height: min(35vh, 16rem); overflow: auto; padding: 6px 10px; margin-block: 6px; list-style: none; background: var(--canvas); border-radius: 6px; }
.rule-import-sample li { display: grid; gap: 2px; padding: 4px 0; font-size: 0.8125rem; overflow-wrap: anywhere; }
.rule-import-sample li + li { border-top: 1px solid var(--line); }
.link-dialog.rule-preview-dialog { width: min(740px, calc(100% - 32px)); }
.rule-preview-content { display: grid; gap: 10px; }
.reorder-actions { display: flex; justify-content: flex-end; align-items: center; gap: 4px; }
.reorder-actions .button-icon { min-height: 38px; }
.order-list:empty { display: none; }
.order-list li { display: flex; gap: 8px; align-items: center; min-height: 40px; padding: 3px 6px 3px 10px; background: var(--canvas); border: 1px solid var(--line); border-radius: 6px; font-size: 0.875rem; overflow-wrap: anywhere; }
.order-list li .reorder-actions { flex: 0 0 auto; margin-left: auto; }
.profile-rule-order li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(132px, 175px) auto; padding-block: 7px; }
.profile-rule-order .field { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
.profile-rule-order .field > span:first-child { white-space: nowrap; font-size: 0.8125rem; }

.preview-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.preview-code { max-height: min(62vh, 650px); overflow: auto; margin: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--canvas); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 0.8125rem; tab-size: 2; }
.source-preview-code { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.source-preview-controls { align-items: center; color: var(--muted); font-size: 0.875rem; }
.source-settings-fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.source-link-history { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; }
.source-link-history summary { color: var(--accent-strong); font-size: 0.875rem; cursor: pointer; }
.source-link-history-content { margin-top: 8px; }
.source-link-list { max-height: min(35vh, 16rem); overflow: auto; padding: 0; list-style: none; }
.source-link-list li { display: grid; gap: 4px; padding: 7px 0; font-size: 0.8125rem; }
.source-link-list li + li { border-top: 1px solid var(--line); }
.source-link-list code { overflow-wrap: anywhere; }
.source-cache-version { max-width: 26rem; }
.toast { position: fixed; z-index: 3; right: var(--gutter); bottom: 20px; max-width: min(420px, calc(100vw - 2 * var(--gutter))); border: 1px solid var(--rail-line); background: var(--rail); color: var(--rail-ink); padding: 10px 15px; border-radius: 8px; font-size: 0.875rem; overflow-wrap: anywhere; }
.toast-error { background: var(--danger-soft); color: var(--danger); border-color: oklch(85% 0.055 25); }
.link-dialog { width: min(480px, calc(100% - 32px)); padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.link-dialog::backdrop { background: oklch(20% 0.045 282 / 0.5); }
.link-dialog form { display: grid; gap: 13px; }
.link-dialog h2 { font-size: 1.125rem; }
.link-dialog p:not(.form-error) { color: var(--muted); font-size: 0.875rem; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

@media (max-width: 1080px) {
  .shell { grid-template-columns: 192px minmax(0, 1fr); }
  .diagram { grid-template-columns: minmax(174px, 0.8fr) minmax(265px, 1.2fr); padding: 22px; min-height: 206px; }
  .diagram h2 { font-size: 1.375rem; }
  .rule-row { grid-template-columns: 20px minmax(116px, 0.85fr) minmax(90px, 1.35fr) auto; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: relative; height: auto; padding: 12px var(--gutter) 8px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
  .brand { padding: 0; }
  .brand-name small { display: none; }
  .brand-mark { width: 32px; height: 32px; flex-basis: 32px; }
  .brand-mark::before { left: 5px; top: 5px; }
  .brand-mark::after { right: 5px; bottom: 5px; }
  .navigation { display: flex; grid-column: 1 / -1; grid-row: 2; gap: 3px; overflow-x: auto; }
  .navigation a { min-height: 40px; padding: 5px 9px; gap: 5px; font-size: 0.875rem; }
  .sidebar-foot { border: 0; margin: 0; padding: 0; align-self: center; }
  .topbar { min-height: 48px; }
  .view { padding-top: 25px; }
}
@media (max-width: 600px) {
  :root { --gutter: 16px; }
  .navigation a .glyph { display: none; }
  .view { padding-bottom: 32px; }
  .page-heading { flex-wrap: wrap; }
  .session-username { max-width: 13ch; }
  .page-heading h1 { font-size: 1.875rem; }
  .page-heading p { margin-top: 6px; font-size: 0.9375rem; }
  .diagram { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 18px; }
  .diagram::before { mask-image: linear-gradient(to bottom, transparent 10%, currentColor 90%); }
  .diagram-step { min-height: 83px; }
  .ledger { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-block: 16px 25px; }
  .ledger-item:nth-child(3) { border-inline-start: 0; }
  .ledger-item:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .ledger-item:first-child { border-end-start-radius: 0; }
  .ledger-item:nth-child(2) { border-start-end-radius: inherit; }
  .ledger-item:nth-child(3) { border-end-start-radius: inherit; }
  .ledger-item:last-child { border-start-end-radius: 0; }
  .overview-panels { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .node-search, .filters { width: 100%; }
  .search-input { flex: 1 1 160px; }
  .rule-row { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .rule-row .rule-value { grid-column: 2 / -1; }
  .rule-row .reorder-actions { grid-area: 1 / 3; }
  .rule-row .reorder-actions .button-icon { min-width: 32px; }
  .profile-rule-order li { grid-template-columns: minmax(0, 1fr) auto; }
  .profile-rule-order li .field { grid-column: 1; }
  .profile-rule-order li .reorder-actions { grid-area: 1 / 2 / span 2; }
}
@media (prefers-reduced-motion: no-preference) {
  .button, .diagram-step, .navigation a, .ledger-item { transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease; }
}
@media (pointer: coarse) {
  .node-history-trigger { min-height: 36px; }
}
