/* ===========================================================================
   Online Base64 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;
  --editor-selection: #264f78;
  --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;
  --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;
  --stage-bg:         #1b1b1b;
  --checker-a:        #2a2a2a;
  --checker-b:        #232323;

  /* Base64 / hex tokens */
  --tok-prefix: #c586c0;
  --tok-data:   #ce9178;
  --tok-pad:    #6a9955;
  --tok-bad:    #f14c4c;
  --tok-off:    #858585;
  --tok-hex:    #9cdcfe;
  --tok-ascii:  #b5cea8;
}

/* ---------- 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;
  --editor-selection: #add6ff;
  --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;
  --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;
  --stage-bg:         #f7f7f7;
  --checker-a:        #e9e9e9;
  --checker-b:        #f6f6f6;

  --tok-prefix: #af00db;
  --tok-data:   #a31515;
  --tok-pad:    #098658;
  --tok-bad:    #e51400;
  --tok-off:    #6e7681;
  --tok-hex:    #0451a5;
  --tok-ascii:  #098658;
}

/* ---------- 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); }
code { font-family: var(--font-mono); font-size: .92em; }
[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;   /* title / workbench / status / ad */
  height: 100%;
}

/* ---------- title bar ---------- */
.titlebar {
  display: flex; align-items: center;
  background: var(--titlebar-bg); color: var(--titlebar-fg);
  font-size: 12px; user-select: none;
}
.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; justify-content: 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;
}
.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;
}
/* 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; }

.workbench.sidebar-hidden { grid-template-columns: 48px 0 0 1fr; }
.workbench.sidebar-hidden .sidebar { visibility: hidden; }
.workbench.sidebar-hidden #sashSidebar { pointer-events: none; }

.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; }

.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; 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;
}
.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: 12px 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; line-height: 1.5; }
.sb-check { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 6px 0; cursor: pointer; }
.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); white-space: nowrap; }
.statlist dd {
  margin: 0; font-family: var(--font-mono); font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right;
}

/* snippets */
.snip { margin: 0 0 14px; }
.snip-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.snip-name { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--sidebar-title); }
.snip-copy { font-size: 11px; padding: 2px 8px; border-radius: 2px; background: var(--btn-sec-bg); color: var(--sidebar-fg); }
.snip-copy:hover { background: var(--btn-sec-hover); }
.snip-code {
  margin: 0; padding: 6px 8px; max-height: 92px; overflow: auto;
  background: var(--editor-bg); border: 1px solid var(--panel-border); border-radius: 3px;
  font-family: var(--font-mono); font-size: 11px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--editor-fg);
}

/* file icons */
.fi { width: 16px; height: 16px; flex: 0 0 16px; display: inline-block; background: center/contain no-repeat; }
.fi-b64 { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="%238dc149" d="M2 3h12v2H2zm0 4h7v2H2zm0 4h12v2H2z"/><path fill="%23519aba" d="M10 7h4v2h-4z"/></svg>'); }
.fi-img { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="%23a074c4" d="M2 3h12v10H2z"/><path fill="%23ffffff" d="M4 10.5l2.4-3 1.8 2.2 1.5-1.7 2.3 2.5z"/><circle fill="%23ffffff" cx="5.4" cy="5.6" r="1.1"/></svg>'); }

/* sashes take their size from the grid track, never a fixed width */
.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 > .panes     { grid-row: 3; }
.editorgroup > #sashPanel { grid-row: 4; }
.editorgroup > .panel     { grid-row: 5; }

/* The two editors: stacked (one visible at a time) or side by side.
   Every child keeps an explicit column so hiding one never reflows the other. */
.panes {
  display: grid;
  grid-template-columns: 1fr 0 0;
  grid-template-rows: 100%;
  min-width: 0; min-height: 0; overflow: hidden;
}
.panes > #paneText    { grid-column: 1; grid-row: 1; }
.panes > #sashSplit   { grid-column: 2; grid-row: 1; }
.panes > #panePreview { grid-column: 3; grid-row: 1; }

.panes:not(.split) > #paneText,
.panes:not(.split) > #panePreview { grid-column: 1; }
.panes:not(.split) > #sashSplit { display: none; }

.panes.split {
  grid-template-columns: minmax(220px, 1fr) 4px minmax(260px, var(--split-w, 520px));
}
/* both editors are on screen in split mode, so neither is "inactive" */
.panes.split > .pane { display: flex; flex-direction: column; }
.panes.split > .pane-preview { border-left: 1px solid var(--panel-border); }

.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;
}
.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; gap: 2px; 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.on { color: var(--tab-active-fg); background: var(--list-hover); }

.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 8px; }
.tsep { width: 1px; height: 16px; background: var(--contrast-border); margin: 0 6px; flex: 0 0 1px; }
.tfill { flex: 1 1 auto; }

.pane { display: none; min-width: 0; min-height: 0; overflow: hidden; position: relative; }
.pane.active { display: flex; flex-direction: column; }

/* ---------- base64 text editor ---------- */
.editor-body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: var(--gutter-w, 58px) 1fr;
  min-height: 0; background: var(--editor-bg); position: relative;
}
/* No padding here: line numbers are placed from the measured line boxes, and
   those offsets already include the highlight layer's own top padding. */
.gutter {
  position: relative; overflow: hidden;
  background: var(--editor-bg); user-select: none;
}
.gutter-inner {
  position: relative;
  font-family: var(--font-mono); font-size: 13px; line-height: 19px;
  color: var(--editor-line-nr); text-align: right; padding-right: 14px;
  will-change: transform;
}
/* one absolutely placed number per logical line, so soft wrap stays aligned */
.gutter-inner span {
  position: absolute; right: 14px; display: block; white-space: nowrap;
}
.gutter-inner span.act { color: var(--editor-line-act); }

.code-area { position: relative; overflow: hidden; min-width: 0; }
.hl-layer, #edit {
  font-family: var(--font-mono);
  font-size: 13px; line-height: 19px;
  tab-size: 4; letter-spacing: 0;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-all;
  padding: 8px 12px 8px 4px; margin: 0; border: 0;
}
.editor-body.nowrap .hl-layer,
.editor-body.nowrap #edit { white-space: pre; overflow-wrap: normal; word-break: normal; }
.hl-layer {
  position: absolute; inset: 0; overflow: hidden;
  pointer-events: none; color: var(--editor-fg);
}
.hl-layer code { display: block; will-change: transform; font: inherit; }
.hl-layer .ln { display: block; min-height: 19px; }
#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; }
/* The textarea's own text is transparent (the highlight layer underneath draws
   it), so an opaque selection would paint over those glyphs. Give selected
   text a real colour so it stays readable on top of the selection. */
#edit::selection { background: var(--editor-selection); color: var(--editor-fg); }
#edit::placeholder { color: var(--input-ph); }
.cur-line {
  position: absolute; left: 0; right: 0; top: 0; height: 19px;
  background: var(--editor-cur-line); pointer-events: none; will-change: transform;
}

.b64-prefix { color: var(--tok-prefix); }
.b64-data   { color: var(--tok-data); }
.b64-pad    { color: var(--tok-pad); }
.b64-bad    { color: var(--tok-bad); text-decoration: wavy underline; background: rgba(241,76,76,.12); }

/* drop overlay */
.dropzone {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45); backdrop-filter: blur(1px);
}
:root[data-theme="light"] .dropzone { background: rgba(255,255,255,.7); }
.dz-inner {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 32px 48px; border: 2px dashed var(--focus-border); border-radius: 8px;
  background: var(--widget-bg); color: var(--editor-fg); font-size: 14px;
}

/* ---------- preview pane ---------- */
.preview-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 4px var(--pg-w, 300px);
  min-height: 0;
}
.preview-main { grid-column: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#sashGrid     { grid-column: 2; }
.propgrid     { grid-column: 3; }
.preview-grid.nogrid { grid-template-columns: 1fr 0 0; }
.preview-grid.nogrid .propgrid { visibility: hidden; }
.preview-grid.nogrid #sashGrid { pointer-events: none; }

/* When the preview pane is narrow - typically in split view - the properties
   move under the image instead of stealing width from it. */
.preview-grid.stacked {
  grid-template-columns: 100%;
  grid-template-rows: minmax(0, 1fr) 0 minmax(110px, 32%);
}
.preview-grid.stacked > .preview-main { grid-column: 1; grid-row: 1; }
.preview-grid.stacked > #sashGrid { display: none; }
.preview-grid.stacked > .propgrid {
  grid-column: 1; grid-row: 3;
  border-left: 0; border-top: 1px solid var(--panel-border);
}
.preview-grid.stacked.nogrid { grid-template-rows: 1fr 0 0; }

.preview-bar {
  display: flex; align-items: center; gap: 4px; padding: 5px 8px;
  background: var(--toolbar-bg); border-bottom: 1px solid var(--panel-border);
  flex: 0 0 auto; overflow-x: auto; scrollbar-width: none;
}
.preview-bar::-webkit-scrollbar { height: 0; }
.preview-bar .sb-check { margin: 0; white-space: nowrap; }

.seg { display: inline-flex; border: 1px solid var(--contrast-border); border-radius: 3px; overflow: hidden; }
.seg-btn {
  height: 24px; padding: 0 12px; font-size: 12px;
  color: var(--editor-fg); background: var(--btn-sec-bg);
  border-right: 1px solid var(--contrast-border);
}
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { background: var(--btn-sec-hover); }
.seg-btn.active { background: var(--button-bg); color: var(--button-fg); }
.zoom-group { display: inline-flex; gap: 2px; }

.preview-body { flex: 1 1 auto; min-height: 0; position: relative; background: var(--stage-bg); }
.pv-stage {
  position: absolute; inset: 0; overflow: auto;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.pv-stage.checker {
  background-image:
    linear-gradient(45deg, var(--checker-a) 25%, transparent 25%, transparent 75%, var(--checker-a) 75%),
    linear-gradient(45deg, var(--checker-a) 25%, transparent 25%, transparent 75%, var(--checker-a) 75%);
  background-color: var(--checker-b);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
#pvImg { display: block; image-rendering: auto; box-shadow: 0 2px 10px var(--widget-shadow); }
#pvImg.fit { max-width: 100%; max-height: 100%; object-fit: contain; }
#pvImg.pixelated { image-rendering: pixelated; }

.pv-text {
  position: absolute; inset: 0; overflow: auto; margin: 0; padding: 12px 16px;
  background: var(--editor-bg); color: var(--editor-fg);
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.pv-hex {
  position: absolute; inset: 0; overflow: auto; padding: 12px 16px;
  background: var(--editor-bg);
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55;
  white-space: pre;
}
.pv-hex .off { color: var(--tok-off); }
.pv-hex .hx  { color: var(--tok-hex); }
.pv-hex .as  { color: var(--tok-ascii); }
.pv-more {
  display: block; margin: 12px 0 0; padding: 6px 12px;
  background: var(--btn-sec-bg); color: var(--editor-fg); border-radius: 2px; font-size: 12px;
}
.pv-more:hover { background: var(--btn-sec-hover); }
.pv-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  color: var(--editor-line-nr); font-size: 13px; text-align: center;
}

/* properties */
.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: 42% 58%;
  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: 42% 58%;
  font-size: 12px; border-bottom: 1px solid var(--panel-border); cursor: default;
}
.pg-row:hover { background: var(--list-hover); }
.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(--sidebar-title); }
.pg-row .pg-v { font-family: var(--font-mono); font-size: 11px; }
.pg-empty { padding: 14px 12px; color: var(--sidebar-title); font-size: 12px; }

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

/* ---------- bottom panel ---------- */
.panel {
  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; }
.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;
  font-family: var(--font-mono); font-size: 11.5px;
}
.prob.err  .dot { color: var(--err); }
.prob.warn .dot { color: var(--warn); }
.prob.ok   .dot { color: var(--ok); }
.prob .dot { width: 14px; height: 14px; flex: 0 0 14px; margin-top: 1px; }
.panel-empty { color: var(--editor-line-nr); padding: 8px 4px; }
#panelOutput { font-family: var(--font-mono); font-size: 11.5px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- 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(--sidebar-bg);
  border-top: 1px solid var(--panel-border);
  display: flex; justify-content: center;
}
.adbar.collapsed { display: none; }
.adbar-inner {
  position: relative;
  width: 100%; max-width: 970px; min-height: 64px;
  display: flex; align-items: center; justify-content: center;
  padding: 4px 0;
}
.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; }
/* the placeholder has no definite parent height to inherit, so reserve it here */
.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; text-align: center; padding: 0 12px;
}


/* ---------- 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 .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;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.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 {
  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) {
  /* the side bar floats over the editor instead of taking a column */
  .workbench { position: relative; grid-template-columns: 48px 0 0 1fr; }
  .workbench .sidebar { visibility: hidden; }
  .workbench.sidebar-open .sidebar {
    visibility: visible;
    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; }
  .preview-grid { grid-template-columns: 1fr 0 0; }
  .preview-grid .propgrid { visibility: hidden; }
  .editor-body { grid-template-columns: var(--gutter-w, 46px) 1fr; }
  .statusbar .sbi-static { display: none; }
}
@media (max-width: 560px) {
  .menubar .menu-btn[data-menu="convert"] { display: none; }
  .tbtn { padding: 0 7px; font-size: 11px; }
  #checkerToggleWrap { display: none; }
}

/* ---------- print ---------- */
@media print {
  html, body { height: auto; overflow: visible; background: #fff; color: #000; }
  .titlebar, .activitybar, .sidebar, .sash, .tabs, .toolbar,
  .statusbar, .panel, .preview-bar, .ctx, .menu-shield,
  .modal-backdrop, .palette-backdrop, .dropzone,
  .adbar { display: none !important; }
  #app, .workbench, .editorgroup { display: block; height: auto; }
  .pane { display: block !important; }
  .preview-body, .pv-stage { position: static; }
}
