/* ===========================================================================
   Online JSON Viewer - Visual Studio Code styled workbench
   Theme tokens follow the official "Dark+" and "Light+" colour themes.
   =========================================================================== */

/* ---------- Dark+ (default) ---------- */
:root,
:root[data-theme="dark"] {
  --font-ui:   "Segoe WPC", "Segoe UI", system-ui, -apple-system, "Malgun Gothic", sans-serif;
  --font-mono: "Cascadia Mono", "Cascadia Code", Consolas, "Courier New", "D2Coding", monospace;

  --titlebar-bg:      #3c3c3c;
  --titlebar-fg:      #cccccc;
  --activitybar-bg:   #333333;
  --activitybar-fg:   #ffffff;
  --activitybar-in:   #868686;
  --activitybar-bd:   #ffffff;
  --sidebar-bg:       #252526;
  --sidebar-fg:       #cccccc;
  --sidebar-title:    #bbbbbb;
  --sectionheader-bg: #383838;
  --editor-bg:        #1e1e1e;
  --editor-fg:        #d4d4d4;
  --editor-line-nr:   #858585;
  --editor-line-act:  #c6c6c6;
  --editor-cur-line:  #282828;
  --find-match:       rgba(234, 92, 0, .33);
  --find-current:     #515c6a;
  --editor-selection: rgba(38, 119, 210, .45); /* translucent: #edit sits above the highlight layer */
  --tab-active-bg:    #1e1e1e;
  --tab-active-fg:    #ffffff;
  --tab-inactive-bg:  #2d2d2d;
  --tab-inactive-fg:  #969696;
  --tab-border:       #252526;
  --tab-top-border:   #007acc;
  --toolbar-bg:       #252526;
  --statusbar-bg:     #007acc;
  --statusbar-fg:     #ffffff;
  --statusbar-hover:  rgba(255,255,255,.12);
  --panel-bg:         #1e1e1e;
  --panel-border:     #2b2b2b;
  --contrast-border:  #454545;
  --widget-bg:        #252526;
  --widget-border:    #454545;
  --widget-shadow:    rgba(0,0,0,.36);
  --input-bg:         #3c3c3c;
  --input-fg:         #cccccc;
  --input-border:     #3c3c3c;
  --input-ph:         #a6a6a6;
  --button-bg:        #0e639c;
  --button-hover:     #1177bb;
  --button-fg:        #ffffff;
  --btn-sec-bg:       #3a3d41;
  --btn-sec-hover:    #45494e;
  --list-hover:       #2a2d2e;
  --list-active:      #04395e;
  --list-inactive:    #37373d;
  --list-focus-bd:    #007fd4;
  --focus-border:     #007fd4;
  --link:             #3794ff;
  --scroll-thumb:     rgba(121,121,121,.4);
  --scroll-hover:     rgba(100,100,100,.7);
  --badge-bg:         #4d4d4d;
  --badge-fg:         #ffffff;
  --err:              #f14c4c;
  --warn:             #cca700;
  --ok:               #89d185;
  --sash-hover:       #007acc;
  --indent-guide:     #404040;
  --minimap-bg:       #1e1e1e;
  --minimap-slider:   rgba(121,121,121,.2);
  --ad-bg:            #252526;
  --ad-border:        #2b2b2b;

  /* JSON syntax tokens - Dark+ */
  --tok-key:    #9cdcfe;
  --tok-string: #ce9178;
  --tok-number: #b5cea8;
  --tok-bool:   #569cd6;
  --tok-null:   #569cd6;
  --tok-punct:  #d4d4d4;
  --tok-brace:  #ffd700;
  --tok-brace2: #da70d6;
  --tok-brace3: #179fff;
}

/* ---------- Light+ ---------- */
:root[data-theme="light"] {
  --titlebar-bg:      #dddddd;
  --titlebar-fg:      #333333;
  --activitybar-bg:   #2c2c2c;
  --activitybar-fg:   #ffffff;
  --activitybar-in:   #a1a1a1;
  --activitybar-bd:   #ffffff;
  --sidebar-bg:       #f3f3f3;
  --sidebar-fg:       #3b3b3b;
  --sidebar-title:    #6f6f6f;
  --sectionheader-bg: #e4e4e4;
  --editor-bg:        #ffffff;
  --editor-fg:        #3b3b3b;
  --editor-line-nr:   #6e7681;
  --editor-line-act:  #171184;
  --editor-cur-line:  #f5f5f5;
  --find-match:       rgba(234, 92, 0, .33);
  --find-current:     #a8ac94;
  --editor-selection: rgba(0, 120, 215, .28);
  --tab-active-bg:    #ffffff;
  --tab-active-fg:    #333333;
  --tab-inactive-bg:  #ececec;
  --tab-inactive-fg:  #6f6f6f;
  --tab-border:       #f3f3f3;
  --tab-top-border:   #005fb8;
  --toolbar-bg:       #f3f3f3;
  --statusbar-bg:     #005fb8;
  --statusbar-fg:     #ffffff;
  --statusbar-hover:  rgba(255,255,255,.18);
  --panel-bg:         #ffffff;
  --panel-border:     #e5e5e5;
  --contrast-border:  #e5e5e5;
  --widget-bg:        #f8f8f8;
  --widget-border:    #c8c8c8;
  --widget-shadow:    rgba(0,0,0,.16);
  --input-bg:         #ffffff;
  --input-fg:         #3b3b3b;
  --input-border:     #cecece;
  --input-ph:         #767676;
  --button-bg:        #005fb8;
  --button-hover:     #0258a8;
  --button-fg:        #ffffff;
  --btn-sec-bg:       #e5e5e5;
  --btn-sec-hover:    #cccccc;
  --list-hover:       #e8e8e8;
  --list-active:      #0060c0;
  --list-inactive:    #e4e6f1;
  --list-focus-bd:    #005fb8;
  --focus-border:     #005fb8;
  --link:             #005fb8;
  --scroll-thumb:     rgba(100,100,100,.4);
  --scroll-hover:     rgba(100,100,100,.7);
  --badge-bg:         #c4c4c4;
  --badge-fg:         #333333;
  --err:              #e51400;
  --warn:             #bf8803;
  --ok:               #1a7f37;
  --sash-hover:       #005fb8;
  --indent-guide:     #d3d3d3;
  --minimap-bg:       #ffffff;
  --minimap-slider:   rgba(100,100,100,.14);
  --ad-bg:            #f3f3f3;
  --ad-border:        #e5e5e5;

  /* JSON syntax tokens - Light+ */
  --tok-key:    #0451a5;
  --tok-string: #a31515;
  --tok-number: #098658;
  --tok-bool:   #0000ff;
  --tok-null:   #0000ff;
  --tok-punct:  #3b3b3b;
  --tok-brace:  #0431fa;
  --tok-brace2: #319331;
  --tok-brace3: #7b3814;
}

/* ---------- reset ---------- */
* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--editor-fg);
  background: var(--editor-bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--link); }
[hidden] { display: none !important; }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 14px; height: 14px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }

:focus-visible { outline: 1px solid var(--focus-border); outline-offset: -1px; }

/* ---------- app shell ---------- */
#app {
  display: grid;
  grid-template-rows: 35px 1fr 22px auto;
  height: 100%;
}

/* ---------- title bar ---------- */
.titlebar {
  display: flex;
  align-items: center;
  background: var(--titlebar-bg);
  color: var(--titlebar-fg);
  font-size: 12px;
  user-select: none;
  border-bottom: 1px solid transparent;
}
.tb-side { display: flex; align-items: center; flex: 0 0 auto; }
.tb-left { padding-left: 8px; gap: 4px; }
.tb-right { padding-right: 6px; margin-left: auto; }
.tb-logo { display: flex; align-items: center; padding: 0 4px; }
.menubar { display: flex; }
.menu-btn {
  padding: 4px 8px;
  color: inherit;
  border-radius: 4px;
  line-height: 16px;
}
.menu-btn:hover, .menu-btn.open { background: rgba(128,128,128,.28); }
.tb-center { flex: 1 1 auto; display: flex; justify-content: center; min-width: 0; padding: 0 12px; }
.tb-quickopen {
  display: flex; align-items: center; gap: 6px;
  max-width: 600px; width: 100%;
  height: 22px; padding: 0 8px;
  color: var(--titlebar-fg);
  background: rgba(128,128,128,.14);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  overflow: hidden;
  justify-content: center;
}
.tb-quickopen:hover { background: rgba(128,128,128,.25); }
.tb-quickopen span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-icon {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 24px; border-radius: 4px; color: inherit;
}
.tb-icon:hover { background: rgba(128,128,128,.28); }

:root[data-theme="dark"]  .ico-sun  { display: none; }
:root[data-theme="light"] .ico-moon { display: none; }

/* ---------- workbench ---------- */
.workbench {
  display: grid;
  grid-template-columns: 48px var(--sidebar-w, 250px) 4px 1fr;
  min-height: 0;
  overflow: hidden;
}
/* Collapsing uses zero-width tracks rather than `display:none`, so the grid
   items keep their column assignment and the editor stays in the last track. */
.workbench.sidebar-hidden { grid-template-columns: 48px 0 0 1fr; }
.workbench.sidebar-hidden .sidebar { visibility: hidden; }
.workbench.sidebar-hidden #sashSidebar { pointer-events: none; }

/* Explicit tracks: auto-placement would shift the editor whenever a sibling
   leaves the flow (collapsed side bar, floating side bar on phones). */
.activitybar  { grid-column: 1; }
.sidebar      { grid-column: 2; }
#sashSidebar  { grid-column: 3; }
.editorgroup  { grid-column: 4; }

/* activity bar */
.activitybar {
  display: flex; flex-direction: column; align-items: center;
  background: var(--activitybar-bg);
  padding-top: 2px;
}
.act {
  position: relative;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  color: var(--activitybar-in);
  border-left: 2px solid transparent;
}
.act:hover { color: var(--activitybar-fg); }
.act.active { color: var(--activitybar-fg); border-left-color: var(--activitybar-bd); }
.act-spacer { flex: 1 1 auto; }

/* side bar */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex; flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.sbview { display: none; flex-direction: column; min-height: 0; overflow: auto; height: 100%; }
.sbview.active { display: flex; }
.sb-title {
  flex: 0 0 auto;
  padding: 10px 20px 8px;
  font-size: 11px; font-weight: 400;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--sidebar-title);
}
.sb-sect { border-top: 1px solid var(--panel-border); }
.sb-sect > summary {
  display: flex; align-items: center; gap: 2px;
  height: 22px; padding: 0 8px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  cursor: pointer; user-select: none; list-style: none;
  background: var(--sidebar-bg);
}
.sb-sect > summary::-webkit-details-marker { display: none; }
.sb-sect > summary:hover { background: var(--list-hover); }
.twisty {
  width: 16px; height: 16px; flex: 0 0 16px;
  background: currentColor;
  -webkit-mask: var(--chev) center/16px no-repeat;
  mask: var(--chev) center/16px no-repeat;
  --chev: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M6 4l4 4-4 4z"/></svg>');
  transition: transform .1s;
}
.sb-sect[open] > summary .twisty { transform: rotate(90deg); }
.sb-body { padding: 4px 8px 10px 12px; }
.sb-label {
  font-size: 11px; color: var(--sidebar-title);
  margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .4px;
}
.sb-body > .sb-label:first-child { margin-top: 2px; }
.sb-btn {
  display: block; width: 100%;
  margin: 4px 0; padding: 5px 10px;
  text-align: center;
  background: var(--btn-sec-bg); color: var(--sidebar-fg);
  border: 1px solid transparent; border-radius: 2px;
  font-size: 12px;
}
.sb-btn:hover { background: var(--btn-sec-hover); }
.sb-hint { font-size: 11px; color: var(--sidebar-title); margin: 6px 0; }
.sb-check { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 6px 0; cursor: pointer; }
.sb-field { margin: 2px 0 6px; }
.sb-prose { font-size: 12px; line-height: 1.55; }
.sb-prose p { margin: 0 0 10px; }
.oe-item {
  display: flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 4px; border-radius: 3px;
  cursor: pointer; font-size: 13px; white-space: nowrap;
}
.oe-item:hover { background: var(--list-hover); }
.oe-item.active { background: var(--list-inactive); }
.sample-item {
  display: flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 4px; border-radius: 3px;
  cursor: pointer; font-size: 13px;
}
.sample-item:hover { background: var(--list-hover); }
.statlist { margin: 0; font-size: 12px; }
.statlist div { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.statlist dt { color: var(--sidebar-title); }
.statlist dd { margin: 0; font-family: var(--font-mono); font-size: 11px; }
.sb-results { margin-top: 6px; }
.sb-result {
  display: block; width: 100%; text-align: left;
  padding: 3px 6px; border-radius: 3px;
  font-family: var(--font-mono); font-size: 11px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--sidebar-fg);
}
.sb-result:hover { background: var(--list-hover); }
.sb-result.current { background: var(--list-inactive); }
.sb-result mark { background: rgba(234,92,0,.33); color: inherit; border-radius: 2px; }

/* file icons */
.fi { width: 16px; height: 16px; flex: 0 0 16px; display: inline-block; background: center/contain no-repeat; }
.fi-json { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="%23cbcb41" d="M5.6 1.2c-1.5.3-2.1 1-2.1 2.4v1.9c0 1-.4 1.5-1.5 1.7v1.6c1.1.2 1.5.7 1.5 1.7v1.9c0 1.4.6 2.1 2.1 2.4v-1.3c-.7-.2-.9-.5-.9-1.3v-1.8c0-1-.4-1.6-1.2-1.9.8-.3 1.2-.9 1.2-1.9V3.8c0-.8.2-1.1.9-1.3V1.2zm4.8 0v1.3c.7.2.9.5.9 1.3v1.8c0 1 .4 1.6 1.2 1.9-.8.3-1.2.9-1.2 1.9v1.8c0 .8-.2 1.1-.9 1.3v1.3c1.5-.3 2.1-1 2.1-2.4v-1.9c0-1 .4-1.5 1.5-1.7V7.2c-1.1-.2-1.5-.7-1.5-1.7V3.6c0-1.4-.6-2.1-2.1-2.4z"/></svg>'); }
.fi-tree { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="%23519aba" d="M2 2h5v3H2zM9 6.5h5v3H9zM9 11h5v3H9zM4 5v8h4v-1H5V9.5h3v-1H5V5z"/></svg>'); }

/* Sashes take their size from the grid track they sit in, never from a fixed
   width, so a collapsed track really does collapse. */
.sash { background: transparent; position: relative; z-index: 5; overflow: hidden; min-width: 0; min-height: 0; }
.sash-v { cursor: col-resize; }
.sash-h { cursor: row-resize; }
.sash::after { content: ""; position: absolute; inset: 0; background: transparent; transition: background .1s .2s; }
.sash:hover::after, .sash.dragging::after { background: var(--sash-hover); }

/* ---------- editor group ---------- */
.editorgroup {
  display: grid;
  grid-template-rows: 35px 35px 1fr 0 0;
  min-width: 0; min-height: 0;
  background: var(--editor-bg);
  overflow: hidden;
}
.editorgroup.panel-open { grid-template-rows: 35px 35px 1fr 4px var(--panel-h, 180px); }
.editorgroup > .tabs    { grid-row: 1; }
.editorgroup > .toolbar { grid-row: 2; }
.editorgroup > #sashPanel { grid-row: 4; }
.editorgroup > .panel   { grid-row: 5; }

/* tabs */
.tabs {
  display: flex; align-items: stretch;
  background: var(--tab-border);
  overflow: hidden;
}
.tab {
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px; min-width: 120px; max-width: 220px;
  background: var(--tab-inactive-bg); color: var(--tab-inactive-fg);
  border-right: 1px solid var(--tab-border);
  border-top: 1px solid transparent;
  cursor: pointer; user-select: none; font-size: 13px;
  position: relative;
}
.tab:hover { background: var(--tab-active-bg); }
.tab.active {
  background: var(--tab-active-bg); color: var(--tab-active-fg);
  border-top-color: var(--tab-top-border);
}
.tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dirty { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0; flex: 0 0 8px; }
.tab.dirty-on .dirty { opacity: .85; }
.tabs-fill { flex: 1 1 auto; background: var(--tab-border); }
.tabs-actions { display: flex; align-items: center; padding-right: 6px; background: var(--tab-border); }
.tba {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 4px;
  color: var(--tab-inactive-fg);
}
.tba:hover { background: var(--list-hover); color: var(--tab-active-fg); }
.tba.active { color: var(--tab-active-fg); background: var(--list-hover); }

/* toolbar */
.toolbar {
  display: flex; align-items: center; gap: 2px;
  padding: 0 8px;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--panel-border);
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { height: 0; }
.tbtn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px;
  color: var(--editor-fg);
  background: var(--btn-sec-bg);
  border: 1px solid transparent; border-radius: 3px;
  font-size: 12px; white-space: nowrap;
}
.tbtn:hover { background: var(--btn-sec-hover); }
.tbtn:active { transform: translateY(1px); }
.tbtn-primary { background: var(--button-bg); color: var(--button-fg); }
.tbtn-primary:hover { background: var(--button-hover); }
.tbtn-icon { padding: 0 6px; background: transparent; }
.tbtn-icon:hover { background: var(--btn-sec-hover); }
.tsep { width: 1px; height: 16px; background: var(--contrast-border); margin: 0 6px; flex: 0 0 1px; }
.tfill { flex: 1 1 auto; }

/* panes */
.pane { display: none; min-height: 0; overflow: hidden; grid-row: 3; grid-column: 1; }
.pane.active { display: flex; flex-direction: column; }

/* ---------- text editor ---------- */
.editor-body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: var(--gutter-w, 58px) 1fr auto;
  min-height: 0;
  background: var(--editor-bg);
  position: relative;
}
.gutter {
  position: relative;
  overflow: hidden;
  background: var(--editor-bg);
  user-select: none;
  padding-top: 8px;
}
/* the active line number, drawn over the plain number column */
.gutter-active {
  position: absolute;
  top: 0; right: 14px;
  font-family: var(--font-mono);
  font-size: 13px; line-height: 19px;
  color: var(--editor-line-act);
  background: var(--editor-bg);
  padding-left: 6px;
  will-change: transform;
  pointer-events: none;
}
/* current line highlight, sits behind the highlight layer */
.cur-line {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 19px;
  background: var(--editor-cur-line);
  pointer-events: none;
  will-change: transform;
}
.gutter-inner {
  font-family: var(--font-mono);
  font-size: 13px; line-height: 19px;
  color: var(--editor-line-nr);
  text-align: right;
  padding-right: 14px;
  white-space: pre;
  will-change: transform;
}
.code-area { position: relative; overflow: hidden; min-width: 0; }
.hl-layer, .find-layer, #edit {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 19px;
  tab-size: 4;
  letter-spacing: 0;
  white-space: pre;
  word-wrap: normal;
  padding: 8px 0 8px 4px;
  margin: 0;
  border: 0;
}
.hl-layer {
  position: absolute; inset: 0;
  overflow: hidden;
  pointer-events: none;
  color: var(--editor-fg);
}
.hl-layer code, .find-layer code { display: block; will-change: transform; font: inherit; }
.find-layer {
  position: absolute; inset: 0;
  overflow: hidden;
  pointer-events: none;
  color: transparent;
}
.find-layer .fm { background: var(--find-match); color: transparent; border-radius: 2px; }
.find-layer .fm-cur { background: var(--find-current); outline: 1px solid var(--focus-border); }
#edit {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  resize: none; outline: none;
  background: transparent;
  color: transparent;
  caret-color: var(--editor-fg);
  overflow: auto;
}
#edit.plain { color: var(--editor-fg); }
.hl-layer.off { display: none; }
#edit::selection { background: var(--editor-selection); }
#edit::placeholder { color: var(--input-ph); }
.minimap {
  display: block;
  background: var(--minimap-bg);
  cursor: pointer;
  border-left: 1px solid transparent;
}
.editor-body.no-minimap .minimap { display: none; }

/* syntax tokens */
.t-key    { color: var(--tok-key); }
.t-str    { color: var(--tok-string); }
.t-num    { color: var(--tok-number); }
.t-bool   { color: var(--tok-bool); }
.t-null   { color: var(--tok-null); }
.t-punct  { color: var(--tok-punct); }
.t-b0     { color: var(--tok-brace); }
.t-b1     { color: var(--tok-brace2); }
.t-b2     { color: var(--tok-brace3); }
.t-err    { color: var(--err); text-decoration: wavy underline; }

/* ---------- viewer ---------- */
.pane-viewer { flex-direction: column; }
.viewer-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 4px var(--pg-w, 300px);
  min-height: 0;
}
.viewer-grid.nogrid { grid-template-columns: 1fr 0 0; }
.viewer-grid.nogrid .propgrid { visibility: hidden; }
.viewer-grid.nogrid #sashGrid { pointer-events: none; }
.tree-wrap { grid-column: 1; overflow: auto; min-width: 0; background: var(--editor-bg); }
#sashGrid  { grid-column: 2; }
.propgrid  { grid-column: 3; }
.tree { padding: 6px 0 12px; font-size: 13px; min-width: min-content; }

.trow {
  display: flex; align-items: center; gap: 4px;
  height: 22px; padding-right: 12px;
  cursor: default; white-space: nowrap;
  position: relative;
}
.trow:hover { background: var(--list-hover); }
.trow.selected { background: var(--list-inactive); }
.tree:focus-within .trow.selected { background: var(--list-active); color: #fff; }
.trow.match { outline: 1px solid var(--warn); outline-offset: -1px; }
.tw {
  width: 16px; height: 16px; flex: 0 0 16px;
  display: inline-block; cursor: pointer;
  background: currentColor; opacity: .85;
  -webkit-mask: var(--chev) center/16px no-repeat;
  mask: var(--chev) center/16px no-repeat;
  --chev: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M6 4l4 4-4 4z"/></svg>');
  transition: transform .08s linear;
}
.tnode.expanded > .trow > .tw { transform: rotate(90deg); }
.tw.leaf { background: none; cursor: default; }

.ticon { width: 14px; height: 14px; flex: 0 0 14px; border-radius: 3px; display: inline-block; }
.ticon.obj  { background: #cbcb41; border-radius: 2px; }
.ticon.arr  { background: #8dc149; border-radius: 2px; }
.ticon.str  { background: #4f9fdc; border-radius: 50%; }
.ticon.num  { background: #3fa34d; border-radius: 50%; }
.ticon.bool { background: #e2c541; border-radius: 50%; }
.ticon.nul  { background: #e05252; border-radius: 50%; }

.tkey { color: var(--tok-key); }
.tsepc { color: var(--tok-punct); opacity: .8; padding: 0 2px; }
.tval.str  { color: var(--tok-string); }
.tval.num  { color: var(--tok-number); }
.tval.bool { color: var(--tok-bool); }
.tval.nul  { color: var(--tok-null); }
.tcount { color: var(--editor-line-nr); font-size: 11px; margin-left: 6px; font-style: italic; }
.tempty { padding: 24px; color: var(--editor-line-nr); font-size: 13px; }
.tguides { position: absolute; left: 0; top: 0; bottom: 0; pointer-events: none; }

/* property grid */
.propgrid {
  display: flex; flex-direction: column;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--panel-border);
  min-width: 0; overflow: hidden;
}
.pg-title {
  padding: 8px 12px 6px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--sidebar-title);
}
.pg-head {
  display: grid; grid-template-columns: 40% 60%;
  font-size: 11px; font-weight: 700;
  background: var(--sectionheader-bg);
  border-top: 1px solid var(--panel-border);
  border-bottom: 1px solid var(--panel-border);
}
.pg-head span { padding: 4px 8px; border-right: 1px solid var(--panel-border); }
.pg-body { overflow: auto; flex: 1 1 auto; }
.pg-row {
  display: grid; grid-template-columns: 40% 60%;
  font-size: 12px; border-bottom: 1px solid var(--panel-border);
  cursor: default;
}
.pg-row:hover { background: var(--list-hover); }
.pg-row.selected { background: var(--list-inactive); }
.pg-row > span {
  padding: 3px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-right: 1px solid var(--panel-border);
}
.pg-row .pg-k { color: var(--tok-key); font-weight: 600; }
.pg-row .pg-v { font-family: var(--font-mono); font-size: 11px; }
.pg-empty { padding: 14px 12px; color: var(--sidebar-title); font-size: 12px; }

/* editor find widget (VS Code style) */
.editor-find {
  position: absolute; top: 0; right: 96px; z-index: 5;
  display: flex; align-items: center; gap: 2px;
  padding: 4px 6px;
  background: var(--widget-bg);
  border: 1px solid var(--widget-border); border-top: 0;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 2px 8px var(--widget-shadow);
  max-width: calc(100% - 16px);
}
.editor-find .vsinput { width: 220px; min-width: 80px; flex: 1 1 auto; height: 24px; }
.editor-find .vsinput.no-match { border-color: var(--err); }
.ef-count { font-size: 12px; padding: 0 6px; min-width: 66px; white-space: nowrap; color: var(--editor-fg); }
.ef-count.err { color: var(--err); }
.ef-btn {
  display: flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 3px; border-radius: 3px;
  color: var(--editor-fg); font-size: 12px;
}
.ef-btn:hover { background: var(--list-hover); }
.ef-toggle.active { background: var(--list-hover); outline: 1px solid var(--focus-border); outline-offset: -1px; }
@media (max-width: 600px) { .editor-find { right: 8px; } .editor-find .vsinput { width: 120px; } }

/* find bar */
.findbar {
  display: none; align-items: center; gap: 6px;
  padding: 5px 8px;
  background: var(--toolbar-bg);
  border-top: 1px solid var(--panel-border);
  flex: 0 0 auto;
}
.findbar.open { display: flex; }
.fb-label { font-size: 12px; color: var(--sidebar-title); }
.fb-result { font-size: 12px; font-weight: 700; padding: 0 6px; }
.fb-result.err { color: var(--err); }

/* inputs */
.vsinput, .vsselect {
  height: 26px; padding: 0 8px;
  background: var(--input-bg); color: var(--input-fg);
  border: 1px solid var(--input-border); border-radius: 2px;
  outline: none; width: 100%;
}
.vsinput:focus, .vsselect:focus { border-color: var(--focus-border); }
.vsinput::placeholder { color: var(--input-ph); }
#searchInput { width: 240px; }
.vsselect { margin-bottom: 4px; }

/* ---------- bottom panel ---------- */
.panel {
  grid-row: 5;
  display: none; flex-direction: column;
  background: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
  min-height: 0;
}
.editorgroup.panel-open .panel { display: flex; }
.editorgroup.panel-open #sashPanel { grid-row: 4; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px; height: 35px; flex: 0 0 35px;
}
.panel-tabs { display: flex; gap: 12px; }
.ptab {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--tab-inactive-fg);
  border-bottom: 1px solid transparent;
  padding: 8px 2px;
}
.ptab.active { color: var(--tab-active-fg); border-bottom-color: currentColor; }
.badge {
  display: inline-block; min-width: 16px; padding: 0 4px;
  background: var(--badge-bg); color: var(--badge-fg);
  border-radius: 9px; font-size: 10px; text-align: center;
}
.panel-body { flex: 1 1 auto; overflow: auto; padding: 4px 12px 12px; font-size: 12px; }
.prob {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 3px 4px; border-radius: 3px; cursor: pointer;
  font-family: var(--font-mono); font-size: 11.5px;
}
.prob:hover { background: var(--list-hover); }
.prob .dot { width: 14px; height: 14px; flex: 0 0 14px; margin-top: 1px; }
.prob.err .dot  { color: var(--err); }
.prob.ok  .dot  { color: var(--ok); }
.prob .loc { color: var(--editor-line-nr); margin-left: auto; padding-left: 12px; }
.panel-empty { color: var(--editor-line-nr); padding: 8px 4px; }
#panelOutput { font-family: var(--font-mono); font-size: 11.5px; white-space: pre-wrap; }

/* ---------- status bar ---------- */
.statusbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--statusbar-bg); color: var(--statusbar-fg);
  font-size: 12px; padding: 0 4px; user-select: none;
}
.statusbar.error { background: var(--err); }
.sb-group { display: flex; align-items: center; height: 22px; }
.sb-right { margin-left: auto; }
.sbi {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 6px; color: inherit; white-space: nowrap;
}
.sbi:not(.sbi-static):hover { background: var(--statusbar-hover); }
.sbi-static { cursor: default; }

/* ---------- ad slots ---------- */
.adbar {
  background: var(--ad-bg);
  border-top: 1px solid var(--ad-border);
  display: flex; justify-content: center;
}
.adbar-inner {
  position: relative;
  width: 100%; max-width: 970px;
  min-height: 64px;
  display: flex; align-items: center; justify-content: center;
  padding: 4px 0;
}
.adbar.collapsed { display: none; }
.adbar-tag {
  position: absolute; top: 2px; left: 6px;
  font-size: 9px; letter-spacing: .6px; text-transform: uppercase;
  color: var(--sidebar-title);
}
.ad-slot { width: 100%; min-height: 60px; display: block; text-align: center; }
.ad-placeholder {
  display: flex; align-items: center; justify-content: center;
  height: 100%; min-height: 60px;
  border: 1px dashed var(--contrast-border); border-radius: 4px;
  color: var(--sidebar-title); font-size: 11px;
}


/* ---------- menus / context menu ---------- */
.menu-shield { position: fixed; inset: 0; z-index: 800; }
.ctx {
  position: fixed; z-index: 810;
  min-width: 200px; padding: 4px;
  background: var(--widget-bg);
  border: 1px solid var(--widget-border);
  border-radius: 5px;
  box-shadow: 0 2px 8px var(--widget-shadow);
  font-size: 13px;
}
.ctx-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 4px 26px 4px 22px;
  border-radius: 3px; color: var(--editor-fg);
  text-align: left; white-space: nowrap;
}
.ctx-item:hover:not(:disabled) { background: var(--list-active); color: #fff; }
.ctx-item:disabled { opacity: .4; cursor: default; }
.ctx-item .key { margin-left: auto; opacity: .7; font-size: 11px; }
.ctx-item:hover:not(:disabled) .key { opacity: .9; }
.ctx-item .chk { position: absolute; margin-left: -18px; }
.ctx-sep { height: 1px; margin: 4px 8px; background: var(--contrast-border); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 850;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  width: 100%; max-width: 660px; max-height: 80vh;
  display: flex; flex-direction: column;
  background: var(--widget-bg);
  border: 1px solid var(--widget-border);
  border-radius: 6px;
  box-shadow: 0 8px 32px var(--widget-shadow);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 8px 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--panel-border);
}
.modal-body { padding: 14px; overflow: auto; font-size: 13px; line-height: 1.6; }
.modal-body p { margin: 0 0 10px; }
.modal-body h3 { font-size: 13px; margin: 16px 0 6px; }
.modal-body pre {
  background: var(--editor-bg); border: 1px solid var(--panel-border);
  border-radius: 4px; padding: 10px; overflow: auto;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
}
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 10px 14px; border-top: 1px solid var(--panel-border);
}
.modal-foot:empty { display: none; }
.mbtn {
  min-width: 80px; padding: 5px 14px; border-radius: 2px;
  background: var(--btn-sec-bg); color: var(--editor-fg);
}
.mbtn:hover { background: var(--btn-sec-hover); }
.mbtn-primary { background: var(--button-bg); color: var(--button-fg); }
.mbtn-primary:hover { background: var(--button-hover); }
.modal-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--panel-border); padding: 0 8px; }
.modal-tab { padding: 7px 12px; font-size: 12px; color: var(--tab-inactive-fg); border-bottom: 1px solid transparent; }
.modal-tab.active { color: var(--tab-active-fg); border-bottom-color: var(--tab-top-border); }
.modal-icon { display: flex; gap: 12px; align-items: flex-start; }
.modal-icon svg { flex: 0 0 22px; margin-top: 2px; }
.modal-err { color: var(--err); }

/* ---------- command palette ---------- */
.palette-backdrop {
  position: fixed; inset: 0; z-index: 860;
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 40px;
  background: rgba(0,0,0,.18);
}
.palette {
  width: min(600px, 92vw);
  background: var(--widget-bg);
  border: 1px solid var(--widget-border);
  border-radius: 6px;
  box-shadow: 0 8px 32px var(--widget-shadow);
  overflow: hidden;
}
.palette-input {
  width: 100%; height: 30px; padding: 0 8px; margin: 6px;
  width: calc(100% - 12px);
  background: var(--input-bg); color: var(--input-fg);
  border: 1px solid var(--focus-border); border-radius: 2px; outline: none;
}
.palette-list { max-height: 55vh; overflow: auto; padding: 4px 6px 8px; }
.pal-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 5px 8px; border-radius: 3px;
  color: var(--editor-fg); text-align: left; font-size: 13px;
}
.pal-item.sel { background: var(--list-active); color: #fff; }
.pal-item .key { font-size: 11px; opacity: .7; white-space: nowrap; }
.pal-item .cat { opacity: .6; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  /* On phones the side bar floats over the editor instead of taking a column,
     so the editor never gets squeezed down to a sliver. */
  .workbench { position: relative; grid-template-columns: 48px 0 0 1fr; }
  .workbench .sidebar { visibility: hidden; }
  .workbench.sidebar-open .sidebar {
    visibility: visible;
    /* the containing block is this item's own (zero-width) grid area */
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: min(290px, 78vw);
    z-index: 30;
    box-shadow: 4px 0 14px var(--widget-shadow);
    border-right: 1px solid var(--panel-border);
  }
  .tb-center { display: none; }
  .viewer-grid { grid-template-columns: 1fr 0 0; }
  .viewer-grid .propgrid { visibility: hidden; }
  .editor-body { grid-template-columns: var(--gutter-w, 46px) 1fr; }
  .minimap { display: none; }
  #searchInput { width: 120px; }
  .statusbar .sbi-static { display: none; }
}
@media (max-width: 560px) {
  .menubar .menu-btn[data-menu="selection"],
  .menubar .menu-btn[data-menu="go"] { display: none; }
  .tbtn { padding: 0 7px; font-size: 11px; }
}

/* ---------- print: just the JSON, nothing else ---------- */
@media print {
  html, body { height: auto; overflow: visible; background: #fff; color: #000; }
  .titlebar, .activitybar, .sidebar, .sash, .tabs, .toolbar,
  .statusbar, .adbar, .panel, .findbar, .minimap,
  .ctx, .menu-shield, .modal-backdrop, .palette-backdrop { display: none !important; }
  #app { display: block; height: auto; }
  .workbench { display: block; }
  .editorgroup { display: block; }
  .pane { display: block !important; }
  .editor-body { display: block; height: auto; }
  .code-area { position: static; overflow: visible; height: auto; }
  .hl-layer { position: static; overflow: visible; white-space: pre-wrap; color: #000; }
  .hl-layer code { transform: none !important; }
  #edit { display: none; }
  .tree-wrap { overflow: visible; }
}
