:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --side: #111827;
  --side-text: #c9d1e0;
  --side-active: #ffffff;
  --text: #18202e;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #2f5bea;
  --accent-soft: #e8eefe;
  --ok: #12805c;
  --ok-soft: #e3f5ee;
  --warn: #b25e09;
  --warn-soft: #fdf1e1;
  --bad: #c4321c;
  --bad-soft: #fde9e6;
  --bar: #e9ecf2;
  --code: #f2f4f7;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --panel: #161b22;
    --side: #0a0d12;
    --side-text: #9aa4b5;
    --text: #e6e9ef;
    --muted: #8b95a7;
    --line: #2a313c;
    --accent: #6d8dff;
    --accent-soft: #1d2747;
    --ok: #3ccf91;
    --ok-soft: #12301f;
    --warn: #f0a24a;
    --warn-soft: #36260f;
    --bad: #ff7a66;
    --bad-soft: #3a1712;
    --bar: #252c37;
    --code: #1c222b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 13px; margin: 16px 0 8px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--code); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; margin: 6px 0 0; }
.hint { color: var(--muted); font-size: 12.5px; }

button {
  font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 7px; padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button.small { padding: 2px 8px; font-size: 12.5px; }
button.link { border: 0; background: none; color: inherit; padding: 0; text-decoration: underline; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input:disabled { background: var(--code); color: var(--muted); }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 8px;
}
.login-card h1 { margin-top: 8px; }
.login-card label { margin-top: 8px; font-weight: 600; }
.login-card button { margin-top: 8px; padding: 9px; }

/* layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100%; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 16px 10px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { color: var(--side-text); text-decoration: none; padding: 8px 10px; border-radius: 7px; }
nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
nav a.active { background: rgba(255,255,255,.1); color: var(--side-active); font-weight: 600; }
.side-foot { margin-top: auto; padding: 10px; font-size: 12.5px; display: flex; flex-direction: column; gap: 8px; }
.node-badge { color: #fff; }
.node-badge small { display: block; color: var(--side-text); }
main { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .muted { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; min-width: 0; }
.card + .card { margin-top: 16px; }
.grid .card + .card { margin-top: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.stat { font-size: 26px; font-weight: 650; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.stats .label { color: var(--muted); font-size: 12.5px; }

.meter { margin: 10px 0 14px; }
.meter-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.meter-bar { height: 9px; border-radius: 5px; background: var(--bar); overflow: hidden; }
.meter-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 5px; transition: width .4s; }
.meter-bar.warn > span { background: var(--warn); }
.meter-bar.bad > span { background: var(--bad); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--code); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.banner { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--accent-soft); color: var(--accent); }

/* tables */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--panel); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.sql { font-family: var(--mono); font-size: 12px; max-width: 520px; white-space: pre-wrap; overflow-wrap: anywhere; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover, tbody tr.selected { background: var(--accent-soft); }
.empty { padding: 24px; text-align: center; color: var(--muted); }
td.null { color: var(--muted); font-style: italic; }

/* tables page */
.split { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 16px; align-items: start; }

/* sql console */
.errbox { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 14px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; }
.okbox { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: 10px 14px; }
.bad-text { color: var(--bad); }
main:has(.qwin) { padding-bottom: 20px; }
.qwin { display: flex; flex-direction: column; height: calc(100vh - 44px); min-height: 520px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.qtabs { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--bg); overflow-x: auto; flex: none; }
.qtab { display: inline-flex; align-items: center; gap: 7px; padding: 4px 6px 4px 10px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; font-size: 13px; color: var(--muted); user-select: none; }
.qtab:hover { background: var(--code); }
.qtab.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--text); }
.qtab-title { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.qtab-close { border: 0; background: none; padding: 0 4px; color: var(--muted); font-size: 15px; line-height: 1; }
.qtab-close:hover { color: var(--bad); }
.qtab-add { border: 0; background: none; font-size: 18px; line-height: 1; padding: 2px 8px; color: var(--muted); }
.qtab-add:hover { color: var(--text); background: var(--code); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.q-toolbar { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; flex: none; }
.q-toolbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.q-toolbar select { padding: 2px 6px; font-size: 12.5px; }
.q-field { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); }
.q-status { display: inline-flex; align-items: center; gap: 6px; min-width: 90px; }
.spacer { flex: 1; }
.spin { width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.q-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.q-editor { flex: 0 0 42%; min-height: 60px; display: flex; flex-direction: column; position: relative; }
.q-divider { flex: none; height: 7px; cursor: row-resize; background: var(--bg); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); position: relative; touch-action: none; }
.q-divider::after { content: ""; position: absolute; left: 50%; top: 2px; width: 36px; height: 1px; margin-left: -18px; background: var(--muted); opacity: .5; box-shadow: 0 2px 0 var(--muted); }
.q-results { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

/* editor: a transparent textarea over its highlighted text */
:root { --sx-kw: #0a52c7; --sx-str: #1a7f37; --sx-num: #b3560d; --sx-fn: #7b3fce; --sx-type: #0b7d8a; --sx-com: #6e7781; --sx-q: #953800; --ed-line: 20px; }
@media (prefers-color-scheme: dark) { :root { --sx-kw: #79c0ff; --sx-str: #7ee787; --sx-num: #ffa657; --sx-fn: #d2a8ff; --sx-type: #56d4c4; --sx-com: #8b949e; --sx-q: #ffa198; } }
.ed { flex: 1; display: flex; min-height: 0; font-family: var(--mono); font-size: 13px; line-height: var(--ed-line); }
.ed-gutter { flex: none; min-width: 44px; padding: 10px 8px 40px 6px; text-align: right; color: var(--muted); opacity: .7; overflow: hidden; user-select: none; background: var(--bg); border-right: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.ed-gutter .cur { color: var(--text); opacity: 1; font-weight: 600; }
.ed-main { position: relative; flex: 1; min-width: 0; }
.ed-hl, .ed-input { position: absolute; inset: 0; margin: 0; padding: 10px 12px 40px; font: inherit; line-height: inherit; tab-size: 2; white-space: pre; border: 0; border-radius: 0; letter-spacing: 0; }
.ed-hl { overflow: hidden; color: var(--text); pointer-events: none; }
.ed-input { resize: none; background: transparent; color: transparent; caret-color: var(--accent); overflow: auto; outline: none; }
.ed-input:focus { outline: none; }
.ed-input::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); color: transparent; }
.ed-input::placeholder { color: var(--muted); }
.ed-hl .k { color: var(--sx-kw); font-weight: 600; }
.ed-hl .t { color: var(--sx-type); }
.ed-hl .f { color: var(--sx-fn); }
.ed-hl .s { color: var(--sx-str); }
.ed-hl .q { color: var(--sx-q); }
.ed-hl .n { color: var(--sx-num); }
.ed-hl .c { color: var(--sx-com); font-style: italic; }
.ed-hl .o { color: var(--muted); }
.ed-hl mark { background: color-mix(in srgb, #f5c400 35%, transparent); color: inherit; border-radius: 2px; }
.ed-hl mark.cur { background: color-mix(in srgb, #f59e00 70%, transparent); outline: 1px solid #d48300; }
.find-panel { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--bg); font-size: 12.5px; flex: none; }
.find-panel input { padding: 3px 8px; font-size: 12.5px; width: 200px; }
.find-panel .fp-count { min-width: 64px; }
button.toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* results */
.rtabs { display: flex; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
.rtab { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; background: none; font-size: 12.5px; padding: 3px 10px; border-radius: 7px; color: var(--muted); white-space: nowrap; }
.rtab:hover { background: var(--code); border-color: transparent; }
.rtab.active { background: var(--accent-soft); color: var(--text); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.rtab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.res-pad { padding: 10px; overflow: auto; flex: 1; min-height: 0; }
.res-pad > * + * { margin-top: 10px; }
.res-sql { font-family: var(--mono); font-size: 12px; background: var(--code); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; margin: 0; }
.res-grid { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px 10px; gap: 6px; }
.res-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.res-bar select { padding: 2px 6px; font-size: 12.5px; }
.res-table { flex: 1; min-height: 0; }
table.rgrid td { font-family: var(--mono); font-size: 12.5px; white-space: pre; max-width: 420px; overflow: hidden; text-overflow: ellipsis; padding: 4px 10px; }
table.rgrid th { padding: 5px 10px; vertical-align: bottom; }
table.rgrid th.sortable { cursor: pointer; user-select: none; }
table.rgrid th.sortable:hover { color: var(--text); }
table.rgrid th .type { display: block; font-weight: 400; font-size: 10.5px; opacity: .75; font-family: var(--mono); }
table.rgrid .idx { color: var(--muted); text-align: right; width: 1%; background: var(--bg); font-variant-numeric: tabular-nums; }
table.rgrid th.idx { z-index: 2; }
table.rgrid .filler { width: 100%; padding: 0; }
table.rgrid tbody tr:hover td:not(.idx) { background: var(--accent-soft); }
table.rgrid td.sql { white-space: nowrap; max-width: 560px; font-size: 12px; }
/* query plan graph */
.pg-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pg { position: relative; flex: 1; min-height: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background-color: var(--bg); background-image: radial-gradient(circle, color-mix(in srgb, var(--muted) 35%, transparent) 1px, transparent 1px); background-size: 16px 16px; }
.pg-canvas { position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none; }
.pg-canvas.drag { cursor: grabbing; }
.pg-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.pg-edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.pg-edges path { fill: none; stroke: var(--muted); opacity: .7; }
.pg-edges .pg-arrow { fill: var(--muted); stroke: none; }
.pg-edge-label { font-size: 11px; fill: var(--muted); font-family: var(--mono); }
.pg-node { position: absolute; background: var(--panel); border: 1.5px solid; border-radius: 10px; padding: 8px 10px 7px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.08); overflow: hidden; }
.pg-node:hover { box-shadow: 0 3px 12px rgba(0,0,0,.15); }
.pg-node.sel { border-width: 2px; box-shadow: 0 0 0 4px var(--pg-c); }
.pg-row1 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pg-badge { font-size: 11.5px; font-weight: 650; padding: 1px 7px; border-radius: 6px; border: 1px solid; white-space: nowrap; }
.pg-obj { font-family: var(--mono); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.pg-info { font-size: 11px; color: var(--muted); line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.pg-spacer { flex: 1; }
.pg-row3 { display: flex; justify-content: space-between; font-size: 11.5px; font-family: var(--mono); }
.pg-rows { color: var(--text); font-weight: 600; }
.pg-bar { height: 4px; border-radius: 2px; background: var(--bar); overflow: hidden; }
.pg-bar > span { display: block; height: 100%; border-radius: 2px; }
.pg-controls { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 4px; }
.pg-controls button { background: var(--panel); min-width: 30px; }
.pg-detail { position: absolute; top: 10px; right: 10px; bottom: 10px; width: min(340px, 60%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); display: flex; flex-direction: column; overflow: hidden; }
.pg-dhead { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.pg-dtitle { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 14px; }
.pg-dtext { margin-top: 6px; font-family: var(--mono); font-size: 11.5px; color: var(--text); max-height: 160px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.pg-dbody { padding: 8px 12px 12px; overflow: auto; font-size: 12.5px; }
.pg-dgroup { margin: 10px 0 4px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pg-drow { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.pg-drow span:first-child { color: var(--muted); }
.pg-drow span:last-child { font-family: var(--mono); text-align: right; overflow-wrap: anywhere; }
.pg-text { flex: 1; margin: 0; overflow: auto; font-family: var(--mono); font-size: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.pg-bar-top .sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 7px 0 0 7px; margin-left: 0; }
.seg button:last-child { border-radius: 0 7px 7px 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); position: relative; }

select.as-user { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); font-weight: 600; }

/* users and roles */
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 1px 4px 1px 9px; margin: 1px 4px 1px 0; border-radius: 999px; background: var(--code); font-size: 12.5px; }
.chip-x { border: 0; background: none; padding: 0 4px; color: var(--muted); font-size: 14px; line-height: 1; }
.chip-x:hover { color: var(--bad); }
.sec-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.sec-form select[multiple] { min-width: 120px; padding: 2px; }
.sec-form .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* query profiles */
.prof-graph { height: 560px; display: flex; flex-direction: column; margin-top: 10px; }
.pg-rows.pg-misest { color: var(--warn); }
.prof-link { margin-left: auto; }

/* sheets (history, library) */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; padding: 24px; z-index: 20; }
.sheet { width: min(560px, 100%); max-height: 86vh; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 48px rgba(0,0,0,.3); }
.sheet.wide { width: min(900px, 100%); }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sheet-title { flex: 1; font-weight: 650; font-size: 15px; }
.sheet-body { flex: 1; overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.sheet-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
.hist-list { display: flex; flex-direction: column; gap: 10px; }
.hist-item { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.hist-meta { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--bg); font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.hist-meta strong { color: var(--text); }
.hist-sql { margin: 0; padding: 8px 12px; font-family: var(--mono); font-size: 12px; max-height: 140px; overflow: auto; white-space: pre; cursor: pointer; }
.hist-sql:hover { background: var(--accent-soft); }

/* config */
.cfg td input { width: 100%; min-width: 160px; }
.cfg td input[type=checkbox], .cfg td input[type=radio] { width: auto; min-width: 0; }
.cfg td:first-child { white-space: nowrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
.tabs button.active { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }
.file-editor { width: 100%; min-height: 420px; font-family: var(--mono); font-size: 12.5px; padding: 12px; border-radius: 10px; }
.check { margin-top: 10px; }

/* log */
.log { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; height: calc(100vh - 190px); min-height: 300px; overflow: auto; font-family: var(--mono); font-size: 12px; padding: 8px 0; }
.log div { padding: 1px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.log .t { color: var(--muted); }
.log .ERROR { color: var(--bad); }
.log .WARN { color: var(--warn); }
.log .DEBUG, .log .TRACE { color: var(--muted); }

/* cluster */
.buckets { display: flex; flex-wrap: wrap; gap: 3px; margin: 12px 0 4px; }
.bucket { width: 12px; height: 12px; border-radius: 3px; background: var(--bar); }
.bucket.ok { background: var(--ok); }
.bucket.accent { background: var(--accent); }
.bucket.warn { background: var(--warn); }
.bucket.bad { background: var(--bad); }
.node-card h2 .actions { gap: 6px; }
.node-card > .actions { margin-top: 8px; }
/* nodes */
.node-card h2 { display: flex; justify-content: space-between; align-items: center; }
.node-card.this { border-color: var(--accent); }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--side); color: #fff; padding: 10px 16px; border-radius: 9px; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: 420px; z-index: 10; }
.toast.bad { background: var(--bad); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 16px; }
  .brand { padding: 0 8px 0 0; }
  nav { flex-direction: row; flex-wrap: wrap; }
  nav a { padding: 6px 8px; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; padding: 0; }
  main { padding: 16px; }
  .split { grid-template-columns: 1fr; }
  .qwin { height: calc(100vh - 120px); }
}

.work { margin: 10px 0 14px; }
.spark { display: flex; align-items: flex-end; gap: 1px; height: 36px; background: var(--bar); border-radius: 5px; padding: 2px; overflow: hidden; }
.spark > span { flex: 1; background: var(--accent); border-radius: 1px; min-width: 1px; transition: height .3s; }


/* ---------- backup & restore ---------- */
.form-grid { display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 8px 14px; align-items: center; max-width: 820px; }
.form-grid > label:first-child, .form-grid > label { color: var(--muted); }
.form-grid .hint { margin: 2px 0 0; }
label.check { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--text); }
.ok-text { color: var(--ok); }
.job-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.job-list li { line-height: 1.5; overflow-wrap: anywhere; }
.chains { display: grid; gap: 12px; margin: 10px 0; }
.chain { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.chain.has-selection { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.chain-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.chain-size { margin-left: auto; font-size: 12.5px; }
.timeline { display: flex; align-items: center; overflow-x: auto; padding: 4px 2px 8px; }
.timeline .link { flex: 0 0 28px; height: 2px; background: var(--line); }
.timeline .link.broken { background: repeating-linear-gradient(90deg, var(--bad) 0 4px, transparent 4px 8px); }
.point { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 8px; border-radius: 9px; border: 1px solid transparent; background: none; min-width: 96px; cursor: pointer; }
.point:hover:not(:disabled) { border-color: var(--line); }
.point .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; border: 2px solid var(--accent); color: var(--accent); background: var(--panel); }
.point.full .dot { background: var(--accent); color: #fff; }
.point .when { font-size: 12px; white-space: nowrap; }
.point .size { font-size: 11.5px; color: var(--muted); }
.point.broken { cursor: not-allowed; opacity: .55; }
.point.broken .dot { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.point.needed { background: var(--accent-soft); }
.point.chosen { border-color: var(--accent); }
.point.chosen .dot { box-shadow: 0 0 0 3px var(--accent-soft); }
.restore-point { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 4px; }
.restore-point code { font-size: 12px; }
.schema-picks { display: grid; gap: 8px; margin: 10px 0; }
.schema-pick .picks { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 0 0 24px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
