/* Database editor styles: the tree (left), the tabs and their views (centre), the cell (right), the grid. */
#main { display: flex; flex-direction: row; flex: 1; min-width: 0; min-height: 0; background: var(--panel); }
#db-left, #db-side { min-height: 0; }
.db-pane { display: flex; flex-direction: column; min-height: 0; }
.db-pane.grow { flex: 1; }
#db-tree, #db-cell { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#db-centre { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
#db-view { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#main .material-symbols-outlined { font-size: var(--ic); }
.grow { flex: 1; }
.db-mute { color: var(--muted); }
.db-p { margin: 8px 14px; font-size: 13px; }

/* the tree */
.db-tree-list { flex: 1; min-height: 0; overflow: auto; padding: 6px 4px 12px; font-size: 13px; }
.db-tree-db, .db-tree-i { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: var(--radius-s); cursor: pointer; white-space: nowrap; }
/* the database: a little bigger, what's in it under its name; its tables indented under it, on a line from it */
.db-tree-db { align-items: flex-start; padding: 6px 8px; margin-bottom: 2px; }
.db-tree-db > .material-symbols-outlined { color: var(--prog); font-size: 20px; margin-top: 1px; }
.db-tree-db .db-tree-n { font-size: 14.5px; font-weight: 600; }
.db-tree-kids { margin-left: 17px; padding-left: 6px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 1px; }
/* a table: its name and rows, and under them what it's made of */
.db-tree-i { align-items: flex-start; padding: 5px 8px; }
.db-tree-i > .material-symbols-outlined { color: var(--prog); font-size: 17px; margin-top: 1px; }
.db-tree-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.db-tree-l1 { display: flex; align-items: baseline; min-width: 0; }
.db-tree-n { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.db-tree-s { margin-left: auto; color: var(--muted); font-size: 11.5px; font-weight: 400; font-variant-numeric: tabular-nums; padding-left: 8px; flex: none; }
.db-tree-m { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.db-tree-db:hover, .db-tree-i:hover { background: var(--line-soft); }
.db-tree-db.on, .db-tree-i.on { background: var(--prog-soft); color: var(--prog-strong); }
.db-tree-i.on .db-tree-n { font-weight: 600; }
.db-tree-none { padding: 6px 8px; color: var(--muted); }
.db-tree-none .link-btn { padding: 0; font-size: inherit; }

/* bars and forms */
/* a view's own bar (Structure, SQL, Tables, Diagram …): its buttons look like the top bar's (shared/chrome.css .cmd-btn) –
   flat, an icon and a label, a soft background on hover; the view's main one has its icon in the program's colour */
.db-bar { flex: none; display: flex; align-items: center; gap: 2px; min-height: 41px; padding: 4px 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.db-bar > .db-mute, .db-bar > .db-count, .db-bar > .db-chips, .db-bar > .db-ro, .db-bar > .db-search-what { margin: 0 6px; }
.db-bar .btn { height: 32px; padding: 0 8px 0 6px; gap: 6px; border: 0; border-radius: var(--radius); background: transparent; color: var(--text); font-size: 12.5px; font-weight: 400; }
.db-bar .btn:hover, .db-bar .btn.primary:hover { background: var(--hover); border-color: transparent; }
.db-bar .btn .material-symbols-outlined { font-size: 20px; }
.db-bar .btn.primary { background: transparent; border-color: transparent; color: var(--text); font-weight: 500; }
.db-bar .btn.primary .material-symbols-outlined { color: var(--prog); }
.db-bar .btn:focus-visible { outline: 2px solid var(--prog); outline-offset: 1px; }
.db-bar .btn[disabled] { opacity: .35; cursor: default; background: transparent; }
.db-bar .btn.on { background: var(--prog-soft); color: var(--prog-strong); }
.db-bar .btn.on .material-symbols-outlined { color: var(--prog-strong); }
.db-count { color: var(--text-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
/* the conditions (Advanced, db/find.js) as chips over the rows */
.db-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.db-chip { display: inline-flex; align-items: center; max-width: 100%; border: 1px solid var(--prog); border-radius: var(--radius-pill); background: var(--prog-soft); color: var(--prog-strong); font-size: 12.5px; }
.db-chip-t { border: 0; background: none; color: inherit; font: inherit; padding: 3px 4px 3px 10px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.db-chip-x { border: 0; background: none; color: inherit; padding: 0 6px 0 2px; height: 22px; display: inline-flex; align-items: center; cursor: pointer; border-radius: 0 var(--radius-pill) var(--radius-pill) 0; }
.db-chip-x .material-symbols-outlined { font-size: 15px; }
.db-chip-x:hover, .db-chip-t:hover { color: var(--text); }
/* Advanced: conditions per column */
.db-adv { display: flex; flex-direction: column; gap: 12px; }
.db-adv-match { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.db-adv-match .inp { width: auto; height: 30px; }
.db-adv-rows { display: flex; flex-direction: column; gap: 6px; }
.db-adv-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.db-adv-row .inp { height: 32px; min-width: 0; width: 100%; }
.db-adv-row input.inp[hidden] { display: block !important; visibility: hidden; }
.db-adv-add { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; }
.db-adv-all { align-self: flex-start; padding-left: 0; }
.db-search-what { font-size: 13px; font-weight: 600; }
.db-topsearch { flex-basis: 260px; }
@media (max-width: 560px) { .db-adv-row { grid-template-columns: 1fr 1fr auto; } .db-adv-row input.inp { grid-column: 1 / 3; } }
.db-ro { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12.5px; }
.db-form { display: flex; flex-direction: column; gap: 10px; }
.db-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.db-h { margin: 18px 14px 8px; font-size: 14px; display: flex; gap: 8px; align-items: baseline; }
.db-h span { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.db-sql { margin: 0; padding: 10px 12px; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius); font: 12.5px/1.5 var(--font-mono); white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; }
.db-sql.bad { color: var(--danger); }
.db-structure .db-sql.db-create, .db-trig .db-sql { margin: 0 14px 12px; }
.db-structure, .db-tables, .db-ops, .db-searchtab { overflow: auto; flex: 1; min-height: 0; padding-bottom: 24px; }

/* tables (HTML) */
.db-tbl { margin: 0 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.db-tbl table { width: 100%; border-collapse: collapse; font-size: 13px; }
.db-tbl th, .db-tbl td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.db-tbl tr:last-child td, .db-tbl tr:last-child th { border-bottom: 0; }
.db-tbl thead th { color: var(--text-2); font-weight: 600; font-size: 12px; background: var(--panel); }
.db-tbl tbody th { color: var(--text-2); font-weight: 500; width: 200px; }
.db-tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.db-tbl code { font-size: 12px; }
.db-more { white-space: normal !important; color: var(--text-2); font-size: 12.5px; max-width: 420px; }
.db-acts { text-align: right; white-space: nowrap; }
.db-acts .icon-btn { width: 28px; height: 28px; }
.db-keyi { color: var(--warn); font-size: 16px; vertical-align: -3px; }
.db-tlink { display: inline-flex; align-items: center; gap: 6px; color: var(--text); text-decoration: none; font-weight: 600; }
.db-tlink:hover { color: var(--prog); }
.db-tlink .material-symbols-outlined { color: var(--prog); font-size: 17px; }
.db-trig { margin: 0 0 4px; }
.db-trig > div { display: flex; align-items: center; gap: 6px; margin: 0 14px 4px; }

/* the grid */
.db-browse, .db-sqltab { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.db-gridbox { flex: 1; min-height: 0; position: relative; }
textarea.dbg-edit { font: 12.5px/1.45 var(--font-mono); }
/* transposed (DbGrid.setTransposed): the rows across, each column's name on the left */

/* the progress panel floats below the tabs */
#db-centre > .op-stack.in-host { top: 50px; }

/* editing together: who has which table open */
.db-peers { display: inline-flex; gap: 2px; margin-left: 6px; }
/* content: on the person's own colour */
.db-peer { width: 16px; height: 16px; border-radius: 50%; color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

/* the diagram */
.db-diagram { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.db-dia-box { flex: 1; min-height: 0; position: relative; background: var(--desk); overflow: hidden; cursor: grab; }
.db-dia-box:active { cursor: grabbing; }
.db-dia-svg { width: 100%; height: 100%; display: block; user-select: none; }
.db-dia-t { cursor: move; }
.db-dia-bg { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1; filter: drop-shadow(0 2px 4px color-mix(in srgb, var(--text) 8%, transparent)); }
.db-dia-head { fill: var(--prog); }
/* content: on the program's colour (the table's head) */
.db-dia-name { fill: #fff; font: 600 13px var(--font); }
.db-dia-cn { fill: var(--text); font: 12px var(--font); }
.db-dia-cn.pk { font-weight: 700; }
.db-dia-ct { fill: var(--muted); font: 11px var(--font); }
.db-dia-key { font-size: 10px; fill: var(--warn); }
.db-dia-key.fk { fill: var(--prog); font-size: 12px; font-weight: 700; }
.db-dia-c:hover rect { fill: var(--prog-soft) !important; }
.db-dia-port { fill: var(--surface); stroke: var(--prog); stroke-width: 1.5; opacity: 0; cursor: crosshair; }
.db-dia-c:hover .db-dia-port { opacity: 1; }
.db-dia-fk { fill: none; stroke: var(--prog); stroke-width: 1.6; opacity: .75; }
.db-dia-fk.drag { stroke-dasharray: 5 4; opacity: 1; }
.db-dia-end { fill: var(--prog); }

/* the check */
.db-lint { flex: 1; min-height: 0; overflow: auto; }
.db-lint-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 24px; }
.db-lint-i { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 13px; line-height: 1.45; }
.db-lint-i > .material-symbols-outlined { margin-top: 1px; }
.db-lint-i.problem > .material-symbols-outlined { color: var(--danger); }
.db-lint-i.advice > .material-symbols-outlined { color: var(--warn); }
.db-lint-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.db-lint-tb { font-weight: 600; color: var(--text); text-decoration: none; }
.db-lint-i .btn { flex: none; }
.db-plan-fix { margin-left: 10px; height: 24px; padding: 0 8px; font-size: 12px; }

/* the cell */
.db-cell-empty { padding: 16px; color: var(--muted); font-size: 13px; }
.db-cell-head { padding: 10px 12px 6px; display: flex; flex-direction: column; gap: 2px; }
.db-cell-head span { color: var(--muted); font-size: 12px; }
.db-cell-body { flex: 1; min-height: 0; overflow: auto; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.db-cell-text, .db-cell-json, .db-cell-hex { margin: 0; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.5 var(--font-mono); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
.db-cell-hex { white-space: pre; overflow: auto; font-size: 11.5px; }
.db-cell-edit { min-height: 140px; font: 12.5px/1.5 var(--font-mono); resize: vertical; }
.db-cell-bar { display: flex; gap: 6px; }
.db-cell-img { max-width: 100%; border-radius: var(--radius-s); background: var(--checker); align-self: flex-start; }

/* insert form, designer */
.db-insert { max-height: 60vh; overflow: auto; }
.db-ins-row { display: grid; grid-template-columns: 180px 1fr auto; gap: 10px; align-items: center; }
.db-ins-l { display: flex; flex-direction: column; font-size: 13px; }
.db-ins-l span { color: var(--muted); font-size: 11.5px; }
.db-ins-row textarea { min-height: 32px; resize: vertical; font: inherit; }
.db-designer { display: flex; flex-direction: column; gap: 10px; }
.db-des-top { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.db-des-top .field { flex: 1; min-width: 220px; }
.db-des-cols { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.db-des-cols table { width: 100%; border-collapse: collapse; font-size: 13px; }
.db-des-cols th { position: sticky; top: 0; background: var(--panel); text-align: left; padding: 6px; font-size: 12px; color: var(--text-2); z-index: 1; }
.db-des-cols td { padding: 3px 4px; border-top: 1px solid var(--line-soft); }
.db-des-cols td input.inp, .db-des-cols td select.inp { height: 30px; width: 100%; min-width: 70px; }
.db-des-cols td:nth-child(2) input { min-width: 140px; }
.db-des-cols td input[type=checkbox] { width: 16px; height: 16px; }
/* a column's handle: drag to move it */
.db-des-mv { width: 26px; padding: 0 !important; text-align: center; }
.db-des-grip { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 30px; border-radius: var(--radius-s); color: var(--muted); cursor: grab; touch-action: none; }
.db-des-grip:hover { background: var(--hover); color: var(--text); }
.db-des-grip #main .material-symbols-outlined { font-size: var(--ic); }
body.db-des-moving, body.db-des-moving * { cursor: grabbing !important; user-select: none; }
.db-des-cols tr.db-des-dragging td { opacity: .45; }
.db-des-cols tr.db-des-drop-before td { box-shadow: inset 0 2px 0 var(--prog); }
.db-des-cols tr.db-des-drop-after td { box-shadow: inset 0 -2px 0 var(--prog); }
.db-des-add { align-self: flex-start; }
.db-des-cons textarea { width: 100%; font: 12.5px/1.5 var(--font-mono); margin-top: 6px; }
.db-ixcols { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
.db-ixcols .db-dir { height: 26px; margin-left: auto; padding: 0 4px; }

/* SQL tab */
.db-sql-ed { flex: none; position: relative; border-bottom: 1px solid var(--line); min-height: 80px; }
.db-sql-fallback, .db-sql-fallback textarea { position: absolute; inset: 0; width: 100%; height: 100%; }
.db-sql-fallback textarea { border: 0; border-radius: 0; font: 13.5px/1.5 var(--font-mono); padding: 10px; resize: none; }
.db-sql-msg { color: var(--text-2); font-size: 12.5px; }
.db-sql-res { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.db-res-tabs { flex: none; display: flex; gap: 4px; padding: 6px 10px 0; overflow-x: auto; }
.db-res-tab { border: 1px solid var(--line); border-bottom: 0; background: var(--panel); color: var(--text-2); font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: var(--radius-s) var(--radius-s) 0 0; cursor: pointer; white-space: nowrap; }
.db-res-tab.on { background: var(--surface); color: var(--text); font-weight: 600; }
.db-res-tab.err { color: var(--danger); }
.db-res-body { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.db-res-sql { flex: none; padding: 6px 12px; font: 12px/1.4 var(--font-mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--line-soft); }
.db-res-err { margin: 12px; padding: 10px 12px; border-radius: var(--radius); background: color-mix(in oklab, var(--danger) 10%, transparent); color: var(--danger); font: 13px/1.5 var(--font-mono); white-space: pre-wrap; }
.db-res-ok, .db-res-none { padding: 14px; color: var(--text-2); font-size: 13px; }
.db-plan { padding: 8px 0; overflow: auto; }
.db-plan-l { display: flex; gap: 6px; align-items: center; padding: 3px 12px; font: 12.5px/1.5 var(--font-mono); }
.db-plan-l.scan { color: var(--warn); }
.db-plan-l.scan .material-symbols-outlined { color: var(--warn); }
.db-plan-l .material-symbols-outlined { font-size: 16px; color: var(--prog); }

/* tables tab, search, operations */
.db-welcome { margin: 48px auto; max-width: 560px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text-2); }
.db-welcome > .material-symbols-outlined { font-size: 48px; color: var(--prog); }
.db-welcome b { font-size: 17px; color: var(--text); }
.db-welcome-b { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.db-welcome-b .btn { display: inline-flex; align-items: center; gap: 6px; }
.db-search-list { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.db-search-hit { display: flex; gap: 12px; align-items: baseline; padding: 6px 8px; border-radius: var(--radius-s); font-size: 13px; }
.db-search-hit:hover { background: var(--line-soft); }
.db-search-hit a { display: inline-flex; gap: 6px; align-items: center; color: var(--text); text-decoration: none; }
.db-search-hit .material-symbols-outlined { color: var(--prog); font-size: 17px; }
.db-ops-sec { margin-bottom: 8px; }
.db-ops-b { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 14px; }
.db-ops-b .btn { display: inline-flex; align-items: center; gap: 6px; }
.db-peek { max-height: 50vh; }
.db-err { color: var(--danger); }

/* Find (and replace) in the SQL's text (db/findreplace.js) */
.db-findhl { background: var(--find-hl); border-radius: var(--radius-xs); }
.db-findhl.cur { background: var(--find-cur); }
