:root {
  --bg: #f6f6f4; --card: #ffffff; --text: #1d1d1f; --muted: #6e6e73;
  --line: #e2e2de; --accent: #2b6cb0; --hover: #eef2f7; --danger: #c53030;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618; --card: #1f1f22; --text: #ececee; --muted: #9a9aa0;
    --line: #2e2e33; --accent: #6aa5e8; --hover: #2a2d33; --danger: #f07171;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 860px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
h1 { font-size: 22px; margin: 0; }
button, .button, input, select {
  font: inherit; color: inherit; border: 1px solid var(--line); background: var(--card);
  border-radius: 8px; padding: 7px 12px;
}
button, .button { cursor: pointer; }
button:hover, .button:hover { background: var(--hover); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.error { color: var(--danger); min-height: 1.4em; }

#login form { display: grid; gap: 12px; max-width: 360px; margin-top: 24px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
label input, label select { color: var(--text); font-size: 15px; width: 100%; }

header { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
header #search { flex: 1 1 200px; min-width: 0; }
.tools { display: flex; gap: 8px; }
.menu { position: relative; }
.menu summary { list-style: none; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; background: var(--card); }
.menu summary::-webkit-details-marker { display: none; }
.menu > div {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; display: grid; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-width: 240px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.menu > div > * { text-align: left; border: 0; }
#meta { color: var(--muted); font-size: 13px; margin: 10px 2px; }

.root { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px; margin-bottom: 14px; }
.root > h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 6px 8px; }
ul { list-style: none; margin: 0; padding: 0 0 0 18px; }
.root > ul { padding-left: 0; }
.row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 7px; min-height: 34px; }
.row:hover { background: var(--hover); }
.row a, .row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); text-decoration: none; }
.row a:hover { color: var(--accent); }
.row .path { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.badge {
  flex: none; width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: #fff; background: var(--accent);
}
.folder > .row { cursor: pointer; font-weight: 500; }
.folder > .row .badge { background: none; color: var(--muted); font-size: 14px; }
.folder.closed > ul { display: none; }
.actions { display: flex; gap: 2px; opacity: 0; }
.row:hover .actions, .row:focus-within .actions { opacity: 1; }
@media (hover: none) { .actions { opacity: .7; } }
.actions button { border: 0; background: none; padding: 2px 6px; color: var(--muted); }
.empty { color: var(--muted); padding: 6px 8px; font-size: 13px; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); width: min(460px, calc(100vw - 32px)); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog form { display: grid; gap: 12px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 6px 0 0; padding: 0; }
