:root {
  color-scheme: light;
  --bg: #f4f4f4;
  --header-bg: #333;
  --card-bg: #fff;
  --text: #1d2733;
  --muted: #667085;
  --line: #d6dde7;
  --panel: #f4f4f4;
  --toolbar: #f7f8fa;
  --primary: #1769aa;
  --primary-hover: #0f548a;
  --danger: #d9534f;
  --danger-hover: #c7423e;
  --focus: #1769aa;
  --radius: 8px;
  --shadow: 0 0 10px rgba(0,0,0,.1);
  --link: #333;
  --link-hover: #007BFF;
}

* {
  box-sizing: border-box;
}

html, body {
  min-height: 100%;
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}

.topbar-inner {
  width: 100%;
  min-height: 51px;
  margin: 0;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
  min-width: 0;
}

.home-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  flex: 0 0 auto;
}

.home-logo:hover {
  color: #fff;
  text-decoration: none;
  opacity: .92;
}

.home-logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #2b7bbb, #1769aa);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}

.home-logo-text {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.brand {
  flex: 0 0 auto;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  position: relative;
  padding-left: 14px;
}

.brand::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 1px;
  height: 16px;
  transform: translateY(-50%);
  background: rgba(255,255,255,.28);
}

.brand:hover {
  color: #fff;
  text-decoration: none;
  opacity: .92;
}

.brand span {
  color: #9fd0ff;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.main-nav a {
  color: #d2d6da;
  padding: 16px 12px;
  white-space: nowrap;
}

.main-nav a:hover,
.main-nav .active {
  background: #222;
  color: #fff;
  text-decoration: none;
}

.main-nav a:hover {
  color: #fff;
}

.main-nav a:not([data-category]) {
  opacity: .7;
}

[hidden] {
  display: none !important;
}

.page {
  width: 100%;
  margin: 0;
  padding-right: 32px;
  padding-left: 32px;
}

main.page {
  padding-top: 18px;
  padding-bottom: 24px;
  flex: 1 1 auto;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  max-height: none;
  overflow: visible;
}

.tabs a {
  padding: 10px 12px;
  border: 1px solid transparent;
  border-bottom: none;
  white-space: nowrap;
  color: var(--primary);
}

.tabs .current {
  color: var(--text);
  background: var(--card-bg);
  border-color: var(--line);
  border-radius: 8px 8px 0 0;
  font-weight: 600;
}

.tabs a:hover {
  color: var(--link-hover);
}

h1 {
  margin: 0 0 14px;
  font-size: 22px;
  color: #101828;
  line-height: 1.35;
}

h2 {
  margin: 24px 0 8px;
  font-size: 18px;
}

.tool {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  background: var(--toolbar);
  border-bottom: 1px solid var(--line);
}

.button-group,
.options {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.advanced-options {
  margin-right: auto;
  padding-top: 2px;
}

.tool-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tool-field input {
  width: 150px;
  padding: 0 8px;
}

.tool-field-segmented {
  gap: 0;
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid #c9ced6;
  border-radius: 7px;
  background: #fff;
}

.segmented-control button {
  min-width: 112px;
  height: 34px;
  padding: 0 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-weight: 600;
}

.segmented-control button + button {
  border-left: 1px solid #c9ced6;
}

.segmented-control button:hover:not(.active) {
  background: #eef1f4;
}

.segmented-control button.active,
.segmented-control button[aria-pressed="true"] {
  background: var(--primary);
  color: #fff;
}

.segmented-control button:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid #6d96c5;
  outline-offset: -2px;
}

button,
select,
input {
  font: inherit;
}

button,
select,
input[type="number"] {
  height: 32px;
  border: 1px solid #c9ced6;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

button {
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  background: #f7f7f7;
}

.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-hover);
}

.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.danger:hover {
  background: var(--danger-hover);
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

#fileInput {
  display: none;
}

#imageFileInput {
  display: none;
}

.options label {
  color: #333;
}

.options select {
  width: 96px;
  padding: 0 8px;
}

.options input[type="number"] {
  width: 78px;
  padding: 0 8px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.check input {
  height: auto;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.workspace.has-secondary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.workspace.has-output {
  grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr);
}

.workspace.has-tree {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.workspace.has-output.has-tree {
  grid-template-columns: minmax(0, 1fr) 64px repeat(2, minmax(0, 1fr));
}

.workspace.has-secondary.has-output {
  grid-template-columns: repeat(2, minmax(0, 1fr)) 64px minmax(0, 1fr);
}

.workspace.secondary-first #secondaryPane {
  order: -1;
}

.editor-pane,
.tree-pane {
  min-width: 0;
  border-right: 1px solid var(--line);
}

.editor-pane:last-child,
.tree-pane:last-child {
  border-right: 0;
}

.pane-title {
  height: 34px;
  padding: 7px 10px;
  background: #f7f8fa;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.editor {
  width: 100%;
  height: 505px;
}

.tree-pane {
  background: #fff;
}

.json-tree {
  height: 505px;
  overflow: auto;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.json-tree details {
  margin: 2px 0 2px 14px;
}

.json-tree summary {
  cursor: pointer;
  color: #234f7d;
}

.json-tree .tree-leaf {
  margin: 2px 0 2px 24px;
  white-space: pre-wrap;
}

.json-tree .tree-key {
  color: #7a3f14;
}

.json-tree .tree-value {
  color: #1d6f42;
}

.json-editor-toolbar {
  align-items: center;
}

.json-editor-toolbar-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.json-editor-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px minmax(0, 1fr);
  min-height: 505px;
}

.json-editor-pane {
  min-width: 0;
  background: #fff;
}

.json-editor-tree-pane {
  border-right: 1px solid var(--line);
}

.json-editor-raw-pane {
  display: flex;
  flex-direction: column;
}

.json-editor-tree {
  height: 505px;
  overflow: auto;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.json-editor-tree details {
  margin: 2px 0 2px 14px;
}

.json-editor-tree > .json-editor-node > details {
  margin-left: 0;
}

.json-editor-tree summary {
  padding: 4px 6px;
  cursor: pointer;
  color: #234f7d;
  user-select: none;
}

.json-editor-tree summary:hover {
  background: #f2f6fa;
}

.json-editor-entries {
  padding-left: 10px;
  border-left: 1px solid #e3e7eb;
}

.json-editor-entry,
.json-editor-primitive {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  margin: 3px 0;
}

.json-editor-key,
.json-editor-index {
  flex: 0 0 auto;
  color: #7a3f14;
}

.json-editor-key-input {
  width: min(150px, 28%);
  min-width: 70px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid #c9ced6;
  border-radius: 6px;
  color: #7a3f14;
}

.json-editor-type {
  width: 84px;
  padding: 0 5px;
}

.json-editor-value {
  flex: 1 1 auto;
  min-width: 60px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid #c9ced6;
  border-radius: 6px;
  font-family: Consolas, "Courier New", monospace;
}

.json-editor-remove,
.json-editor-add {
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.json-editor-remove {
  flex: 0 0 auto;
  color: #a94442;
}

.json-editor-add {
  margin: 5px 0 5px 10px;
  color: #286090;
}

.json-editor-sync {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: #fafafa;
}

.json-editor-sync button {
  width: 100%;
  padding: 0 6px;
  white-space: nowrap;
}

.json-editor-sync button:first-child,
.json-editor-sync button:last-child {
  font-size: 20px;
}

#jsonEditorRaw {
  width: 100%;
  flex: 1 1 auto;
  min-height: 450px;
  resize: vertical;
  padding: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  color: #263238;
  font: 13px/1.65 Consolas, "Courier New", monospace;
}

#jsonEditorRaw:focus {
  box-shadow: inset 0 0 0 2px rgba(75, 145, 199, .28);
}

.json-editor-message {
  min-height: 38px;
  margin: 0;
  padding: 9px 12px;
  color: #3c763d;
  font-size: 13px;
}

.json-editor-message.error {
  color: #a94442;
}

.json-editor-empty {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.image-toolbar {
  align-items: flex-start;
  flex-direction: column;
}

.image-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  width: 100%;
}

.image-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  white-space: nowrap;
}

.image-field input[type="text"] {
  width: 150px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid #c9ced6;
  border-radius: 6px;
}

.image-field input[type="number"] {
  width: 82px;
  padding: 0 8px;
}

.image-field input[type="range"] {
  width: 132px;
  accent-color: var(--primary);
}

.image-field input[type="color"] {
  width: 42px;
  height: 32px;
  padding: 2px;
  border: 1px solid #c9ced6;
  border-radius: var(--radius);
  background: var(--card-bg);
}

.image-field select {
  min-width: 104px;
  padding: 0 8px;
}

.image-field output {
  min-width: 46px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.image-field small {
  color: var(--muted);
}

.image-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.image-pane {
  min-width: 0;
}

.image-pane:first-child {
  border-right: 1px solid var(--line);
}

.image-pane-body,
.image-result {
  min-height: 505px;
  padding: 14px;
  background: #fff;
}

.image-dropzone {
  min-height: 425px;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 18px;
  border: 1px dashed #b9c2cc;
  background: #fafbfc;
  color: var(--muted);
  cursor: pointer;
}

.image-dropzone:hover,
.image-dropzone.dragging {
  border-color: var(--primary);
  background: #f4f9fc;
}

.image-dropzone:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.image-dropzone p {
  margin: 0;
  text-align: center;
}

.image-dropzone img {
  display: block;
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
}

.image-text-entry {
  min-height: 425px;
}

.image-text-entry label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
}

.image-text-entry textarea,
.image-text-output {
  width: 100%;
  min-height: 390px;
  resize: vertical;
  padding: 12px;
  border: 1px solid #c9ced6;
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  font: 13px/1.55 Consolas, "Courier New", monospace;
}

.image-generated-hint,
.image-file-ready {
  min-height: 425px;
  display: grid;
  place-items: center;
  border: 1px dashed #c9ced6;
  background: #fafbfc;
  color: var(--muted);
  text-align: center;
}

.image-meta,
.image-result-meta {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.image-result {
  overflow: auto;
}

.image-result-empty {
  min-height: 455px;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.image-result-preview {
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: auto;
  background: repeating-conic-gradient(#f1f3f5 0 25%, #fff 0 50%) 50% / 20px 20px;
  border: 1px solid var(--line);
}

.image-result-canvas {
  display: block;
  max-width: 100%;
  max-height: 440px;
  object-fit: contain;
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.image-gallery figure {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  background: #fafafa;
}

.image-gallery-canvas {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: contain;
  background: repeating-conic-gradient(#f1f3f5 0 25%, #fff 0 50%) 50% / 16px 16px;
}

.image-gallery figcaption {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 7px;
  color: var(--muted);
  font-size: 12px;
}

.image-gallery figcaption span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-gallery figcaption button {
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.network-toolbar {
  align-items: flex-start;
  flex-direction: column;
}

.network-options {
  width: 100%;
}

.network-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.network-pane {
  min-width: 0;
}

.network-pane:first-child {
  border-right: 1px solid var(--line);
}

.network-controls,
.network-result {
  min-height: 505px;
  padding: 14px;
  background: #fff;
}

.network-controls {
  display: flex;
  align-content: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.network-field {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.network-field > span {
  flex: 0 0 90px;
  color: var(--muted);
}

.network-field input[type="text"],
.network-field input[type="number"],
.network-field select {
  width: min(260px, 100%);
  height: 32px;
  padding: 0 8px;
  border: 1px solid #c9ced6;
  border-radius: var(--radius);
  background: var(--card-bg);
}

.network-field input[type="range"] {
  width: min(220px, 100%);
  accent-color: var(--primary);
}

.network-field output,
.network-field small {
  color: var(--muted);
}

.network-info-hint {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fafafa;
  color: var(--muted);
}

.network-result {
  overflow: auto;
}

.network-result-empty {
  min-height: 455px;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.network-result-text {
  min-height: 455px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  background: #fafafa;
  color: #263238;
  font: 13px/1.65 Consolas, "Courier New", monospace;
}

.network-mouse-surface,
.network-keyboard-surface {
  width: 100%;
  min-height: 425px;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px dashed #aeb9c4;
  background: #fafbfc;
  color: var(--muted);
  text-align: center;
  cursor: crosshair;
}

.network-keyboard-surface {
  cursor: text;
}

.network-mouse-surface:focus-visible,
.network-keyboard-surface:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.network-mic-meter {
  width: 100%;
  height: 30px;
  overflow: hidden;
  border: 1px solid #b9c2cc;
  background: #f1f3f5;
}

.network-mic-level {
  width: 0;
  height: 100%;
  background: #4caa6a;
  transition: width .08s linear;
}

.network-screen-surface {
  width: 100%;
  min-height: 425px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(120px, 1fr));
  border: 1px solid #222;
  overflow: hidden;
}

.network-screen-swatch {
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
}

.network-screen-swatch.black { background: #000; color: #fff; }
.network-screen-swatch.white { background: #fff; color: #111; }
.network-screen-swatch.red { background: #f00; color: #fff; }
.network-screen-swatch.green { background: #0c0; color: #111; }
.network-screen-swatch.blue { background: #00f; color: #fff; }
.network-screen-swatch.gray { background: #888; color: #fff; }

.details {
  max-width: none;
  padding: 18px 0 50px;
}

.details p {
  margin: 0 0 8px;
  color: #333;
}

dialog {
  border: 0;
  border-radius: 6px;
  padding: 0;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .28);
}

dialog::backdrop {
  background: rgba(0, 0, 0, .28);
}

.settings {
  width: min(480px, calc(100vw - 36px));
  padding: 18px;
  display: grid;
  gap: 10px;
}

.settings header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings h2 {
  margin: 0;
}

.settings input,
.settings select {
  width: 100%;
  padding: 0 10px;
}

.settings footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
}

.icon-button {
  width: 32px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  z-index: 20;
  min-width: 160px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 10px 14px;
  border-radius: 6px;
  background: rgba(32, 36, 42, .94);
  color: #fff;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* site-aligned help spacing under tools */
main.page > h2 {
  margin-top: 28px;
  margin-bottom: 8px;
  font-size: 18px;
  color: #101828;
}

main.page > p {
  margin: 0 0 10px;
  color: var(--text);
  line-height: 1.7;
}

.footer {
  border-top: 1px solid #222;
  background: var(--header-bg);
  color: #abb3bf;
  padding: 14px 10px;
  margin-top: auto;
  flex-shrink: 0;
}

.footer p {
  margin: 0 0 6px;
  text-align: center;
}

.footer-record {
  margin-top: 0 !important;
}

.footer-record a {
  color: #abb3bf;
  font-size: 0.9em;
  text-decoration: none;
}

.footer-record a:hover {
  color: #fff;
}

@media (max-width: 900px) {
  .topbar-inner {
    align-items: stretch;
    flex-direction: column;
    gap: 0;
    padding: 8px 0;
  }

  .brand-cluster {
    padding: 4px 12px 6px;
  }

  .home-logo-text {
    font-size: 13px;
  }

  .main-nav {
    overflow-x: auto;
  }

  .main-nav a {
    padding: 8px 10px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace.has-secondary,
  .workspace.has-output,
  .workspace.has-tree,
  .workspace.has-output.has-tree,
  .workspace.has-secondary.has-output {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor-pane,
  .tree-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .image-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .image-pane:first-child {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .network-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .network-pane:first-child {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .json-editor-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .json-editor-tree-pane,
  .json-editor-sync {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .json-editor-sync {
    flex-direction: row;
    align-items: center;
    justify-content: center;
  }

  .json-editor-sync button {
    width: auto;
    min-width: 72px;
  }
}

/* Editors and result panes always consume the full width of their work area. */
.tool,
.workspace,
.editor-pane,
.tree-pane,
.editor,
.json-editor-workspace,
.json-editor-pane,
.json-editor-tree,
#jsonEditorRaw,
.image-workspace,
.image-pane,
.image-pane-body,
.image-result,
.network-workspace,
.network-pane,
.network-controls,
.network-result {
  width: 100%;
  min-width: 0;
}

/* Keep the page chrome centered, but let every editor surface use the viewport width. */
#toolPanel,
.json-editor-tool,
.image-tool,
.network-tool {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

@media (max-width: 560px) {
  .page,
  .topbar-inner {
    width: 100%;
    padding-right: 10px;
    padding-left: 10px;
  }

  .button-group button {
    flex: 1 1 calc(33.333% - 6px);
    padding: 0 8px;
  }

  .options {
    align-items: flex-start;
    width: 100%;
  }

  .editor {
    height: 62vh;
    min-height: 420px;
  }

  .image-options {
    align-items: flex-start;
    flex-direction: column;
  }

  .image-field {
    width: 100%;
  }

  .image-field input[type="range"] {
    flex: 1 1 auto;
    min-width: 110px;
  }

  .image-pane-body,
  .image-result {
    min-height: 390px;
  }

  .image-dropzone,
  .image-text-entry,
  .image-generated-hint,
  .image-file-ready {
    min-height: 340px;
  }

  .image-text-entry textarea,
  .image-text-output {
    min-height: 320px;
  }

  .image-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .network-controls,
  .network-result {
    min-height: 390px;
  }

  .network-mouse-surface,
  .network-keyboard-surface,
  .network-screen-surface {
    min-height: 340px;
  }

  .network-field {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .network-field > span {
    flex-basis: 100%;
  }

  .json-editor-toolbar-note {
    width: 100%;
  }

  .json-editor-entry,
  .json-editor-primitive {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .json-editor-key-input {
    width: 100%;
  }

  .json-editor-type {
    width: 90px;
  }

  .json-editor-value {
    min-width: 0;
  }
}

/* JSON editor visual overrides */
.json-editor-tool {
  overflow: hidden;
  border-color: #cbd5e1;
  box-shadow: 0 8px 24px rgba(30, 41, 59, .07);
}

.json-editor-workspace {
  grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr);
  min-height: 510px;
}

.json-editor-tree-pane {
  border-right: 0;
  border-left: 1px solid #dbe3ec;
}

.json-editor-pane-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 7px 10px;
  border-bottom: 1px solid #dbe3ec;
  background: #f8fafc;
}

.json-editor-pane-label {
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
}

.json-editor-mode-buttons,
.json-editor-tree-actions,
.json-editor-footer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.json-editor-mode-buttons button,
.json-editor-tree-actions button {
  width: 32px;
  height: 26px;
  padding: 0;
  border-color: #b7c8d8;
  background: #e9f6ff;
  color: #27658b;
  font-size: 0;
}

#jsonEditorFormat::before {
  content: "{}";
  font-size: 12px;
}

#jsonEditorCompact::before {
  content: "≡";
  font-size: 16px;
}

#jsonEditorExpand::before {
  content: "↕";
  font-size: 16px;
}

#jsonEditorCollapse::before {
  content: "↔";
  font-size: 16px;
}

.json-editor-mode-buttons button:hover,
.json-editor-tree-actions button:hover {
  border-color: #75acd0;
  background: #d9effc;
}

.json-editor-tree {
  height: 468px;
  overflow: auto;
  padding: 12px 14px 20px;
  font-size: 13px;
}

.json-editor-tree details {
  margin: 0 0 2px 12px;
}

.json-editor-tree > .json-editor-node > details {
  margin-left: 0;
}

.json-editor-tree summary {
  min-height: 28px;
  padding: 5px 7px;
  border-radius: 6px;
  color: #475569;
  font-weight: 600;
}

.json-editor-tree summary:hover {
  background: #f1f5f9;
}

.json-editor-entries {
  margin-left: 8px;
  padding: 2px 0 2px 12px;
  border-left: 1px solid #dbe3ec;
}

.json-editor-entry {
  display: grid;
  grid-template-columns: minmax(90px, 28%) minmax(0, 1fr) 30px;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 32px;
  margin: 2px 0;
}

.json-editor-key,
.json-editor-index {
  min-width: 0;
  overflow: hidden;
  color: #475569;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.json-editor-key-input {
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 5px;
  border: 1px solid transparent;
  background: transparent;
  color: #334155;
  font-family: Consolas, "Courier New", monospace;
}

.json-editor-key-input:hover,
.json-editor-key-input:focus,
.json-editor-type:hover,
.json-editor-type:focus,
.json-editor-value:hover,
.json-editor-value:focus {
  border-color: #b7c8d8;
  background: #fff;
  outline: none;
}

.json-editor-node {
  min-width: 0;
}

.json-editor-primitive {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.json-editor-type {
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 3px;
  border-color: transparent;
  background: transparent;
  color: #64748b;
  font-size: 12px;
}

.json-editor-value {
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 5px;
  border: 1px solid transparent;
  background: transparent;
  color: #159447;
  font-family: Consolas, "Courier New", monospace;
}

.json-editor-remove {
  width: 30px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: #a94442;
  font-size: 0;
  opacity: 0;
}

.json-editor-remove::before {
  content: "×";
  font-size: 18px;
}

.json-editor-entry:hover .json-editor-remove,
.json-editor-remove:focus {
  border-color: #e3b3b1;
  background: #fff8f7;
  opacity: 1;
}

.json-editor-add {
  width: 18px;
  height: 18px;
  margin: 5px 0 5px 8px;
  padding: 0;
  border: 1px dashed #b7c8d8;
  background: #f8fafc;
  color: #27658b;
  font-size: 0;
  line-height: 1;
}

.json-editor-add::before {
  content: "+";
  font-size: 15px;
}

.json-editor-add:hover {
  border-color: #75acd0;
  background: #e9f6ff;
}

.json-editor-sync {
  gap: 10px;
  padding: 12px 8px;
  border-right: 0;
  background: #f8fafc;
}

.json-editor-sync button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-color: #c4d0dc;
  background: #fff;
  color: #64748b;
  font-size: 17px;
}

.json-editor-sync button:hover {
  border-color: #75acd0;
  background: #e9f6ff;
  color: #27658b;
}

#jsonEditorRaw {
  height: 468px;
  min-height: 0;
  resize: none;
  padding: 14px 16px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #334155;
  font: 13px/1.75 Consolas, "Courier New", monospace;
}

.json-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 8px 12px;
  border-top: 1px solid #dbe3ec;
  background: #f8fafc;
}

.json-editor-message {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 28px;
  margin: 0;
  padding: 5px 0;
  color: #3c763d;
  font-size: 13px;
}

.json-editor-footer-actions button {
  height: 30px;
  padding: 0 10px;
}

.json-editor-empty {
  margin: 30px 0;
}

@media (max-width: 900px) {
  .json-editor-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .json-editor-tree-pane {
    border-top: 1px solid #dbe3ec;
    border-left: 0;
  }

  .json-editor-sync {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    border-top: 1px solid #dbe3ec;
    border-bottom: 1px solid #dbe3ec;
  }

  .json-editor-sync button {
    width: 54px;
  }

  .json-editor-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .json-editor-footer-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .json-editor-footer-actions button {
    flex: 1 1 auto;
  }

  .json-editor-tree,
  #jsonEditorRaw {
    height: 420px;
  }
}

@media (max-width: 560px) {
  .json-editor-entry {
    grid-template-columns: minmax(80px, 30%) minmax(0, 1fr) 30px;
  }

  .json-editor-primitive {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .json-editor-key-input {
    font-size: 12px;
  }

  .json-editor-type {
    font-size: 11px;
  }
}

/* Keep deeply nested tree controls readable instead of forcing them into one row. */
.json-editor-entry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}

.json-editor-entry > .json-editor-key-input,
.json-editor-entry > .json-editor-index {
  flex: 0 0 auto;
  min-width: 0;
}

.json-editor-entry > .json-editor-node {
  flex: 1 1 170px;
  min-width: 0;
}

.json-editor-entry > .json-editor-key-input {
  width: auto;
  max-width: 18ch;
}

.json-editor-separator {
  flex: 0 0 auto;
  color: #94a3b8;
}

.json-editor-entry > .json-editor-remove {
  position: absolute;
  top: 2px;
  right: 0;
  flex: 0 0 30px;
  margin-left: 0;
}

.json-editor-primitive {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}

.json-editor-primitive > .json-editor-type {
  flex: 0 1 76px;
  width: 76px;
}

.json-editor-primitive > .json-editor-value {
  flex: 1 1 72px;
  width: auto;
}

.json-editor-entry {
  position: relative;
  padding-right: 34px;
}

.json-editor-key-input,
.json-editor-value {
  border-color: transparent;
  background: transparent;
}

.json-editor-type {
  flex: 0 0 12px !important;
  width: 12px !important;
  padding: 0 !important;
  border-color: transparent;
  background: transparent;
  color: transparent;
  font-size: 0;
  appearance: none;
}

.json-editor-type:hover,
.json-editor-type:focus {
  width: 84px !important;
  flex-basis: 84px !important;
  padding: 0 4px !important;
  font-size: 12px;
  color: #64748b;
  appearance: auto;
}

.json-editor-value-string {
  color: #15803d;
}

.json-editor-value-number {
  color: #dc2626;
}

.json-editor-value-boolean {
  color: #2563eb;
}

.json-editor-value-null {
  color: #94a3b8;
}

/* Field names stay text-like while remaining editable. */
.json-editor-key-input,
.json-editor-key-input:hover,
.json-editor-key-input:focus,
.json-editor-key-input:focus-visible,
.json-editor-value,
.json-editor-value:hover,
.json-editor-value:focus,
.json-editor-value:focus-visible {
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

.json-editor-remove {
  border-color: transparent;
  background: #f1f5f9;
  color: #94a3b8;
  opacity: .72;
}

.json-editor-entry:hover .json-editor-remove,
.json-editor-remove:focus {
  border-color: #cbd5e1;
  background: #e2e8f0;
  color: #475569;
  opacity: 1;
}

/* Keep JSON editor controls compact, like the reference editor. */
.editor-transfer,
.json-editor-sync {
  align-items: center;
  gap: 14px;
  padding: 8px;
}

.editor-transfer {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  min-height: 0;
  background: #f8fafc;
}

#outputPane {
  border-left: 1px solid #dbe3ec;
}

.editor-transfer button,
.json-editor-sync button {
  box-sizing: border-box;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border-color: #c4d0dc;
  background: #fff;
  color: #64748b;
  font-size: 0;
}

.editor-transfer button:hover {
  border-color: #75acd0;
  background: #e9f6ff;
  color: #27658b;
}

#editorToOutput::before,
#editorToInput::before,
#jsonEditorToTree::before,
#jsonEditorToRaw::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

#editorToOutput::before,
#jsonEditorToTree::before {
  border-left: 8px solid currentColor;
  transform: translateX(1px);
}

#editorToInput::before,
#jsonEditorToRaw::before {
  border-right: 8px solid currentColor;
  transform: translateX(-1px);
}

@media (max-width: 900px) {
  .editor-transfer {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  #outputPane {
    border-left: 0;
  }
}

.json-editor-entry {
  padding-right: 26px;
}

.json-editor-entry > .json-editor-remove {
  top: 5px;
  width: 22px;
  height: 22px;
  flex-basis: 22px;
}

.json-editor-remove::before {
  font-size: 16px;
}

/* Dense tree rows keep related JSON fields visually grouped. */
.json-editor-tree {
  line-height: 1.35;
}

.json-editor-tree details {
  margin: 0 0 1px 10px;
}

.json-editor-tree summary {
  min-height: 24px;
  padding: 3px 5px;
  line-height: 18px;
}

.json-editor-entries {
  margin-left: 6px;
  padding: 0 0 0 10px;
}

.json-editor-entry,
.json-editor-primitive {
  min-height: 24px;
  margin: 0;
}

.json-editor-entry > .json-editor-key-input,
.json-editor-entry > .json-editor-separator {
  align-self: flex-start;
  margin-top: 0;
}

.json-editor-entry > .json-editor-index {
  align-self: flex-start;
  margin-top: 3px;
}

.json-editor-key-input,
.json-editor-value,
.json-editor-type {
  height: 24px;
}

.json-editor-key-input,
.json-editor-value,
.json-editor-separator {
  line-height: 24px;
}

.json-editor-separator {
  height: 24px;
}

.json-editor-entry > .json-editor-remove {
  top: 1px;
}

.json-editor-add {
  margin-top: 2px;
  margin-bottom: 2px;
}

/* Branch rows use content-sized key columns so nested summaries never overlap keys. */
.json-editor-entry {
  display: grid;
  grid-template-columns: max-content max-content minmax(0, 1fr) 18px;
  align-items: start;
  gap: 4px;
  padding-right: 0;
}

.json-editor-entry > .json-editor-node {
  min-width: 0;
}

.json-editor-entry > .json-editor-remove {
  position: static;
  grid-column: -1;
  width: 18px;
  height: 18px;
  flex-basis: 18px;
  margin: 0;
  align-self: start;
}

.json-editor-remove {
  padding: 0;
  border: 1px dashed #b7c8d8;
  background: #f8fafc;
  color: #64748b;
  line-height: 1;
  opacity: 1;
}

.json-editor-remove::before {
  font-size: 14px;
}

.json-editor-entry:hover .json-editor-remove,
.json-editor-remove:focus {
  border-color: #75acd0;
  background: #e9f6ff;
  color: #27658b;
  opacity: 1;
}

.json-editor-entry > .json-editor-key-input {
  width: var(--json-key-width, auto);
  max-width: calc(18ch + 12px);
}

/* Type selection stays available but does not reserve an empty inline column. */
.json-editor-primitive {
  position: relative;
}

.json-editor-primitive > .json-editor-type {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.json-editor-primitive > .json-editor-type:focus {
  width: 84px !important;
  height: 24px !important;
  padding: 0 4px !important;
  border: 1px solid #b7c8d8 !important;
  background: #fff;
  color: #64748b;
  opacity: 1;
  pointer-events: auto;
}

.json-editor-primitive > .json-editor-value {
  flex: 0 1 auto;
  width: auto;
  min-width: calc(4ch + 12px);
  max-width: calc(32ch + 12px);
}

.json-editor-workspace {
  height: 510px;
  min-height: 360px;
}

.workspace {
  height: 539px;
  min-height: 360px;
}

.workspace > .editor-pane,
.workspace > .tree-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.workspace .editor,
.workspace .json-tree {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

.json-editor-pane,
.json-editor-sync {
  height: 100%;
  min-height: 0;
}

.json-editor-tree-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.json-editor-tree,
#jsonEditorRaw {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

.editor-resize-handle {
  position: relative;
  height: 9px;
  border-top: 1px solid #dbe3ec;
  border-bottom: 1px solid #dbe3ec;
  background: #f8fafc;
  cursor: ns-resize;
  touch-action: none;
}

.editor-resize-handle::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 50%;
  width: 44px;
  height: 2px;
  transform: translateX(-50%);
  background: #94a3b8;
}

.editor-resize-handle:hover,
.editor-resize-handle.dragging,
.editor-resize-handle:focus-visible {
  background: #e9f6ff;
  outline: none;
}

.editor-resize-handle:hover::before,
.editor-resize-handle.dragging::before,
.editor-resize-handle:focus-visible::before {
  background: #27658b;
}

@media (max-width: 900px) {
  .workspace,
  .json-editor-workspace {
    height: auto !important;
    min-height: 0;
  }

  .workspace > .editor-pane,
  .workspace > .tree-pane {
    height: auto;
  }

  .workspace .editor,
  .workspace .json-tree {
    flex: none;
    height: 505px;
  }

  .json-editor-pane,
  .json-editor-sync {
    height: auto;
  }

  .json-editor-tree,
  #jsonEditorRaw {
    flex: none;
    height: 420px;
  }

  .editor-resize-handle {
    display: none;
  }
}

@media (max-width: 560px) {
  .workspace .editor,
  .workspace .json-tree {
    height: 62vh;
    min-height: 420px;
  }
}

@media (max-width: 900px) {
  .json-editor-entry > .json-editor-node {
    flex-basis: 150px;
  }
}
