/* ---------------------------------------------------------------------------
   JSON:API Lens
   --------------------------------------------------------------------------- */

:root {
  color-scheme: dark;
  --bg: #070a10;
  --bg-deep: #05070b;
  --pane: #0c1018;
  --pane-2: #0f141e;
  --surface: #101622;
  --surface-2: #141b28;
  --surface-3: #19212f;
  --border: #1c2533;
  --border-strong: #273245;
  --text: #e7ecf5;
  --text-soft: #c2cbd9;
  --muted: #8e9bb0;
  --faint: #5f6c80;
  --accent: #5eead4;
  --accent-2: #a78bfa;
  --blue: #60a5fa;
  --pink: #f472b6;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #fb7185;
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 16px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --toast-bg: #1b2332;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f6;
  --bg-deep: #e5e9f1;
  --pane: #ffffff;
  --pane-2: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f3f6fb;
  --surface-3: #e9eef6;
  --border: #dbe2ec;
  --border-strong: #c6d0de;
  --text: #111827;
  --text-soft: #2b3545;
  --muted: #5c6a7e;
  --faint: #8794a8;
  --accent: #0f766e;
  --accent-2: #6d28d9;
  --blue: #1d4ed8;
  --pink: #be185d;
  --green: #047857;
  --amber: #b45309;
  --red: #be123c;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  --toast-bg: #111827;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(1100px 520px at 8% -10%, rgba(94, 234, 212, 0.09), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(167, 139, 250, 0.1), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html[data-theme="light"] body {
  background:
    radial-gradient(1100px 520px at 8% -10%, rgba(20, 184, 166, 0.1), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(139, 92, 246, 0.1), transparent 55%),
    var(--bg);
}

button,
select,
textarea,
input {
  font: inherit;
  color: inherit;
}

input[type="checkbox"] {
  width: 13px;
  height: 13px;
  accent-color: var(--accent);
  cursor: pointer;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
}

::selection {
  background: rgba(94, 234, 212, 0.28);
  color: var(--text);
}

/* Scrollbars --------------------------------------------------------------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--faint);
  background-clip: content-box;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* Top bar ------------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex: 0 0 auto;
  padding: 12px 20px 10px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(12, 16, 24, 0.85), rgba(7, 10, 16, 0.55));
  backdrop-filter: blur(14px);
}

html[data-theme="light"] .topbar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(245, 247, 251, 0.7));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid rgba(94, 234, 212, 0.32);
  background: linear-gradient(145deg, rgba(94, 234, 212, 0.17), rgba(167, 139, 250, 0.14));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 20px rgba(0, 0, 0, 0.25);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -1px;
}

.brand-mark i {
  font-style: normal;
  color: var(--accent-2);
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-text p {
  margin: 1px 0 0;
  color: var(--faint);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.icon-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 550;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.icon-btn:hover,
.ghost-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn:active,
.ghost-btn:active {
  transform: translateY(1px);
}

.icon-btn:focus-visible,
.ghost-btn:focus-visible,
.tab:focus-visible,
select:focus-visible,
button:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#theme-toggle {
  width: 32px;
  padding: 0;
  font-size: 15px;
}

.select-wrap {
  position: relative;
  display: inline-flex;
}

.select-wrap::after {
  content: "▾";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-52%);
  font-size: 10px;
  color: var(--muted);
  pointer-events: none;
}

.select-wrap select {
  appearance: none;
  height: 32px;
  padding: 0 28px 0 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
}

.select-wrap select:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

/* Layout ------------------------------------------------------------------- */

.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(340px, 43%) minmax(0, 1fr);
  gap: 14px;
  padding: 14px 16px 16px;
}

.pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 120px), var(--pane);
  box-shadow: var(--shadow);
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  height: 44px;
  padding: 0 12px 0 15px;
  border-bottom: 1px solid var(--border);
  background: var(--pane-2);
}

.pane-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.12);
}

.pane-tools {
  display: flex;
  gap: 6px;
}

.url-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--pane-2);
}

.url-bar[hidden] {
  display: none;
}

.url-bar input {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
}

.url-bar input:focus {
  border-color: transparent;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.url-bar .url-load,
.url-bar .url-close {
  flex: 0 0 auto;
}

.url-bar button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.ghost-btn {
  height: 26px;
  padding: 0 9px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
}

.ghost-btn:hover {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

/* Editor ------------------------------------------------------------------- */

.editor-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  background:
    linear-gradient(90deg, rgba(94, 234, 212, 0.03), transparent 24%),
    var(--pane);
}

#editor {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  padding: 15px 17px 22px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}

#editor::placeholder {
  color: var(--faint);
  opacity: 0.85;
}

#editor:focus {
  color: var(--text);
}

.drop-overlay {
  position: absolute;
  inset: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(94, 234, 212, 0.55);
  border-radius: 12px;
  background: rgba(9, 14, 22, 0.86);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

html[data-theme="light"] .drop-overlay {
  background: rgba(248, 250, 252, 0.9);
}

.editor-wrap.is-dragging .drop-overlay {
  opacity: 1;
}

.drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-soft);
  font-size: 13px;
}

.drop-inner strong {
  color: var(--text);
  font-size: 15px;
}

.drop-inner span {
  color: var(--muted);
  font-size: 12px;
}

.drop-mark {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 26px;
  margin-bottom: 4px;
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 15px;
  border-top: 1px solid var(--border);
  background: var(--pane-2);
  color: var(--muted);
  font-size: 11.5px;
}

.status-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.status-dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.12);
}

.status-dot.bad {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.12);
}

.status-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-meta {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10.5px;
  white-space: nowrap;
}

/* Output pane -------------------------------------------------------------- */

.output-pane {
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.025), transparent 180px), var(--pane);
}

.summary {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--pane-2);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.summary::-webkit-scrollbar {
  display: none;
}

.summary:empty::before {
  content: "No document parsed yet";
  color: var(--faint);
  font-size: 12px;
  padding-left: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  height: 27px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.chip b {
  color: var(--text-soft);
  font-weight: 600;
}

button.chip {
  transition: border-color 0.15s ease, background 0.15s ease;
}

button.chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.chip .chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
}

.chip.is-ok {
  border-color: rgba(52, 211, 153, 0.28);
  background: rgba(52, 211, 153, 0.08);
  color: #8ef0c8;
}

html[data-theme="light"] .chip.is-ok {
  color: #047857;
}

.chip.is-ok .chip-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.12);
}

.chip.is-bad {
  border-color: rgba(251, 113, 133, 0.32);
  background: rgba(251, 113, 133, 0.09);
  color: #ffb3bf;
}

html[data-theme="light"] .chip.is-bad {
  color: #be123c;
}

.chip.is-bad .chip-dot {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.12);
}

.chip.is-warn {
  border-color: rgba(251, 191, 36, 0.26);
  background: rgba(251, 191, 36, 0.07);
  color: #fcd77f;
}

html[data-theme="light"] .chip.is-warn {
  color: #b45309;
}

.chip.is-warn .chip-dot {
  background: var(--amber);
}

.chip.is-info {
  border-color: rgba(96, 165, 250, 0.24);
  background: rgba(96, 165, 250, 0.07);
  color: #a8cbfb;
}

html[data-theme="light"] .chip.is-info {
  color: #1d4ed8;
}

.chip.is-info .chip-dot {
  background: var(--blue);
}

.tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  flex: 0 0 auto;
  height: 40px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  background: var(--pane);
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  letter-spacing: 0.01em;
}

.tab:hover {
  color: var(--text-soft);
}

.tab:disabled {
  color: var(--muted);
  opacity: 0.4;
  cursor: not-allowed;
}

.tab:disabled:hover {
  color: var(--muted);
}

.tab.is-active {
  color: var(--text);
}

.tab.is-active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 17px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
}

.tab-count.has-errors {
  background: rgba(251, 113, 133, 0.15);
  color: #ffa7b4;
}

html[data-theme="light"] .tab-count.has-errors {
  color: #be123c;
}

.tab-count.has-warnings {
  background: rgba(251, 191, 36, 0.14);
  color: #fbd277;
}

html[data-theme="light"] .tab-count.has-warnings {
  color: #b45309;
}

.view {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  outline: none;
}

.view.view--graph {
  overflow: hidden;
  padding: 0;
}

/* Tree --------------------------------------------------------------------- */

.tree-toolbar {
  position: sticky;
  top: -14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: -14px -14px 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 16, 24, 0.9);
  backdrop-filter: blur(12px);
}

html[data-theme="light"] .tree-toolbar {
  background: rgba(255, 255, 255, 0.92);
}

.tree-toolbar .toolbar-label {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-right: 2px;
}

.toolbar-spacer {
  flex: 1 1 auto;
}

.depth-select {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--faint);
  font-size: 11px;
}

.depth-select select {
  height: 27px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 11px;
  cursor: pointer;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 27px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 550;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tool-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.tool-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tool-btn:disabled:hover {
  border-color: var(--border);
  background: var(--surface);
  color: var(--muted);
}

.tool-btn.primary {
  border-color: rgba(94, 234, 212, 0.3);
  background: rgba(94, 234, 212, 0.08);
  color: var(--accent);
}

.section {
  margin-bottom: 18px;
}

.section:last-child {
  margin-bottom: 4px;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 2px 9px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.section-head .section-kicker {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
}

.section-head .spacer {
  flex: 1 1 auto;
}

.section-collapse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
}

.section-collapse .chev {
  color: var(--faint);
  font-size: 9px;
  transition: transform 0.15s ease;
}

.section-collapse[aria-expanded="false"] .chev {
  transform: rotate(-90deg);
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  min-width: 19px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
}

.count-pill.warn {
  background: rgba(251, 191, 36, 0.13);
  color: #fbd277;
}

html[data-theme="light"] .count-pill.warn {
  color: #b45309;
}

/* Document extras ---------------------------------------------------------- */

.doc-extra {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--pane-2);
  overflow: hidden;
}

.doc-extra > summary {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 550;
  list-style: none;
}

.doc-extra > summary::-webkit-details-marker {
  display: none;
}

.doc-extra > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 7px;
  color: var(--faint);
  font-size: 9px;
  transition: transform 0.15s ease;
}

.doc-extra[open] > summary::before {
  transform: rotate(90deg);
}

.doc-extra pre {
  margin: 0;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  overflow: auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
}

/* Resource cards ----------------------------------------------------------- */

.card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.022), rgba(255, 255, 255, 0) 70px), var(--surface);
  overflow: hidden;
}

.card + .card {
  margin-top: 8px;
}

.card-nested {
  margin-top: 8px;
  border-color: var(--border-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.028), rgba(255, 255, 255, 0) 60px), var(--surface);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
}

.card.flash {
  animation: card-flash 1.5s ease;
}

@keyframes card-flash {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(94, 234, 212, 0);
  }
  18% {
    box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.35);
  }
  60% {
    box-shadow: 0 0 0 2px rgba(94, 234, 212, 0.16);
  }
}

.card-head {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.014);
}

.card-head .spacer {
  flex: 1 1 auto;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  height: 20px;
  padding: 0 7px;
  border: 1px solid hsl(var(--h, 190) 65% 60% / 0.28);
  border-radius: 6px;
  background: hsl(var(--h, 190) 70% 55% / 0.1);
  color: hsl(var(--h, 190) 80% 70%);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-theme="light"] .type-badge {
  border-color: hsl(var(--h, 190) 55% 45% / 0.26);
  background: hsl(var(--h, 190) 70% 50% / 0.09);
  color: hsl(var(--h, 190) 62% 33%);
}

.type-badge.is-inline {
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  font-size: 11.5px;
  font-weight: 650;
}

.card-id {
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 12px;
}

.card-label {
  max-width: min(360px, 60%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11.5px;
}

.card-badges {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  height: 17px;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.mini-badge.warn {
  background: rgba(251, 191, 36, 0.12);
  color: #f6cd6d;
}

html[data-theme="light"] .mini-badge.warn {
  color: #b45309;
}

.mini-badge.danger {
  background: rgba(251, 113, 133, 0.12);
  color: #ff9bab;
}

html[data-theme="light"] .mini-badge.danger {
  color: #be123c;
}

.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  font-size: 11px;
}

.icon-action:hover {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
}

.via-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-bottom: 1px dashed var(--border);
  background: rgba(94, 234, 212, 0.028);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10.5px;
}

.via-strip .via-arrow {
  color: var(--accent);
  opacity: 0.7;
}

.via-strip .via-path {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.via-strip .via-pointer {
  color: var(--faint);
  opacity: 0.85;
}

.via-strip .icon-action {
  width: 20px;
  height: 18px;
  font-size: 10px;
}

.card-body {
  padding: 2px 0 9px;
}

.attrs {
  padding: 4px 8px 4px;
}

.attr {
  display: grid;
  grid-template-columns: minmax(96px, 24%) minmax(0, 1fr);
  gap: 12px;
  padding: 3px 6px;
  border-radius: 5px;
}

.attr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.014);
}

html[data-theme="light"] .attr:nth-child(odd) {
  background: rgba(15, 23, 42, 0.025);
}

.attr-name {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
}

.attr-value {
  min-width: 0;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.val-string {
  color: #a5e8c8;
}

html[data-theme="light"] .val-string {
  color: #0f766e;
}

.val-number {
  color: #f2b880;
}

html[data-theme="light"] .val-number {
  color: #b45309;
}

.val-boolean {
  color: #c4b5fd;
}

html[data-theme="light"] .val-boolean {
  color: #6d28d9;
}

.val-null {
  color: var(--faint);
  font-style: italic;
}

.val-object {
  color: var(--blue);
}

.value-details {
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
}

.value-details > summary {
  cursor: pointer;
  color: var(--blue);
  font-size: 11px;
  list-style: none;
}

.value-details > summary::-webkit-details-marker {
  display: none;
}

.value-details > summary::before {
  content: "▸ ";
  font-size: 9px;
  color: var(--faint);
}

.value-details[open] > summary::before {
  content: "▾ ";
}

.value-details pre {
  margin: 5px 0 2px;
  padding: 8px 10px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-deep);
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.value-details.value-deep {
  display: block;
  padding: 6px 8px;
  border: 1px dashed var(--border-strong);
  border-radius: 7px;
  background: var(--bg-deep);
}

.value-deep-head {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--blue);
}

.value-deep-note {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.card-empty {
  padding: 8px 14px;
  color: var(--faint);
  font-size: 11.5px;
  font-style: italic;
}

/* Relationships ------------------------------------------------------------ */

.rels {
  margin: 4px 8px 0;
  padding-top: 5px;
  border-top: 1px dashed var(--border);
}

.rel {
  padding: 3px 0;
}

.rel-row {
  display: grid;
  grid-template-columns: minmax(90px, 21%) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 3px 6px;
  border-radius: 6px;
}

.rel-name {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding-top: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.rel-name::before {
  content: "→";
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 10px;
  opacity: 0.8;
}

.rel-targets {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 0;
}

.target-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-height: 24px;
  padding: 2px 7px 2px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.3;
  text-align: left;
  transition: border-color 0.13s ease, background 0.13s ease, transform 0.1s ease;
}

.target-chip:hover {
  border-color: hsl(var(--h, 190) 70% 60% / 0.5);
  background: var(--surface-3);
}

.target-chip:active {
  transform: translateY(1px);
}

.target-chip .caret {
  flex: 0 0 auto;
  width: 9px;
  color: var(--faint);
  font-size: 9px;
}

.target-chip .t-type {
  color: hsl(var(--h, 190) 78% 70%);
  font-weight: 600;
}

html[data-theme="light"] .target-chip .t-type {
  color: hsl(var(--h, 190) 62% 33%);
}

.target-chip .t-sep {
  color: var(--faint);
  opacity: 0.7;
}

.target-chip .t-id {
  color: var(--text-soft);
}

.target-chip .t-label {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 10.5px;
}

.target-chip .missing-mark {
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(251, 191, 36, 0.13);
  color: #f6cd6d;
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

html[data-theme="light"] .target-chip .missing-mark {
  color: #b45309;
}

.target-chip.is-missing {
  border-style: dashed;
  border-color: rgba(251, 191, 36, 0.32);
}

.target-chip.is-open {
  border-color: hsl(var(--h, 190) 70% 60% / 0.55);
  background: hsl(var(--h, 190) 60% 50% / 0.09);
}

.null-chip,
.linkage-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 23px;
  padding: 2px 7px;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10.5px;
}

.linkage-note {
  border-style: solid;
  border-color: transparent;
  background: rgba(255, 255, 255, 0.02);
}

.rel-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 23px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--blue);
  font-size: 10.5px;
  font-weight: 550;
  text-decoration: none;
}

.rel-link:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.rel-children {
  margin: 5px 0 3px 20px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.missing-card,
.cycle-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px dashed rgba(251, 191, 36, 0.3);
  border-radius: 9px;
  background: rgba(251, 191, 36, 0.045);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.cycle-note {
  border-color: rgba(167, 139, 250, 0.3);
  background: rgba(167, 139, 250, 0.05);
}

.missing-card .note-icon,
.cycle-note .note-icon {
  flex: 0 0 auto;
  color: var(--amber);
  font-size: 13px;
  line-height: 1.4;
}

.cycle-note .note-icon {
  color: var(--accent-2);
}

.missing-card .note-body,
.cycle-note .note-body {
  min-width: 0;
}

.missing-card .note-title,
.cycle-note .note-title {
  color: var(--text-soft);
  font-weight: 600;
}

.missing-card code,
.cycle-note code {
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 10.5px;
  overflow-wrap: anywhere;
}

.missing-card .note-meta {
  margin-top: 2px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  overflow-wrap: anywhere;
}

.card-more {
  margin: 7px 8px 0;
  border-top: 1px dashed var(--border);
}

.card-more > summary {
  padding: 5px 6px 4px;
  cursor: pointer;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 550;
  list-style: none;
}

.card-more > summary::-webkit-details-marker {
  display: none;
}

.card-more > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 5px;
  font-size: 8px;
  transition: transform 0.15s ease;
}

.card-more[open] > summary::before {
  transform: rotate(90deg);
}

.card-more pre {
  margin: 2px 0 6px;
  padding: 7px 9px;
  max-height: 200px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-deep);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Included groups ---------------------------------------------------------- */

.type-group {
  margin-bottom: 12px;
}

.type-group-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 2px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.type-group-head .count-pill {
  height: 16px;
  font-size: 9.5px;
}

.included-capped {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 9px;
  color: var(--muted);
  font-size: 11.5px;
}

/* Empty / notices ---------------------------------------------------------- */

.empty,
.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 100%;
  padding: 40px 20px;
  text-align: center;
}

.empty-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin-bottom: 2px;
  border: 1px solid rgba(94, 234, 212, 0.24);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(94, 234, 212, 0.1), rgba(167, 139, 250, 0.1));
  color: var(--accent);
  font-family: var(--mono);
  font-size: 27px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.empty h2,
.panel h2 {
  max-width: 460px;
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.empty p,
.panel p {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.empty-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid rgba(94, 234, 212, 0.35);
  border-radius: 8px;
  background: rgba(94, 234, 212, 0.1);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.primary-btn:hover {
  border-color: rgba(94, 234, 212, 0.55);
  background: rgba(94, 234, 212, 0.16);
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 550;
}

.secondary-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.empty-features {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 520px;
  margin-top: 8px;
}

.feature-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10.5px;
}

.feature-pill b {
  color: var(--accent);
  font-weight: 600;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.055);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.notice strong {
  color: var(--text-soft);
}

.notice .notice-icon {
  flex: 0 0 auto;
  color: var(--amber);
}

.notice.info {
  border-color: rgba(96, 165, 250, 0.25);
  background: rgba(96, 165, 250, 0.055);
}

.notice.info .notice-icon {
  color: var(--blue);
}

.notice.error {
  border-color: rgba(251, 113, 133, 0.3);
  background: rgba(251, 113, 133, 0.06);
}

.notice.error .notice-icon {
  color: var(--red);
}

/* Parse error -------------------------------------------------------------- */

.parse-error {
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 4px;
}

.parse-error-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.parse-error-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(251, 113, 133, 0.3);
  border-radius: 10px;
  background: rgba(251, 113, 133, 0.08);
  color: var(--red);
  font-size: 17px;
}

.parse-error-head h2 {
  margin: 0 0 3px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.parse-error-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.parse-error-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.code-snippet {
  margin: 0;
  padding: 12px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-deep);
  overflow: auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.65;
}

.snippet-line {
  display: flex;
  gap: 12px;
  padding: 0 14px;
  white-space: pre;
}

.snippet-line .ln {
  flex: 0 0 34px;
  color: var(--faint);
  text-align: right;
  user-select: none;
}

.snippet-line.is-bad {
  background: rgba(251, 113, 133, 0.1);
  color: var(--text);
}

.snippet-line.is-bad .ln {
  color: var(--red);
}

.parse-hint {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.55;
}

.parse-hint .tip {
  color: var(--accent);
}

/* JSON view ---------------------------------------------------------------- */

.json-toolbar {
  position: sticky;
  top: -14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -14px -14px 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 16, 24, 0.9);
  backdrop-filter: blur(12px);
}

html[data-theme="light"] .json-toolbar {
  background: rgba(255, 255, 255, 0.92);
}

.json-toolbar .toolbar-label {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.json-meta {
  margin-left: auto;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10.5px;
}

.json-code {
  margin: 0;
  padding: 14px 16px 22px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-deep);
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.62;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}

.json-code.wrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tok-key {
  color: #8ecae6;
}

html[data-theme="light"] .tok-key {
  color: #1d4ed8;
}

.tok-str {
  color: #a5e8c8;
}

html[data-theme="light"] .tok-str {
  color: #0f766e;
}

.tok-num {
  color: #f2b880;
}

html[data-theme="light"] .tok-num {
  color: #b45309;
}

.tok-lit {
  color: #c4b5fd;
}

html[data-theme="light"] .tok-lit {
  color: #6d28d9;
}

.json-plain {
  color: var(--muted);
}

/* Issues ------------------------------------------------------------------- */

.issues-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.issues-toolbar .toolbar-label {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.issue {
  display: flex;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.issue + .issue {
  margin-top: 7px;
}

.issue-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.issue.is-error .issue-icon {
  background: rgba(251, 113, 133, 0.13);
  color: var(--red);
}

.issue.is-warning .issue-icon {
  background: rgba(251, 191, 36, 0.13);
  color: var(--amber);
}

.issue.is-info .issue-icon {
  background: rgba(96, 165, 250, 0.12);
  color: var(--blue);
}

.issue-main {
  min-width: 0;
  flex: 1 1 auto;
}

.issue-title-line {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.issue-title {
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 650;
}

.issue-code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.issue-message {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.issue-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 7px;
}

.pointer {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--pane-2);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9.5px;
  overflow-wrap: anywhere;
}

.pointer button {
  border: 0;
  background: transparent;
  color: var(--faint);
  padding: 0;
  font-size: 10px;
}

.pointer button:hover {
  color: var(--accent);
}

.issue-spec {
  color: var(--faint);
  font-size: 9.5px;
  text-decoration: none;
}

.issue-spec:hover {
  color: var(--accent);
}

.issue-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 2px 8px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.issue-group-label:first-child {
  margin-top: 0;
}

.checks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 640px;
  margin-top: 8px;
  text-align: left;
}

.check-item {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}

.check-item .tick {
  flex: 0 0 auto;
  color: var(--green);
}

/* Graph -------------------------------------------------------------------- */

.graph {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.graph-toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--pane-2);
}

.graph-toolbar .toolbar-label {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-right: 2px;
}

.graph-toolbar .toolbar-spacer {
  flex: 1 1 auto;
}

.zoom-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.zoom-group button {
  width: 28px;
  height: 26px;
  border: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}

.zoom-group button:first-child {
  border-left: 0;
}

.zoom-group button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.graph-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.graph-canvas {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(148, 163, 184, 0.14) 1px, transparent 1px),
    radial-gradient(900px 500px at 30% 20%, rgba(94, 234, 212, 0.05), transparent 60%);
  background-size: 22px 22px, 100% 100%;
}

html[data-theme="light"] .graph-canvas {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(71, 85, 105, 0.15) 1px, transparent 1px),
    radial-gradient(900px 500px at 30% 20%, rgba(20, 184, 166, 0.06), transparent 60%);
}

.graph-canvas.is-panning {
  cursor: grabbing;
}

.graph-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.graph-edge {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1.4;
  transition: opacity 0.15s ease, stroke 0.15s ease;
}

.graph-edge.is-back {
  stroke-dasharray: 4 4;
  opacity: 0.7;
}

.graph-edge.is-hot {
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 1;
}

.graph-svg.has-selection .graph-edge:not(.is-hot) {
  opacity: 0.18;
}

.graph-edge-label {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  paint-order: stroke;
  stroke: var(--bg-deep);
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}

html[data-theme="light"] .graph-edge-label {
  stroke: #f8fafc;
}

.graph-svg.has-selection .graph-edge-label:not(.is-hot) {
  opacity: 0.15;
}

.graph-edge-label.is-hot {
  fill: var(--accent);
}

.node-group {
  cursor: pointer;
}

.graph-node rect {
  fill: var(--surface-2);
  stroke: hsl(var(--h, 190) 60% 55% / 0.55);
  stroke-width: 1.4;
  rx: 10;
  transition: fill 0.15s ease, stroke 0.15s ease, opacity 0.15s ease;
}

.graph-node:hover rect {
  fill: var(--surface-3);
  stroke: hsl(var(--h, 190) 70% 62% / 0.9);
}

.graph-node .node-type {
  fill: hsl(var(--h, 190) 75% 70%);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  pointer-events: none;
}

html[data-theme="light"] .graph-node .node-type {
  fill: hsl(var(--h, 190) 60% 32%);
}

.graph-node .node-id {
  fill: var(--text-soft);
  font-family: var(--mono);
  font-size: 10.5px;
  pointer-events: none;
}

.graph-node .node-included {
  fill: var(--faint);
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  pointer-events: none;
}

.graph-node.is-root rect {
  fill: hsl(var(--h, 190) 60% 50% / 0.1);
}

.graph-node.is-orphan rect {
  stroke-dasharray: 5 4;
  stroke: rgba(251, 191, 36, 0.6);
}

.graph-node.is-missing rect {
  fill: transparent;
  stroke: rgba(251, 113, 133, 0.5);
  stroke-dasharray: 3 3;
}

.graph-node.is-missing .node-type {
  fill: var(--red);
}

.graph-node.is-selected rect {
  stroke: var(--accent);
  stroke-width: 2.4;
  filter: drop-shadow(0 0 10px rgba(94, 234, 212, 0.3));
}

.graph-node.is-dim {
  opacity: 0.25;
}

.graph-node:focus {
  outline: none;
}

.graph-node:focus-visible rect {
  stroke: var(--accent);
  stroke-width: 2.2;
}

.graph-hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(12, 16, 24, 0.82);
  color: var(--faint);
  font-size: 10px;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

html[data-theme="light"] .graph-hint {
  background: rgba(255, 255, 255, 0.86);
}

.graph-hint kbd {
  padding: 0 4px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.graph-legend {
  position: absolute;
  right: 12px;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(12, 16, 24, 0.82);
  color: var(--faint);
  font-size: 9.5px;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

html[data-theme="light"] .graph-legend {
  background: rgba(255, 255, 255, 0.86);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
}

.legend-swatch.root {
  border-color: rgba(94, 234, 212, 0.6);
  background: rgba(94, 234, 212, 0.14);
}

.legend-swatch.orphan {
  border-style: dashed;
  border-color: rgba(251, 191, 36, 0.65);
  background: transparent;
}

.legend-swatch.missing {
  border-style: dotted;
  border-color: rgba(251, 113, 133, 0.6);
  background: transparent;
}

.graph-inspector {
  flex: 0 0 280px;
  min-width: 0;
  overflow: auto;
  border-left: 1px solid var(--border);
  background: var(--pane-2);
  padding: 12px;
}

.inspector-kicker {
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.inspector-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.inspector-id {
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.inspector-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11.5px;
}

.inspector-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.inspector-stat {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.inspector-stat b {
  display: block;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}

.inspector-stat span {
  color: var(--faint);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.inspector-section-label {
  margin: 12px 0 5px;
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.inspector-rel {
  display: flex;
  gap: 6px;
  padding: 3px 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
}

.inspector-rel .rel-arrow {
  color: var(--faint);
}

.inspector-rel .rel-target {
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.inspector-attr {
  display: grid;
  grid-template-columns: minmax(60px, 35%) 1fr;
  gap: 6px;
  padding: 2px 0;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
}

.inspector-attr .k {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.inspector-attr .v {
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.inspector-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.graph-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

/* Toast -------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 100;
  transform: translate(-50%, 12px);
  max-width: min(92vw, 420px);
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--toast-bg);
  color: #e7ecf5;
  font-size: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Responsive --------------------------------------------------------------- */

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: minmax(300px, 38%) minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .brand-text p {
    display: none;
  }
}

@media (max-width: 860px) {
  body {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  .topbar {
    padding: 10px 12px;
  }

  .brand-text h1 {
    font-size: 14px;
  }

  .spec-link {
    display: none;
  }

  .select-wrap select {
    max-width: 150px;
  }

  .layout {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 10px;
  }

  .input-pane {
    height: 420px;
    flex: 0 0 auto;
  }

  .output-pane {
    height: 720px;
    flex: 0 0 auto;
  }

  .graph-inspector {
    flex-basis: 240px;
  }

  .attr,
  .rel-row {
    grid-template-columns: minmax(84px, 30%) minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .brand-text h1 {
    font-size: 13px;
  }

  .pane-tools .ghost-btn {
    padding: 0 6px;
  }

  .output-pane {
    height: 760px;
  }

  .card-label {
    display: none;
  }

  .graph-inspector {
    display: none;
  }

  .graph-hint {
    display: none;
  }

  .graph-legend {
    display: none;
  }

  .view {
    padding: 10px;
  }

  .tree-toolbar,
  .json-toolbar {
    margin-left: -10px;
    margin-right: -10px;
    padding-left: 10px;
    padding-right: 10px;
    top: -10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
