:root {
  color-scheme: light dark;
  --bg: #f4f5f7; --panel: #ffffff; --panel2: #eef0f3; --panel3: #e3e6ea;
  --line: #d7dbe0; --text: #1c2128; --muted: #5d6673; --faint: #8b94a1; --strong: #0b0f14;
  --accent: #2563eb; --accent-soft: #dbe7ff; --accent-text: #ffffff;
  --danger: #d1242f; --danger-soft: #fde8ea; --warn: #9a6700; --warn-soft: #fff4d6; --ok: #1a7f37; --ok-soft: #dff5e5;
  --null: #9aa3af; --num: #0a5bd6; --blob: #8a3ffc; --key: #b7791f;
  --mono: ui-monospace, "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 8px 30px rgba(0, 0, 0, .18);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --panel: #1b1f26; --panel2: #232831; --panel3: #2c323d;
    --line: #333a46; --text: #dfe3ea; --muted: #a2abb8; --faint: #7a8494; --strong: #ffffff;
    --accent: #4c8dff; --accent-soft: #1d3157; --accent-text: #0b1220;
    --danger: #ff6b73; --danger-soft: #3a1d21; --warn: #e3b341; --warn-soft: #3a2f12; --ok: #56d364; --ok-soft: #14301c;
    --null: #6b7482; --num: #79b0ff; --blob: #c29bff; --key: #e3b341;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 13px/1.4 var(--sans); color: var(--text); background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.app { display: flex; flex-direction: column; height: 100vh; }

/* ---- top bar ---- */
.top { display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--strong); letter-spacing: .2px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--accent) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.8'><ellipse cx='12' cy='6' rx='7' ry='3'/><path d='M5 6v6c0 1.7 3.1 3 7 3s7-1.3 7-3V6'/><path d='M5 12v6c0 1.7 3.1 3 7 3s7-1.3 7-3v-6'/></svg>") center/16px no-repeat; }
.dbname { color: var(--muted); max-width: 46vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 4px; }
.dbname strong { color: var(--text); font-weight: 600; }
.spacer { flex: 1; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.big { height: 38px; padding: 0 22px; font-size: 14px; }
.btn.icon { width: 30px; padding: 0; justify-content: center; }
.btn.small { height: 24px; padding: 0 8px; font-size: 12px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 34px; height: 18px; border-radius: 9px; background: var(--panel3); position: relative; transition: background .15s; border: 1px solid var(--line); }
.switch .track::after { content: ""; position: absolute; top: 1px; left: 1px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .track { background: var(--warn-soft); border-color: var(--warn); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--warn); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-label { font-weight: 600; font-size: 12px; color: var(--muted); }
.switch input:checked ~ .switch-label { color: var(--warn); }

/* ---- layout ---- */
.body { flex: 1; display: flex; min-height: 0; }
.side { width: 270px; flex: none; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.status { flex: none; height: 26px; display: flex; align-items: center; gap: 16px; padding: 0 14px; background: var(--panel); border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; }
.status .badge { padding: 1px 8px; border-radius: 10px; font-weight: 600; }
.badge.ro { background: var(--ok-soft); color: var(--ok); }
.badge.rw { background: var(--warn-soft); color: var(--warn); }

/* ---- sidebar ---- */
.side-search { padding: 10px; border-bottom: 1px solid var(--line); }
.side-search input { width: 100%; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); outline: none; }
.side-search input:focus { border-color: var(--accent); }
.side-list { flex: 1; overflow: auto; padding: 6px 0; }
.side-group { padding: 10px 14px 4px; font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--faint); display: flex; justify-content: space-between; }
.obj { display: flex; align-items: center; gap: 8px; padding: 0 14px; height: 28px; cursor: pointer; border-left: 3px solid transparent; }
.obj:hover { background: var(--panel2); }
.obj.active { background: var(--accent-soft); border-left-color: var(--accent); color: var(--strong); }
.obj .ico { width: 14px; flex: none; text-align: center; color: var(--faint); font-size: 12px; }
.obj .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obj .cnt { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.obj.sys .nm { color: var(--muted); font-style: italic; }
.side-empty { padding: 14px; color: var(--faint); }
.side-foot { padding: 8px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; display: flex; gap: 8px; align-items: center; cursor: pointer; }

/* ---- welcome ---- */
.welcome { flex: 1; display: grid; place-items: center; padding: 24px; overflow: auto; }
.welcome-card { width: min(560px, 100%); text-align: center; padding: 38px 34px; background: var(--panel); border: 2px dashed var(--line); border-radius: 16px; }
.welcome-card.drag { border-color: var(--accent); background: var(--accent-soft); }
.welcome-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 16px; background: var(--accent) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.6'><ellipse cx='12' cy='6' rx='7' ry='3'/><path d='M5 6v6c0 1.7 3.1 3 7 3s7-1.3 7-3V6'/><path d='M5 12v6c0 1.7 3.1 3 7 3s7-1.3 7-3v-6'/></svg>") center/38px no-repeat; }
.welcome h1 { margin: 0 0 8px; font-size: 22px; color: var(--strong); }
.welcome p { margin: 0 0 18px; color: var(--muted); }
.welcome .hint { margin: 14px 0 0; font-size: 12px; color: var(--faint); }
.recent { margin-top: 22px; text-align: left; }
.recent h3 { margin: 0 0 6px; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--faint); }
.recent-item { display: flex; gap: 10px; align-items: baseline; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.recent-item:hover { background: var(--panel2); }
.recent-item .n { font-weight: 600; white-space: nowrap; }
.recent-item .p { color: var(--faint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.dropveil { position: fixed; inset: 0; background: color-mix(in srgb, var(--accent) 30%, transparent); display: grid; place-items: center; z-index: 50; pointer-events: none; }
.dropveil div { padding: 22px 34px; background: var(--panel); border: 2px dashed var(--accent); border-radius: 14px; font-size: 18px; font-weight: 600; }

/* ---- tabs and panes ---- */
.work { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; align-items: flex-end; gap: 2px; padding: 8px 14px 0; background: var(--bg); border-bottom: 1px solid var(--line); flex: none; }
.tab { padding: 7px 16px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; background: none; cursor: pointer; color: var(--muted); font-weight: 600; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--panel); border-color: var(--line); color: var(--strong); }
.tab:disabled { opacity: .4; cursor: default; }
.tabs-title { margin-left: auto; padding: 0 4px 8px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs-title strong { color: var(--text); }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--panel); }

/* ---- browse ---- */
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex: none; flex-wrap: wrap; }
.bar input[type="search"], .bar input[type="text"], .bar select, .bar input[type="number"] { height: 26px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); outline: none; }
.bar input:focus, .bar select:focus { border-color: var(--accent); }
.bar .grow { flex: 1; }
.bar .sep { width: 1px; height: 18px; background: var(--line); }
.bar .info { color: var(--muted); font-size: 12px; }
.pager { display: inline-flex; align-items: center; gap: 4px; }
.pager input { width: 56px; text-align: center; }
.split { flex: 1; min-height: 0; display: flex; }
.gridwrap { flex: 1; min-width: 0; overflow: auto; position: relative; }
table.grid { border-collapse: separate; border-spacing: 0; font-family: var(--mono); font-size: 12px; width: max-content; } /* as wide as its content: opening the value panel must not move the columns under the pointer */
.grid th, .grid td { padding: 0 10px; height: 26px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.grid thead th { position: sticky; top: 0; z-index: 2; background: var(--panel2); font-family: var(--sans); font-weight: 600; height: 34px; cursor: pointer; user-select: none; }
.grid thead tr.filters th { top: 34px; height: 30px; z-index: 2; padding: 2px 4px; cursor: default; background: var(--panel); }
.grid thead th:hover:not(.rn) { background: var(--panel3); }
.grid thead th .ty { display: block; font-weight: 400; font-size: 10px; color: var(--faint); line-height: 1; margin-top: 1px; }
.grid thead th .nm { display: inline-block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.grid thead th .arrow { color: var(--accent); margin-left: 4px; }
.grid thead th .pk { color: var(--key); margin-right: 3px; }
.grid th.rn, .grid td.rn { position: sticky; left: 0; z-index: 1; width: 1%; min-width: 48px; text-align: right; color: var(--faint); background: var(--panel); font-variant-numeric: tabular-nums; }
.grid thead th.rn { z-index: 3; background: var(--panel2); cursor: default; }
.grid tbody tr:hover td { background: var(--panel2); }
.grid tbody tr.sel td { background: var(--accent-soft); }
.grid td.sel-cell { outline: 2px solid var(--accent); outline-offset: -2px; }
.grid td.null { color: var(--null); font-style: italic; }
.grid td.num { color: var(--num); text-align: right; }
.grid td.blob { color: var(--blob); }
.grid td.long::after { content: " …"; color: var(--faint); }
.grid th.rn input, .grid td.rn input { margin: 0 6px 0 0; vertical-align: middle; }
.grid tr.picked td { background: var(--danger-soft); }
.edit-area { width: 100%; min-height: 220px; resize: vertical; padding: 8px 10px; border: 1px solid var(--accent); border-radius: 6px; background: var(--bg); font: 12px/1.5 var(--mono); outline: none; }
.grid .filters input { width: 100%; min-width: 70px; height: 22px; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); font: 11px var(--mono); outline: none; }
.grid .filters input:focus { border-color: var(--accent); }
.grid .filters input.on { border-color: var(--accent); background: var(--accent-soft); }
.empty { padding: 40px 20px; text-align: center; color: var(--faint); }
.gridwrap .busy { position: absolute; top: 8px; right: 12px; color: var(--muted); font-size: 12px; }

/* ---- the value drawer ---- */
.drawer { width: 340px; flex: none; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.drawer-head { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.drawer-head .t { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-meta { padding: 6px 12px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; }
.drawer-body { flex: 1; overflow: auto; padding: 10px 12px; }
.drawer-body pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 12px/1.5 var(--mono); }
.drawer-body .nullv { color: var(--null); font-style: italic; }
.drawer-body .note { margin-top: 8px; color: var(--warn); font-size: 12px; }
.drawer-foot { padding: 8px 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; }

/* ---- structure ---- */
.scroll { flex: 1; overflow: auto; padding: 16px 20px 30px; }
.scroll h3 { margin: 22px 0 8px; font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.scroll h3:first-child { margin-top: 0; }
table.info { border-collapse: collapse; font-size: 12.5px; width: 100%; max-width: 1100px; }
.info th, .info td { text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.info th { background: var(--panel2); font-weight: 600; font-size: 12px; position: sticky; top: 0; }
.info td.mono, .info .mono { font-family: var(--mono); font-size: 12px; }
.tag { display: inline-block; padding: 0 7px; border-radius: 9px; font-size: 11px; font-weight: 600; background: var(--panel3); color: var(--muted); margin-right: 4px; }
.tag.pk { background: var(--warn-soft); color: var(--warn); }
.tag.uq { background: var(--accent-soft); color: var(--accent); }
.tag.nn { background: var(--ok-soft); color: var(--ok); }
.link { color: var(--accent); cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
pre.sql { margin: 0; padding: 12px 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font: 12px/1.55 var(--mono); overflow: auto; white-space: pre; max-width: 1100px; }
.sqlcard { position: relative; max-width: 1100px; }
.sqlcard .btn { position: absolute; top: 6px; right: 6px; }
.kw { color: var(--accent); font-weight: 600; }
.str { color: var(--ok); }
.cmt { color: var(--faint); font-style: italic; }
.numlit { color: var(--num); }

/* ---- SQL console ---- */
.console { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.editor { flex: none; display: flex; flex-direction: column; border-bottom: 1px solid var(--line); }
.editor textarea { width: 100%; height: 150px; min-height: 60px; resize: vertical; padding: 10px 14px; border: 0; background: var(--bg); font: 13px/1.5 var(--mono); outline: none; tab-size: 2; white-space: pre; }
.editor-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--panel); }
.tpl-bar { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.tpl-bar .hint { color: var(--faint); font-size: 12px; margin-right: 4px; }
.editor-bar .hint { color: var(--faint); font-size: 12px; }
.results { flex: 1; overflow: auto; padding: 12px 14px 24px; }
.res { margin-bottom: 18px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.res-head { display: flex; gap: 12px; align-items: center; padding: 6px 12px; background: var(--panel2); border-bottom: 1px solid var(--line); font-size: 12px; }
.res-head .q { flex: 1; min-width: 0; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.res-head .st { color: var(--muted); white-space: nowrap; }
.res-body { max-height: 420px; overflow: auto; }
.res-ok { padding: 10px 14px; color: var(--ok); }
.res.err { border-color: var(--danger); }
.res.err .res-head { background: var(--danger-soft); }
.res-err { padding: 10px 14px; color: var(--danger); font-family: var(--mono); white-space: pre-wrap; }
.res-note { padding: 6px 12px; background: var(--warn-soft); color: var(--warn); font-size: 12px; }
.history { position: absolute; z-index: 20; min-width: 420px; max-width: 70vw; max-height: 320px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.history div { padding: 6px 12px; font: 12px var(--mono); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history div:hover { background: var(--accent-soft); }
.history .none { color: var(--faint); cursor: default; }

/* ---- dialogs and toasts ---- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 100; }
.dialog { width: min(460px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 18px 20px; }
.dialog h2 { margin: 0 0 8px; font-size: 16px; color: var(--strong); }
.dialog-body { color: var(--muted); margin-bottom: 16px; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.dialog-actions .hint { margin-right: auto; color: var(--faint); font-size: 12px; }
.dialog-option { display: flex; align-items: center; gap: 4px; margin: -4px 0 16px; color: var(--text); cursor: pointer; }
.dialog.wide { width: min(700px, 94vw); max-height: 88vh; display: flex; flex-direction: column; }
.dialog .mono { font-family: var(--mono); }
.form { overflow: auto; margin: 0 -6px 12px; padding: 0 6px; flex: 1; min-height: 0; }
.frow { display: grid; grid-template-columns: minmax(130px, 200px) auto 1fr; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); }
.frow:last-child { border-bottom: 0; }
.flabel { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; min-width: 0; }
.flabel .nm { font-weight: 600; word-break: break-word; }
.flabel .ty { color: var(--faint); font-size: 11px; }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; margin-left: -1px; padding: 0 9px; }
.seg .btn:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg .btn:last-child { border-radius: 0 6px 6px 0; }
.seg .btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); position: relative; z-index: 1; }
.frow input[type="text"] { height: 26px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); outline: none; min-width: 0; font: 12px var(--mono); }
.frow input[type="text"]:focus { border-color: var(--accent); }
.frow input[type="text"].off { opacity: .5; }
.ferr { margin: 0 0 10px; padding: 8px 12px; border-radius: 6px; background: var(--danger-soft); color: var(--danger); font-family: var(--mono); font-size: 12px; white-space: pre-wrap; }
.tag.pk, .tag.nn { margin-left: 2px; }
.dialog-input { width: 100%; height: 30px; margin: 0 0 16px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); outline: none; font: 13px var(--mono); }
.dialog-input:focus { border-color: var(--accent); }
.dialog.huge { width: min(1100px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.te-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 0 0 10px; }
.te-head input[type="text"] { height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); outline: none; font: 13px var(--mono); }
.te-head .name { width: 260px; }
.te-head label { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.te-scroll { overflow: auto; flex: 1; min-height: 120px; margin: 0 -6px; padding: 0 6px; }
table.te { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.te th { position: sticky; top: 0; background: var(--panel2); text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); padding: 6px 6px; z-index: 1; }
.te td { padding: 3px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.te td input[type="text"], .te td select { height: 26px; padding: 0 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); outline: none; font: 12px var(--mono); min-width: 0; width: 100%; }
.te td input[type="text"]:focus, .te td select:focus { border-color: var(--accent); }
.te td.c { text-align: center; }
.te .mv { display: inline-flex; gap: 2px; }
.te .mv button, .te .x { width: 22px; height: 22px; padding: 0; border: 1px solid transparent; background: none; border-radius: 4px; cursor: pointer; color: var(--muted); }
.te .mv button:hover:not(:disabled), .te .x:hover { background: var(--panel3); color: var(--strong); }
.te .mv button:disabled { opacity: .25; cursor: default; }
.te tr.newrow td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.te .w-name { width: 17%; } .te .w-type { width: 14%; } .te .w-def { width: 16%; } .te .w-ref { width: 22%; }
.te-ref { display: flex; gap: 4px; }
.te-plan { margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); }
.te-plan h4 { margin: 0; padding: 6px 12px; font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); background: var(--panel2); border-bottom: 1px solid var(--line); }
.te-plan pre { margin: 0; padding: 10px 12px; max-height: 190px; overflow: auto; font: 12px/1.5 var(--mono); white-space: pre-wrap; }
.te-notes { padding: 6px 12px; background: var(--warn-soft); color: var(--warn); font-size: 12px; }
.te-notes div + div { margin-top: 3px; }
.te-err { padding: 8px 12px; background: var(--danger-soft); color: var(--danger); font: 12px var(--mono); white-space: pre-wrap; }
.te-warn { margin: 0 0 10px; padding: 8px 12px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; }
.side-new { margin: 8px 10px 0; width: calc(100% - 20px); justify-content: center; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 14px; }
.tools .hint { color: var(--faint); font-size: 12px; }
.info .btn.small { height: 22px; }
.bar-track { height: 8px; border-radius: 4px; background: var(--panel3); overflow: hidden; margin: 0 0 16px; }
.bar-fill { height: 100%; width: 6%; background: var(--accent); transition: width .2s; }
.checklist { max-height: 160px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; margin: 4px 0 8px; background: var(--bg); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.preview { margin: 6px 0 10px; }
.preview-scroll { max-height: 170px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.preview-scroll table.info { max-width: none; }
.cols { border: 1px solid var(--line); border-radius: 6px; max-height: 200px; overflow: auto; margin: 4px 0 10px; }
.colrow { display: grid; grid-template-columns: auto 1fr 130px; gap: 8px; align-items: center; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.colrow:last-child { border-bottom: 0; }
.colrow input[type="text"], .colrow select, .dialog select { height: 26px; padding: 0 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); outline: none; font: 12px var(--mono); min-width: 0; }
.dialog .blk-field { display: block; margin: 0 0 10px; }
.dialog .blk-label { display: block; font-weight: 600; margin-bottom: 3px; }
.dialog .blk-field select { width: 100%; }
.dialog .blk-note { display: block; color: var(--muted); font-size: 12px; margin: 2px 0; }
.result-lines div { padding: 2px 0; word-break: break-all; }
.res-head .btn { flex: none; }
.api { max-width: 1100px; }
.api-head { display: flex; gap: 20px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.api-head h2 { margin: 0 0 4px; font-size: 20px; color: var(--strong); }
.api-head p { margin: 0; color: var(--muted); max-width: 640px; }
.api-head .tools { margin: 0; }
.api-status { margin: 0 0 14px; padding: 8px 12px; border-radius: 8px; font-size: 12.5px; }
.api-status.ok { background: var(--ok-soft); color: var(--ok); }
.api-status.bad { background: var(--danger-soft); color: var(--danger); font-family: var(--mono); white-space: pre-wrap; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 12px; margin: 0 0 16px; }
.card h3 { margin: 0 0 10px !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.af { display: block; margin: 0 0 10px; }
.af.check { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 4px 0 8px; cursor: pointer; }
.afl { display: block; font-weight: 600; font-size: 12px; margin-bottom: 3px; color: var(--text); }
.afh { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.afh.warn { color: var(--warn); background: var(--warn-soft); padding: 6px 10px; border-radius: 6px; }
.af.check .afh { flex-basis: 100%; margin: 0 0 0 24px; }
.af input[type="text"], .af input[type="number"], .af textarea, .af select { height: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); outline: none; font: 13px var(--sans); min-width: 0; width: 100%; }
.af textarea { height: auto; padding: 6px 8px; resize: vertical; }
.af input.mono, .af textarea.mono { font: 12.5px var(--mono); }
.af input:focus, .af textarea:focus, .af select:focus { border-color: var(--accent); }
.keyrow { display: flex; gap: 6px; align-items: center; }
.keyrow .keyval { flex: 1; }
.tcard { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; background: var(--panel); }
.tcard.off { opacity: .55; }
.tc-head { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; padding: 8px 12px; }
.tc-name { display: flex; gap: 8px; align-items: center; min-width: 170px; cursor: pointer; }
.tc-path { display: flex; align-items: center; gap: 2px; }
.tc-path .pre { color: var(--faint); }
.pathin { height: 26px; width: 150px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); outline: none; font: 12.5px var(--mono); }
.pathin:focus { border-color: var(--accent); }
.tc-ops { display: flex; gap: 12px; flex-wrap: wrap; margin-left: auto; }
.op { display: inline-flex; align-items: center; gap: 2px; cursor: pointer; }
.op.dis { opacity: .4; cursor: default; }
.tc-body { padding: 0 12px 10px; }
.tc-body:empty { padding: 0; }
.cols-table { max-width: none; margin-top: 6px; }
.cols-table td.c, .cols-table th:nth-child(n+4) { text-align: center; }
.toasts { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 120; pointer-events: none; } /* at the top, so the buttons at the bottom of the value panel stay free */
.toast { padding: 9px 14px; border-radius: 8px; background: var(--strong); color: var(--bg); box-shadow: var(--shadow); max-width: 420px; transition: opacity .25s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.out { opacity: 0; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: var(--panel3); border-radius: 6px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: padding-box; border: 3px solid transparent; }
::-webkit-scrollbar-corner { background: transparent; }

/* ---- the Articles tab ---- */
.art { flex: 1; min-height: 0; display: flex; }
.art-side { width: 270px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); }
.art-search { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); }
.art-search input { flex: 1; min-width: 0; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); outline: none; }
.art-search input:focus { border-color: var(--accent); }
.art-items { flex: 1; overflow: auto; }
.art-item { padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.art-item:hover { background: var(--panel2); }
.art-item.active { background: var(--accent-soft); }
.art-item .t { font-weight: 600; color: var(--strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.art-item .m { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.art-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.art-note { padding: 8px 16px; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line); }
.art-form { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; }
.art-row { display: flex; gap: 8px; }
.art-row input { flex: 1; min-width: 0; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); outline: none; }
.art-row input:focus { border-color: var(--accent); }
.art-row input[name="title"] { flex: 2; font-weight: 600; }
.art-bar { display: flex; align-items: center; gap: 8px; }
.art-tools { display: flex; gap: 4px; }
.art-tools .btn { min-width: 28px; justify-content: center; padding: 0 6px; }
.art-state { color: var(--muted); font-size: 12px; }
.art-state.dirty { color: var(--warn); font-weight: 600; }
.art-edit { flex: 1; min-height: 0; display: flex; gap: 10px; }
.art-md { flex: 1; min-width: 0; resize: none; padding: 10px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font: 13px/1.55 var(--mono); outline: none; tab-size: 2; }
.art-md:focus { border-color: var(--accent); }
.art-preview { flex: 1; min-width: 0; overflow: auto; padding: 10px 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.art-edit[data-view="editor"] .art-preview, .art-edit[data-view="preview"] .art-md { display: none; }
.md { line-height: 1.6; overflow-wrap: anywhere; }
.md h1, .md h2, .md h3, .md h4 { color: var(--strong); line-height: 1.25; margin: 1.1em 0 .4em; }
.md h1 { font-size: 1.7em; } .md h2 { font-size: 1.4em; } .md h3 { font-size: 1.15em; }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md table { margin: .6em 0; }
.md a { color: var(--accent); }
.md img { max-width: 100%; height: auto; }
.md code { font: 12px var(--mono); background: var(--panel2); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--panel2); padding: 10px 12px; border-radius: 6px; overflow: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--line); margin-left: 0; padding-left: 12px; color: var(--muted); }
.md table { border-collapse: collapse; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; }
