:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #333333;
  --line: #c4c9d0;
  --accent: #1f3a5f;
  --accent-fg: #ffffff;
  --sel: #dbe7f7;
  --hit: #fff1a8;
  --btn: #e9edf3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --fg: #f2f2f2;
    --muted: #d0d4da;
    --line: #3a3f47;
    --accent: #8db4ee;
    --accent-fg: #0b1220;
    --sel: #23324a;
    --hit: #6b5b00;
    --btn: #272c33;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--fg);
  font: 17px/1.35 system-ui, sans-serif;
  padding-top: env(safe-area-inset-top);
}
header { padding: 8px 10px 4px; border-bottom: 1px solid var(--line); }
.top { display: flex; gap: 8px; }
#search { flex: 1; min-width: 0; }
input, textarea, button {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
}
input { padding: 10px 12px; }
button { padding: 10px 12px; background: var(--btn); min-height: 44px; }
button:active { filter: brightness(0.9); }
#crumbs { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 0 2px; }
#crumbs:empty { display: none; }
#crumbs button { min-height: 36px; padding: 4px 10px; }

main { flex: 1; overflow-y: auto; padding: 6px 6px 40vh; -webkit-overflow-scrolling: touch; }
.row { display: flex; align-items: flex-start; }
.node { border-radius: 6px; }
.node.sel > .row { background: var(--sel); }
.chev, .dot {
  flex: none; width: 36px; min-height: 40px; border: 0; background: none;
  padding: 0; color: var(--accent); font-size: 18px; line-height: 40px; text-align: center;
}
.dot { font-size: 22px; }
.kids { margin-left: 18px; border-left: 1px solid var(--line); }
.txt {
  flex: 1; min-width: 0; border: 0; background: transparent; border-radius: 6px;
  padding: 8px 6px; resize: none; overflow: hidden; line-height: 1.3;
}
.txt:focus { outline: 2px solid var(--accent); }
.badge { flex: none; align-self: center; color: var(--muted); font-size: 14px; padding: 0 8px; }
mark { background: var(--hit); color: inherit; }
.empty { padding: 24px 12px; color: var(--muted); }

footer { border-top: 1px solid var(--line); background: var(--bg); padding-bottom: env(safe-area-inset-bottom); }
#status { padding: 4px 12px; min-height: 26px; font-size: 14px; color: var(--muted); }
#bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 4px 8px 8px; }
#bar button { white-space: nowrap; padding: 6px 4px; min-height: 40px; }
#bar button[data-act="delete"] { color: #b00020; }
@media (prefers-color-scheme: dark) { #bar button[data-act="delete"] { color: #ff8a9b; } }

dialog {
  width: min(92vw, 520px); max-height: 86vh; overflow: auto;
  border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  background: var(--bg); color: var(--fg);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog h2 { margin: 0 0 10px; font-size: 20px; }
dialog > button { display: block; width: 100%; margin: 6px 0; text-align: left; }
dialog .plain { background: none; text-align: center; }
#menuInfo { color: var(--muted); font-size: 14px; }
#pickSearch, #pasteBox { width: 100%; margin-bottom: 8px; }
#pasteBox { padding: 8px; }
#pickList { max-height: 50vh; overflow-y: auto; }
#pickList button { display: block; width: 100%; text-align: left; margin: 3px 0; }
.row .plain { width: auto; }
dialog .row { gap: 8px; }
