:root {
  color-scheme: light dark;
  --bg:#f4f6f1; --paper:#fff; --aside:#ebf0e9; --ink:#162e28; --muted:#4e635a;
  --line:#d3dfd6; --accent:#126348; --accent-ink:#fff; --soft:#dceee2; --top:#142f2d;
  --danger:#9d302d; --star:#845200; --shadow:0 14px 42px #17372c23;
  font: 100%/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme:dark) {
  :root {--bg:#111c18;--paper:#192823;--aside:#16251e;--ink:#edf5eb;--muted:#b5c8bd;--line:#3a5044;--accent:#9cdbb7;--accent-ink:#10251b;--soft:#284438;--top:#112b27;--danger:#ffa6a1;--star:#ffd07d;--shadow:0 14px 42px #0006;}
}
* {box-sizing:border-box}
[hidden] {display:none!important}
body {margin:0;background:var(--bg);color:var(--ink)}
a {color:var(--accent);text-underline-offset:.2em}
button,input,select {font:inherit;color:inherit}
button {cursor:pointer}
:focus-visible {outline:3px solid var(--accent);outline-offset:2px}
button:disabled {opacity:.55;cursor:wait}
h1,h2,p,ul {margin:0}
ul {list-style:none;padding:0}
button, .open, .tag, nav a {min-height:44px}
.visually-hidden,.skip:not(:focus) {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.skip {position:fixed;top:1rem;left:1rem;z-index:20;background:var(--paper);padding:.6rem}
.masthead {background:var(--top);color:#f4faf5}
.mast-inner {width:min(100%,100rem);margin:auto;padding:.45rem clamp(.8rem,3vw,2.8rem);min-height:64px;display:flex;align-items:center;justify-content:space-between;gap:.5rem;flex-wrap:wrap}
.brand {display:flex;align-items:center;gap:.55rem;font-weight:750;color:inherit;text-decoration:none;letter-spacing:-.025em;min-height:44px}
.brand>span {font-size:.73rem;letter-spacing:.02em;background:#d7eddf;color:#16382c;padding:.22rem .42rem;border-radius:.3rem}
.brand>span>span {color:#0d6e51}
.mast-actions {display:flex;align-items:center;gap:.5rem}
.mast-actions a,.mast-actions button {font-size:.84rem;padding:.25rem .55rem;min-height:44px;display:grid;place-items:center;color:inherit;background:none;border:0;text-decoration:none}
.mast-actions button:hover,.mast-actions a:hover {text-decoration:underline}
.masthead :focus-visible {outline-color:#b7f1ce}
.layout {display:grid;grid-template-columns:minmax(13.5rem,17rem) minmax(0,1fr);width:min(100%,100rem);margin:auto;align-items:start}
aside {position:sticky;top:0;align-self:start;max-height:100dvh;overflow:auto;padding:1.2rem .85rem 2rem;background:var(--aside);border-right:1px solid var(--line);scrollbar-width:thin}
aside section {margin-top:1rem;border-top:1px solid var(--line);padding-top:.35rem}
aside nav a,.tree-label {display:flex;align-items:center;gap:.55rem;padding:.4rem .6rem;border-radius:.55rem;color:var(--ink);text-decoration:none;min-width:0;overflow-wrap:anywhere;font-weight:620;font-size:.93rem}
aside nav a {justify-content:space-between}
aside a[aria-current="page"] {background:var(--soft);color:var(--accent)}
aside a:hover,.icon:hover, .view-switch button:hover {background:var(--soft)}
.side-heading {display:flex;justify-content:space-between;align-items:center;padding-left:.6rem}
.side-heading h2 {font-size:.82rem;font-weight:750;color:var(--muted)}
.side-heading button,.icon,.collapse,.node-edit {display:grid;place-items:center;width:44px;min-width:44px;padding:0;font-size:1.1rem;background:none;border:0;border-radius:.5rem}
.tree-row {display:flex;align-items:center}
.tree-label {min-height:44px;flex:1;padding-left:.3rem;line-height:1.2}
.tree-dot {color:var(--accent);font-weight:500}
.tree ul {margin-left:.55rem;border-left:1px solid var(--line);padding-left:.25rem}
.tree .collapse {width:32px;min-width:32px;color:var(--muted)}
.tree .node-edit {width:36px;min-width:36px;color:var(--muted)}
.tree .indent {flex:0 0 .35rem}
main:focus {outline:none}
main {min-width:0;padding:clamp(1rem,3vw,2.7rem);min-height:calc(100vh - 64px)}
.hero {display:flex;justify-content:space-between;align-items:flex-end;gap:1rem;flex-wrap:wrap;margin-bottom:1.2rem}
h1 {font-size:clamp(2rem,4.7vw,3.65rem);line-height:1.03;letter-spacing:-.065em;overflow-wrap:anywhere}
#scope-meta {margin-top:.55rem;color:var(--muted);font-size:.92rem;overflow-wrap:anywhere}
.view-switch {display:flex;gap:.2rem;padding:.2rem;background:var(--aside);border:1px solid var(--line);border-radius:.72rem}
.view-switch button {border:0;border-radius:.5rem;background:transparent;font-weight:650;padding:0 .8rem}
.view-switch button[aria-pressed=true] {background:var(--accent);color:var(--accent-ink)}
.filters {display:flex;align-items:stretch;gap:.5rem;flex-wrap:wrap}
#search-form {display:flex;flex:2 1 17rem;min-width:0}
#search {flex:1;min-width:0;padding:.58rem .75rem;border:1px solid var(--line);border-right:0;border-radius:.6rem 0 0 .6rem;background:var(--paper);font-size:1rem}
#search::-webkit-search-cancel-button {display:none}
#search-form button,.select-label {background:var(--paper);border:1px solid var(--line);min-height:44px}
#search-form button {border-radius:0 .6rem .6rem 0;min-width:44px;font-size:1.2rem}
.select-label {display:flex;align-items:center;border-radius:.6rem;padding:0 .35rem 0 .7rem}
.select-label span {font-size:.8rem;color:var(--muted)}
select {border:0;background:transparent;min-height:44px;padding:0 .35rem}
option {background:var(--paper);color:var(--ink)}
.result-bar {display:flex;justify-content:space-between;align-items:center;gap:.5rem;min-height:3rem;color:var(--muted);font-size:.87rem}
.result-bar button {padding:0 .4rem;border:0;background:none;color:var(--accent)}
.results {display:grid;gap:.6rem}
.card {min-width:0;border:1px solid var(--line);background:var(--paper);border-radius:.72rem;padding:.78rem .85rem}
.card-head {display:flex;align-items:flex-start;justify-content:space-between;min-width:0;gap:.35rem}
.card-head h2,.card summary h2 {font-size:1.07rem;line-height:1.3;letter-spacing:-.015em;overflow-wrap:anywhere}
.card-meta {font-size:.78rem;color:var(--muted);margin-bottom:.2rem;overflow-wrap:anywhere}
.card-summary {color:var(--muted);margin:.45rem 0 0;overflow-wrap:anywhere;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden}
.row-actions {display:flex;flex-shrink:0;align-items:center}
.star.active {color:var(--star)}
.grip {font-size:1.35rem;cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none}
body.dragging {cursor:grabbing;user-select:none;-webkit-user-select:none}
.row-links {display:flex;align-items:center;flex-wrap:wrap;column-gap:.45rem;margin-top:.2rem}
.open,.tag {display:inline-flex;align-items:center;text-decoration:none;font-size:.87rem;font-weight:680}
.open {margin-right:.25rem;padding-right:.4rem}
.tag {text-align:left;background:none;border:0;padding:0 .35rem;color:var(--accent);overflow-wrap:anywhere}
.tag:hover,.open:hover {text-decoration:underline}
.titles .card {padding:0 .85rem}
.card details {min-width:0;width:100%}
.card summary {display:list-item;cursor:pointer;padding:.62rem 0;min-height:52px;overflow-wrap:anywhere}
.card summary h2 {display:inline;color:var(--ink)}
.titles .card-head {position:relative}
.titles .card summary {padding-right:94px}
.titles .row-actions {position:absolute;top:.2rem;right:0}
.details-body {padding:0 .8rem .65rem 0}
.empty {border:1px dashed var(--line);padding:1.2rem;border-radius:.72rem;color:var(--muted)}
.more,.mobile-nav,.primary,.danger {border-radius:.55rem;border:1px solid var(--line);background:var(--paper);padding:.5rem .85rem;font-weight:650}
.more {margin:1rem 0}
#snapshot {margin-top:1.6rem;color:var(--muted);font-size:.79rem}
.mobile-nav {display:none}
dialog {width:min(35rem,calc(100% - 1.4rem));max-height:calc(100dvh - 1.4rem);overflow:auto;background:var(--paper);color:var(--ink);border:1px solid var(--line);border-radius:.9rem;padding:1rem;box-shadow:var(--shadow)}
dialog::backdrop {background:#071b17a0}
dialog header,dialog footer {display:flex;align-items:center;justify-content:space-between;gap:.5rem}
dialog h2 {font-size:1.35rem;line-height:1.25;overflow-wrap:anywhere}
dialog footer {justify-content:flex-end;margin-top:1rem}
#editor-fields {display:grid;gap:.7rem;margin-top:.7rem}
.field {display:grid;gap:.2rem;font-weight:600}
.field input,.field select {width:100%;min-height:44px;padding:.45rem .55rem;border:1px solid var(--line);border-radius:.5rem;background:var(--bg);font-size:1rem}
.tag-options {max-height:42dvh;overflow:auto;border:1px solid var(--line);border-radius:.5rem;padding:.35rem}
.tag-option {min-height:44px;display:flex;align-items:center;gap:.55rem;padding:.15rem .4rem;overflow-wrap:anywhere}
.tag-option input {width:1rem;height:1rem;accent-color:var(--accent);flex:none}
.tabs {display:flex;gap:.5rem;flex-wrap:wrap}
.tabs button {background:var(--bg);border:1px solid var(--line);border-radius:.5rem;padding:0 .55rem}
.tabs button[aria-pressed=true] {background:var(--soft);font-weight:700}
.primary {background:var(--accent);color:var(--accent-ink);border-color:transparent}
.danger,#editor-error,#load-error {color:var(--danger)}
#editor-error {margin-top:.7rem}
#message:not(:empty) {position:fixed;bottom:max(.7rem,env(safe-area-inset-bottom));right:.7rem;z-index:8;background:var(--top);color:#fff;padding:.7rem .9rem;max-width:calc(100% - 1.4rem);border-radius:.55rem;box-shadow:var(--shadow)}
#drop-panel {position:fixed;right:1rem;top:5rem;z-index:7;background:var(--paper);border:1px solid var(--accent);padding:.65rem;border-radius:.72rem;width:min(24rem,calc(100vw - 2rem));box-shadow:var(--shadow)}
#drop-title {font-weight:700;margin-bottom:.35rem}
#drop-targets {max-height:min(55dvh,31rem);overflow:auto}
.drop-zone {padding:.45rem .65rem;border-radius:.5rem;min-height:38px;overflow-wrap:anywhere;font-size:.87rem}
.drop-zone:hover,.drop-zone.over,.tree-label.over {background:var(--soft);outline:2px solid var(--accent);outline-offset:-2px}
.drop-label {font-size:.75rem;font-weight:730;color:var(--muted);padding:.4rem .65rem .1rem}
#drag-label {position:fixed;z-index:9;left:0;top:0;pointer-events:none;max-width:min(65vw,18rem);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:var(--top);color:#fff;border-radius:.35rem;padding:.3rem .55rem;font-size:.78rem}
@media (min-width:75rem) { .results.cards {grid-template-columns:repeat(2,minmax(0,1fr))} }
@media (max-width:49.99rem) {
  .layout {display:block}
  .filters {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
  #search-form {grid-column:1 / -1}
  .select-label span {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
  .select-label select {width:100%;min-width:0}
  .tree .collapse,.tree .node-edit {width:44px;min-width:44px}
  aside {display:none;position:static;max-height:none;border-right:0;border-bottom:1px solid var(--line)}
  aside[data-open=true] {display:block}
  .mobile-nav {display:flex;align-items:center;gap:.55rem;margin:.6rem .9rem 0}
  #drop-panel {top:auto;bottom:max(.55rem,env(safe-area-inset-bottom));right:.5rem;width:calc(100vw - 1rem)}
  #drop-targets {max-height:35dvh}
}
@media (max-width:24rem) {
  .mast-inner {padding-inline:.6rem}
  .mast-actions {gap:0}
  .mast-actions a,.mast-actions button {padding-inline:.3rem}
  main {padding-inline:.7rem}
  .view-switch button {padding-inline:.65rem}
  .card {padding-inline:.58rem}
}
.login-page {min-height:100dvh;display:grid;place-items:center;padding:1rem}
.login-panel {background:var(--paper);border:1px solid var(--line);border-radius:1rem;width:min(100%,28rem);min-height:0;padding:clamp(1.1rem,5vw,2.2rem);box-shadow:var(--shadow)}
.login-panel h1 {font-size:2.15rem;line-height:1.1}
.login-intro {color:var(--muted);margin:.7rem 0 1.3rem}
.login-form {display:grid;gap:.6rem}
.password-field {display:flex;background:var(--bg);border:1px solid var(--line);border-radius:.5rem}
.password-field input {min-width:0;flex:1;border:0;background:transparent;font-size:1rem;padding:.45rem .55rem}
.password-field button {display:grid;place-items:center;min-width:48px;border:0;background:transparent;border-radius:.5rem}
.remember {display:flex;align-items:center;gap:.6rem;min-height:48px}
.remember input {width:1.1rem;height:1.1rem;accent-color:var(--accent)}
.login-form>button {min-height:48px}
