:root {
  --accent: #1f7a5a;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ea;
  --bg: #ffffff;
  --bg-side: #f6f6f4;
  --bg-list: #fbfbfa;
  --bg-hover: #efefec;
  --bg-active: #e3f1ea;
  --border: #e4e4e0;
  --text: #1d1d1b;
  --muted: #6d6d68;
  --faint: #a3a39d;
  --danger: #b4372f;
  --mark: #fff0a6;
  --code-bg: #f3f3f0;
  --shadow: 0 8px 28px rgba(0,0,0,.14), 0 1px 3px rgba(0,0,0,.08);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #3fb68b; --accent-ink: #0d1f18; --accent-soft: #183a2e;
    --bg: #1b1b1a; --bg-side: #222221; --bg-list: #1f1f1e; --bg-hover: #2c2c2a; --bg-active: #183a2e;
    --border: #353532; --text: #ebebe6; --muted: #a0a09a; --faint: #6b6b66; --danger: #ef7a70;
    --mark: #6a5a12; --code-bg: #2a2a28; --shadow: 0 8px 28px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent: #3fb68b; --accent-ink: #0d1f18; --accent-soft: #183a2e;
  --bg: #1b1b1a; --bg-side: #222221; --bg-list: #1f1f1e; --bg-hover: #2c2c2a; --bg-active: #183a2e;
  --border: #353532; --text: #ebebe6; --muted: #a0a09a; --faint: #6b6b66; --danger: #ef7a70;
  --mark: #6a5a12; --code-bg: #2a2a28; --shadow: 0 8px 28px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.danger { color: var(--danger) !important; }
kbd { font: 11px var(--mono); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--bg); }
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico.faint { color: var(--faint); }

#app { display: grid; grid-template-columns: 250px 340px 1fr; height: 100vh; overflow: hidden; }

/* ---------- sidebar ---------- */
#sidebar { background: var(--bg-side); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 16px; padding: 16px 16px 10px; letter-spacing: -.01em; }
.search-wrap { position: relative; margin: 4px 12px 10px; }
.search-wrap .ico { position: absolute; left: 9px; top: 9px; color: var(--muted); }
#search { width: 100%; padding: 7px 30px 7px 30px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); outline: none; }
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#search-help-btn { position: absolute; right: 4px; top: 4px; }
.primary-btn { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 12px 10px; padding: 8px 12px; border: 0; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.primary-btn:hover { filter: brightness(1.07); }
#nav { flex: 1; overflow-y: auto; padding: 0 6px 12px; min-height: 0; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 6px; color: var(--text); text-decoration: none; cursor: pointer; user-select: none; position: relative; }
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { background: var(--bg-active); color: var(--accent); font-weight: 600; }
.nav-item .count { margin-left: auto; color: var(--faint); font-size: 12px; font-weight: 400; }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nav-item .row-menu { display: none; margin-left: 4px; }
.nav-item:hover .row-menu { display: inline-flex; }
.nav-item:hover .count { display: none; }
.nav-item.trash { margin-top: 10px; }
.section-head { display: flex; align-items: center; gap: 6px; margin: 14px 4px 4px; padding: 0 6px; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); cursor: pointer; user-select: none; }
.section-head .caret { width: 14px; height: 14px; display: inline-flex; transition: transform .15s; }
.section-head.collapsed .caret { transform: rotate(-90deg); }
.section-head .add { margin-left: auto; }
.mini-filter { margin-left: auto; width: 82px; font-size: 11px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--bg); text-transform: none; letter-spacing: 0; font-weight: 400; }
.collapsible.collapsed { display: none; }
.sub-list .nav-item { padding-left: 34px; font-size: 13px; }

.stack .children { margin-left: 14px; }
.stack.closed .children { display: none; }

#tag-list .nav-item { font-size: 13px; padding: 4px 10px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.ghost-btn { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 6px; padding: 5px 10px; text-decoration: none; font-size: 13px; }
.ghost-btn:hover { background: var(--bg-hover); }
.ghost-btn.small { padding: 3px 8px; font-size: 12px; }
.icon-btn { border: 0; background: transparent; border-radius: 6px; padding: 4px 7px; color: var(--muted); line-height: 1; font-size: 16px; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.small { font-size: 12px; padding: 3px 7px; }
.icon-btn.on { color: #d49b00; }

/* ---------- list ---------- */
#list-pane { background: var(--bg-list); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.list-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; padding: 16px 14px 10px; border-bottom: 1px solid var(--border); }
.list-title-wrap { min-width: 0; flex: 1; }
#list-title { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#list-sub { font-size: 12px; flex-basis: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
#sort { border: 1px solid var(--border); background: var(--bg); border-radius: 6px; padding: 3px 4px; font-size: 12px; }
.search-error { margin: 8px 12px 0; padding: 6px 10px; border-radius: 6px; background: #fdecea; color: var(--danger); font-size: 12px; }
#note-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; outline: none; }
.note-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.note-item:hover { background: var(--bg-hover); }
.note-item.active { background: var(--bg-active); box-shadow: inset 3px 0 0 var(--accent); }
.note-item .txt { flex: 1; min-width: 0; }
.note-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.note-item .m { color: var(--faint); font-size: 11.5px; margin-top: 4px; display: flex; gap: 8px; overflow: hidden; white-space: nowrap; }
.note-item .m .nb { overflow: hidden; text-overflow: ellipsis; }
.note-item .thumb { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; flex: none; border: 1px solid var(--border); background: var(--bg); }
.note-item mark, .note-body mark.hl { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.load-more { padding: 12px; text-align: center; }
.empty { display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px; color: var(--muted); }
.empty.big { height: 100%; }

/* ---------- editor ---------- */
#editor-pane { display: flex; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
#editor { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.editor-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.crumb { display: flex; align-items: center; gap: 6px; color: var(--muted); }
#note-notebook { border: 0; background: transparent; color: var(--muted); font-size: 13px; max-width: 230px; padding: 2px; border-radius: 5px; }
#note-notebook:hover { background: var(--bg-hover); }
.tags-input { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; flex: 1; min-width: 140px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 4px 1px 9px; font-size: 12px; }
.chip button { border: 0; background: transparent; color: inherit; padding: 0 4px; font-size: 13px; line-height: 1; opacity: .7; }
.chip button:hover { opacity: 1; }
#tag-entry { border: 0; outline: none; background: transparent; font-size: 12.5px; min-width: 80px; flex: 1; padding: 2px; }
.top-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
#save-state { margin-right: 6px; min-width: 44px; text-align: right; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 190px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 5px; font-size: 13px; }
.menu button:hover { background: var(--bg-hover); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.floating-menu { position: fixed; }
.banner { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: #fff5e0; color: #6b4b00; border-bottom: 1px solid var(--border); font-size: 13px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .banner { background: #3a2f12; color: #f0d48a; } }
.toolbar { display: flex; align-items: center; gap: 2px; padding: 6px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar button { border: 0; background: transparent; border-radius: 5px; min-width: 28px; height: 28px; padding: 0 6px; color: var(--text); font-size: 13px; }
.toolbar button:hover { background: var(--bg-hover); }
.toolbar button.on { background: var(--accent-soft); color: var(--accent); }
.toolbar select { border: 1px solid var(--border); background: var(--bg); border-radius: 5px; font-size: 12.5px; padding: 3px; }
.toolbar .sep { width: 1px; height: 18px; background: var(--border); margin: 0 5px; }
.hl-swatch { background: var(--mark); padding: 0 4px; border-radius: 3px; }
.doc-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.doc { max-width: 880px; margin: 0 auto; padding: 26px 40px 120px; }
.note-title { width: 100%; border: 0; outline: none; background: transparent; font-size: 28px; font-weight: 700; letter-spacing: -.02em; padding: 0; margin-bottom: 14px; }
.note-title::placeholder { color: var(--faint); }
.note-body { outline: none; min-height: 50vh; font-size: 15px; line-height: 1.6; word-wrap: break-word; overflow-wrap: anywhere; }
.note-body:empty::before { content: "Start writing…"; color: var(--faint); }
.note-body img { max-width: 100%; height: auto; border-radius: 4px; }
.note-body table { border-collapse: collapse; margin: 8px 0; max-width: 100%; }
.note-body td, .note-body th { border: 1px solid var(--border); padding: 5px 8px; vertical-align: top; min-width: 40px; }
.note-body pre { background: var(--code-bg); border-radius: 6px; padding: 10px 12px; font: 13px/1.5 var(--mono); white-space: pre-wrap; overflow-x: auto; }
.note-body code { background: var(--code-bg); border-radius: 4px; padding: 1px 4px; font: .9em var(--mono); }
.note-body pre code { background: none; padding: 0; }
.note-body blockquote { margin: 8px 0; padding: 2px 14px; border-left: 3px solid var(--border); color: var(--muted); }
.note-body h1 { font-size: 1.6em; margin: .8em 0 .3em; } .note-body h2 { font-size: 1.3em; margin: .8em 0 .3em; } .note-body h3 { font-size: 1.1em; margin: .8em 0 .3em; }
.note-body p { margin: 0 0 .6em; }
.note-body input[type="checkbox"] { width: 15px; height: 15px; margin: 0 7px 0 0; vertical-align: -2px; accent-color: var(--accent); cursor: pointer; }
.note-body a { cursor: pointer; }
.note-body .att-card { display: inline-flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px 9px 40px; margin: 6px 0; min-width: 240px; max-width: 100%; position: relative; background: var(--bg-list); user-select: none; }
.note-body .att-card::before { content: "📄"; position: absolute; left: 12px; top: 10px; font-size: 18px; }
.note-body .att-card[data-mime="application/pdf"]::before { content: "📕"; }
.note-body .att-card[data-mime^="audio"]::before { content: "🎵"; }
.note-body .att-card a { font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.note-body .att-card .att-meta { color: var(--muted); font-size: 12px; }
.note-body .en-crypt { color: var(--muted); }
.note-body .att-missing { color: var(--danger); font-size: 12px; }
.note-body.drag { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 4px; }
.editor-foot { padding: 6px 16px; border-top: 1px solid var(--border); display: flex; gap: 16px; flex-wrap: wrap; }
#info-panel { width: 290px; border-left: 1px solid var(--border); padding: 16px; overflow-y: auto; background: var(--bg-list); font-size: 13px; }
#info-panel h4 { margin: 0 0 10px; }
#info-panel dl { margin: 0; display: grid; grid-template-columns: 80px 1fr; gap: 6px 8px; }
#info-panel dt { color: var(--muted); }
#info-panel dd { margin: 0; word-break: break-word; }
#info-panel ul { padding-left: 16px; margin: 4px 0; }
#info-panel input { width: 100%; border: 1px solid var(--border); border-radius: 5px; padding: 4px 6px; background: var(--bg); font-size: 12px; }

/* ---------- popovers / modal / toast ---------- */
.popover { position: fixed; z-index: 50; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 14px 16px; width: 470px; max-width: calc(100vw - 24px); font-size: 13px; }
.popover h4 { margin: 0 0 8px; }
.popover table { border-collapse: collapse; width: 100%; }
.popover td { padding: 3px 6px 3px 0; vertical-align: top; }
.popover code { font: 12px var(--mono); background: var(--code-bg); padding: 1px 4px; border-radius: 4px; white-space: nowrap; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: var(--bg); border-radius: 12px; box-shadow: var(--shadow); width: 460px; max-width: 100%; padding: 20px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 12px; font-size: 17px; }
.modal label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
.modal input[type="text"], .modal select { width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.modal input:focus, .modal select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-actions .primary-btn { margin: 0; }
.modal .drop { border: 2px dashed var(--border); border-radius: 10px; padding: 20px; text-align: center; color: var(--muted); }
.modal .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.modal .pick-row { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.progress { height: 6px; background: var(--bg-hover); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.progress.indeterminate > div { width: 30%; animation: slide 1.1s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.import-log { font: 12px var(--mono); max-height: 140px; overflow-y: auto; background: var(--bg-list); border-radius: 6px; padding: 8px; white-space: pre-wrap; }
.picker-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; margin-top: 8px; }
.picker-list div { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--border); }
.picker-list div:hover, .picker-list div.sel { background: var(--bg-hover); }
.picker-list .nbname { color: var(--faint); font-size: 12px; margin-left: 6px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 13px; z-index: 200; box-shadow: var(--shadow); }

/* ---------- login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; background: var(--bg-side); }
.login-card { width: 320px; background: var(--bg); padding: 26px; border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.login-card .brand { padding: 0 0 18px; }
.login-card label { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.login-card input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 14px; background: var(--bg); }
.login-card .primary-btn { margin: 0; }
.login-error { color: var(--danger); font-size: 13px; margin: -6px 0 12px; }

/* ---------- print ---------- */
@media print {
  #sidebar, #list-pane, .editor-top, .toolbar, .editor-foot, #info-panel, .banner { display: none !important; }
  #app { display: block; height: auto; }
  .doc-scroll { overflow: visible; }
  .doc { padding: 0; max-width: none; }
}

/* ---------- responsive ---------- */
.mobile-only { display: none; }
@media (max-width: 1100px) {
  #app { grid-template-columns: 220px 290px 1fr; }
  #info-panel { position: absolute; right: 0; top: 0; bottom: 0; box-shadow: var(--shadow); z-index: 20; }
  .doc { padding: 22px 24px 100px; }
}
@media (max-width: 800px) {
  .mobile-only { display: inline-flex; }
  #app { grid-template-columns: 1fr; }
  #sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  #app.show-menu #sidebar { transform: none; }
  #app.show-list #editor-pane { display: none; }
  #app.show-editor #list-pane { display: none; }
  .doc { padding: 16px 16px 90px; }
  .note-title { font-size: 22px; }
}

/* ---------- security / sharing ---------- */
.user-row { width: 100%; margin-top: 4px; }
.user-btn { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; padding: 6px 4px; border-radius: 6px; text-align: left; }
.user-btn:hover { background: var(--bg-hover); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 650; font-size: 12px; flex: none; }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-size: 13px; }
.admin-pill { margin-left: auto; font-size: 10px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); border-radius: 99px; padding: 1px 7px; }
.admin-all-bar { margin: 0 12px 8px; padding: 5px 9px; border-radius: 6px; background: #fff5e0; color: #6b4b00; font-size: 12px; display: flex; align-items: center; gap: 6px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .admin-all-bar { background: #3a2f12; color: #f0d48a; } }
.admin-all-bar button { margin-left: auto; border: 0; background: transparent; color: inherit; text-decoration: underline; font-size: 12px; }
.nb-badge { color: var(--faint); font-size: 11px; flex: none; display: inline-flex; }
.nb-badge.shared-out { color: var(--accent); }
.banner.info { background: var(--accent-soft); color: var(--accent); }
.share-section { margin-top: 14px; }
.share-section h4 { margin: 0 0 6px; font-size: 13px; }
.share-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.share-row:last-child { border-bottom: 0; }
.share-row .who { flex: 1; min-width: 0; }
.share-row .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-row .who span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.share-row select { width: auto !important; padding: 4px 6px !important; font-size: 12.5px; }
.share-row .rm { border: 0; background: transparent; color: var(--muted); font-size: 16px; padding: 2px 6px; border-radius: 5px; }
.share-row .rm:hover { background: var(--bg-hover); color: var(--danger); }
.pkind { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--bg-hover); font-size: 14px; }
.dir-results { border: 1px solid var(--border); border-radius: 6px; margin-top: 4px; max-height: 220px; overflow-y: auto; }
.dir-results div { padding: 7px 10px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.dir-results div:hover { background: var(--bg-hover); }
.dir-results .muted { font-size: 12px; }
.org-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.org-row .who { flex: 1; }
.audit-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.audit-table th, .audit-table td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.audit-table td.d { color: var(--muted); word-break: break-word; }
.modal.wide { width: 860px; }
.ms-btn { display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; text-decoration: none; color: var(--text); font-weight: 600; background: var(--bg); }
.ms-btn:hover { background: var(--bg-hover); }
.login-card form { display: flex; flex-direction: column; }
.login-card .check { display: flex; align-items: center; gap: 6px; margin: 0 0 14px; }
.login-card .check input { margin: 0; }
.dev-warn { background: #fdecea; color: var(--danger); border-radius: 6px; padding: 6px 8px; font-size: 12px; margin-bottom: 12px; }
.org-row .who b { display: block; font-weight: 600; }
.org-row .who span { display: block; }
.org-row select, .share-row select { width: auto !important; flex: none; }
.perm-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.perm-bar input { flex: 1; min-width: 200px; width: auto !important; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: var(--bg); padding: 5px 10px; font-size: 12.5px; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button span { color: var(--faint); margin-left: 3px; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.perm-wrap { max-height: 58vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.perm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.perm-table th { position: sticky; top: 0; background: var(--bg-side); text-align: left; font-size: 11.5px; font-weight: 650; color: var(--muted); padding: 7px 10px; border-bottom: 1px solid var(--border); }
.perm-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.perm-table tbody tr { cursor: pointer; }
.perm-table tbody tr:hover { background: var(--bg-hover); }
.perm-table .num { text-align: right; white-space: nowrap; }
.pchip { display: inline-block; margin: 0 4px 4px 0; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--bg-hover); white-space: nowrap; }
.pchip.edit { background: var(--accent-soft); color: var(--accent); }
.pchip.org { background: #fff5e0; color: #6b4b00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pchip.org { background: #3a2f12; color: #f0d48a; } }
.modal.wide { width: 1000px; }

/* expand / collapse chevrons */
.caret svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.stack > .nav-item { padding-left: 4px; }
.stack > .nav-item .caret { display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 22px; height: 22px; padding: 3px; margin-right: -4px; border: 0; border-radius: 5px; background: transparent;
  color: var(--text); opacity: .75; cursor: pointer; transition: transform .15s, background .15s, opacity .15s; }
.stack > .nav-item .caret:hover { background: var(--border); opacity: 1; }
.stack.closed > .nav-item .caret { transform: rotate(-90deg); }
.stack .children { margin-left: 22px; border-left: 1px solid var(--border); padding-left: 2px; }
.nb-badge.hd { font-size: 9.5px; font-weight: 700; letter-spacing: .03em; color: #fff; background: #4f6bd6; border-radius: 4px; padding: 0 4px; line-height: 15px; margin-left: 2px; }
.pchip.hd { background: #e6ebfb; color: #3a50b0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pchip.hd { background: #232b4a; color: #a9b8f2; } }
.modal .hd-opt { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; margin: 0 0 8px; cursor: pointer; color: var(--text) !important; font-size: 14px !important; }
.hd-opt input { margin-top: 3px; }
.hd-opt b { display: block; font-weight: 600; }
.hd-opt span span { display: block; }
.hd-warn { border-radius: 6px; margin: 0 0 4px; }
