/* ============================================================
   NAUT — advanced torrent console
   Dense, keyboard-friendly, dark-first UI.
   ============================================================ */
:root {
  --bg: #0c0f14;
  --bg-1: #11151c;
  --bg-2: #161b24;
  --bg-3: #1d2430;
  --bg-hover: #232c3a;
  --bg-sel: #1b3b53;
  --bg-sel-strong: #1f5174;
  --line: #232b38;
  --line-soft: #1a212c;
  --txt: #d7dde6;
  --txt-dim: #8b97a8;
  --txt-faint: #5c6779;
  --accent: #4ea1ff;
  --accent-2: #7c5cff;
  --dl: #4ea1ff;
  --up: #36d399;
  --warn: #f4bf4f;
  --err: #f0616d;
  --ok: #36d399;
  --pause: #8b97a8;
  --check: #b58cff;
  --queue: #f4bf4f;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --r: 6px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--txt);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a3342; border-radius: 6px; border: 2px solid var(--bg-1); }
::-webkit-scrollbar-track { background: transparent; }

#app {
  display: grid;
  grid-template-rows: 44px 1fr 26px;
  height: 100vh;
}

/* ---------------- Login ---------------- */
.login-screen {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); z-index: 500;
}
.login-box {
  width: min(360px, calc(100vw - 32px));
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.login-brand { margin-bottom: 18px; }
.login-submit { width: 100%; padding: 8px 12px; }
.login-error {
  color: var(--err); border: 1px solid rgba(240,97,109,.45);
  background: rgba(240,97,109,.08); border-radius: 6px;
  padding: 8px 10px; margin-bottom: 12px;
}
.login-note { margin: 12px 0 0; font-size: 12px; line-height: 1.4; }

/* ---------------- Toolbar ---------------- */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 6px; user-select: none; }
.brand-mark { color: var(--accent); font-size: 18px; }
.brand-name { font-weight: 700; letter-spacing: 2px; }
.brand-sub { color: var(--txt-faint); font-size: 11px; letter-spacing: .5px; }
.tb-actions { display: flex; align-items: center; gap: 3px; }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 5px; }
.tb-spacer { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 5px 10px;
  cursor: pointer;
  color: var(--txt);
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--bg-hover); border-color: #344155; }
.btn:active { transform: translateY(1px); }
.btn.icon { padding: 5px 7px; min-width: 32px; }
.btn.danger { color: var(--txt-dim); }
.btn.danger:hover { border-color: var(--err); color: var(--err); }
.btn.alt-toggle.on { background: var(--warn); color: #1a1300; border-color: var(--warn); }

/* inline SVG icon system: monochrome, inherits button color */
.ic-svg {
  width: 16px; height: 16px; flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ic-svg.fill { fill: currentColor; stroke: none; }

.quick-filter {
  width: 240px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 14px; padding: 5px 12px;
}
.quick-filter:focus { outline: none; border-color: var(--accent); }

.tb-rates { display: flex; gap: 12px; font-variant-numeric: tabular-nums; }
.rate { color: var(--txt-dim); font-size: 12px; }
.rate.dl b { color: var(--dl); }
.rate.up b { color: var(--up); }

/* ---------------- Main layout ---------------- */
.main { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: minmax(0, 1fr); min-height: 0; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 8px 0;
}
.side-group { margin-bottom: 6px; }
.side-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px 4px; color: var(--txt-faint);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; user-select: none;
}
.side-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px; cursor: pointer; color: var(--txt-dim);
  border-left: 2px solid transparent;
}
.side-item:hover { background: var(--bg-2); color: var(--txt); }
.side-item.active { background: var(--bg-sel); color: #fff; border-left-color: var(--accent); }
.side-item .ic { width: 16px; text-align: center; opacity: .9; }
.side-item .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .cnt {
  font-size: 11px; color: var(--txt-faint);
  background: var(--bg-3); border-radius: 9px; padding: 0 7px; min-width: 18px; text-align: center;
}
.side-item.active .cnt { background: var(--bg-sel-strong); color: #cfe8ff; }
.side-add {
  background: transparent; border: none; color: var(--txt-faint); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 4px; border-radius: 4px;
}
.side-add:hover { color: var(--accent); background: var(--bg-3); }

/* tag editor */
.taglist { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow: auto; margin-top: 6px;
  border: 1px solid var(--line); border-radius: 6px; padding: 8px; background: var(--bg); }
.check-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 5px; cursor: pointer; color: var(--txt); }
.check-row:hover { background: var(--bg-2); }

/* ---------------- Content / view tabs ---------------- */
.content { display: grid; grid-template-rows: 34px minmax(0, 1fr); min-width: 0; min-height: 0; }
.viewtabs { display: flex; gap: 2px; padding: 4px 8px 0; background: var(--bg-1); border-bottom: 1px solid var(--line); }
.vtab {
  background: transparent; border: 1px solid transparent; border-bottom: none;
  padding: 6px 14px; cursor: pointer; color: var(--txt-dim);
  border-radius: 6px 6px 0 0;
}
.vtab:hover { color: var(--txt); background: var(--bg-2); }
.vtab.active { background: var(--bg); color: #fff; border-color: var(--line); position: relative; top: 1px; }
.view-host { min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ---------------- Torrents view (grid + detail) ---------------- */
.torrents-view { display: grid; grid-template-rows: minmax(0, 1fr) var(--detail-h, 0px); min-height: 0; height: 100%; }
.grid-wrap { overflow: auto; min-height: 0; }
#detailHost { min-height: 0; } /* must NOT clip — the resize handle overhangs the top edge */

table.grid { width: 100%; min-width: 1660px; table-layout: fixed; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-2); text-align: left; font-weight: 600; color: var(--txt-dim);
  padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
  cursor: pointer; user-select: none; font-size: 11.5px;
}
table.grid thead th:hover { color: var(--txt); }
table.grid thead th .sort { color: var(--accent); margin-left: 3px; }
table.grid td {
  padding: 4px 8px; border-bottom: 1px solid var(--line-soft); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 360px;
}
table.grid tbody tr { cursor: default; }
table.grid tbody tr:hover { background: var(--bg-2); }
table.grid tbody tr.sel { background: var(--bg-sel); }
table.grid tbody tr.sel:hover { background: var(--bg-sel-strong); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.dim { color: var(--txt-dim); }
.faint { color: var(--txt-faint); }

.name-cell { display: flex; align-items: center; gap: 7px; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }
.priv-badge { font-size: 9px; color: var(--warn); border: 1px solid var(--warn); border-radius: 3px; padding: 0 3px; opacity: .8; }

/* progress bar in-cell */
.pbar { position: relative; width: 100%; height: 14px; background: var(--bg-3); border-radius: 3px; overflow: hidden; min-width: 90px; }
.pbar > i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #2f6db0, var(--dl)); }
.pbar.done > i { background: linear-gradient(90deg, #1f9e72, var(--up)); }
.pbar.paused > i { background: #3a4452; }
.pbar.error > i { background: linear-gradient(90deg, #8a2b33, var(--err)); }
.pbar.check > i { background: repeating-linear-gradient(45deg, #5b3f99, #5b3f99 6px, #7c5cff 6px, #7c5cff 12px); }
.pbar > span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10.5px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.7); }

.tags-cell { display: flex; gap: 4px; flex-wrap: nowrap; overflow: hidden; }
.tag { background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 0 7px; font-size: 11px; color: var(--txt-dim); }
.cat-chip { color: var(--accent); }

/* state text colors */
.s-downloading, .s-forcedDL, .s-metaDL { color: var(--dl); }
.s-uploading, .s-forcedUP { color: var(--up); }
.s-stalledDL, .s-stalledUP { color: var(--txt-dim); }
.s-pausedDL, .s-pausedUP { color: var(--pause); }
.s-checkingDL, .s-checkingUP, .s-moving { color: var(--check); }
.s-queuedDL, .s-queuedUP { color: var(--queue); }
.s-error, .s-missingFiles { color: var(--err); }

/* ---------------- Detail panel ---------------- */
.detail {
  border-top: 1px solid var(--line); background: var(--bg-1);
  display: grid; grid-template-rows: 30px 1fr; height: 100%;
  position: relative;
}
.detail-resize { position: absolute; top: -6px; left: 0; right: 0; height: 12px; cursor: ns-resize; z-index: 10; touch-action: none; }
.detail-resize::after {
  content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 56px; height: 4px; border-radius: 2px; background: #3a4452;
}
.detail-resize:hover::after { background: var(--accent); }
.detail-tabs { display: flex; gap: 2px; padding: 3px 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
.dtab { background: transparent; border: none; padding: 5px 12px; cursor: pointer; color: var(--txt-dim); border-radius: 5px 5px 0 0; }
.dtab:hover { color: var(--txt); background: var(--bg-2); }
.dtab.active { color: #fff; background: var(--bg-3); }
.detail-close { margin-left: auto; color: var(--txt-faint); }
.detail-body { overflow: auto; padding: 10px 14px; min-height: 0; }
.detail-empty { display: grid; place-items: center; color: var(--txt-faint); height: 100%; }

/* general grid of props */
.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 2px 24px; }
.prop { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px solid var(--line-soft); }
.prop .k { color: var(--txt-faint); }
.prop .v { color: var(--txt); font-variant-numeric: tabular-nums; text-align: right; }
.prop .v.mono { font-family: var(--mono); font-size: 12px; }
.section-h { color: var(--accent); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin: 14px 0 6px; grid-column: 1/-1; }

/* generic data tables inside detail */
table.dtbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.dtbl th { text-align: left; color: var(--txt-faint); font-weight: 600; padding: 4px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-1); font-size: 11px; }
table.dtbl td { padding: 3px 8px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.flagchip { font-family: var(--mono); letter-spacing: 1px; }
.status-working { color: var(--ok); }
.status-error { color: var(--err); }
.status-updating, .status-not.contacted, .status-not { color: var(--warn); }

/* files tree */
.file-row td:first-child { font-family: var(--mono); font-size: 12px; }
.prio-sel { background: var(--bg-3); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }
.mini-bar { width: 80px; height: 9px; background: var(--bg-3); border-radius: 2px; overflow: hidden; display: inline-block; vertical-align: middle; }
.mini-bar > i { display: block; height: 100%; background: var(--up); }

/* piece map */
.piecemap { display: flex; flex-wrap: wrap; gap: 1px; align-content: flex-start; }
.piece { width: 9px; height: 9px; border-radius: 1px; background: var(--bg-3); }
.piece.dl { background: var(--warn); }
.piece.done { background: var(--dl); }
.piece-legend { display: flex; gap: 16px; margin-bottom: 10px; color: var(--txt-dim); font-size: 12px; }
.piece-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }

/* ---------------- RSS view ---------------- */
.pane { padding: 14px 18px; overflow: auto; height: 100%; }
.split2 { display: grid; grid-template-columns: 280px 1fr; gap: 16px; height: 100%; }
.card { background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 10px; font-size: 13px; color: var(--txt); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.feed-row { padding: 6px 0; border-bottom: 1px solid var(--line); }
.feed-row:last-child { border-bottom: none; }
.iconbtn { background: transparent; border: none; color: var(--txt-faint); cursor: pointer;
  font-size: 13px; padding: 2px 6px; border-radius: 5px; }
.iconbtn:hover { color: var(--err); background: var(--bg-3); }
.rule-feeds { display: flex; flex-wrap: wrap; gap: 4px 12px; max-height: 120px; overflow: auto;
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: var(--bg); }
.rule-matches { max-height: 160px; overflow: auto; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg); font-size: 12px; }
.match-row { padding: 3px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.match-row:last-child { border-bottom: none; }
.match-row.grabbed { opacity: .55; }
.rule { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; background: var(--bg-1); }
.rule.off { opacity: .55; }
.rule-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.rule-name { font-weight: 600; }
.pill { font-size: 11px; border-radius: 10px; padding: 1px 8px; border: 1px solid var(--line); color: var(--txt-dim); }
.pill.on { color: var(--ok); border-color: var(--ok); }
.pill.paused { color: var(--warn); border-color: var(--warn); }
.kvrow { display: flex; gap: 8px; font-size: 12px; color: var(--txt-dim); margin: 2px 0; }
.kvrow b { color: var(--txt); font-weight: 500; }
code.inline { background: var(--bg-3); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; font-family: var(--mono); font-size: 12px; color: var(--accent); }

/* ---------------- Automation view ---------------- */
.automation-layout { display: flex; gap: 12px; align-items: flex-start; }
.automation-main { flex: 1 1 auto; min-width: 0; }
.automation-settings { flex: 0 0 300px; align-self: stretch; }
/* Below this the side-by-side editor would be too narrow to read (the app also
 * spends 232px on the sidebar), so stack — settings ABOVE the script. */
@media (max-width: 1100px) {
  /* Stack vertically, settings above the script. (The base .pane height:100%
   * would otherwise make each pane fill the viewport and bury the editor.) */
  .automation-layout {
    flex-direction: column; align-items: stretch;
    flex: 1 1 auto; min-height: 0;
  }
  /* Settings shrink to their content, but never take more than half the
   * height — scroll internally if there are a lot of them. */
  .automation-settings {
    order: -1; align-self: auto; width: 100%;
    flex: 0 1 auto; height: auto; max-height: 50%; overflow: auto;
  }
  /* The script gets the rest (>= half) and its editor fills that space. */
  .automation-main {
    width: 100%; flex: 1 1 0; min-height: 0;
    display: flex; flex-direction: column;
  }
  .automation-main .script-editor { flex: 1 1 auto; min-height: 180px; }
}
.settings-form { display: flex; flex-direction: column; gap: 12px; }
.setting-field { display: flex; flex-direction: column; gap: 5px; }
.setting-field.bool { flex-direction: row; align-items: center; gap: 8px; }
.setting-field .setting-label { color: var(--txt-dim); font-size: 12px; }
.setting-field input[type="text"],
.setting-field input[type="number"] {
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; color: var(--txt); font-size: 13px; outline: none;
}
.setting-field input[type="text"]:focus,
.setting-field input[type="number"]:focus { border-color: var(--accent); }
.setting-field.bool input { width: 15px; height: 15px; accent-color: var(--accent); }
.automation-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.automation-head h3 { margin: 0 0 4px; font-size: 15px; }
.script-actions { display: flex; align-items: center; gap: 8px; }
.script-save-status { min-width: 112px; text-align: right; color: var(--txt-faint); font-size: 12px; }
.script-save-status.dirty { color: var(--warn); }
.script-save-status.ok { color: var(--ok); }
.script-save-status.err { color: var(--err); }
.script-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 12px; }
.script-stat { background: var(--bg-1); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.script-stat span { display: block; color: var(--txt-dim); font-size: 11px; margin-bottom: 4px; }
.script-stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
.script-error { border: 1px solid var(--err); border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; color: var(--err); }
.script-error code { display: block; margin-top: 4px; color: var(--txt); font-family: var(--mono); font-size: 12px; white-space: pre-wrap; }
.script-editor {
  position: relative; min-height: 420px; background: var(--bg-1);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.script-editor.disabled { opacity: .75; }
.script-highlight,
.script-editor textarea {
  position: absolute; inset: 0; margin: 0; padding: 12px; border: 0;
  font: 12px/1.45 var(--mono); tab-size: 4; white-space: pre;
}
.script-highlight { overflow: auto; color: var(--txt); pointer-events: none; }
.script-highlight code { white-space: pre; }
.script-editor textarea {
  width: 100%; height: 100%; resize: none; outline: none; overflow: auto;
  background: transparent; color: transparent; caret-color: var(--txt);
}
.script-editor textarea::selection { background: rgba(73, 157, 253, .28); color: transparent; }
.tok-comment { color: #697586; }
.tok-string { color: #8bd49c; }
.tok-keyword { color: #7fb4ff; }
.tok-number { color: #d8b4fe; }
.tok-api { color: #f6c177; }

/* ---------------- Search view ---------------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-bar input { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
.search-bar input:focus { outline: none; border-color: var(--accent); }

/* ---------------- Settings ---------------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.plugin-metric { font-size: 28px; line-height: 1; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ---------------- Status bar ---------------- */
.statusbar {
  display: flex; align-items: center; gap: 16px; padding: 0 12px;
  background: var(--bg-2); border-top: 1px solid var(--line);
  color: var(--txt-dim); font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.statusbar .sb { display: inline-flex; align-items: center; gap: 5px; }
.statusbar .sb b { color: var(--txt); font-weight: 600; }
.statusbar .conn-ok { color: var(--ok); }
.statusbar .spacer { flex: 1; }
.led { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px var(--ok); }

/* ---------------- Modal ---------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 100; }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; width: min(560px, 92vw); max-height: 86vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal h2 { margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 15px; }
.modal .mbody { padding: 16px 18px; }
.modal .mfoot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.field { margin-bottom: 12px; }
/* checkbox dropdown (multi-select, e.g. tags) */
.cbdrop { position: relative; }
.cbdrop-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
  color: var(--txt); font-size: 13px; cursor: pointer; }
.cbdrop-btn:hover { border-color: var(--accent); }
.cbdrop-btn > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.cbdrop-caret { color: var(--txt-faint); flex: none; }
.cbdrop-menu { position: fixed; z-index: 300; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px; max-height: 240px; overflow: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.cbdrop-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 5px;
  cursor: pointer; color: var(--txt); font-size: 13px; }
.cbdrop-item:hover { background: var(--bg-3); }
.cbdrop-item input { accent-color: var(--accent); }
.cbdrop-new { display: flex; gap: 6px; padding-top: 6px; margin-top: 4px; border-top: 1px solid var(--line); }
.cbdrop-new input { flex: 1; background: var(--bg-1); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 8px; color: var(--txt); font-size: 12px; }
.field label { display: block; color: var(--txt-dim); margin-bottom: 4px; font-size: 12px; }
.field input[type=text], .field input[type=password], .field textarea, .field select {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px;
}
.field input[type=text]:focus, .field input[type=password]:focus, .field textarea:focus, .field select:focus,
.field input[type=file]:focus { outline: none; border-color: var(--accent); }
/* greyed default-location field: shows the category default until clicked */
.field input[type=text].path-default {
  color: var(--txt-faint); background: var(--bg-2); cursor: pointer; }
.field input[type=text].path-default:hover { border-color: var(--accent); }
.field textarea { min-height: 70px; font-family: var(--mono); font-size: 12px; resize: vertical; }

/* themed file picker */
.field input[type=file] {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; color: var(--txt-dim); cursor: pointer; font-size: 12px;
}
.field input[type=file]::file-selector-button {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 5px;
  color: var(--txt); padding: 5px 12px; margin-right: 12px; cursor: pointer;
  font-family: inherit; font-size: 12px;
  transition: background .12s, border-color .12s;
}
.field input[type=file]::file-selector-button:hover { background: var(--bg-hover); border-color: #344155; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.checks label { color: var(--txt-dim); display: inline-flex; gap: 6px; align-items: center; }
.btn.primary { background: var(--accent); color: #052238; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: #6cb3ff; }

/* context menu */
.ctxmenu { position: fixed; z-index: 200; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px; min-width: 200px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.ctxmenu .mi { padding: 6px 12px; border-radius: 5px; cursor: pointer; display: flex; justify-content: space-between; gap: 16px; color: var(--txt); }
.ctxmenu .mi:hover { background: var(--bg-sel-strong); }
.ctxmenu .mi.danger:hover { background: #5a2228; }
.ctxmenu .mi .sc { color: var(--txt-faint); font-size: 11px; }
.ctxmenu .sep { height: 1px; background: var(--line); margin: 5px 4px; }
.ctxmenu .sub { color: var(--txt-faint); padding: 4px 12px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; }

.empty { display: grid; place-items: center; height: 100%; color: var(--txt-faint); }

/* toasts */
.toast-host { position: fixed; right: 16px; bottom: 36px; z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 9px 14px; color: var(--txt); box-shadow: 0 8px 24px rgba(0,0,0,.4);
  max-width: 360px; animation: toast-in .18s ease-out;
}
.toast.err { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* connection banner */
.conn-banner {
  position: fixed; top: 52px; left: 50%; transform: translateX(-50%); z-index: 300;
  background: var(--warn); color: #1a1300; font-weight: 600; font-size: 12px;
  padding: 6px 16px; border-radius: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
