:root {
  color-scheme: dark;
  --shell: #14171d;
  --panel: #1c2028;
  --deep: #171b22;
  --line: #323843;
  --fg: #eef0f4;
  --muted: #a3adbd;
  --blue: #a7c0ff;
  --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, Menlo, monospace;
  --sans: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --code-size: 15px;
  --code-line: 25px;
  --pad-code: 17px;
  font: 14px/1.45 var(--sans);
  color: var(--fg);
  background: var(--shell);
}
* { box-sizing: border-box; }
[hidden], .icon-library { display: none !important; }
body { margin: 0; display: flex; flex-direction: column; min-height: 100vh; height: 100dvh; }
button, input, textarea { font: inherit; }
button, summary, label, input[type="checkbox"] { cursor: pointer; }
button { color: inherit; }
button:disabled { cursor: default; opacity: .48; }
:where(button, a, summary, input, [tabindex]):focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
a { color: var(--blue); text-underline-offset: 3px; }
button { -webkit-tap-highlight-color: transparent; }
button svg, a svg, .panel-heading svg { flex: 0 0 auto; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.filled { fill: currentColor; stroke: none; }
.masthead { display: flex; align-items: center; gap: 16px; height: 64px; flex: none; padding: 0 24px; }
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand b { font-size: 20px; font-weight: 650; letter-spacing: -.7px; }
.mast-divider { color: #677180; font-size: 22px; font-weight: 300; }
h1 { margin: 0; font-size: 18px; font-weight: 450; letter-spacing: -.3px; }
.engine { margin-left: auto; font: 12px var(--mono); color: var(--muted); }
.workbench { display: grid; flex: 1; min-height: 0; grid-template-columns: clamp(216px, 20%, 306px) minmax(0, 1fr) clamp(220px, 18%, 275px); grid-template-rows: minmax(0, 1fr); grid-template-areas: "library panes inspector"; gap: 1px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--line); margin: 0 16px; }
.workspace-panes {
  --min-editor: 150px;
  --min-output: 98px;
  --split-size: 12px;
  --editor-ratio: .64;
  --pane-space: calc(100% - var(--split-size));
  grid-area: panes;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: clamp(var(--min-editor), calc(var(--pane-space) * var(--editor-ratio)), calc(var(--pane-space) - var(--min-output))) var(--split-size) minmax(0, 1fr);
  grid-template-areas: "editor" "splitter" "console";
}
#output-splitter { grid-area: splitter; display: grid; place-items: center; cursor: row-resize; touch-action: none; user-select: none; background: #222832; border-block: 1px solid var(--line); }
#output-splitter::after { content: ""; width: 34px; height: 3px; border-radius: 2px; background: #78889d; }
#output-splitter:is(:hover, :focus-visible, .dragging)::after { background: var(--blue); }
@media (pointer: coarse) { .workspace-panes { --split-size: 24px; } }
.panel { min-width: 0; min-height: 0; background: var(--panel); }
.panel-heading { display: flex; align-items: center; gap: 9px; min-height: 46px; padding: 0 16px; }
.panel-heading > .icon { color: #adb9cb; }
h2 { font-size: 14px; font-weight: 620; margin: 0; letter-spacing: -.12px; }
.library { grid-area: library; overflow: auto; }
.library summary { border-bottom: 1px solid var(--line); list-style: none; position: sticky; top: 0; z-index: 1; background: var(--panel); }
.library summary::-webkit-details-marker { display: none; }
.count { font: 11px var(--mono); border: 1px solid #444d5c; border-radius: 5px; padding: 1px 5px; color: var(--muted); }
.count:empty { display: none; }
.disclosure { margin-left: auto; width: 15px; }
.library:not([open]) .disclosure { transform: rotate(-90deg); }
.examples { padding: 7px; color: var(--muted); font-size: 13px; }
.example { position: relative; display: grid; grid-template-columns: 17px minmax(0,1fr); gap: 2px 9px; align-items: start; width: 100%; padding: 9px 10px; color: var(--fg); border: 1px solid transparent; background: transparent; text-align: left; border-radius: 5px; }
.example > .icon { grid-row: span 2; width: 16px; height: 16px; margin-top: 2px; color: #8290a4; }
.example-name { font: 500 13px/1.5 var(--mono); overflow-wrap: anywhere; }
.example-description { grid-column: 2; font-size: 12px; line-height: 1.45; color: var(--muted); }
.example:hover, .icon-button:hover { background: #282e39; }
.example[aria-current="true"] { background: #293447; border-color: #3a4b64; }
.example[aria-current="true"] .icon, .example[aria-current="true"] .example-name { color: #c1d5ff; }
.retry { margin: 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.editor { grid-area: editor; display: flex; flex-direction: column; background: var(--deep); }
.editor-bar { height: 46px; display: flex; align-items: center; justify-content: space-between; padding-right: 7px; background: #20252e; border-bottom: 1px solid var(--line); flex: none; }
.file-tab { display: flex; align-items: center; gap: 8px; height: calc(100% + 1px); max-width: calc(100% - 45px); padding: 0 17px; border-top: 2px solid var(--blue); border-right: 1px solid var(--line); background: var(--deep); font: 13px var(--mono); }
.file-tab > .icon { width: 16px; color: var(--blue); }
#filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dirty { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); flex: none; }
.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--muted); }
.icon-button:hover { color: #ffc0bb; }
.code-area { flex: 1; min-height: 0; display: flex; direction: ltr; }
.code-viewport { position: relative; min-width: 0; flex: 1; }
.gutter, .code-surface { margin: 0; font: var(--code-size)/var(--code-line) var(--mono); font-variant-ligatures: none; letter-spacing: 0; tab-size: 4; }
.gutter { max-width: 7ch; flex: none; min-width: 3.9ch; overflow: hidden; padding: var(--pad-code) 7px var(--pad-code) 10px; white-space: pre; text-align: right; color: #a9c6bb; opacity: .8; user-select: none; }
.code-surface { position: absolute; inset: 0; min-height: 0; width: 100%; height: 100%; resize: none; border: 0; border-radius: 0; outline: 0; padding: var(--pad-code) 15px var(--pad-code) 6px; white-space: pre; overflow-wrap: normal; word-break: normal; color: #fff; background: transparent; }
#highlight-layer { overflow: hidden; pointer-events: none; }
#source { overflow: auto; caret-color: #fff; }
#source::placeholder { color: #97a1b1; opacity: 1; }
#source::selection { color: transparent; background: rgb(112 151 221 / 35%); }
.syntax-on #source { color: transparent; }
.code-area:not(.syntax-on) #highlight-layer { visibility: hidden; }
.code-area:not(.syntax-on) #source::selection { color: #fff; }
.code-area:focus-within { box-shadow: inset 0 0 0 1px #526480; }
.keyword { color: #dbf485; }
.literal, .operator { color: #d5ede2; }
.comment { color: #9caaa8; }
.editor-footer { min-height: 26px; display: flex; align-items: center; justify-content: space-between; padding: 2px 13px; border-top: 1px solid #292f38; font: 11px var(--mono); color: var(--muted); flex: none; }
.console { grid-area: console; display: flex; flex-direction: column; background: #191d24; }
.console .panel-heading { height: 42px; min-height: 42px; background: #20252d; border-bottom: 1px solid var(--line); flex: none; }
#output-mode { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: 12px; }
#output-mode:not(:empty)::before { content: "/"; margin-right: 9px; color: #778191; }
.run-state { margin-left: auto; white-space: nowrap; font: 11px var(--mono); color: var(--muted); }
.run-state[data-status="ok"] { color: #b7dcb6; }
.run-state:is([data-status="error"], [data-status="timeout"], [data-status="limit"]) { color: #ffb6ab; }
.run-state[data-status="busy"] { color: var(--blue); }
#output { margin: 0; flex: 1; min-height: 0; overflow: auto; padding: 14px 17px; font: 14px/1.55 var(--mono); white-space: pre; tab-size: 4; }
#output.empty-output { color: #a2adbd; font: 13px/1.55 var(--sans); white-space: pre-wrap; }
.inspector { grid-area: inspector; display: flex; flex-direction: column; overflow: auto; }
.controls > .panel-heading { border-bottom: 1px solid var(--line); }
.control-body { padding: 15px 13px 12px; }
.control-body button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 6px 11px; border: 1px solid #3a434f; border-radius: 5px; background: #252b35; text-align: left; font-size: 13px; }
.control-body button:hover:enabled { background: #303846; border-color: #58667c; }
.control-body button > .icon { width: 16px; height: 16px; color: #b4bfd2; }
.control-body .run-button { color: #111b31; background: var(--blue); border-color: #a6bfff; font-weight: 650; }
.control-body .run-button .icon { color: inherit; fill: currentColor; width: 14px; }
.control-body .run-button:hover:enabled { background: #bbceff; border-color: #bbceff; }
kbd { margin-left: auto; font: 11px var(--mono); color: #324570; white-space: nowrap; }
h3 { margin: 19px 0 8px; color: var(--muted); font-size: 12px; font-weight: 550; }
.stage-buttons { display: grid; gap: 6px; }
.settings { display: grid; gap: 8px; padding-top: 15px; margin-top: 16px; border-top: 1px solid var(--line); }
.settings label { display: flex; align-items: center; gap: 9px; width: fit-content; font-size: 13px; color: #d6dbe4; }
.settings input { height: 15px; width: 15px; accent-color: var(--blue); margin: 0; }
.share { margin-top: auto; flex: none; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 9px; border-top: 1px solid var(--line); padding: 14px 0; text-align: center; }
.qr-link { display: block; width: 80%; aspect-ratio: 1; padding: 0; border: 0; overflow: hidden; background: white; border-radius: 4px; cursor: zoom-in; }
.qr-link:focus-visible { outline-offset: 2px; }
.qr-link img { display: block; width: 100%; height: 100%; }
.share h3 { margin: 0 0 4px; color: var(--fg); font-size: 12px; }
.share div a { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; font-size: 12px; }
.share div a:hover { text-decoration: underline; }
.share div .icon { width: 12px; height: 12px; }
#qr-dialog { width: min(560px, 85dvh, 94vw); max-height: 96dvh; margin: auto; padding: 14px; border: 1px solid #546076; border-radius: 8px; background: var(--panel); color: var(--fg); }
#qr-dialog::backdrop { background: rgb(7 10 16 / 85%); }
#qr-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 10px; }
#qr-dialog h2 { font-size: 16px; }
#qr-dialog .icon-button { font-size: 24px; }
#qr-dialog img { display: block; width: 100%; aspect-ratio: 1; background: white; border-radius: 4px; }
#qr-dialog a { display: block; width: fit-content; margin: 12px auto 0; font: 16px var(--mono); }
.workbench-footer { display: flex; flex: none; align-items: center; gap: 7px; min-height: 31px; padding: 0 22px; font-size: 11px; color: var(--muted); }
.status-dot { height: 6px; width: 6px; background: #9cc9ae; border-radius: 50%; }
.limits { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.completion-menu { position: absolute; z-index: 2; border: 1px solid #53627a; border-radius: 5px; background: #242b36; box-shadow: 0 5px 16px #0e11187a; min-width: min(165px,100%); max-width: 100%; max-height: 146px; overflow: auto; overscroll-behavior: contain; }
.completion-menu button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; border: 0; padding: 4px 8px; color: var(--fg); background: none; text-align: left; font: 12px/1.5 var(--mono); }
.completion-menu button[aria-selected="true"] { background: #384964; }
.completion-menu small { color: #c1cbd9; font: 10px var(--sans); }
.completion-menu [aria-selected="true"] small::after { content: " · Tab"; }
@media (min-width: 1500px) { :root { --code-size: 16px; --code-line: 27px; } }
@media (max-width: 960px) and (min-width: 761px) {
  .workbench { grid-template-columns: 175px minmax(0,1fr) 189px; margin: 0 8px; }
  .control-body { padding: 12px 9px; }
  .example { padding: 8px 4px; gap: 2px 5px; }
  .example-name { font-size: 12px; }
  .masthead { padding: 0 15px; }
}
@media (max-width: 760px) {
  body { min-height: 100dvh; height: auto; }
  .masthead { height: 55px; gap: 10px; padding: 0 14px; }
  .brand { gap: 7px; }
  .brand img { width: 28px; height: 28px; }
  .brand b { font-size: 18px; }
  h1 { font-size: 16px; }
  .engine { font-size: 11px; }
  .workbench { flex: auto; grid-template-columns: minmax(0,1fr); grid-template-rows: auto auto max(405px, 64dvh) auto; grid-template-areas: "library" "controls" "panes" "share"; gap: 1px; margin: 0 8px; }
  .panel-heading { min-height: 40px; }
  .library summary { position: static; border: 0; }
  .examples { border-top: 1px solid var(--line); max-height: 36dvh; overflow-y: auto; }
  .example { padding: 7px 8px; }
  .inspector { display: contents; }
  .controls { grid-area: controls; background: var(--panel); }
  .controls > .panel-heading, .control-body > h3 { display: none; }
  .control-body { display: grid; grid-template-columns: 1fr; gap: 7px; padding: 10px; }
  .stage-buttons { display: flex; flex-wrap: wrap; gap: 5px; }
  .stage-buttons button { flex: 1 1 max-content; min-height: 35px; width: auto; gap: 5px; justify-content: center; padding: 4px 6px; font-size: 12px; }
  .stage-buttons button > .icon { width: 14px; }
  .settings { grid-template-columns: auto auto; justify-content: start; gap: 5px 15px; margin: 0; padding: 4px 0 0; border: 0; }
  .settings label:has(#autocomplete) { grid-column: 2; }
  .share { grid-area: share; margin: 0; border: 0; background: var(--panel); }
  .workbench-footer { padding: 0 13px; }
  :root { --code-size: 16px; --pad-code: 11px; }
}
@media (max-width: 395px) { .engine { display: none; } }
@media (max-height: 480px) and (min-width: 761px) { body { height: 510px; } }
@media (forced-colors: active) {
  .syntax-on #source, #source::selection { color: CanvasText; }
  #highlight-layer { display: none; }
}

#draft-entry {
  position: sticky;
  top: 46px;
  z-index: 1;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
#draft-dialog {
  width: min(475px, 94vw);
  max-height: 92dvh;
  padding: 21px;
  margin: auto;
  border: 1px solid #546076;
  border-radius: 8px;
  background: var(--panel);
  color: var(--fg);
}
#draft-dialog::backdrop { background: rgb(7 10 16 / 78%); }
#draft-dialog h2 { font-size: 17px; overflow-wrap: anywhere; }
#draft-dialog p { margin: 12px 0; color: #c5ceda; overflow-wrap: anywhere; }
#draft-dialog code, #draft-current { font-family: var(--mono); }
.draft-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-top: 21px; }
.draft-actions div { display: flex; flex-wrap: wrap; gap: 6px; }
.draft-actions button {
  padding: 7px 10px;
  border: 1px solid #4b5668;
  border-radius: 4px;
  background: #2a3240;
  font-size: 13px;
}
.draft-actions button:hover { background: #354156; }
.draft-actions [value="overwrite"] { background: #36455b; color: #e6edff; }
@media (max-width: 760px) {
  #draft-entry { position: static; max-height: none; }
  #draft-dialog { padding: 15px; }
}
