/* ================================================================
   CPIDE — design system
   Monochrome UI over VS Code editor palettes.
   ================================================================ */

:root {
  --bg: #1e1e1e;
  --panel: #1e1e1e;
  --panel-2: #252526;
  --panel-3: #2f2f33;
  --border: #3c3c3c;
  --border-soft: #2e2e2e;
  --text: #e8e8e8;
  --text-dim: #9d9d9d;
  --text-faint: #6b6b6b;
  --btn-bg: #ffffff;
  --btn-fg: #111111;
  --ac: #3fb950;
  --wa: #f85149;
  --tle: #d29922;
  --re: #db6d28;
  --ce: #db61a2;
  --shadow: 0 10px 32px rgba(0, 0, 0, .5);
  --mono: 'JetBrains Mono', Consolas, monospace;
  --sans: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --radius: 8px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f3f3f3;
  --panel-3: #e8e8e8;
  --border: #d4d4d4;
  --border-soft: #e5e5e5;
  --text: #1f1f1f;
  --text-dim: #616161;
  --text-faint: #9b9b9b;
  --btn-bg: #111111;
  --btn-fg: #ffffff;
  --ac: #1a7f37;
  --wa: #cf222e;
  --tle: #9a6700;
  --re: #bc4c00;
  --ce: #bf3989;
  --shadow: 0 10px 32px rgba(0, 0, 0, .14);
  color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
}

body { display: flex; flex-direction: column; }

kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: transparent;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; border: 2px solid transparent; }

/* ================= Top bar ================= */

#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 10px; margin-right: 6px; user-select: none; }

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 32px; height: 32px;
  border: 1.5px solid var(--text);
  border-radius: 9px;
  font: 700 15px var(--mono);
  color: var(--text);
  animation: markIn .5s cubic-bezier(.2, .8, .2, 1);
}
@keyframes markIn { from { transform: scale(.6) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.brand-mark .lb, .brand-mark .rb { transition: transform .18s ease; line-height: 1; }
.brand-mark .caret {
  width: 2px; height: 13px;
  background: currentColor;
  animation: caretBlink 1.1s steps(1) infinite;
}
@keyframes caretBlink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }
.brand:hover .lb { transform: translateX(-1.5px); }
.brand:hover .rb { transform: translateX(1.5px); }

.brand-name { font-weight: 800; font-size: 15px; letter-spacing: 1.5px; }

.topbar-spacer { flex: 1; }

/* language picker */
.lang-picker { position: relative; }
.lang-btn {
  display: flex; align-items: center; gap: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font: 600 13px var(--sans);
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s;
}
.lang-btn:hover { border-color: var(--text-dim); }
.lang-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ac); flex-shrink: 0; }
.lang-dot.off { background: var(--text-faint); }
.lang-ver { color: var(--text-faint); font-weight: 500; font-size: 11px; font-family: var(--mono); }
.chev { color: var(--text-faint); }

.lang-menu {
  position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 320px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  z-index: 50;
}
.lang-menu.open { display: block; animation: pop .12s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.lang-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0; background: none;
  border-radius: 6px;
  color: var(--text);
  font: 500 13px var(--sans);
  cursor: pointer;
  text-align: left;
}
.lang-item:hover { background: var(--panel-3); }
.lang-item.active { background: var(--panel-3); outline: 1px solid var(--border); }
.lang-item .li-name { font-weight: 600; min-width: 58px; }
.lang-item .li-ver {
  font: 600 10px var(--mono);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.lang-item .li-ver.std { color: var(--text-dim); }
.lang-item .li-detail {
  color: var(--text-faint); font-size: 11px; font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.lang-item.unavailable { opacity: .45; }
.lang-menu-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px 4px;
  border-top: 1px solid var(--border-soft);
  margin-top: 6px;
}
.lang-menu-foot span { font-size: 11px; color: var(--text-faint); }
.lang-menu-foot button {
  background: none; border: 0; color: var(--text);
  font: 600 11px var(--sans); cursor: pointer; padding: 2px 4px;
  text-decoration: underline; text-underline-offset: 3px;
}

/* stopwatch */
.stopwatch {
  display: flex; align-items: center; gap: 6px;
  font: 500 12px var(--mono);
  color: var(--text-faint);
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: color .15s, background .15s;
}
.stopwatch:hover { background: var(--panel-3); }
.stopwatch.running { color: var(--text); }

.icon-btn {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  background: none; border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  transition: all .15s;
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); border-color: var(--border); }

.run-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--btn-bg);
  border: 0;
  color: var(--btn-fg);
  font: 700 13px var(--sans);
  padding: 9px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity .13s, transform .1s;
}
.run-btn:hover { opacity: .85; }
.run-btn:active { transform: translateY(1px); }
.run-btn:disabled { opacity: .45; cursor: wait; }
.run-btn kbd { border-color: currentColor; color: inherit; opacity: .65; }
/* While running the button reads Stop — pulse the square instead of spinning,
   and hide the Ctrl R hint (the shortcut starts runs, it doesn't stop them). */
.run-btn.running svg { animation: runPulse 1.1s ease-in-out infinite; }
.run-btn.running kbd { display: none; }
@keyframes runPulse { 50% { opacity: .4; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= Import + problems bar ================= */

.clone-btn { display: flex; align-items: center; gap: 7px; padding: 7px 12px; font-size: 12px; }

#problemsBar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pb-pills { display: flex; align-items: center; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.pb-pill {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font: 700 12px var(--mono);
  padding: 5px 11px;
  border-radius: 7px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .13s;
}
.pb-pill:hover { color: var(--text); border-color: var(--text-dim); }
.pb-pill.active {
  background: var(--btn-bg);
  border-color: var(--btn-bg);
  color: var(--btn-fg);
}
.pb-pill.scratch { font-family: var(--sans); font-weight: 600; }
.pb-x {
  display: inline-block;
  margin-left: 6px;
  padding: 0 1px;
  color: var(--text-faint);
  font-weight: 400;
  line-height: 1;
  border-radius: 4px;
  transition: color .13s;
}
.pb-pill:hover .pb-x { color: var(--text-dim); }
.pb-pill.active .pb-x { color: var(--btn-fg); opacity: .55; }
.pb-x:hover, .pb-pill.active .pb-x:hover { color: var(--wa); opacity: 1; }
.pb-meta { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.pb-name {
  font: 600 12.5px var(--sans);
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.pb-link {
  font: 600 11px var(--sans); color: var(--text-dim);
  text-decoration: underline; text-underline-offset: 3px; white-space: nowrap;
}
.pb-link:hover { color: var(--text); }
.pb-tl {
  font: 600 10.5px var(--mono);
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 6px;
  white-space: nowrap;
}
.pb-tl:empty { display: none; }
.pb-clear {
  margin-left: auto;
  background: none; border: 0;
  color: var(--text-faint);
  font: 600 11px var(--sans);
  cursor: pointer;
  padding: 4px 8px; border-radius: 6px;
  white-space: nowrap;
}
.pb-clear:hover { color: var(--wa); }

/* input-needed highlight */
.io-box.needs-input {
  border-color: var(--wa);
  animation: needPulse 1.2s ease-in-out 3;
}
@keyframes needPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0); }
  50% { box-shadow: 0 0 0 4px rgba(248, 81, 73, .22); border-color: var(--wa); }
}

/* ================= Import modal ================= */

.modal-wrap {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 70;
  display: grid; place-items: center;
}
.modal {
  width: min(560px, calc(100vw - 32px));
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: pop .15s ease-out;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 0;
  font: 700 15px var(--sans);
}
.modal-body { padding: 14px 20px 20px; }
.modal-hint { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; margin-bottom: 12px; }
.modal-hint.dim { color: var(--text-faint); margin: 12px 0 0; }
.inline-link { color: var(--text-dim); }

.import-tabs {
  display: flex; gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 14px;
}
.import-tab {
  flex: 1;
  background: none; border: 0;
  color: var(--text-dim);
  font: 600 12px var(--sans);
  padding: 7px 0;
  border-radius: 6px;
  cursor: pointer;
}
.import-tab:hover { color: var(--text); }
.import-tab.active { background: var(--btn-bg); color: var(--btn-fg); }

.clone-row { display: flex; gap: 8px; }
.clone-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: 500 12.5px var(--mono);
  padding: 10px 12px;
  outline: 0;
  min-width: 0;
}
.clone-row input:focus { border-color: var(--text-dim); }
.clone-row .run-btn { padding: 9px 20px; }
.clone-sites { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.site {
  font: 600 10.5px var(--sans);
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-faint);
}
.site.ok { color: var(--text); }
.site.meh { color: var(--text-dim); }

.bookmarklet {
  display: inline-block;
  border: 1.5px dashed var(--text-dim);
  color: var(--text);
  font: 700 13px var(--sans);
  padding: 9px 18px;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: grab;
}
.bookmarklet:hover { border-color: var(--text); }

.paste-box { min-height: 140px; max-height: 220px; font-size: 11.5px; }

/* interactive console */
.console-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.console-status { font: 500 11.5px var(--sans); color: var(--text-faint); margin-right: auto; }
.console-status.live { color: var(--ac); }
.console-status.live::before { content: '●'; margin-right: 5px; animation: onlinePulse 1.6s ease-in-out infinite; }
.console-status.ended { color: var(--text-dim); }
.console-status.error { color: var(--wa); }
.console-out {
  height: min(52vh, 440px); overflow-y: auto; margin: 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; font: 13px/1.5 var(--mono); color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.console-out .c-err { color: var(--wa); }
.console-out .c-in { color: var(--text-dim); }
.console-out .c-sys { color: var(--text-faint); font-style: italic; }
.console-input-row {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px;
}
.console-input-row:focus-within { border-color: var(--text-dim); }
.console-prompt { color: var(--ac); font: 600 14px var(--mono); }
.console-input {
  flex: 1; background: transparent; border: 0; outline: 0;
  color: var(--text); font: 13px var(--mono); padding: 10px 0;
}
.console-input:disabled { color: var(--text-faint); }

/* stress testing */
.modal-wide { width: min(860px, calc(100vw - 32px)); }
.stress-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 700px) { .stress-grid { grid-template-columns: 1fr; } }
.stress-col-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 6px;
}
.stress-col-head label {
  font: 600 10.5px var(--sans);
  letter-spacing: .8px; text-transform: uppercase;
  color: var(--text-faint);
}
.stress-col-head select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: 500 11px var(--sans);
  padding: 3px 6px;
  outline: 0;
}
.stress-code { min-height: 170px; max-height: 240px; font-size: 11.5px; resize: vertical; }
.stress-controls {
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.stress-count { font: 600 12px var(--sans); color: var(--text-dim); display: flex; align-items: center; gap: 7px; }
.stress-count input {
  width: 74px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: 500 12px var(--mono);
  padding: 6px 8px;
  outline: 0;
}
.stress-status { font: 600 12px var(--mono); color: var(--text-dim); }
.stress-status.found { color: var(--wa); }
.stress-status.clean { color: var(--ac); }
.stress-result { margin-top: 14px; }
.stress-result .sr-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.stress-result .sr-seed { font: 600 11px var(--mono); color: var(--text-faint); }
.stress-result label {
  display: block;
  font: 600 10.5px var(--sans);
  letter-spacing: .8px; text-transform: uppercase;
  color: var(--text-faint);
  margin: 10px 0 5px;
}
.stress-result pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: 12px/1.5 var(--mono);
  padding: 8px 11px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow-y: auto;
  color: var(--text);
}
.stress-result .sr-exp { border-color: rgba(63, 185, 80, .4); }
.stress-result .sr-got { border-color: rgba(248, 81, 73, .4); }

.clone-status {
  margin-top: 12px;
  font: 500 12.5px var(--sans);
  color: var(--text-dim);
  line-height: 1.5;
  min-height: 18px;
}
.clone-status.error { color: var(--wa); }
.clone-status .spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}

/* ================= Workspace ================= */

#workspace { flex: 1; display: flex; min-height: 0; }
#workspace.flipped { flex-direction: row-reverse; }

#editorPane {
  flex: 1 1 58%;
  min-width: 360px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  min-height: 0;
}

#splitter {
  width: 5px;
  cursor: col-resize;
  background: var(--border-soft);
  flex-shrink: 0;
  transition: background .15s;
  touch-action: none;
}
#splitter:hover, #splitter.dragging { background: var(--text-dim); }

#ioPane {
  width: 42%;
  min-width: 320px;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  background: var(--panel-2);
  min-height: 0;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.pane-title {
  display: flex; align-items: center; gap: 8px;
  font: 600 11px var(--sans);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
}
/* file tabs: the main file plus any helper files added with [+] */
.file-tabs { display: flex; align-items: center; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.file-tabs::-webkit-scrollbar { display: none; }
.file-tab {
  display: flex; align-items: center; gap: 5px;
  font: 500 12px var(--mono); color: var(--text-faint);
  text-transform: none; letter-spacing: 0;
  background: transparent; border: 0; border-radius: 5px;
  padding: 3px 8px; cursor: pointer; white-space: nowrap;
}
.file-tab:hover { color: var(--text-dim); background: var(--panel-3); }
.file-tab.active { color: var(--text-dim); background: var(--panel-3); }
.file-tab.dragging { opacity: .35; }
.file-tab.drop-target { background: var(--panel-3); box-shadow: inset 2px 0 0 var(--text-dim); }
.file-tab .file-x { opacity: 0; font-size: 13px; line-height: 1; margin: 0 -2px 0 0; padding: 0 2px; border-radius: 3px; }
.file-tab:hover .file-x { opacity: .55; }
.file-tab .file-x:hover { opacity: 1; background: var(--border); }
.file-add {
  background: transparent; border: 0; color: var(--text-faint);
  font: 500 15px var(--mono); line-height: 1;
  padding: 2px 7px; border-radius: 5px; cursor: pointer; flex-shrink: 0;
}
.file-add:hover { color: var(--text); background: var(--panel-3); }
.save-state { font-size: 10px; color: var(--text-faint); text-transform: none; letter-spacing: .3px; opacity: 0; transition: opacity .3s; flex-shrink: 0; }
.save-state.show { opacity: 1; }
.case-summary { text-transform: none; letter-spacing: .2px; font-family: var(--mono); font-size: 11px; }

.pane-actions { display: flex; gap: 6px; }
.mini-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font: 600 11px var(--sans);
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: all .15s;
}
.mini-btn:hover { color: var(--text); border-color: var(--text-dim); }
.mini-btn.accent { color: var(--text); }
.mini-btn.ghost { background: none; border: 0; padding: 0 4px; font-size: 10px; }
.mini-btn:disabled { opacity: .5; cursor: wait; }

/* template menu */
.tpl-wrap { position: relative; }
.tpl-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 240px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 5px;
  display: none;
  z-index: 45;
}
.tpl-menu.open { display: block; animation: pop .12s ease-out; }
.tpl-menu button {
  display: block; width: 100%;
  text-align: left;
  background: none; border: 0;
  color: var(--text);
  font: 500 12px var(--sans);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.tpl-menu button:hover { background: var(--panel-3); }
.tpl-menu button.danger:hover { color: var(--wa); }
.tpl-menu button:disabled { opacity: .4; cursor: default; }
.tpl-menu button:disabled:hover { background: none; color: var(--text); }

#editorHost { flex: 1; min-height: 0; position: relative; }
#editor { position: absolute; inset: 0; }
#fallbackEditor {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  background: var(--panel);
  color: var(--text);
  border: 0; outline: 0; resize: none;
  font: 14px/1.6 var(--mono);
  padding: 14px 18px;
  tab-size: 4;
}

/* ================= Test cases ================= */

.case-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 4px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
}
.case-tab {
  display: flex; align-items: center; gap: 7px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font: 600 12px var(--sans);
  padding: 6px 10px 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  flex-shrink: 0;
}
.case-tab:hover { color: var(--text); }
.case-tab.active {
  background: var(--panel-3);
  border-color: var(--text-dim);
  color: var(--text);
}
.case-tab .v-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.case-tab .v-dot.AC { background: var(--ac); }
.case-tab .v-dot.WA { background: var(--wa); }
.case-tab .v-dot.TLE { background: var(--tle); }
.case-tab .v-dot.RE, .case-tab .v-dot.OLE { background: var(--re); }
.case-tab .v-dot.RUN { background: var(--text); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.case-tab .tab-x {
  display: grid; place-items: center;
  width: 16px; height: 16px;
  border-radius: 5px;
  color: var(--text-faint);
  font-size: 13px; line-height: 1;
  visibility: hidden;
}
.case-tab:hover .tab-x { visibility: visible; }
.case-tab .tab-x:hover { color: var(--wa); }

.io-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 20px;
  min-height: 0;
}

.io-field { margin-bottom: 12px; }
.io-field label {
  display: flex; align-items: center; gap: 6px;
  font: 600 10.5px var(--sans);
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.io-field label .mini-btn { margin-left: auto; }

.io-box {
  width: 100%;
  min-height: 76px;
  max-height: 220px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: 13px/1.55 var(--mono);
  padding: 10px 12px;
  resize: vertical;
  outline: 0;
  transition: border-color .15s;
}
.io-box:focus { border-color: var(--text-dim); }

.out-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: 13px/1.55 var(--mono);
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
  min-height: 40px;
  color: var(--text);
}
.out-box.err { color: var(--re); }
.out-box:empty::before { content: '—'; color: var(--text-faint); }

/* verdict */
.result-head {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0 12px;
}
.verdict-chip {
  font: 800 13px var(--sans);
  letter-spacing: .5px;
  padding: 5px 14px;
  border-radius: 7px;
  border: 1px solid;
}
.verdict-chip.AC { color: var(--ac); border-color: var(--ac); background: rgba(63, 185, 80, .08); }
.verdict-chip.WA { color: var(--wa); border-color: var(--wa); background: rgba(248, 81, 73, .08); }
.verdict-chip.TLE { color: var(--tle); border-color: var(--tle); background: rgba(210, 153, 34, .08); }
.verdict-chip.RE, .verdict-chip.OLE { color: var(--re); border-color: var(--re); background: rgba(219, 109, 40, .08); }
.verdict-chip.OK { color: var(--text-dim); border-color: var(--border); background: transparent; }
.result-meta { font: 500 12px var(--mono); color: var(--text-faint); }

.compile-banner {
  border: 1px solid var(--ce);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 8px 0 14px;
}
.compile-banner h4 {
  color: var(--ce);
  font: 800 12px var(--sans);
  letter-spacing: .8px;
  margin-bottom: 8px;
}
.compile-banner pre {
  font: 12px/1.5 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  max-height: 300px;
  overflow-y: auto;
}

.diff-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: 12.5px/1.6 var(--mono);
  padding: 10px 12px;
  overflow-x: auto;
}
.diff-box .d-line { color: var(--text-faint); font-size: 11px; margin-bottom: 4px; font-family: var(--sans); }
.diff-box .d-exp { color: var(--ac); }
.diff-box .d-got { color: var(--wa); }
.diff-box b { font-weight: 600; opacity: .7; font-size: 11px; display: inline-block; width: 76px; }

.meta-warn { color: var(--tle); font-weight: 600; }

.setting.btn-row { display: flex; gap: 8px; }

/* Vim mode indicator + its ':' command line, drawn by monaco-vim */
#vimStatus { font-family: var(--mono); font-size: 10.5px; }
#vimStatus input {
  background: transparent; color: inherit; border: 0; outline: 0;
  font: inherit; width: 160px;
}

/* user-snippet editor modal */
.usnip-top { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.usnip-top select { align-self: flex-start; }
.usnip-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 110px; overflow-y: auto; }
.usnip-item {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 6px 3px 10px;
  font: 500 12px var(--mono); color: var(--text);
  cursor: pointer;
}
.usnip-item:hover { border-color: var(--text-faint); }
.usnip-item .u-desc { color: var(--text-faint); font-family: var(--sans); font-size: 11px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usnip-item .u-x { border: 0; background: none; color: var(--text-faint); cursor: pointer; font-size: 13px; padding: 0 4px; border-radius: 50%; }
.usnip-item .u-x:hover { color: var(--wa); }
.usnip-empty { color: var(--text-faint); font-size: 12px; padding: 2px 0; }
.usnip-body { min-height: 150px; font-family: var(--mono); margin-top: 8px; }
.usnip-actions { margin-top: 8px; align-items: center; }

/* full expected-vs-got diff table */
.full-diff {
  margin-top: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 340px;
  overflow: auto;
  font: 12px/1.65 var(--mono);
}
.fd-row { display: grid; grid-template-columns: 44px 1fr 1fr; min-width: fit-content; }
.fd-row > span { padding: 1px 10px; white-space: pre; }
.fd-row > span:first-child { color: var(--text-faint); text-align: right; user-select: none; border-right: 1px solid var(--border-soft); }
.fd-row > span:nth-child(2) { border-right: 1px solid var(--border-soft); }
.fd-head {
  position: sticky; top: 0;
  background: var(--panel-2);
  font-family: var(--sans); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px; color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.fd-row.mismatch { background: color-mix(in srgb, var(--wa) 12%, transparent); }
.fd-row.mismatch > span:nth-child(2) { color: var(--ac); }
.fd-row.mismatch > span:nth-child(3) { color: var(--wa); }
.fd-missing { color: var(--text-faint); font-style: italic; }
.fd-more { color: var(--text-faint); font-family: var(--sans); font-size: 11px; }

.idle-hint {
  text-align: center;
  color: var(--text-faint);
  padding: 40px 20px;
  font-size: 13px;
}

/* ================= Status bar ================= */

#statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 26px;
  padding: 0 12px;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
  font: 500 11px var(--sans);
  color: var(--text-faint);
  flex-shrink: 0;
  gap: 12px;
}
.status-left, .status-right { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.status-left { min-width: 0; overflow: hidden; }
#toolchainInfo { overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 10.5px; }
.status-sep { opacity: .4; }
.server-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--tle); transition: background .3s; }
.server-dot.on { background: var(--ac); }
.server-dot.err { background: var(--wa); }
.online-badge { display: flex; align-items: center; gap: 5px; cursor: default; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ac); animation: onlinePulse 2s ease-in-out infinite; }
@keyframes onlinePulse { 50% { opacity: .3; } }
#cursorPos { font-family: var(--mono); font-size: 10.5px; }
.status-link {
  color: var(--text-faint);
  text-decoration: none;
  font-weight: 600;
}
.status-link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.status-btn {
  background: none; border: 0;
  color: var(--text-faint);
  font: 700 10px var(--sans);
  cursor: pointer; padding: 2px 4px;
  border-radius: 4px;
}
.status-btn:hover { color: var(--text); background: var(--panel-3); }
#fontSizeLabel { font-family: var(--mono); font-size: 10.5px; }

/* ================= Settings drawer ================= */

#settingsDrawer {
  position: fixed;
  top: 0; right: -340px;
  width: 320px; height: 100%;
  background: var(--panel-2);
  border-left: 1px solid var(--border);
  z-index: 60;
  transition: right .22s cubic-bezier(.4, 0, .2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
#settingsDrawer.open { right: 0; }
#drawerScrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 55;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
#drawerScrim.show { opacity: 1; pointer-events: auto; }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  font: 700 14px var(--sans);
  border-bottom: 1px solid var(--border);
}
.drawer-body { padding: 18px; overflow-y: auto; }
.setting { margin-bottom: 18px; }
.setting.row { display: flex; align-items: center; justify-content: space-between; }
.setting > label { display: block; font: 600 12px var(--sans); margin-bottom: 6px; color: var(--text-dim); }
.setting.row > label { margin: 0; }
.setting input[type="number"], .setting select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: 500 13px var(--mono);
  padding: 8px 10px;
  outline: 0;
}
.setting input:focus, .setting select:focus { border-color: var(--text-dim); }
.setting input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--text); }
.setting-hint { font-size: 11px; color: var(--text-faint); margin-top: 6px; line-height: 1.5; }
.drawer-section {
  font: 700 10.5px var(--sans);
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-faint);
  margin: 22px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.shortcuts { width: 100%; border-collapse: collapse; }
.shortcuts td { padding: 5px 0; font-size: 12px; color: var(--text-dim); }
.shortcuts td:first-child { width: 110px; }

/* ================= Toast ================= */

#toast {
  position: fixed;
  bottom: 44px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--panel-3);
  border: 1px solid var(--border);
  color: var(--text);
  font: 600 12.5px var(--sans);
  padding: 9px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: all .25s cubic-bezier(.4, 0, .2, 1);
  z-index: 100;
  max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================= Responsive ================= */

@media (max-width: 900px) {
  #workspace, #workspace.flipped { flex-direction: column; }
  #splitter { display: none; }
  #editorPane { flex: 1 1 55%; min-width: 0; }
  #ioPane { width: 100%; max-width: none; min-width: 0; flex: 1 1 45%; border-top: 1px solid var(--border); }
}

@media (max-width: 768px) {
  #topbar { gap: 8px; padding: 0 10px; }
  .brand-name, .run-btn kbd, .stopwatch, .clone-btn span { display: none; }
  .lang-ver { display: none; }
  .run-btn { padding: 9px 14px; }
  #toolchainInfo, #cursorPos { display: none; }
  .pb-name { font-size: 11.5px; }
  #problemsBar { padding: 0 10px; gap: 8px; }
}
