/* ==========================================================================
   rismayilov.dev · SQL Studio (classic)
   Themes: data-theme="classic" (default) | "dark"
   ========================================================================== */

:root,
[data-theme="classic"] {
  --ui: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", "SF Mono", Menlo, "DejaVu Sans Mono", monospace;
  --app-bg: #e9edf3;
  --title-bg: linear-gradient(#3e6196, #2b4a79);
  --title-fg: #ffffff;
  --chrome: #f6f7f9;
  --chrome-2: #eef1f6;
  --toolbar: linear-gradient(#fcfdfe, #e9edf2);
  --border: #c5cdd9;
  --border-2: #d9dee6;
  --panel: #ffffff;
  --panel-head: #dfe5ee;
  --panel-head-fg: #2d3b50;
  --text: #1e1e1e;
  --muted: #5b6575;
  --faint: #8a94a5;
  --link: #1d4f91;
  --accent: #1d4f91;
  --accent-fg: #ffffff;
  --sel: #cce4f7;
  --sel-strong: #3d6aa8;
  --hover: #e5f1fb;
  --btn: linear-gradient(#ffffff, #eef1f5);
  --btn-border: #b5bfcd;
  --ask: #fff8dc;
  --ask-border: #e7d48c;
  --ask-fg: #6b5300;
  --tab: #e7ecf3;
  --tab-active: #fff7d6;
  --tab-accent: #f2b84b;
  --editor: #ffffff;
  --gutter: #f6f6f6;
  --ln: #2b91af;
  --t-kw: #0000ff;
  --t-st: #d10000;
  --t-cm: #008000;
  --t-op: #808080;
  --t-fn: #c000c0;
  --t-sp: #8b008b;
  --t-nu: #098658;
  --t-var: #1f6f8b;
  --grid-head: linear-gradient(#fbfbfb, #ececec);
  --grid-line: #e1e1e1;
  --grid-head-line: #c9c9c9;
  --rn-bg: #f1f1f1;
  --null-bg: #ffffe1;
  --status-ok: #fff1b8;
  --status-ok-b: #e3cd72;
  --status-ok-fg: #2f5f1f;
  --status-run: #d7e8fb;
  --status-run-b: #9fc3ec;
  --status-err: #fde2e1;
  --status-err-b: #ebb0ad;
  --err: #d00000;
  --info: #1d4f91;
  --menu: #ffffff;
  --menu-icon: #f1f3f6;
  --shadow: 0 6px 18px rgba(20, 30, 50, 0.22);
  --scroll: #c3cad6;
  color-scheme: light;
}

[data-theme="dark"] {
  --app-bg: #1e1e1e;
  --title-bg: linear-gradient(#3a3a3e, #2d2d30);
  --title-fg: #e6e6e6;
  --chrome: #2d2d30;
  --chrome-2: #252526;
  --toolbar: linear-gradient(#333337, #2d2d30);
  --border: #3f3f46;
  --border-2: #333337;
  --panel: #252526;
  --panel-head: #2d2d30;
  --panel-head-fg: #d0d0d0;
  --text: #dcdcdc;
  --muted: #a0a0a0;
  --faint: #7a7a7a;
  --link: #6cb6ff;
  --accent: #0e639c;
  --accent-fg: #ffffff;
  --sel: #094771;
  --sel-strong: #0e639c;
  --hover: #2a2d2e;
  --btn: linear-gradient(#3c3c3c, #333333);
  --btn-border: #4b4b52;
  --ask: #2b2a1f;
  --ask-border: #5c5428;
  --ask-fg: #e2c86b;
  --tab: #2d2d30;
  --tab-active: #1e1e1e;
  --tab-accent: #e2b24b;
  --editor: #1e1e1e;
  --gutter: #1e1e1e;
  --ln: #858585;
  --t-kw: #569cd6;
  --t-st: #ce9178;
  --t-cm: #6a9955;
  --t-op: #b4b4b4;
  --t-fn: #dcdcaa;
  --t-sp: #c586c0;
  --t-nu: #b5cea8;
  --t-var: #9cdcfe;
  --grid-head: linear-gradient(#333337, #2d2d30);
  --grid-line: #333337;
  --grid-head-line: #45454c;
  --rn-bg: #2d2d30;
  --null-bg: #3a3a26;
  --status-ok: #007acc;
  --status-ok-b: #0a6bb0;
  --status-ok-fg: #ffffff;
  --status-run: #68217a;
  --status-run-b: #561b66;
  --status-err: #8a2a2a;
  --status-err-b: #6e2020;
  --err: #f48771;
  --info: #6cb6ff;
  --menu: #2d2d30;
  --menu-icon: #2a2a2d;
  --shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
  --scroll: #4a4a50;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--app-bg);
  color: var(--text);
  font: 13px/1.4 var(--ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--sel-strong); outline-offset: 1px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); }
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }

.skip { position: absolute; left: 8px; top: -60px; z-index: 1000; background: var(--accent); color: var(--accent-fg); padding: 6px 10px; border-radius: 3px; }
.skip:focus { top: 8px; }

/* ---------- app grid ---------- */
.app {
  display: grid;
  grid-template-rows: 30px 26px 36px auto minmax(0, 1fr) 24px;
  height: 100vh;
  height: 100dvh;
}

/* title bar */
.titlebar { display: flex; align-items: center; gap: 8px; padding-left: 10px; background: var(--title-bg); color: var(--title-fg); user-select: none; min-width: 0; }
.titlebar .ic { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 4px; background: #f2b84b; color: #2b4a79; font: 800 9.5px var(--ui); flex: none; }
.titlebar .ttl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.titlebar .ttl b { font-weight: 600; }
.titlebar .wc { margin-left: auto; display: flex; height: 100%; }
.titlebar .wc button { width: 46px; height: 100%; border: 0; background: transparent; color: var(--title-fg); font-size: 13px; opacity: 0.9; }
.titlebar .wc button:hover { background: rgba(255, 255, 255, 0.14); }
.titlebar .wc button.x:hover { background: #d63c3c; }

/* menu bar */
.menubar { display: flex; align-items: center; gap: 2px; padding: 0 6px; background: var(--chrome); border-bottom: 1px solid var(--border-2); min-width: 0; }
.menubar > button { height: 22px; padding: 0 8px; border: 1px solid transparent; background: transparent; border-radius: 2px; }
.menubar > button:hover, .menubar > button[aria-expanded="true"] { background: var(--hover); border-color: var(--sel); }
.menubar .right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.menubar .right a, .menubar .right button { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 2px; border: 1px solid transparent; background: transparent; color: var(--link); font-weight: 600; text-decoration: none; white-space: nowrap; }
.menubar .right a:hover, .menubar .right button:hover { background: var(--hover); border-color: var(--sel); }
.menubar .right .cv { background: var(--accent); color: var(--accent-fg); }
.menubar .right .cv:hover { background: var(--sel-strong); color: #fff; }

/* toolbar */
.toolbar { display: flex; align-items: center; gap: 3px; padding: 0 6px; background: var(--toolbar); border-bottom: 1px solid var(--border); min-width: 0; overflow: hidden; }
.tb { display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 26px; min-width: 26px; padding: 0 6px; border: 1px solid transparent; border-radius: 3px; background: transparent; white-space: nowrap; }
.tb:hover { background: var(--hover); border-color: var(--sel); }
.tb[aria-pressed="true"] { background: var(--sel); border-color: var(--sel-strong); }
.tb svg { width: 16px; height: 16px; flex: none; }
.tb .lbl { font-size: 12.5px; }
.sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex: none; }
.dbsel { height: 24px; border: 1px solid var(--btn-border); background: var(--panel); padding: 0 4px; border-radius: 2px; min-width: 110px; }
.exec { border-color: var(--btn-border); background: var(--btn); font-weight: 600; }
.exec .bang { color: #d42020; font-weight: 900; font-size: 15px; line-height: 1; }
.exec.flash { animation: flash 0.5s ease; }
@keyframes flash { 0%, 100% { box-shadow: none; } 40% { box-shadow: 0 0 0 3px rgba(212, 32, 32, 0.35); } }
.conn { margin-left: auto; color: var(--status-ok-fg); font-weight: 600; font-size: 12px; white-space: nowrap; padding-right: 4px; }
[data-theme="dark"] .conn { color: #89d185; }
.mobile-only { display: none !important; }

/* ask bar */
.askbar { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--ask); border-bottom: 1px solid var(--ask-border); }
.askbar label { font-weight: 700; color: var(--ask-fg); white-space: nowrap; }
.askbar .in { position: relative; flex: 1; min-width: 0; }
.askbar input { width: 100%; height: 28px; border: 1px solid var(--ask-border); background: var(--panel); padding: 0 10px; border-radius: 2px; font-size: 13.5px; }
.askbar input:focus { outline: none; border-color: var(--sel-strong); box-shadow: 0 0 0 2px rgba(61, 106, 168, 0.25); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 12px; border: 1px solid var(--btn-border); border-radius: 3px; background: var(--btn); font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--text); }
.btn:hover { border-color: var(--sel-strong); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.askbar .hint { color: var(--ask-fg); opacity: 0.8; font-size: 12px; white-space: nowrap; }
.suggest { position: absolute; left: 0; right: 0; top: 30px; z-index: 40; background: var(--menu); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 4px 0; max-height: 320px; overflow: auto; }
.suggest .h { padding: 4px 10px; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }
.suggest button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 6px 12px; border: 0; background: transparent; text-align: left; }
.suggest button:hover, .suggest button.on { background: var(--sel); }
.suggest button .k { color: var(--faint); font-size: 11.5px; margin-left: auto; font-family: var(--mono); }

/* facts strip (mobile) + quick chips */
.facts { display: none; }
.chips { display: none; }

/* ---------- main area ---------- */
.main { display: grid; grid-template-columns: 236px minmax(0, 1fr) 272px; min-height: 0; }
.app.no-explorer .main { grid-template-columns: 0 minmax(0, 1fr) 272px; }
.app.no-props .main { grid-template-columns: 236px minmax(0, 1fr) 0; }
.app.no-explorer.no-props .main { grid-template-columns: 0 minmax(0, 1fr) 0; }
.app.no-explorer .explorer, .app.no-props .props { display: none; }

.pane-h { height: 24px; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 6px 0 8px; background: var(--panel-head); color: var(--panel-head-fg); border-bottom: 1px solid var(--border); font-weight: 600; flex: none; }
.pane-h .pb { display: flex; gap: 2px; }
.pane-h .pb button { width: 20px; height: 18px; border: 0; background: transparent; color: var(--muted); border-radius: 2px; font-size: 11px; }
.pane-h .pb button:hover { background: var(--hover); }

/* explorer */
.explorer { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--border); }
.tree { flex: 1; overflow: auto; padding: 4px 0; font-size: 12.5px; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree li > ul { padding-left: 14px; }
.tree .node { display: flex; align-items: center; gap: 4px; height: 22px; padding: 0 6px 0 4px; white-space: nowrap; cursor: default; border: 1px solid transparent; }
.tree .node:hover { background: var(--hover); }
.tree .node.sel { background: var(--sel); border: 1px dotted var(--sel-strong); }
.tree .tw { width: 14px; height: 14px; display: grid; place-items: center; border: 0; background: transparent; padding: 0; font-size: 0; flex: none; }
.tree .tw::before { content: ""; border: 4px solid transparent; border-left: 5px solid var(--muted); border-right: 0; transition: transform 0.12s ease; }
.tree li[aria-expanded="true"] > .node .tw::before { transform: rotate(90deg); border-left-color: var(--text); }
.tree .tw.leaf { visibility: hidden; }
.tree .lbl { overflow: hidden; text-overflow: ellipsis; }
.tree li[aria-expanded="false"] > ul { display: none; }
.ti { width: 15px; height: 15px; flex: none; display: inline-block; border-radius: 2px; }
.ti.srv { background: linear-gradient(#7aa0d8, #3d6aa8); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.15); }
.ti.fld { background: linear-gradient(#ffd97a, #e9b23f); border-radius: 2px 5px 2px 2px; }
.ti.db { background: linear-gradient(90deg, #d79a2b, #f2c46a 45%, #c8902a); border-radius: 50% / 28%; }
.ti.tbl { background-color: var(--panel); border: 1px solid #5b7fb3; background-image: linear-gradient(#5b7fb3 1px, transparent 1px), linear-gradient(90deg, #5b7fb3 1px, transparent 1px); background-size: 6px 4px; background-position: -1px -1px; }
.ti.view { background-color: var(--panel); border: 1px solid #3f9b6a; background-image: linear-gradient(#3f9b6a 1px, transparent 1px); background-size: 4px 4px; }
.ti.col { width: 10px; height: 10px; margin: 0 2.5px; background: #8fa9cf; border-radius: 1px; }
.ti.key { width: 12px; height: 8px; margin: 0 1.5px; background: #e2b336; border-radius: 4px 1px 1px 4px; }
.ti.sp { background: linear-gradient(#b7a3e6, #7d62c8); border-radius: 3px; }
.ti.usr { background: radial-gradient(circle at 50% 35%, #6f8fbf 0 3px, transparent 3.5px), radial-gradient(ellipse at 50% 100%, #6f8fbf 0 6px, transparent 6.5px); }
.ti.idx { width: 12px; height: 12px; margin: 0 1.5px; border: 2px solid #8fa9cf; border-radius: 50%; }

.quick { border-top: 1px solid var(--border-2); padding: 6px 6px 8px; flex: none; }
.quick .h { font-size: 10.5px; font-weight: 700; color: var(--faint); letter-spacing: 0.06em; text-transform: uppercase; margin: 2px 4px 4px; }
.quick button { display: flex; align-items: center; gap: 6px; width: 100%; padding: 4px 6px; border: 0; background: transparent; color: var(--link); font-weight: 600; text-align: left; border-radius: 2px; }
.quick button:hover { background: var(--hover); }
.quick button::before { content: "▸"; color: var(--faint); font-size: 10px; }

/* document area */
.doc { --ed: 40%; display: grid; grid-template-rows: 28px var(--ed) 6px minmax(0, 1fr); min-width: 0; min-height: 0; background: var(--panel); }
.qtabs { display: flex; align-items: flex-end; gap: 2px; padding: 0 4px; background: var(--panel-head); border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.qtab { display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 4px 0 10px; border: 1px solid var(--border); border-bottom: 0; background: var(--tab); color: var(--muted); font-size: 12px; white-space: nowrap; cursor: default; flex: none; }
.qtab.on { background: var(--tab-active); color: var(--text); font-weight: 600; box-shadow: inset 0 2px 0 var(--tab-accent); height: 25px; }
.qtab .x { width: 16px; height: 16px; border: 0; background: transparent; color: var(--faint); border-radius: 2px; font-size: 13px; line-height: 1; padding: 0; }
.qtab .x:hover { background: var(--hover); color: var(--text); }
.qtab-new { height: 22px; width: 24px; border: 1px dashed var(--border); background: transparent; color: var(--muted); margin-bottom: 1px; flex: none; }
.qtab-new:hover { background: var(--hover); }

.editor { display: grid; grid-template-columns: 46px minmax(0, 1fr); min-height: 0; background: var(--editor); }
.gutter { overflow: hidden; background: var(--gutter); border-right: 1px solid var(--border-2); color: var(--ln); text-align: right; padding: 6px 8px 6px 0; font: 13px/19px var(--mono); user-select: none; }
.code { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.code pre, .code textarea {
  position: absolute; inset: 0; margin: 0; padding: 6px 10px 6px 8px; border: 0;
  font: 13px/19px var(--mono); letter-spacing: 0; tab-size: 4; white-space: pre; word-wrap: normal; overflow: auto;
}
.code pre { overflow: hidden; pointer-events: none; color: var(--text); }
.code textarea { background: transparent; color: transparent; caret-color: var(--text); resize: none; outline: none; -webkit-text-fill-color: transparent; }
.code textarea::selection { background: rgba(51, 136, 255, 0.28); -webkit-text-fill-color: transparent; }
.t-kw { color: var(--t-kw); } .t-st { color: var(--t-st); } .t-cm { color: var(--t-cm); } .t-op { color: var(--t-op); }
.t-fn { color: var(--t-fn); } .t-sp { color: var(--t-sp); } .t-nu { color: var(--t-nu); } .t-var { color: var(--t-var); }

/* IntelliSense */
.ac { position: absolute; z-index: 30; min-width: 230px; max-width: 340px; background: var(--menu); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 12.5px; padding: 2px 0; }
.ac .it { display: flex; align-items: center; gap: 7px; padding: 3px 8px; white-space: nowrap; cursor: default; }
.ac .it.on { background: var(--sel-strong); color: #fff; }
.ac .it .kd { width: 16px; height: 16px; display: grid; place-items: center; font: 700 10px var(--mono); border-radius: 2px; background: var(--menu-icon); color: var(--muted); flex: none; }
.ac .it.on .kd { background: rgba(255, 255, 255, 0.25); color: #fff; }
.ac .it .dt { margin-left: auto; padding-left: 14px; color: var(--faint); font-size: 11px; }
.ac .it.on .dt { color: rgba(255, 255, 255, 0.8); }

/* splitter */
.splitter { background: var(--chrome-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: row-resize; position: relative; }
.splitter::after { content: ""; position: absolute; left: 50%; top: 1px; width: 28px; height: 2px; margin-left: -14px; border-top: 1px dotted var(--faint); border-bottom: 1px dotted var(--faint); }
.splitter:hover, .splitter.drag { background: var(--sel); }

/* results */
.results { display: grid; grid-template-rows: 26px minmax(0, 1fr); min-height: 0; }
.rtabs { display: flex; align-items: flex-end; gap: 2px; padding: 0 4px; background: var(--chrome-2); border-bottom: 1px solid var(--border); }
.rtabs button { height: 22px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid transparent; border-bottom: 0; background: transparent; color: var(--muted); font-size: 12px; }
.rtabs button[aria-selected="true"] { background: var(--panel); border-color: var(--border); color: var(--text); font-weight: 600; height: 23px; }
.rtabs .ri { width: 12px; height: 12px; display: inline-block; flex: none; }
.rtabs .ri.g { border: 1px solid #5b7fb3; background-image: linear-gradient(#5b7fb3 1px, transparent 1px), linear-gradient(90deg, #5b7fb3 1px, transparent 1px); background-size: 4px 4px; }
.rtabs .ri.m { border-radius: 2px; background: #6aa0d8; clip-path: polygon(0 0, 100% 0, 100% 75%, 40% 75%, 15% 100%, 20% 75%, 0 75%); }
.rtabs .ri.p { border-radius: 50%; border: 2px solid #3f9b6a; }
.rtabs .cnt { font-size: 11px; color: var(--faint); font-weight: 400; }
.rbody { overflow: auto; background: var(--panel); position: relative; }
.pane { display: none; }
.pane.on { display: block; }
.empty { padding: 18px; color: var(--faint); }
.empty kbd, .dialog kbd { font: 11px var(--mono); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 3px; padding: 0 4px; background: var(--chrome); color: var(--text); }

.rs { margin: 6px; }
.rs + .rs { margin-top: 10px; padding-top: 8px; border-top: 3px double var(--border); }
.grid { border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.grid th { position: sticky; top: 0; z-index: 1; background: var(--grid-head); border: 1px solid var(--grid-head-line); border-width: 1px 1px 1px 0; padding: 3px 18px 3px 8px; text-align: left; font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none; }
.grid th:first-child { border-left-width: 1px; }
.grid th .s { position: absolute; right: 5px; color: var(--faint); font-size: 9px; }
.grid th:hover { filter: brightness(0.97); }
.grid td { border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line); padding: 3px 8px; white-space: nowrap; max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.grid td:first-child { border-left: 1px solid var(--grid-line); }
.grid .rn { background: var(--rn-bg); color: var(--muted); text-align: center; min-width: 30px; position: sticky; left: 0; border-right-color: var(--grid-head-line); cursor: default; }
.grid th.rn { z-index: 2; }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.null { background: var(--null-bg); color: var(--muted); font-style: italic; }
.grid tbody tr { cursor: default; }
.grid tbody tr:hover td:not(.rn) { background-color: var(--hover); }
.grid tbody tr.sel td:not(.rn) { background: var(--sel); }
.grid tbody tr.sel td.rn { background: var(--sel-strong); color: #fff; }
.grid tbody tr.sel td.cur { outline: 1px dotted var(--text); outline-offset: -3px; }
.grid tbody tr.zero td { color: var(--faint); font-style: italic; text-align: left; }
.cards { display: none; }
.textout { margin: 0; padding: 8px 10px; font: 12.5px/1.5 var(--mono); white-space: pre; }

.msgs { margin: 0; padding: 8px 10px; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; }
.msgs .e { color: var(--err); }
.msgs .i { color: var(--info); }
.msgs .d { color: var(--faint); }

.plan { padding: 10px 12px; }
.plan .q { font: 12px var(--mono); color: var(--t-cm); margin-bottom: 10px; white-space: pre-wrap; }
.plan .flow { display: flex; align-items: flex-start; gap: 0; flex-wrap: wrap; row-gap: 14px; }
.pn { width: 150px; text-align: center; padding: 6px 6px 8px; border: 1px solid transparent; border-radius: 3px; cursor: default; }
.pn:hover { background: var(--hover); border-color: var(--sel); }
.pn .ico { width: 44px; height: 44px; margin: 0 auto 6px; display: grid; place-items: center; border-radius: 4px; background: linear-gradient(#f4f8fd, #d6e4f5); border: 1px solid #9fb8da; font-size: 20px; color: #2c5a94; }
[data-theme="dark"] .pn .ico { background: linear-gradient(#2f3b4a, #253140); border-color: #3f5878; color: #9cc3f0; }
.pn .op { font-weight: 600; font-size: 12px; line-height: 1.25; }
.pn .dt { font-size: 11px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.pn .cost { margin-top: 4px; font-size: 11.5px; }
.pn .cost b { font-weight: 700; }
.pn .rows { font-size: 11px; color: var(--faint); }
.arrow { width: 34px; align-self: center; margin-top: -26px; height: 3px; background: var(--faint); position: relative; flex: none; }
.arrow::before { content: ""; position: absolute; left: -6px; top: -5px; border: 6.5px solid transparent; border-right-color: var(--faint); border-left: 0; }

/* properties */
.props { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-left: 1px solid var(--border); }
.props .cb { margin: 6px; min-height: 24px; border: 1px solid var(--btn-border); display: flex; align-items: center; gap: 6px; padding: 2px 6px; font-size: 12px; background: var(--panel); }
.props .cb b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.props .cb span { color: var(--muted); white-space: nowrap; }
.props .pbody { flex: 1; overflow: auto; }
.pg { font-size: 12px; }
.pg .cat { display: flex; align-items: center; gap: 4px; width: 100%; padding: 2px 6px; border: 0; border-top: 1px solid var(--border-2); background: var(--chrome-2); color: var(--panel-head-fg); font-weight: 700; text-align: left; }
.pg .cat[aria-expanded="false"] + .rows { display: none; }
.pg .row { display: grid; grid-template-columns: 92px minmax(0, 1fr); border-top: 1px solid var(--border-2); }
.pg .row > span { padding: 2px 6px; min-width: 0; }
.pg .row > span:first-child { color: var(--muted); border-right: 1px solid var(--border-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg .row > span:last-child { font-weight: 600; overflow-wrap: anywhere; }
.pg .row:hover > span { background: var(--hover); }
.props .desc { border-top: 1px solid var(--border); padding: 6px 8px 8px; font-size: 12px; line-height: 1.45; background: var(--chrome-2); max-height: 42%; overflow: auto; flex: none; }
.props .desc b { display: block; margin-bottom: 2px; }
.props .desc ul { margin: 4px 0 0; padding-left: 16px; }
.props .desc li { margin-top: 2px; }
.props .desc .stack { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 3px; }
.props .desc .stack span { font: 11px var(--mono); padding: 0 5px; border: 1px solid var(--border); background: var(--panel); border-radius: 2px; }

/* status bar */
.statusbar { display: flex; align-items: stretch; background: var(--status-ok); border-top: 1px solid var(--status-ok-b); color: var(--status-ok-fg); font-size: 12px; min-width: 0; }
.statusbar > span { display: flex; align-items: center; padding: 0 10px; border-left: 1px solid var(--status-ok-b); white-space: nowrap; }
.statusbar > span:first-child { flex: 1; border-left: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.statusbar.run { background: var(--status-run); border-top-color: var(--status-run-b); color: var(--text); }
.statusbar.run > span { border-left-color: var(--status-run-b); }
.statusbar.err { background: var(--status-err); border-top-color: var(--status-err-b); color: var(--err); }
.statusbar.err > span { border-left-color: var(--status-err-b); }
[data-theme="dark"] .statusbar.run, [data-theme="dark"] .statusbar.err { color: #fff; }
.spin { display: inline-block; width: 11px; height: 11px; margin-right: 6px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- menus, context menus, dialogs, toast ---------- */
.menu { position: fixed; z-index: 100; min-width: 230px; background: var(--menu); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 2px; font-size: 12.5px; background-image: linear-gradient(90deg, var(--menu-icon) 26px, transparent 26px); }
.menu button { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; width: 100%; padding: 4px 10px 4px 4px; border: 1px solid transparent; background: transparent; text-align: left; border-radius: 2px; white-space: nowrap; }
.menu button:hover, .menu button:focus { background: var(--sel); border-color: var(--sel-strong); outline: none; }
.menu button .ck { text-align: center; font-size: 11px; }
.menu button .sc { color: var(--faint); font-size: 11.5px; padding-left: 20px; }
.menu hr { border: 0; border-top: 1px solid var(--border-2); margin: 3px 2px 3px 30px; }

.backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(15, 25, 40, 0.35); display: grid; place-items: center; padding: 16px; animation: fade 0.15s ease; }
@keyframes fade { from { opacity: 0; } }
.dialog { width: min(460px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid #2b4a79; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45); animation: pop 0.16s ease; }
.dialog.wide { width: min(680px, 100%); }
@keyframes pop { from { transform: translateY(6px) scale(0.98); opacity: 0; } }
.dialog .dh { height: 30px; display: flex; align-items: center; gap: 8px; padding-left: 10px; background: var(--title-bg); color: var(--title-fg); font-size: 12.5px; flex: none; }
.dialog .dh .x { margin-left: auto; width: 40px; height: 100%; border: 0; background: transparent; color: inherit; }
.dialog .dh .x:hover { background: #d63c3c; }
.dialog .db { padding: 16px 18px; overflow: auto; line-height: 1.5; }
.dialog .df { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; background: var(--chrome-2); border-top: 1px solid var(--border-2); flex: none; flex-wrap: wrap; }
.dialog .df .btn { min-width: 84px; }
.dialog .df .btn:focus-visible { outline: 2px solid var(--sel-strong); }
.dialog h3 { margin: 0 0 6px; font-size: 16px; }
.dialog p { margin: 0 0 10px; }
.dialog table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.dialog td { padding: 4px 6px; border-bottom: 1px solid var(--border-2); vertical-align: top; }
.dialog td:first-child { white-space: nowrap; }
.dialog .samples button { display: block; width: 100%; text-align: left; padding: 6px 8px; margin: 0 0 4px; border: 1px solid var(--border-2); background: var(--chrome-2); border-radius: 2px; font: 12px var(--mono); white-space: pre-wrap; color: var(--text); }
.dialog .samples button:hover { border-color: var(--sel-strong); background: var(--sel); }

.dialog.connect .db { padding: 0; }
.connect .brandband { display: flex; align-items: center; gap: 12px; padding: 16px 18px; background: linear-gradient(120deg, #2b4a79, #3e6196 60%, #5b7fb3); color: #fff; }
.connect .brandband .ic { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; background: #f2b84b; color: #2b4a79; font: 800 15px var(--ui); }
.connect .brandband b { display: block; font-size: 17px; font-weight: 600; letter-spacing: 0.01em; }
.connect .brandband span { font-size: 12px; opacity: 0.85; }
.connect .fields { display: grid; grid-template-columns: 120px 1fr; gap: 8px 10px; align-items: center; padding: 16px 18px 6px; }
.connect .fields label { color: var(--muted); }
.connect .fields .v { height: 26px; border: 1px solid var(--btn-border); background: var(--panel); display: flex; align-items: center; padding: 0 8px; }
.connect .fields select { height: 26px; border: 1px solid var(--btn-border); background: var(--panel); padding: 0 4px; }
.connect .prog { padding: 4px 18px 0; height: 22px; color: var(--muted); font-size: 12px; display: flex; align-items: center; }
.connect .bar { height: 3px; margin: 0 18px 12px; background: var(--border-2); overflow: hidden; }
.connect .bar i { display: block; height: 100%; width: 0; background: var(--sel-strong); transition: width 0.9s ease; }

.about { display: grid; grid-template-columns: 96px 1fr; gap: 16px; }
.about img { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.about .ver { font: 12px var(--mono); color: var(--muted); }

.toast { position: fixed; right: 14px; bottom: 34px; z-index: 300; max-width: 360px; background: var(--menu); border: 1px solid var(--border); border-left: 4px solid var(--sel-strong); box-shadow: var(--shadow); padding: 10px 12px; font-size: 12.5px; animation: pop 0.2s ease; }

/* ---------- responsive: phone & small tablet ---------- */
@media (max-width: 1180px) and (min-width: 901px) {
  .main { grid-template-columns: 210px minmax(0, 1fr) 236px; }
  .app.no-explorer .main { grid-template-columns: 0 minmax(0, 1fr) 236px; }
  .app.no-props .main { grid-template-columns: 210px minmax(0, 1fr) 0; }
  .askbar .hint { display: none; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .app { display: flex; flex-direction: column; height: auto; min-height: 100vh; padding-bottom: 30px; }
  .titlebar { order: -2; }
  .facts { order: -1; }
  .facts .plain { display: inline-block; margin-top: 8px; font-weight: 600; text-decoration: none; }
  .titlebar { height: 32px; position: sticky; top: 0; z-index: 20; }
  .titlebar .wc button { width: 38px; }
  .menubar { display: none; }
  .toolbar { height: 46px; gap: 6px; padding: 0 8px; overflow-x: auto; }
  .toolbar .desk-only { display: none !important; }
  .mobile-only { display: inline-flex !important; }
  .tb { height: 34px; padding: 0 10px; border-color: var(--btn-border); background: var(--btn); }
  .tb.cvb { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
  .conn { display: none; }
  .facts { display: block; padding: 10px 12px 12px; background: var(--panel); border-bottom: 1px solid var(--border); }
  .facts h1 { margin: 0; font-size: 21px; letter-spacing: -0.01em; }
  .facts p { margin: 2px 0 0; color: var(--muted); }
  .facts .kv { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
  .facts .kv span { font-size: 11.5px; padding: 1px 7px; border: 1px solid var(--border); background: var(--chrome-2); border-radius: 2px; }
  .askbar { flex-wrap: wrap; padding: 8px 10px; }
  .askbar label { width: 100%; }
  .askbar .hint { display: none; }
  .askbar input { height: 34px; font-size: 15px; }
  .askbar .btn { height: 34px; }
  .chips { display: flex; gap: 6px; padding: 8px 10px; overflow-x: auto; background: var(--chrome-2); border-bottom: 1px solid var(--border); scrollbar-width: none; }
  .chips button { flex: none; height: 30px; padding: 0 12px; border: 1px solid var(--btn-border); background: var(--panel); border-radius: 15px; font-weight: 600; color: var(--link); }
  .main { display: block; }
  .explorer, .props { position: fixed; top: 0; bottom: 0; z-index: 150; width: min(320px, 86vw); transform: translateX(-102%); transition: transform 0.2s ease; box-shadow: var(--shadow); display: flex !important; }
  .explorer { left: 0; }
  .props { right: 0; left: auto; transform: translateX(102%); }
  .explorer.open, .props.open { transform: none; }
  .drawer-bg { position: fixed; inset: 0; z-index: 140; background: rgba(0, 0, 0, 0.35); }
  .doc { display: block; }
  .qtabs { height: 30px; }
  .editor { height: 150px; }
  .editor.tall { height: 300px; }
  .splitter { display: none; }
  .results { display: block; }
  .rbody { overflow: visible; min-height: 220px; }
  .rs.wide .grid { display: none; }
  .rs.wide .cards { display: block; }
  .cards .card { margin: 0 0 8px; border: 1px solid var(--border); background: var(--panel); padding: 8px 10px; }
  .cards .card.sel { border-color: var(--sel-strong); box-shadow: inset 3px 0 0 var(--sel-strong); }
  .cards .card b { display: block; font-size: 14px; margin-bottom: 2px; }
  .cards .card dl { margin: 0; display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 1px 8px; font-size: 12.5px; }
  .cards .card dt { color: var(--muted); }
  .cards .card dd { margin: 0; overflow-wrap: anywhere; }
  .cards .card dd.null { color: var(--faint); font-style: italic; }
  .grid td { max-width: 220px; }
  .statusbar { position: fixed; left: 0; right: 0; bottom: 0; height: 30px; z-index: 20; }
  .statusbar .desk-only { display: none; }
  .menu { max-width: calc(100vw - 16px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
