/* ── Self-hosted fonts (OFL 1.1 — see /fonts/LICENSE-*.txt) ── */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/inter-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/inter-600.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-500.woff2') format('woff2');
}

/* ── Design tokens ─────────────────────────────────────── */
:root {
  --bg-base:       #0d0f12;
  --bg-panel:      #13161b;
  --bg-surface:    #1a1e26;
  --bg-hover:      #1f2430;
  --bg-active:     #252c3a;
  --border:        #2a2f3d;
  --border-focus:  #4a90e2;

  --text-primary:  #e2e6f0;
  --text-secondary:#7a8299;
  --text-muted:    #4a5068;
  --text-accent:   #4a90e2;
  --text-success:  #4caf82;
  --text-error:    #e25c5c;
  --text-warn:     #e2a94a;

  --accent:        #4a90e2;
  --accent-dim:    rgba(74,144,226,0.12);
  --success:       #4caf82;
  --error:         #e25c5c;

  --sidebar-w:     220px;
  --font-mono:     'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --font-ui:       'Inter', system-ui, -apple-system, sans-serif;
  --radius:        6px;
  --radius-sm:     4px;
  --transition:    150ms ease;
}

body.light {
  --bg-base:       #f4f5f7;
  --bg-panel:      #ffffff;
  --bg-surface:    #eceef2;
  --bg-hover:      #e4e6ec;
  --bg-active:     #d8dbe6;
  --border:        #d0d3de;
  --border-focus:  #4a90e2;

  --text-primary:  #1a1d27;
  --text-secondary:#4a5068;
  --text-muted:    #9099b2;
  --text-accent:   #2e6ec4;
  --text-success:  #2e8a5c;
  --text-error:    #c0392b;
  --text-warn:     #b07a1a;

  --accent:        #2e6ec4;
  --accent-dim:    rgba(46,110,196,0.10);
  --success:       #2e8a5c;
  --error:         #c0392b;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-ui);
  font-size: 13px;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
}

/* ── Scrollbars ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Layout ─────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
#header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 48px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
#header .logo {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
#header .logo span { color: var(--accent); }
#sidebar-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 5px 8px;
  font-size: 14px;
  line-height: 1;
  transition: var(--transition);
}
#sidebar-toggle:hover { border-color: var(--accent); color: var(--accent); }
#theme-toggle {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  transition: var(--transition);
  margin-left: 8px;
}
#theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
#theme-toggle svg { width: 16px; height: 16px; }
.header-spacer { flex: 1; }
.header-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Main body */
#body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: width 200ms ease, opacity 200ms ease;
}
#sidebar.collapsed {
  width: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.sidebar-section { margin-top: 8px; }
.sidebar-group-label {
  padding: 8px 14px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  user-select: none;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12.5px;
  border-radius: 0;
  transition: var(--transition);
  border-left: 2px solid transparent;
  white-space: nowrap;
  user-select: none;
}
.sidebar-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent);
}
.sidebar-item .icon { font-size: 13px; opacity: 0.7; }

/* Content area */
#content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Tool panels */
.tool-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  content-visibility: auto;
}
.tool-panel.active {
  display: flex;
}

/* Utility: small number/text input used in tool headers */
.tool-input-sm {
  width: 52px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 3px 6px;
  font-size: 12px;
  outline: none;
}

/* Auto-render toggle switch */
.zpl-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.zpl-toggle-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.zpl-toggle-track {
  display: inline-flex;
  align-items: center;
  width: 28px;
  height: 16px;
  background: var(--border);
  border-radius: 8px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.zpl-toggle-label input:checked + .zpl-toggle-track {
  background: var(--accent);
}
.zpl-toggle-thumb {
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  margin-left: 2px;
  transition: transform 0.15s;
}
.zpl-toggle-label input:checked + .zpl-toggle-track .zpl-toggle-thumb {
  transform: translateX(12px);
}

/* Utility: vertical divider used in tool headers */
.tool-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
  display: inline-block;
  flex-shrink: 0;
}

/* Utility: muted label text in tool headers */
.tool-label-sm {
  font-size: 11px;
  color: var(--text-muted);
}

/* Tool header bar */
.tool-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-panel);
}
.tool-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.tool-desc {
  font-size: 11px;
  color: var(--text-muted);
}
.tool-spacer { flex: 1; }

/* Two-pane layout for tools with input/output */
.pane-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}
.pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
/* Resize divider between panes */
.pane-divider {
  flex: 0 0 9px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: background 0.15s;
  position: relative;
  z-index: 1;
}
.pane-divider:hover,
.pane-divider.dragging {
  background: var(--accent-dim);
  border-color: var(--accent);
}
/* Five-dot vertical grip via box-shadow */
.divider-grip {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 6px 0 var(--text-muted), 0 -6px 0 var(--text-muted),
              0 12px 0 var(--text-muted), 0 -12px 0 var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}
.pane-divider:hover .divider-grip,
.pane-divider.dragging .divider-grip {
  background: var(--accent);
  box-shadow: 0 6px 0 var(--accent), 0 -6px 0 var(--accent),
              0 12px 0 var(--accent), 0 -12px 0 var(--accent);
}
.pane-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pane-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* Textareas */
.editor-wrap {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--bg-base);
}
.editor-wrap:focus-within { background: var(--bg-surface); }
.line-numbers {
  padding: 12px 8px 12px 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-muted);
  text-align: right;
  user-select: none;
  white-space: pre;
  overflow: hidden;
  flex-shrink: 0;
  min-width: 32px;
  border-right: 1px solid var(--border);
}
.editor-inner {
  position: relative;
  flex: 1;
  overflow: hidden;
}
.zpl-highlight {
  position: absolute;
  inset: 0;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
  overflow: auto;
  pointer-events: none;
  scrollbar-width: none;
}
.zpl-highlight::-webkit-scrollbar { display: none; }
textarea.code-input {
  flex: 1;
  background: var(--bg-base);
  color: var(--text-primary);
  border: none;
  outline: none;
  resize: none;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  tab-size: 2;
  overflow: auto;
}
textarea.code-input:focus { background: var(--bg-surface); }
textarea.code-input::placeholder { color: var(--text-muted); }

/* ZPL editor only: transparent text so the highlight layer shows through */
.editor-inner textarea.code-input {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  background: transparent;
  color: transparent;
  caret-color: var(--text-primary);
  padding: 12px 14px;     /* must match .zpl-highlight padding exactly */
  word-break: break-all;  /* must match .zpl-highlight word-break exactly */
  scrollbar-width: none;
}
.editor-inner textarea.code-input::-webkit-scrollbar { display: none; }
.editor-inner textarea.code-input:focus { background: transparent; }
/* ZPL syntax token colors */
.zpl-cmd     { color: #4a90e2; }
.zpl-tilde   { color: #c792ea; }
.zpl-string  { color: #4caf82; }
.zpl-num     { color: #e8963a; }
.zpl-comment { color: var(--text-muted); }

/* Output display (non-editable) */
.code-output {
  flex: 1;
  background: var(--bg-base);
  color: var(--text-primary);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
}

/* ── Line numbers gutter ─────────────────────────────────────────── */
.code-editor-wrap {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.line-gutter {
  flex-shrink: 0;
  width: 42px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 12px 8px 12px 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-muted);
  text-align: right;
  overflow: hidden;
  user-select: none;
  white-space: pre;
}
.line-gutter span { display: flex; align-items: flex-start; justify-content: flex-end; }

/* code-output and code-input now live inside .code-editor-wrap */
.code-editor-wrap .code-output,
.code-editor-wrap textarea.code-input {
  flex: 1;
  min-width: 0;
}

/* JSON/XML pane header strip — sits above the resizable pane-layout */
.jx-pane-headers {
  display: flex;
  flex-shrink: 0;
}
#jx-header-left  { flex: 0 0 50%; min-width: 0; overflow: hidden; white-space: nowrap; }
#jx-header-right { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }

.jx-tree-controls { display: flex; gap: 4px; }

/* JSON/XML tool: tighter left padding next to the gutter */
#panel-formatter .code-editor-wrap .code-output,
#panel-formatter .code-editor-wrap textarea.code-input {
  padding-left: 8px;
}
#panel-formatter .jx-error-line {
  margin-left: -8px;
  padding-left: 5px;
}

/* ── highlight.js theme (CSS-variable-driven, dark/light aware) ── */
.hljs                          { background: transparent; color: var(--text-primary); }
.hljs-attr, .hljs-name        { color: #7eb8f7; }          /* JSON keys / XML tag names  */
.hljs-string                   { color: #98d9a0; }          /* string values               */
.hljs-number                   { color: #f2a96a; }          /* numbers                     */
.hljs-literal                  { color: #c792ea; }          /* true / false / null         */
.hljs-punctuation,
.hljs-operator                 { color: var(--text-secondary); }
.hljs-tag .hljs-name           { color: #7eb8f7; }          /* XML tag                     */
.hljs-tag .hljs-attr           { color: #ffd580; }          /* XML attribute name          */
.hljs-tag                      { color: var(--text-secondary); } /* < > brackets            */
.hljs-comment                  { color: var(--text-muted); font-style: italic; }

body.light .hljs-attr,
body.light .hljs-name          { color: #1a5fb4; }
body.light .hljs-string        { color: #1e7c3c; }
body.light .hljs-number        { color: #b5500b; }
body.light .hljs-literal       { color: #6b3fa0; }
body.light .hljs-tag .hljs-attr{ color: #8c6a00; }
body.light .tree-key           { color: #1a5fb4; }
body.light .tree-str           { color: #1e7c3c; }
body.light .tree-num           { color: #b5500b; }
body.light .tree-bool          { color: #6b3fa0; }
body.light .tree-null          { color: #6b3fa0; }

/* ── JSON error list panel ───────────────────────────────────────── */
.jx-error-panel {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  max-height: 160px;
  display: flex;
  flex-direction: column;
}
.jx-error-panel.hidden { display: none; }
.jx-error-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-error);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.jx-error-panel-toggle {
  font-size: 10px;
  background: none;
  border: none;
  color: var(--text-secondary, var(--text-primary));
  cursor: pointer;
  padding: 0;
  opacity: 0.7;
}
.jx-error-panel-toggle:hover { opacity: 1; color: var(--text-primary); }
.jx-error-panel-list {
  overflow-y: auto;
  flex: 1;
}
.jx-error-item {
  display: flex;
  gap: 12px;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  border-bottom: 1px solid var(--border);
}
.jx-error-item:last-child { border-bottom: none; }
.jx-error-item:hover { background: color-mix(in srgb, var(--border) 40%, transparent); }
.jx-error-item-active { background: color-mix(in srgb, var(--error) 10%, transparent) !important; }
.jx-error-item-pos  { color: var(--text-primary); opacity: 0.6; white-space: nowrap; flex-shrink: 0; }
.jx-error-item-msg  { color: var(--text-error); }

/* Column-level error marker (wavy underline) */
.jx-err-col {
  text-decoration: underline wavy var(--error);
  text-underline-offset: 2px;
}

/* Input gutter error line marker */
.jx-gutter-error {
  color: var(--error) !important;
  box-shadow: inset 3px 0 0 var(--error);
  cursor: default;
}
.jx-gutter-error-focused { background: rgba(226, 92, 92, 0.15); }
.jx-gutter-error-dimmed  { opacity: 0.3; }

/* Input pane error overlay (sits over the textarea, pointer-events:none) */
#jx-input-wrap { position: relative; }
.jx-input-overlay {
  position: absolute;
  top: 0; bottom: 0; right: 0;
  left: 42px; /* gutter width */
  pointer-events: none;
  overflow: hidden;
  padding-top: 12px;
  padding-left: 8px;
  padding-bottom: 12px;
  box-sizing: border-box;
}
.jx-input-overlay.hidden { display: none; }
.jx-input-overlay-line         { }
.jx-input-overlay-line.error   { background: rgba(226,92,92,0.12); box-shadow: inset 3px 0 0 var(--error); margin-left: -8px; padding-left: 5px; }
.jx-input-overlay-line.focused { background: rgba(226,92,92,0.20); box-shadow: inset 3px 0 0 var(--error); margin-left: -8px; padding-left: 5px; }
.jx-input-overlay-line.dimmed  { background: rgba(226,92,92,0.03); box-shadow: inset 3px 0 0 rgba(226,92,92,0.2); margin-left: -8px; padding-left: 5px; }

/* Dimmed non-focused error lines */
.jx-error-line.jx-error-dimmed {
  background: rgba(226,92,92,0.04);
  border-left-color: rgba(226,92,92,0.2);
  color: var(--text-muted);
}

/* Error annotation in output pane */
.jx-error-line {
  background: rgba(226, 92, 92, 0.12);
  border-left: 3px solid var(--error);
  margin-left: -14px;
  padding-left: 11px;
}
.jx-error-output {
  color: var(--text-error);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  white-space: nowrap;
  user-select: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #5a9ee8; }
.btn.danger { color: var(--error); border-color: var(--error); }
.btn.danger:hover { background: rgba(226,92,92,0.1); }
.btn.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
#zpl-mode-overlay.active { background: rgba(180,0,0,0.12); color: #c84040; border-color: rgba(180,0,0,0.5); }

/* ── Lucide icons ───────────────────────────────────────── */
.btn svg { width: 13px; height: 13px; vertical-align: -2px; flex-shrink: 0; }
.icon svg { width: 15px; height: 15px; vertical-align: -3px; }
#sidebar-toggle svg { width: 16px; height: 16px; vertical-align: -3px; }

/* ── Badges / tags ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
}
.badge.success { background: rgba(76,175,130,0.12); color: var(--success); }
.badge.error   { background: rgba(226,92,92,0.12);  color: var(--error); }
.badge.warn    { background: rgba(226,169,74,0.12); color: var(--text-warn); }

/* ── Status bar ──────────────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  flex-shrink: 0;
  min-height: 26px;
}
.status-bar .status-ok {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 35%, transparent);
  border-radius: 4px;
  padding: 1px 7px;
  font-weight: 500;
}
.status-bar .status-err {
  color: var(--error);
  background: color-mix(in srgb, var(--error) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--error) 35%, transparent);
  border-radius: 4px;
  padding: 1px 7px;
  font-weight: 500;
}
.status-bar .status-info  { color: var(--accent); }
.status-bar .status-muted { color: var(--text-primary); opacity: 0.75; margin-right: auto; }
.code-output[contenteditable]:focus { outline: none; }

/* ── Options row ─────────────────────────────────────────── */
.options-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.options-row label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  user-select: none;
}
.options-row input[type=checkbox] { accent-color: var(--accent); }
.options-row select, .options-row input[type=number] {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 3px 7px;
  font-size: 12px;
  font-family: var(--font-ui);
  outline: none;
}
.options-row select:focus, .options-row input:focus { border-color: var(--accent); }

/* Render spin buttons using dark-mode native style */
input[type=number] { color-scheme: dark; }
body.light input[type=number] { color-scheme: light; }

/* Range slider — accent colour for thumb/fill; scheme matches current theme */
input[type=range] {
  accent-color: var(--accent);
  color-scheme: dark;
}
body.light input[type=range] { color-scheme: light; }

/* ── Tree view ───────────────────────────────────────────── */
.tree-view { flex: 1; overflow-y: auto; padding: 10px 12px; font-family: var(--font-mono); font-size: 12px; line-height: 1.8; min-height: 0; }
.tree-node { padding-left: 18px; position: relative; }
.tree-node > .tree-toggle {
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tree-toggle:hover { color: var(--accent); }
.tree-arrow { font-size: 10px; color: var(--text-muted); transition: transform 150ms; display: inline-block; width: 10px; }
.tree-arrow.open { transform: rotate(90deg); }
.tree-key   { color: #7eb8f7; }
.tree-index { color: var(--text-muted); }
.tree-dash  { color: var(--text-muted); }
.tree-str   { color: #98d9a0; }
.tree-num   { color: #f2a96a; }
.tree-bool  { color: #c792ea; }
.tree-null  { color: #c792ea; }
.tree-children.collapsed { display: none; }
.tree-count { color: var(--text-muted); font-size: 11px; margin-left: 4px; }

/* ── Diff view ───────────────────────────────────────────── */
.diff-container { flex: 1; overflow: auto; font-family: var(--font-mono); font-size: 12px; line-height: 1.65; }

.diff-line { display: flex; min-width: 0; }
.diff-line-num {
  min-width: 44px;
  padding: 0 8px;
  color: var(--text-muted);
  text-align: right;
  user-select: none;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 11px;
}
.diff-line-content { padding: 0 10px; white-space: pre; flex: 1; overflow-x: auto; }
.diff-add    { background: rgba(76,175,130,0.08); color: #7dc98a; }
.diff-remove { background: rgba(226,92,92,0.08);  color: #e07b7b; }
.diff-equal  { color: var(--text-secondary); }
.diff-header { background: rgba(74,144,226,0.08); color: var(--accent); font-style: italic; }
.diff-side-by-side { display: grid; grid-template-columns: 1fr 1fr; flex: 1; overflow: hidden; }
.diff-side { overflow: auto; }
.diff-side + .diff-side { border-left: 1px solid var(--border); }

/* ── Timestamp tool ─────────────────────────────────────── */
.ts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1px;
  background: var(--border);
}
.ts-row {
  background: var(--bg-base);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ts-row-label { color: var(--text-muted); font-size: 11px; min-width: 130px; font-family: var(--font-mono); }
.ts-row-value { color: var(--text-primary); font-family: var(--font-mono); font-size: 12.5px; flex: 1; }
.ts-row-value.copyable { cursor: pointer; }
.ts-row-value.copyable:hover { color: var(--accent); }

/* ── Timezone tool ──────────────────────────────────────── */
.tz-list { display: flex; flex-direction: column; gap: 1px; background: var(--border); overflow-y: auto; }
.tz-entry {
  background: var(--bg-base);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.tz-entry:hover { background: var(--bg-surface); }
.tz-name { min-width: 200px; font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); }
.tz-time { font-family: var(--font-mono); font-size: 14px; color: var(--text-primary); flex: 1; }
.tz-offset { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.tz-dst { font-size: 10px; padding: 1px 5px; border-radius: 3px; background: rgba(226,169,74,0.12); color: var(--text-warn); }

/* ── Toasts ─────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}
.toast {
  background: var(--bg-active);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-primary);
  animation: toastIn 200ms ease;
  pointer-events: all;
  max-width: 280px;
}
.toast.ok     { border-left: 3px solid var(--success); }
.toast.error  { border-left: 3px solid var(--error); }
@keyframes toastIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: none; } }

/* ── Utility ─────────────────────────────────────────────── */
.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }
.flex { display: flex; }

/* ── ZPL Per-page sections ────────────────────────────────── */
#zpl-pages-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 24px;
}
.zpl-page-section {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0 auto; /* centers when smaller than wrap; clamps to left edge when overflowing so left side stays scrollable */
}
.zpl-page-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  flex-wrap: wrap;
}
.btn-label-compact { display: none; }
.zpl-page-header.compact .btn-label { display: none; }
.zpl-page-header.compact .btn-label-compact { display: inline; }
.zpl-page-header.compact-actions .zpl-pg-copy .btn-label,
.zpl-page-header.compact-actions .zpl-pg-dl .btn-label,
.zpl-page-header.compact-actions .zpl-pg-print .btn-label { display: none; }

.zpl-page-label {
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--text-primary);
  margin-right: 4px;
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.zpl-page-canvas {
  display: block;
  align-self: center;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}
.zpl-page-section:not(:has(.zpl-page-header)) .zpl-page-canvas {
  border-radius: var(--radius);
}
.zpl-page-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 0 4px;
}
#zpl-render-spinner {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}
#zpl-render-spinner::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: zpl-spin 0.7s linear infinite;
}
@keyframes zpl-spin { to { transform: rotate(360deg); } }

/* Labelary warning modal */
.zpl-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.zpl-modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.zpl-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.zpl-modal-body {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 10px;
  line-height: 1.6;
}
.zpl-modal-body p { margin: 0; }
.zpl-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  opacity: 0.88;
}
