/* Linksz, in the look of omarchy.org: Tokyo Night when dark, Catppuccin
   Latte when light, square corners, a 1px ring where a shadow would be, Oxygen
   for text and JetBrains Mono for code and keys. Light or dark follows the
   system unless the person picks one. */

/* Both faces are shipped with the app so it looks the same offline and on a
   phone that does not have them. Latin only, SIL Open Font License:
   fonts/OFL-Oxygen.txt and fonts/OFL.txt. Oxygen comes in 400 and 700; the
   weights in between resolve to one of the two. */
@font-face {
  font-family: "Oxygen";
  src: url("/fonts/oxygen-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Oxygen";
  src: url("/fonts/oxygen-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono Variable";
  src: url("/fonts/jetbrains-mono.woff2") format("woff2-variations"), url("/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #eff1f5;
  --surface: #f8f9fb;
  --surface-2: #e6e9ef;
  --hover: #dce0e8;
  --border: #d7d8dc;
  --border-strong: #acb0be;
  --text: #4c4f69;
  --muted: #5c5f77;
  --faint: #8c8fa1;
  --accent: #1e66f5;
  --accent-text: #1e66f5;
  --accent-soft: rgb(30 102 245 / 0.12);
  --on-accent: #ffffff;
  --danger: #d20f39;
  --danger-soft: rgb(210 15 57 / 0.1);
  --ok: #40a02b;
  --mark: rgb(223 142 29 / 0.3);
  --shadow: 0 0 0 1px rgb(0 0 0 / 0.06), 0 1px 3px rgb(0 0 0 / 0.05), 0 4px 10px -4px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 0 0 1px rgb(0 0 0 / 0.09), 0 16px 48px rgb(0 0 0 / 0.16);

  --radius: 0;
  --radius-sm: 0;
  --side-w: 272px;
  --mono: "JetBrains Mono Variable", "JetBrains Mono", "JetBrainsMono Nerd Font", ui-monospace, Menlo, Consolas, monospace;
  --font: "Oxygen", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1b26;
    --surface: #1f2230;
    --surface-2: #24283b;
    --hover: #292e42;
    --border: #292e42;
    --border-strong: #414868;
    --text: #c0caf5;
    --muted: #8b93b8;
    --faint: #565f89;
    --accent: #9ece6a;
    --accent-text: #9ece6a;
    --accent-soft: rgb(158 206 106 / 0.12);
    --on-accent: #0c0e10;
    --danger: #f7768e;
    --danger-soft: rgb(247 118 142 / 0.12);
    --ok: #9ece6a;
    --mark: rgb(224 175 104 / 0.35);
    --shadow: 0 0 0 1px rgb(255 255 255 / 0.07);
    --shadow-lg: 0 0 0 1px rgb(255 255 255 / 0.1), 0 16px 48px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1a1b26;
  --surface: #1f2230;
  --surface-2: #24283b;
  --hover: #292e42;
  --border: #292e42;
  --border-strong: #414868;
  --text: #c0caf5;
  --muted: #8b93b8;
  --faint: #565f89;
  --accent: #9ece6a;
  --accent-text: #9ece6a;
  --accent-soft: rgb(158 206 106 / 0.12);
  --on-accent: #0c0e10;
  --danger: #f7768e;
  --danger-soft: rgb(247 118 142 / 0.12);
  --ok: #9ece6a;
  --mark: rgb(224 175 104 / 0.35);
  --shadow: 0 0 0 1px rgb(255 255 255 / 0.07);
  --shadow-lg: 0 0 0 1px rgb(255 255 255 / 0.1), 0 16px 48px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
a { color: inherit; text-decoration: none; }
code, kbd { font-family: var(--mono); font-size: 0.86em; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 5px; text-align: center;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 0;
  background: var(--surface); color: var(--muted); line-height: 1.5;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
.center { text-align: center; }
.spacer { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 0; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- controls ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 0;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); background: var(--accent); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { filter: brightness(1.07); background: var(--danger); }
.btn.danger-text { color: var(--danger); }
.btn.danger-text:hover:not(:disabled) { background: var(--danger-soft); }
.btn.link { border: 0; background: none; color: var(--accent-text); padding: 0 4px; height: auto; }
.btn.link:hover:not(:disabled) { background: none; text-decoration: underline; }
.btn.icon { width: 34px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); }
.btn.icon:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.btn.sm { height: 26px; font-size: 12.5px; }
.btn.icon.sm { width: 26px; }
.btn.block { width: 100%; height: 40px; }

input, textarea, select {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: 0;
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 64px; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.form-error { color: var(--danger); font-size: 13px; margin: 8px 0 0; min-height: 0; }
.form-error:empty { display: none; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 0; }
.segmented button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 550;
  padding: 5px 12px; border-radius: 0; cursor: pointer;
}
.segmented button.on { background: var(--accent); color: var(--on-accent); }
.devices { list-style: none; margin: 12px 0; padding: 0; border-top: 1px solid var(--border); }
.devices li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.device-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.device-main .muted { font-size: 12px; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; margin-left: 6px; padding: 1px 6px; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent-text); }
.palettes-label { margin: 18px 0 8px; }
.palettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.palettes button {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; min-width: 0;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
}
.palettes button:hover { background: var(--hover); }
.palettes button.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.palettes button > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch { display: inline-flex; flex: none; box-shadow: 0 0 0 1px var(--border-strong); }
.swatch i { width: 10px; height: 18px; }
.segmented.wide { display: flex; width: 100%; margin-bottom: 12px; }
.segmented.wide button { flex: 1; display: flex; flex-direction: column; padding: 8px; }
.segmented small { font-weight: 400; font-size: 12px; color: var(--muted); }
/* On the chosen one the caption sits on the accent, where the grey all but
   disappeared: it takes the button's own colour, a step lighter in weight. */
.segmented button.on small { color: inherit; }

.logo {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 0;
  background: var(--accent); color: var(--on-accent);
}
.logo svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }

/* ---------------- the shell ---------------- */

.shell { display: grid; grid-template-columns: var(--side-w) 1fr; height: 100%; }

.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 14px 10px 10px;
  padding-top: max(14px, env(safe-area-inset-top));
}
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 0;
  color: var(--muted); font-weight: 550;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent-text); }
.nav-count { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--faint); font-variant-numeric: tabular-nums; }

.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 6px 6px 10px; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint);
}

/* the folder tree */
.tree { flex: 1; overflow: auto; margin: 0 -4px; padding: 0 4px 8px; }
.node {
  display: flex; align-items: center; gap: 4px; height: 30px; padding-right: 8px;
  border-radius: 0; cursor: pointer; color: var(--text); user-select: none;
}
.node:hover { background: var(--hover); }
.node.on { background: var(--accent-soft); color: var(--accent-text); }
.node.drop { background: var(--accent); color: var(--on-accent); }
.node.drop .node-count { color: inherit; }
.node .twisty {
  display: grid; place-items: center; width: 18px; height: 18px; border-radius: 0; color: var(--faint);
  transition: transform 0.12s;
}
.node .twisty svg { width: 14px; height: 14px; }
.node .twisty.open { transform: rotate(90deg); }
.node .twisty.leaf { visibility: hidden; }
.node > svg { width: 16px; height: 16px; color: var(--faint); }
.node.on > svg { color: inherit; }
.node-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---------------- views ---------------- */

.view { min-width: 0; min-height: 0; overflow: auto; padding: 0 28px 120px; }
.view-head {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 18px 0 14px; background: var(--bg);
  padding-top: max(18px, env(safe-area-inset-top));
}
.titles { flex: 1; min-width: 0; }
.titles p { margin: 2px 0 0; }
.only-mobile { display: none; }

/* the search box */
.search {
  position: relative; flex: 1; display: flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 0; box-shadow: none;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; padding: 0; height: 100%; background: transparent; font-size: 15px; box-shadow: none; }
.search input:focus { box-shadow: none; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search-icon { color: var(--faint); }
.search-kbd { font-size: 11px; }
.search:focus-within .search-kbd { display: none; }
.history-wrap { position: relative; flex: none; }
.search-history {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: min(360px, calc(100vw - 32px));
  max-height: 60vh; overflow: auto; background: var(--surface); box-shadow: var(--shadow-lg);
}
.search-history-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.search-history ul { list-style: none; margin: 0; padding: 4px 0; }
.search-history li button {
  display: flex; width: 100%; align-items: baseline; gap: 10px; padding: 7px 10px;
  border: 0; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.search-history li button:hover, .search-history li button:focus-visible { background: var(--hover); outline: none; }
.search-history .q { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-history time { flex: none; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.search-history .empty-history { padding: 10px; color: var(--muted); font-size: 12.5px; }
.search.small { height: 38px; margin: 0 0 8px; }
.scope {
  display: inline-flex; align-items: center; gap: 4px; max-width: 45%;
  padding: 2px 4px 2px 8px; border-radius: 0; background: var(--accent-soft); color: var(--accent-text);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.scope span { overflow: hidden; text-overflow: ellipsis; }
.scope button { display: grid; place-items: center; border: 0; background: none; color: inherit; padding: 1px; cursor: pointer; border-radius: 0; }
.scope button:hover { background: rgb(0 0 0 / 0.08); }
.scope svg { width: 14px; height: 14px; }

.list-meta { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 8px; font-size: 12.5px; }
.list-meta { flex-wrap: wrap; gap: 6px; }
.list-tools { display: flex; align-items: center; gap: 10px; }
.segmented.sm { padding: 2px; }
.segmented.sm button { padding: 3px 10px; font-size: 12.5px; }
.syntax {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 12px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 0; font-size: 12.5px;
}
.syntax code { padding: 1px 6px; background: var(--surface-2); border-radius: 0; }

/* ---------------- the link list ---------------- */

.list {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 0; overflow: hidden;
}
.list:empty { display: none; }
.row {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 8px 10px 8px 12px; border-top: 1px solid var(--border);
  cursor: pointer;
}
.row:first-child { border-top: 0; }
.row:hover { background: var(--surface-2); }
.row.cursor { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.row.marked { background: var(--accent-soft); }
.row.dragging { opacity: 0.5; }

.check-box {
  flex: none; display: grid; place-items: center; width: 18px; height: 18px;
  border: 1.5px solid var(--border-strong); border-radius: 0; background: var(--surface);
  color: transparent; cursor: pointer; transition: all 0.1s;
}
.check-box svg { width: 13px; height: 13px; stroke-width: 3; }
.row.marked .check-box, .orow.marked .check-box, .check-box.on {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.check-box.some { background: var(--accent); border-color: var(--accent); }
.check-box.some::after { content: ''; width: 8px; height: 2px; background: var(--on-accent); border-radius: 0; }
/* The box is there when it is useful: on hover, or once anything is selected. */
.list .check-box { opacity: 0; }
.list .row:hover .check-box, .list.selecting .check-box, .row.marked .check-box { opacity: 1; }

.fav {
  position: relative; flex: none; display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 0; background: var(--surface-2); color: var(--muted);
  font-size: 12px; font-weight: 700; text-transform: uppercase; overflow: hidden;
}
.fav img { position: absolute; inset: 6px; width: 16px; height: 16px; }
.row-main { flex: 1; min-width: 0; }
.row-title {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 550; color: var(--text);
}
.row-meta {
  display: flex; align-items: center; gap: 6px; margin-top: 2px; min-width: 0;
  font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden;
}
.row-meta .host { overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 40px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; flex: none; max-width: 220px;
  padding: 0 7px; height: 20px; border-radius: 0; border: 0;
  background: var(--surface-2); color: var(--muted); font: inherit; font-size: 12px; cursor: pointer;
}
.chip span { overflow: hidden; text-overflow: ellipsis; }
.chip svg { width: 12px; height: 12px; }
.chip:hover { color: var(--text); background: var(--hover); }
.row.marked .chip { background: var(--surface); }
.tag { color: var(--accent-text); cursor: pointer; flex: none; }
.tag:hover { text-decoration: underline; }
.opens { flex: none; color: var(--faint); font-variant-numeric: tabular-nums; }
mark { background: var(--mark); color: inherit; border-radius: 0; padding: 0 1px; }

.row-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.1s; }
.row:hover .row-actions, .row.cursor .row-actions { opacity: 1; }
.row-actions .btn.icon { width: 30px; height: 30px; }

/* By folder: a heading over each folder's rows. */
.group {
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px 0 4px; min-height: 38px; border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.group:first-child { border-top: 0; }
.group-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px 6px;
  border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; text-align: left; cursor: pointer;
}
.group-toggle svg { flex: none; width: 15px; height: 15px; color: var(--muted); }
.group-chev { transition: transform 0.12s; }
.group.collapsed .group-chev { transform: rotate(-90deg); }
.group-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-parent { color: var(--muted); font-weight: 400; }
.group-n { flex: none; color: var(--muted); font-weight: 400; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.group .btn.link { flex: none; }
.list.grouped .row .chip[data-act="scope"] { display: none; }

.more {
  display: block; width: 100%; padding: 12px; border: 0; border-top: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font: inherit; cursor: pointer;
}
.more:hover { background: var(--surface-2); color: var(--text); }

.empty { padding: 56px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* ---------------- organize ---------------- */

.panes {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 14px;
  height: calc(100vh - 130px); min-height: 420px;
}
#view-organize { padding-bottom: 24px; }
.pane {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 0; overflow: hidden;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.pane.focus { border-color: var(--border-strong); }
.pane.drop { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pane-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 8px; }
.pane-folder {
  flex: 1; min-width: 0; justify-content: flex-start; height: 38px; font-size: 14.5px; font-weight: 650;
  border-color: transparent; background: var(--surface-2);
}
.pane-folder span { overflow: hidden; text-overflow: ellipsis; }
.pane-folder .chev { margin-left: auto; color: var(--faint); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 0 12px 8px; font-size: 12.5px; color: var(--muted); min-height: 8px; }
.crumbs button { border: 0; background: none; color: inherit; font: inherit; padding: 1px 4px; border-radius: 0; cursor: pointer; }
.crumbs button:hover { background: var(--hover); color: var(--text); }
.crumbs button.drop { background: var(--accent); color: var(--on-accent); }
.crumbs svg { width: 12px; height: 12px; color: var(--faint); }
.pane-tools { display: flex; align-items: center; gap: 8px; padding: 0 10px 10px 12px; border-bottom: 1px solid var(--border); }
.pane-tools input { height: 32px; padding: 4px 10px; }
.pane-count { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pane-list { flex: 1; overflow: auto; list-style: none; margin: 0; padding: 4px; }
.orow {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 5px 8px;
  border-radius: 0; cursor: pointer; user-select: none;
}
.orow:hover { background: var(--surface-2); }
.orow.marked { background: var(--accent-soft); }
.orow.drop { background: var(--accent); color: var(--on-accent); }
.orow.drop .muted, .orow.drop svg { color: inherit; }
.orow .fav { width: 22px; height: 22px; border-radius: 0; font-size: 10.5px; }
.orow .fav img { inset: 4px; width: 14px; height: 14px; }
.orow-main { flex: 1; min-width: 0; }
.orow-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orow-host { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orow.folder { font-weight: 550; }
.orow.folder > svg { color: var(--faint); }
.orow .open-link, .orow .edit-link { opacity: 0; }
.orow:hover .open-link, .orow:hover .edit-link,
.orow .open-link:focus-visible, .orow .edit-link:focus-visible { opacity: 1; }
/* No hover on a touch screen: the buttons are just there. */
@media (hover: none) { .orow .open-link, .orow .edit-link { opacity: 1; } }
.orow .btn.icon { width: 28px; height: 28px; }
.pane-empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; }

.pane-actions { display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.move-btn { flex-direction: column; width: 64px; height: auto; padding: 10px 6px; gap: 4px; font-size: 12px; }
.move-btn svg { width: 20px; height: 20px; }
.move-btn:not(:disabled) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.move-btn:not(:disabled):hover { filter: brightness(1.07); background: var(--accent); }
.move-btn span:empty { display: none; }

/* ---------------- cards (activity, data, settings) ---------------- */

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cards.narrow { grid-template-columns: 1fr; max-width: 640px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 0; padding: 18px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card > .muted { margin: 0 0 4px; }
.prefix { margin: 10px 0 14px; }
.prefix code { display: block; padding: 8px 10px; background: var(--surface-2); border-radius: 0; font-size: 12.5px; overflow-wrap: anywhere; user-select: all; }
#bookmarklet { margin-left: 6px; cursor: grab; }

.chart { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 18px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar { width: 100%; max-width: 36px; min-height: 2px; background: var(--accent); border-radius: 0; opacity: 0.85; }
.bar.zero { background: var(--border); }
.bar-val { font-size: 11px; color: var(--muted); margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.bar-day { font-size: 11px; color: var(--faint); margin-top: 5px; height: 14px; white-space: nowrap; }

.plain-list { list-style: none; margin: 0; padding: 0; }
/* ---------------- audit ---------------- */

#view-audit .view-head { flex-wrap: wrap; }
.audit-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.audit-tools input { flex: 1; min-width: 180px; }
.audit-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); }
.audit-wrap:has(table[hidden]) { display: none; }
.audit { width: 100%; border-collapse: collapse; font-size: 13px; }
.audit th {
  position: sticky; top: 0; text-align: left; font-weight: 600; font-size: 12px; color: var(--muted);
  padding: 8px 10px; background: var(--surface-2); white-space: nowrap;
}
.audit td { padding: 8px 10px; border-top: 1px solid var(--border); vertical-align: top; }
.aud-when { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.aud-link { max-width: 320px; }
.aud-link a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.aud-link a:hover { color: var(--accent-text); }
.aud-link .muted { font-size: 12px; }
.aud-detail { min-width: 200px; overflow-wrap: anywhere; }
.aud-field + .aud-field { margin-top: 3px; }
.aud-field b { font-weight: 600; margin-right: 4px; }
.aud-from { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.aud-to { color: var(--text); }
.aud-route, .aud-via { white-space: nowrap; }
.aud-target code { font-size: 12px; }
.aud-badge {
  display: inline-block; padding: 1px 7px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--text);
}
.aud-create, .aud-restore { background: var(--accent-soft); color: var(--accent-text); }
.aud-delete { background: var(--danger-soft); color: var(--danger); }
#audit-more { margin-top: 12px; }

.plain-list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.plain-list li:first-child { border-top: 0; }
.plain-list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plain-list a.grow:hover { color: var(--accent-text); }
.plain-list .num { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.file-drop {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 22px;
  border: 1.5px dashed var(--border-strong); border-radius: 0; cursor: pointer; text-align: center;
  transition: border-color 0.12s, background 0.12s;
}
.file-drop:hover, .file-drop.drop { border-color: var(--accent); background: var(--accent-soft); }
.file-drop input { display: none; }
.file-drop-main { font-weight: 600; color: var(--accent-text); }
#io-prefix-row { margin: 14px 0 0; }
.io-stats { margin: 16px 0 8px; color: var(--muted); font-size: 13px; }
.io-summary { list-style: none; margin: 0 0 12px; padding: 0; }
.io-summary li { padding: 4px 0; }
.io-summary b { font-variant-numeric: tabular-nums; }
.io-summary em { display: block; font-style: normal; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.io-warn { padding: 10px 12px; border-radius: 0; background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.io-none { font-size: 13px; }
.choices { border: 0; padding: 0; margin: 12px 0 16px; display: grid; gap: 6px; }
.choices legend { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.choices label { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--border); border-radius: 0; cursor: pointer; }
.choices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choices input { margin-top: 3px; }
.choices span { display: flex; flex-direction: column; }
.choices small { color: var(--muted); }

.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 13.5px; }
.keys dt { white-space: nowrap; color: var(--muted); }
.keys dd { margin: 0; }

/* ---------------- dialogs ---------------- */

.dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 48px); padding: 0;
  border: 1px solid var(--border); border-radius: 0; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgb(10 10 14 / 0.45); }
.dialog[open] { animation: pop 0.14s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
.dialog form { padding: 18px 20px 18px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin: -4px -8px 14px 0; }
.dialog-foot { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.dialog.confirm { width: min(420px, calc(100vw - 24px)); }
.dialog.confirm h2 { font-size: 17px; margin-bottom: 6px; }
.dialog.confirm p { margin: 0; }
/* ---------------- pinned links ---------------- */

.pins { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 10px; }
.pin {
  display: inline-flex; align-items: center; gap: 7px; max-width: 240px; height: 32px; padding: 0 6px 0 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
  font-size: 13px;
}
.pin:hover { border-color: var(--accent); }
.pin.dragging { opacity: 0.45; }
.pin kbd { font-size: 10px; min-width: 16px; text-align: center; color: var(--muted); }
.pin .fav { flex: none; }
.pin > span:not(.fav) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-x {
  display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0;
  background: none; color: var(--faint); cursor: pointer; visibility: hidden;
}
.pin:hover .pin-x, .pin:focus-within .pin-x { visibility: visible; }
.pin-x:hover { color: var(--text); }
.pin-x svg { width: 12px; height: 12px; }
.pin-toggle.on { color: var(--accent); }
.pin-toggle.on svg { fill: currentColor; }

/* ---------------- sorting Temporary ---------------- */

.dialog.triage { width: min(620px, calc(100vw - 24px)); }
.triage-wrap { padding: 18px 20px 20px; }
.triage-wrap h2 { font-size: 17px; margin: 0; }
.triage-link { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.triage-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.triage-title { font-size: 15px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.triage-main .muted { font-size: 12px; }
.triage-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 18px; }
.triage-suggestions .btn, .triage-actions .btn { gap: 8px; }
.triage-suggestions kbd, .triage-actions kbd { font-size: 10px; opacity: 0.75; }
.triage-actions { display: flex; align-items: center; gap: 8px; }
.triage-actions .spacer { flex: 1; }
.triage-done { text-align: center; padding: 18px 0 6px; }
.triage-done p { margin: 6px 0 16px; }

.dialog.preview {
  width: min(1100px, calc(100vw - 48px)); height: min(820px, calc(100vh - 48px));
  max-height: none; display: flex; flex-direction: column;
}
.dialog.preview:not([open]) { display: none; }
.preview-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--border); flex: none;
}
.preview-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.preview-titles h2 { font-size: 15px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-titles span { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-body { flex: 1; min-height: 0; overflow: auto; background: var(--bg); }
.preview-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.preview-wait { padding: 40px; text-align: center; }
.preview-card { max-width: 680px; margin: 0 auto; padding: 28px 24px; }
.preview-card h3 { font-size: 20px; margin: 0 0 10px; color: var(--text); }
.preview-card p { margin: 0 0 12px; }
.preview-image {
  display: block; width: 100%; max-height: 360px; object-fit: cover; margin-bottom: 18px;
  border: 1px solid var(--border); background: var(--surface-2);
}
.preview-url { font-size: 12px; word-break: break-all; }
#preview-open svg { width: 15px; height: 15px; }

.folder-field { justify-content: flex-start; width: 100%; height: 38px; font-weight: 500; }
.folder-field span { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.folder-field .chev { color: var(--faint); }

.picker form { display: flex; flex-direction: column; max-height: min(560px, calc(100vh - 48px)); }
.picker-list { list-style: none; margin: 0 -8px; padding: 0; overflow: auto; flex: 1; min-height: 120px; }
.pick {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 0; cursor: pointer;
}
.pick svg { width: 16px; height: 16px; color: var(--faint); }
.pick .pick-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick .pick-parent { color: var(--muted); }
.pick .pick-count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.pick.cur { background: var(--accent-soft); color: var(--accent-text); }
.pick.cur svg { color: inherit; }
.pick.current .pick-count::after { content: ' · here'; }
.pick.create { color: var(--accent-text); font-weight: 550; }

/* ---------------- floating bits ---------------- */

.selbar {
  position: fixed; left: calc(var(--side-w) + (100vw - var(--side-w)) / 2); bottom: 22px; transform: translateX(-50%);
  z-index: 20; display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 16px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: 0; box-shadow: var(--shadow-lg);
  animation: rise 0.16s ease-out;
}
.selbar #sel-count { font-weight: 600; margin-right: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.selbar .btn { background: transparent; border-color: transparent; color: inherit; }
.selbar .btn:hover { background: rgb(127 127 127 / 0.22); }
.selbar .btn.danger-text { color: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }

.toasts {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 14px; min-width: 240px; max-width: min(520px, calc(100vw - 32px));
  padding: 10px 10px 10px 16px; border-radius: 0; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-lg); pointer-events: auto; animation: rise2 0.16s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast span { flex: 1; }
.toast button { border: 0; background: none; color: var(--accent-text); font: inherit; font-weight: 650; cursor: pointer; padding: 4px 8px; border-radius: 0; }
.toast.error button { color: var(--danger); }
@keyframes rise2 { from { opacity: 0; transform: translateY(10px); } }
body:has(.selbar:not([hidden])) .toasts { bottom: 84px; }

.tabbar { display: none; }
.scrim { display: none; }

/* dragging a group: the little label that follows the pointer */
.drag-ghost {
  position: fixed; top: -100px; left: -100px; padding: 6px 12px; border-radius: 0;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 13px;
}

/* ---------------- small screens ---------------- */

@media (max-width: 1100px) {
  .cards { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(300px, 85vw);
    transform: translateX(-102%); transition: transform 0.2s ease; box-shadow: var(--shadow-lg);
  }
  .shell.menu-open .sidebar { transform: none; }
  .shell.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgb(0 0 0 / 0.35); }
  .only-mobile { display: inline-flex; }
  .view { padding: 0 12px calc(96px + env(safe-area-inset-bottom)); }
  .view-head { padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 10px; gap: 8px; flex-wrap: wrap; }
  .titles p { display: none; }
  #btn-new span, .search-kbd { display: none; }
  #btn-new { width: 42px; padding: 0; height: 42px; }
  .row { gap: 10px; padding-left: 10px; }
  .list .check-box { display: none; }
  .list.selecting .check-box { display: grid; }
  .row-actions { display: none; }
  .row-meta .tag, .row-meta .opens { display: none; }
  .row-meta .host { flex: 0 1 auto; }
  .grid-2 { grid-template-columns: 1fr; }

  .panes { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); height: calc(100vh - 150px - env(safe-area-inset-bottom)); }
  .pane-actions { flex-direction: row; justify-content: center; }
  .move-btn { flex-direction: row; width: auto; padding: 6px 14px; }
  .move-btn svg { transform: rotate(90deg); width: 16px; height: 16px; }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px;
    border: 0; background: none; color: var(--muted); font: inherit; font-size: 11px; font-weight: 550; cursor: pointer;
  }
  .tabbar svg { width: 21px; height: 21px; }
  .tabbar a.on { color: var(--accent-text); }
  .selbar { left: 50%; bottom: calc(70px + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(70px + env(safe-area-inset-bottom)); }
  body:has(.selbar:not([hidden])) .toasts { bottom: calc(130px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
