/* ===== Theme tokens ===== */
:root[data-theme='dark'] {
  --bg: #1e1e1e;
  --bg-alt: #262626;
  --bg-sidebar: #1a1a1a;
  --bg-elevated: #2c2c2c;
  --border: #363636;
  --text: #dcddde;
  --text-muted: #8a8f98;
  --accent: #7c6cf6;
  --accent-hover: #9286f8;
  --danger: #e5534b;
  --row-hover: #2f2f2f;
  --row-selected: #34304d;
  --shadow: rgba(0, 0, 0, 0.4);
  --graph-edge: #6b7180;
  --graph-edge-active: #9286f8;
}
:root[data-theme='light'] {
  --bg: #ffffff;
  --bg-alt: #f6f7f9;
  --bg-sidebar: #f1f2f4;
  --bg-elevated: #ffffff;
  --border: #e1e3e8;
  --text: #2e3338;
  --text-muted: #6b7280;
  --accent: #6c5ce7;
  --accent-hover: #5a4bd4;
  --danger: #d63b30;
  --row-hover: #e9ebef;
  --row-selected: #e4e0fb;
  --shadow: rgba(0, 0, 0, 0.12);
  --graph-edge: #9aa1ad;
  --graph-edge-active: #6c5ce7;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
    Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: var(--app-font-size, 15px);
  line-height: 1.5;
}

/* High-contrast mode: stronger text/border, dimmer muted text gap closed. */
:root[data-contrast='high'][data-theme='dark'] {
  --text: #ffffff;
  --text-muted: #c4c8d0;
  --border: #5a5a5a;
}
:root[data-contrast='high'][data-theme='light'] {
  --text: #000000;
  --text-muted: #444b54;
  --border: #9aa1ad;
}

button { font: inherit; cursor: pointer; }
a { color: var(--accent); }

/* ===== Auth pages ===== */
.auth-page {
  /* Grid centering (not flex) so a card taller than the viewport — e.g. the
     register storage step on small screens — stays fully scrollable instead of
     being clipped at the top. */
  display: grid;
  place-items: center;
  padding: 24px;
  min-height: 100vh;
  min-height: 100dvh;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 8px 30px var(--shadow);
}
.auth-lang { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.auth-logo {
  display: block;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 20px;
  color: var(--accent);
  text-decoration: none;
}
.auth-logo:hover { text-decoration: underline; }
.auth-form h2 { margin: 0 0 14px; font-size: 18px; }
.auth-form label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-form input[type='text'],
.auth-form input[type='password'],
.auth-form input[type='search'] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.auth-alt { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-muted); }
.muted { color: var(--text-muted); font-size: 13px; }
.notice {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 13px;
}
.form-error { color: var(--danger); font-size: 13px; margin: 0 0 12px; }

/* --- Bring-your-own storage form (register step + dashboard section) --- */
.storage-form { margin: 6px 0 4px; min-width: 0; }
/* Example URLs in the help text are long and unbreakable — let them wrap so the
   form never forces horizontal overflow on narrow screens. */
.storage-form p, .settings-hint, .settings-callout { overflow-wrap: anywhere; }
.storage-form .muted { line-height: 1.5; }
.storage-form .small { font-size: 12px; }
.storage-form a { color: var(--accent); word-break: break-word; }
.storage-type {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 12px 0 14px;
}
.storage-type-opt {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}
.storage-type-opt input { flex: none; }
.storage-driver-fields[hidden] { display: none; }
.modal-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
}
.modal-checkbox input { flex: none; margin-top: 2px; }
.storage-test-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
.storage-test-status {
  flex: 1 1 100%;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}
.storage-test-status.ok { color: #2e9e5b; }
.storage-test-status.fail { color: var(--danger); }
.storage-test-status.pending { color: var(--text-muted); }

.storage-help-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.storage-help-links a { color: var(--accent); }
.support-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 18px 0;
}

.storage-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 22px 0 6px;
}
.storage-option-card {
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 12px;
  padding: 18px 20px;
  background: var(--panel, rgba(255, 255, 255, 0.02));
  text-align: left;
}
.storage-option-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}
.storage-option-card p {
  margin: 0 0 6px;
  opacity: 0.9;
  line-height: 1.5;
}
.deploy-note {
  margin: 10px 0 4px;
  font-size: 0.88rem;
  opacity: 0.8;
  line-height: 1.5;
}
.deploy-pay {
  font-weight: 600;
  opacity: 0.95;
}
.deploy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.opt-soon {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  border: 1px solid var(--border, #2a2a2a);
  background: var(--accent-soft, rgba(120, 130, 255, 0.14));
  opacity: 0.85;
  vertical-align: middle;
}

@media (max-width: 480px) {
  .auth-page { padding: 12px; }
  .auth-card { padding: 18px; border-radius: 10px; }
  .storage-type { flex-direction: column; gap: 10px; }
}
.recovery-key-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin: 14px 0;
}
.recovery-key {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
  letter-spacing: 1px;
  font-weight: 600;
  word-break: break-all;
  user-select: all;
  color: var(--text);
  text-align: center;
  line-height: 1.6;
}
.recovery-key-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}
.recovery-key-actions .btn-ghost { width: auto; }
.recovery-confirm {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 14px;
  cursor: pointer;
}
.recovery-confirm input[type='checkbox'] { margin-top: 2px; flex: none; }
.btn-primary {
  width: 100%;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
}
.btn-ghost:hover { background: var(--row-hover); }
.btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.icon-btn { display: inline-flex; align-items: center; justify-content: center; }

.totp-qr {
  display: block;
  width: 200px;
  height: 200px;
  margin: 8px auto 16px;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
}
.totp-secret {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.totp-secret code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  letter-spacing: 1px;
  word-break: break-all;
}

/* ===== App layout ===== */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 40;
}
.brand { font-weight: 700; color: var(--accent); white-space: nowrap; }
.lang-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
}
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 6px;
}
.icon-btn:hover { background: var(--row-hover); }
#sidebar-toggle { display: none; }
.mobile-back { display: none; }

/* The topbar only holds a magnifier trigger; search itself is a centered
   overlay so it is reliably visible on every screen size (the old inline
   dropdown was clipped/hidden behind content on mobile). */
.search-open-btn { margin-right: auto; }

/* Anchored near the top so the results list grows downward without shifting
   the search bar. Scoped with .modal-overlay for specificity over the base
   overlay rule. The base rule also supplies the backdrop + z-index. */
.modal-overlay.search-overlay {
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px 16px;
}
.search-panel {
  width: 100%;
  max-width: 560px;
  /* Cap height so the panel + results always fit the viewport and the inner
     results list scrolls instead of the whole page. */
  max-height: min(80vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px var(--shadow);
  overflow: hidden;
  animation: modal-pop 0.12s ease-out;
}
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  flex: none;
  border-bottom: 1px solid var(--border);
}
#search-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0; /* allow shrinking inside flex so it never collapses */
  padding: 9px 12px;
  font-size: 15px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
#search-input:focus { outline: none; border-color: var(--accent); }
/* Small fixed-size icon trigger on the right; never grows to fill the bar. */
.search-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.search-btn:hover { background: var(--accent-hover); }
.search-btn:disabled { opacity: 0.6; cursor: default; }
.search-filters {
  flex: none;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  max-height: 30vh;
  overflow-y: auto;
}
.search-filters-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.search-filters-none { font-size: 12px; color: var(--text-muted); }
.search-filters-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.search-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.search-chip .bi { font-size: 11px; opacity: 0.7; }
.search-chip:hover { border-color: var(--accent); }
/* Active = this folder is excluded from the search. */
.search-chip.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.search-chip.active .bi { opacity: 1; }
.search-results {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.search-hit {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
}
.search-hit:hover { background: var(--row-hover); }
.search-hit-name { font-weight: 600; font-size: 13px; }
.search-hit-snippet { font-size: 12px; color: var(--text-muted); }
.search-empty { padding: 10px 12px; color: var(--text-muted); font-size: 13px; }
.search-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  color: var(--text-muted);
  font-size: 13px;
}
.search-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: search-spin 0.7s linear infinite;
  flex: 0 0 auto;
}
@keyframes search-spin { to { transform: rotate(360deg); } }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.user:hover { background: var(--row-hover); color: var(--text); }

.layout { display: flex; flex: 1; min-height: 0; position: relative; }

.sidebar {
  width: var(--sidebar-width, 280px);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
}
.sidebar-resizer {
  flex: 0 0 5px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s ease;
  position: relative;
  z-index: 5;
}
.sidebar-resizer:hover,
.sidebar-resizer.dragging {
  background: var(--accent, var(--border));
}
body.sidebar-resizing {
  cursor: col-resize;
  user-select: none;
}
.sidebar-tools-head {
  padding: 4px 8px 0;
  flex: 0 0 auto;
}
.tools-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 4px;
  cursor: pointer;
  border-radius: 6px;
}
.tools-toggle:hover { background: var(--row-hover); color: var(--text); }
.tools-toggle-caret { transition: transform 0.15s ease; }
.sidebar.tools-collapsed .tools-toggle-caret { transform: rotate(-90deg); }
.sidebar.tools-collapsed .sidebar-tools,
.sidebar.tools-collapsed .tools-resizer { display: none; }
.sidebar-tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  max-height: 45vh;
  overflow-y: auto;
}
.tools-resizer {
  flex: 0 0 6px;
  cursor: row-resize;
  background: transparent;
  transition: background 0.15s ease;
  position: relative;
  z-index: 5;
}
.tools-resizer:hover,
.tools-resizer.dragging { background: var(--accent); }
body.tools-resizing { cursor: row-resize; user-select: none; }
.tool-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tool-group-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 2px;
}
.tool-group-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tool-group-btns button {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  white-space: nowrap;
}
.tool-group-btns button:hover { background: var(--row-hover); }
.selected-folder {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  white-space: nowrap;
}

/* ===== Breadcrumb ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.crumb {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}
.crumb-root { display: inline-flex; align-items: center; }
.crumb-current { color: var(--text); font-weight: 600; }
.crumb-link { cursor: pointer; }
.crumb-link:hover { color: var(--accent); text-decoration: underline; }
.crumb-sep { font-size: 9px; color: var(--text-muted); opacity: 0.7; }

.tree { overflow: auto; padding: 6px; flex: 1; }
.tree ul { list-style: none; margin: 0; padding-left: 14px; }
.tree > ul { padding-left: 0; }

/* Obsidian-style indent guide lines for nested folders */
.tree-children { position: relative; }
.tree-children > ul { position: relative; }
.tree-children > ul::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 6px;
  width: 1px;
  background: var(--border);
  transition: background 0.15s ease;
}
.tree-children > ul:hover::before { background: var(--accent); }
.tree-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 6px;
  padding: 3px 6px;
}
.tree-row:hover { background: var(--row-hover); }
.tree-row.selected { background: var(--row-selected); }
/* Files that are open as tabs get a subtle accent; the active tab is bolder. */
.tree-row.tab-open .tree-name { color: var(--text); }
.tree-row.tab-active { background: var(--row-selected); }
.tree-row.tab-active .tree-name { color: var(--accent); font-weight: 600; }
.tree-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  font-size: 14px;
  min-width: 0;
}
.tree-name { overflow: hidden; text-overflow: ellipsis; }
.tree-icon { font-size: 14px; color: var(--text-muted); flex-shrink: 0; }
.tree-icon-dir { color: var(--accent); }
.caret {
  display: inline-block;
  width: 12px;
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.row-menu {
  background: transparent;
  border: none;
  color: var(--text-muted);
  opacity: 0;
  padding: 0 6px;
  border-radius: 4px;
}
.tree-row:hover .row-menu { opacity: 1; }
.row-menu:hover { background: var(--bg-elevated); }

/* Drag & drop */
.tree-row.dragging { opacity: 0.45; }
.tree-row.drop-target {
  background: var(--row-selected);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}
.tree.drop-target-root {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  border-radius: 6px;
}

.context-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px var(--shadow);
  z-index: 60;
  overflow: hidden;
}
.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px 18px;
  font-size: 13px;
}
.context-menu button:hover { background: var(--row-hover); }
.context-menu .context-menu-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--border);
}
.context-menu button i { margin-right: 8px; color: var(--text-muted); }

/* Backdrop shown behind the centered context menu on small screens. */
.context-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 59;
}
.context-menu-backdrop[hidden] { display: none; }

/* ===== Content area ===== */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.welcome { margin: auto; text-align: center; color: var(--text-muted); }
.view { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }

/* ---------- open-file tabs (Obsidian-style) ---------- */
.tabbar {
  display: flex;
  align-items: stretch;
  gap: 2px;
  flex-shrink: 0;
  padding: 6px 8px 0;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.tabbar[hidden] { display: none; }
.tabbar::-webkit-scrollbar { height: 6px; }
.tabbar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.tab-count {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  align-self: center;
  position: sticky;
  left: 0;
  z-index: 1;
  margin-right: 4px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  cursor: default;
  user-select: none;
}
.tab-count.is-full {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}
.tab-count.is-clickable {
  cursor: pointer;
}
.tab-count.is-clickable:hover {
  border-color: var(--accent);
  color: var(--text);
}
.tab-count.is-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.max-tabs-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.max-tabs-row .modal-input {
  width: 96px;
  flex: 0 0 auto;
}
.max-tabs-row .btn-primary {
  width: auto;
  flex: 0 0 auto;
  white-space: nowrap;
}
@media (max-width: 480px) {
  .max-tabs-row {
    flex-wrap: wrap;
  }
}
.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 0;
  max-width: 200px;
  padding: 7px 8px 7px 11px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.tab:hover { background: var(--bg-alt); color: var(--text); }
.tab.active {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
.tab .tab-icon { flex-shrink: 0; font-size: 14px; }
.tab .tab-title { overflow: hidden; text-overflow: ellipsis; }
.tab .tab-dirty {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.tab .tab-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.65;
}
.tab .tab-close:hover { background: var(--border); opacity: 1; }

/* Per-tab panes that persist live DOM (viewer / excalidraw) so switching tabs
   never rebuilds them — iframes/canvases stay mounted, inactive panes hidden. */
.viewer-pane {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px;
  display: flex;
  justify-content: center;
}
.viewer-pane[hidden] { display: none; }
.viewer-pane img { max-width: 100%; height: auto; align-self: flex-start; }
.excalidraw-pane { position: absolute; inset: 0; }
.excalidraw-pane[hidden] { display: none; }
.excalidraw-pane .excalidraw { height: 100%; }
.view[hidden] { display: none; }
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  flex-shrink: 0;
}
.current-path {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.view-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
/* Header action buttons stay compact — the shared .btn-primary is chunky (it is
   width:100% in forms); size it down here so Save doesn't dwarf the toolbar. */
.view-actions .btn-primary,
.view-actions .btn-ghost {
  width: auto;
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
}
/* Let the breadcrumb shrink so the status + buttons always have room. */
.view-header .current-path { flex: 1 1 auto; min-width: 0; }

/* "Saved · 2 min ago" status shown next to the Save button. A coloured dot +
   readable label: green when saved, amber while there are unsaved changes or an
   autosave conflict. Truncates (never wraps) so it stays on one line at any
   width, including mobile. */
.save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
  flex-shrink: 1;
}
.save-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2e9e5b; /* saved */
  flex: none;
}
.save-status.is-unsaved {
  color: var(--warn, #b7791f);
  font-weight: 600;
}
.save-status.is-unsaved::before { background: var(--warn, #b7791f); }
@media (max-width: 560px) {
  /* Keep it visible on mobile but tighter, and let it shrink to just the dot
     (label ellipsised away) rather than pushing the Save button off-screen. */
  .save-status { font-size: 11.5px; max-width: 32vw; }
}

.editor-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.editor-surface { flex: 1; min-height: 0; display: flex; position: relative; }
.editor-surface > [hidden] { display: none; }

/* Wikilink autocomplete popup (anchored at the caret) */
.wikilink-suggest {
  position: absolute;
  z-index: 40;
  width: min(320px, 90vw);
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  -webkit-overflow-scrolling: touch;
}
.wikilink-suggest[hidden] { display: none; }
.wikilink-suggest-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  padding: 7px 9px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.wikilink-suggest-item.active,
.wikilink-suggest-item:hover { background: var(--bg-alt); }
.wikilink-suggest-name { font-size: 14px; }
.wikilink-suggest-path {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wikilink-suggest-empty { padding: 9px; font-size: 13px; color: var(--text-muted); }
@media (max-width: 600px) {
  .wikilink-suggest { width: min(360px, 94vw); max-height: 40vh; }
  .wikilink-suggest-item { padding: 10px 11px; } /* larger tap targets */
}

/* Markdown formatting toolbar (edit mode for .md files) */
.editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  flex-shrink: 0;
}
.editor-toolbar[hidden] { display: none; }
.md-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  padding: 5px 9px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.md-btn:hover { background: var(--bg); border-color: var(--border); }
.md-caret { font-size: 9px; color: var(--text-muted); }
.md-dropdown { position: relative; display: inline-flex; }
.md-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  min-width: 170px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.md-menu[hidden] { display: none; }
.md-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.md-menu-item:hover { background: var(--bg-alt); }
.md-menu-item .md-sample {
  color: var(--text-muted);
  font-family: 'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
}

/* ===== Web link manager ===== */
.weblinks-path {
  color: var(--text-muted);
  font-family: 'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
}
.weblinks-count { font-size: 12px; color: var(--text-muted); }
.weblinks-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  flex-shrink: 0;
}
.weblinks-toolbar .md-btn { border-color: var(--border); }
.weblinks-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
}
.weblinks-search-wrap input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  font-size: 13px;
  width: 180px;
}
.weblinks-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.weblinks-intro {
  margin: 0 0 16px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.weblinks-list { display: flex; flex-direction: column; gap: 8px; }
.weblink-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated, var(--bg-alt));
  border: 1px solid var(--border);
  border-radius: 10px;
}
.weblink-main { min-width: 0; flex: 1; }
.weblink-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
}
.weblink-name:hover { color: var(--accent); text-decoration: underline; }
.weblink-url {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.weblink-desc { margin: 6px 0 0; font-size: 13px; color: var(--text); line-height: 1.4; }
.weblink-tag {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.weblink-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  margin: 8px 0 0;
  font-size: 12px;
}
.weblink-meta dt { color: var(--text-muted); }
.weblink-meta dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.weblink-meta dd a { color: var(--accent); text-decoration: none; }
.weblink-meta dd a:hover { text-decoration: underline; }
.weblink-notes {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.weblink-actions { display: flex; gap: 4px; flex-shrink: 0; }
.weblinks-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 16px;
}
.weblinks-empty i { font-size: 40px; opacity: 0.5; }
.weblinks-empty p { margin: 12px 0 0; font-size: 14px; }
#editor {
  flex: 1;
  width: 100%;
  border: none;
  resize: none;
  padding: 20px;
  background: var(--bg);
  color: var(--text);
  font-family: 'SFMono-Regular', ui-monospace, 'Cascadia Code', Menlo, Consolas,
    monospace;
  font-size: 14px;
  line-height: 1.6;
  outline: none;
}
.preview {
  flex: 1;
  overflow: auto;
  padding: 20px 28px;
  background: var(--bg);
}

/* Markdown rendering */
.markdown h1, .markdown h2, .markdown h3 { line-height: 1.25; }
.markdown h1 { border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.markdown code {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.9em;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.markdown pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  overflow: auto;
}
.markdown pre code { background: transparent; padding: 0; border: 0; color: inherit; }
.markdown blockquote {
  border-left: 3px solid var(--accent);
  margin: 0;
  padding-left: 14px;
  color: var(--text-muted);
}
.markdown mark { background: #b59b1f; color: #f5f5f5; border-radius: 3px; padding: 0 2px; }
:root[data-theme='light'] .markdown mark { background: #fef3a4; color: #1a1a1a; }
.markdown img { max-width: 100%; border-radius: 6px; }
.markdown table { border-collapse: collapse; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 10px; }
.markdown a.wo-wikilink { color: var(--accent); text-decoration: none; border-bottom: 1px dashed var(--accent); }
.markdown a.wo-missing { color: var(--danger); border-bottom-color: var(--danger); }
.markdown iframe.wo-pdf { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: 8px; }
.markdown li.wo-task-item { list-style: none; margin-left: -1.4em; }
.markdown input.wo-task {
  margin-right: 8px;
  width: 16px;
  height: 16px;
  vertical-align: -2px;
  cursor: pointer;
  accent-color: var(--accent);
}

.viewer-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.pdf-frame { width: 100%; height: 100%; border: none; }

/* ===== Wikilink graph ===== */
.graph-body { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--bg); }
#graph-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#graph-canvas:active { cursor: grabbing; }
.graph-tooltip {
  position: absolute;
  z-index: 6;
  transform: translate(-50%, -150%);
  pointer-events: auto;
}
.graph-tooltip[hidden] { display: none; }
.graph-tooltip button {
  max-width: 220px;
  padding: 6px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}
.graph-tooltip button:hover { background: var(--accent-hover); }
.graph-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}
.graph-empty[hidden] { display: none; }
.graph-empty .bi { font-size: 40px; opacity: 0.5; }
.graph-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  max-width: 90%;
  padding: 6px 12px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
  text-align: center;
}
@media (min-width: 768px) {
  /* Pointer devices get hover tooltips, so the touch hint is unnecessary. */
  .graph-hint { display: none; }
}

.excalidraw-root { flex: 1; min-height: 0; position: relative; }
.excalidraw-root .excalidraw { height: 100%; }
/* ===== Mobile sidebar ===== */
.sidebar-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 20;
}

@media (max-width: 800px) {
  #sidebar-toggle { display: inline-block; }
  .brand { display: none; }
  /* Allow the topbar to scroll horizontally so the account and logout
     controls stay reachable when they don't fit on narrow screens. */
  .topbar {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar::-webkit-scrollbar { display: none; }
  .topbar > * { flex-shrink: 0; }
  /* Phones: use the full width and start higher so the on-screen keyboard
     leaves room for results. */
  .modal-overlay.search-overlay { padding: 4vh 10px 10px; }
  .search-panel { max-height: 88vh; }
  .search-bar { padding: 10px; gap: 6px; }
  #search-input { font-size: 16px; } /* >=16px stops iOS zoom-on-focus */
  .mobile-back { display: inline-flex; align-items: center; }
  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(280px, 85vw);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 20px var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-resizer { display: none; }
  .btn-label { display: none; }
  /* Give the drawing canvas a guaranteed height so it stays editable on mobile. */
  .excalidraw-root { min-height: 70vh; min-height: 70dvh; }
  /* Same for the Kanban board: keep columns tall + scrollable on tablet/mobile. */
  .kanban-root { min-height: 70vh; min-height: 70dvh; }

  /* Tabs: momentum scroll, hide the scrollbar, finger-friendly hit targets. */
  .tabbar {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 5px 6px 0;
  }
  .tabbar::-webkit-scrollbar { display: none; }
  .tab {
    max-width: 60vw;
    padding: 9px 8px 9px 12px;
    font-size: 14px;
  }
  .tab .tab-close { width: 26px; height: 26px; }

  /* Centered, finger-friendly context menu on phones. */
  .context-menu.context-menu-centered {
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%);
    width: min(320px, calc(100vw - 48px));
    max-height: 80vh;
    max-height: 80dvh;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: 0 16px 48px var(--shadow);
  }
  .context-menu.context-menu-centered button { padding: 14px 18px; font-size: 15px; }

  /* Landing top navbar on narrow screens: let the actions wrap onto a second
     row so every link stays visible (no hidden horizontal scroll), and shrink
     the controls so they fit. */
  .landing-nav { flex-wrap: wrap; gap: 8px 6px; padding: 12px 16px; }
  .landing-brand { flex-shrink: 0; }
  .landing-nav-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }
  .landing-nav-actions > * { flex-shrink: 0; white-space: nowrap; }
  .landing-nav-actions .btn-ghost,
  .landing-nav-actions .btn-primary { padding: 6px 10px; font-size: 13px; }
}

@media (max-width: 480px) {
  /* Very narrow: stack brand over a full-width, left-aligned action row that
     wraps freely. */
  .landing-nav { flex-direction: column; align-items: stretch; }
  .landing-nav-actions { justify-content: flex-start; width: 100%; }
}

/* ===== Flash toast ===== */
.flash {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 18px;
  border-radius: 20px;
  box-shadow: 0 6px 20px var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  /* Must sit ABOVE the upload panel overlay (.wo-up-overlay, z-index 1000) so
     errors like a reached upload/quota limit are never hidden behind it. */
  z-index: 1100;
}
.flash.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Loading overlay ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Must sit BELOW modal-overlay (z-index 100). If the spinner stacks above an
     alert, it covers the OK button so the alert can never be dismissed and the
     spinner hangs forever (e.g. an import error). */
  z-index: 90;
}
.loading-overlay[hidden] { display: none; }
.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 30px;
  box-shadow: 0 16px 48px var(--shadow);
}
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading-text { font-size: 13px; color: var(--text-muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Determinate progress overlay (export / delete of large folders). Reuses the
   loading-box look but shows a real bar + counts instead of a bare spinner. */
.progress-box { min-width: 280px; max-width: min(420px, 90vw); }
.progress-box .loading-text { font-size: 14px; color: var(--text); font-weight: 600; }
.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 6px;
  background: var(--bg-alt);
  overflow: hidden;
}
.progress-track > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s ease;
}
/* Indeterminate state (total unknown yet): an animated sliding sweep. */
.progress-track.indeterminate > i {
  width: 35%;
  animation: progress-sweep 1.1s ease-in-out infinite;
}
@keyframes progress-sweep {
  0% { margin-left: -35%; }
  100% { margin-left: 100%; }
}
.progress-sub { font-size: 12px; color: var(--text-muted); }
/* Inline spinning icon (e.g. on a button while an action is in progress). */
.spin { display: inline-block; animation: spin 0.7s linear infinite; }

/* ===== Import options ===== */
.import-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
.import-option {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 2px;
  align-items: center;
  text-align: left;
  padding: 14px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.import-option:hover { border-color: var(--accent); background: var(--row-hover); }
.import-option > i {
  grid-row: 1 / span 2;
  font-size: 22px;
  color: var(--accent);
}
.import-option-title { font-weight: 600; font-size: 14px; }
.import-option-desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.import-limit-note { margin: 16px 0 0; text-align: center; }

/* ---------- modal dialog ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-overlay[hidden] { display: none; }
/* Opens on top of the account dashboard overlay, which shares z-index 100. */
#change-password-overlay,
#reset-totp-overlay { z-index: 110; }
.modal {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px var(--shadow);
  padding: 20px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: modal-pop 0.12s ease-out;
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.modal-message {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.modal-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 16px;
}
.modal-input:focus {
  outline: none;
  border-color: var(--accent);
}
.modal-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.modal-error {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--danger, #e5484d);
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal-actions .btn-primary,
.modal-actions .btn-ghost {
  width: auto;
  padding: 8px 16px;
}
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
}
.btn-danger:hover { background: var(--danger); filter: brightness(1.1); }

/* ===== Trash view ===== */
.trash-list {
  max-height: 50vh;
  overflow-y: auto;
  margin: 6px 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.trash-empty-msg {
  padding: 26px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.trash-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.trash-row:last-child { border-bottom: none; }
.trash-row > .ti { color: var(--text-muted); flex: none; font-size: 16px; }
.trash-row .meta { flex: 1; min-width: 0; }
.trash-row .tname {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trash-row .tpath {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trash-row .tdate { font-size: 11px; color: var(--text-muted); flex: none; }
.trash-row .trestore {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 12px;
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.trash-row .trestore:hover { border-color: var(--accent); color: var(--accent); }
.trash-row .trestore:disabled { opacity: 0.5; cursor: default; }
/* Keep the delete-account button small to avoid accidental clicks. */
#delete-account-btn {
  width: auto;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  gap: 5px;
}

/* ---------- account dashboard / settings (Firefox-style) ---------- */
/* Kept for backwards compatibility with any remaining markup. */
.dashboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.dashboard-head .modal-title { margin: 0; }

/* The settings dialog is a wide two-pane shell, not the small centered modal. */
.settings-overlay { padding: 0; }
.settings-modal {
  width: 100%;
  max-width: 980px;
  /* As a flex item, default min-width:auto would let long unbreakable text
     (e.g. example URLs in the storage help) push the modal wider than the
     viewport, shoving inputs off-screen on mobile. Allow it to shrink. */
  min-width: 0;
  height: 100%;
  max-height: 100%;
  margin: auto;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: 0 16px 48px var(--shadow);
  overflow: hidden;
  animation: modal-pop 0.12s ease-out;
}
@media (min-width: 700px) {
  .settings-overlay { padding: 24px; }
  .settings-modal {
    /* A DEFINITE height (not auto) so the grid tracks bound the body and it
       scrolls internally — and so the window keeps a constant size whichever
       section is open (no jump between short/tall panes). */
    height: min(760px, calc(100dvh - 48px));
    border-radius: 14px;
  }
}

/* --- left nav --- */
.settings-nav {
  display: flex;
  flex-direction: column;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
}
.settings-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
.settings-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-search-wrap {
  position: relative;
  margin-bottom: 12px;
}
.settings-search-wrap .bi {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}
#settings-search {
  width: 100%;
  padding: 8px 10px 8px 30px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}
#settings-search:focus { outline: none; border-color: var(--accent); }
.settings-nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
}
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.settings-nav-item[hidden] { display: none; }
.settings-nav-item .bi { color: var(--text-muted); font-size: 16px; flex: none; }
.settings-nav-item:hover { background: var(--bg-elevated); }
.settings-nav-item.active { background: var(--accent); color: #fff; }
.settings-nav-item.active .bi { color: #fff; }
.settings-version {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* --- right body --- */
.settings-body {
  padding: 22px 26px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  min-width: 0;
}
.settings-back {
  display: none;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 6px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.settings-pane { display: none; }
.settings-pane.active { display: block; }
.settings-pane-title {
  margin: 0 0 18px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.settings-group {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.settings-group:first-of-type { border-top: none; padding-top: 0; }
.settings-group-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
}
.settings-group-title .bi { color: var(--text-muted); }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.settings-row + .settings-row { margin-top: 14px; }
.settings-label { color: var(--text-muted); font-size: 14px; }
.settings-value { color: var(--text); font-size: 14px; font-weight: 600; word-break: break-word; }
.settings-hint {
  margin: 6px 0 10px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}
.settings-inline-btn { width: auto; display: inline-flex; }

/* contact-email row with a copy button (General + Plan) */
.email-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}
.email-row-inline { vertical-align: middle; }
.email-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 13px;
  word-break: break-all;
}
.email-link:hover { border-color: var(--accent); }
.email-copy {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
}
.email-copy:hover { border-color: var(--accent); color: var(--accent); }
.email-copy.copied { color: #2e9e5b; border-color: #2e9e5b; }

/* connection status badge */
.storage-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.storage-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  flex: none;
}
.storage-status.is-connected { border-color: #1f8b4c55; background: #1f8b4c1a; }
.storage-status.is-connected .storage-status-dot { background: #1f8b4c; box-shadow: 0 0 0 3px #1f8b4c33; }
.storage-status.is-disconnected { border-color: #d9930b55; background: #d9930b1a; }
.storage-status.is-disconnected .storage-status-dot { background: #d9930b; box-shadow: 0 0 0 3px #d9930b33; }

/* callout boxes */
.settings-callout {
  display: flex;
  gap: 9px;
  padding: 11px 13px;
  margin: 10px 0 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
}
.settings-callout .bi { flex: none; margin-top: 2px; }
.settings-callout-warn { border-color: #d9930b55; background: #d9930b14; }
.settings-callout-warn .bi { color: #d9930b; }

/* theme switch */
.theme-switch { display: inline-flex; gap: 10px; flex-wrap: wrap; }
.theme-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.theme-opt:hover { border-color: var(--accent); }
.theme-opt.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.settings-no-results {
  display: none;
  text-align: center;
  color: var(--text-muted);
  padding: 40px 16px;
}
.settings-no-results .bi { font-size: 28px; opacity: 0.5; }
.settings-no-results p { margin: 8px 0 0; font-size: 14px; }

/* search mode: show every pane, hide non-matching groups */
.settings-body.is-searching .settings-pane { display: block; }
.settings-body.is-searching .settings-pane[data-empty] { display: none; }
.settings-body.is-searching .settings-group.is-hidden { display: none; }
.settings-body.is-searching .settings-back { display: none !important; }

/* mobile: single column, slide between nav and pane; modal itself scrolls */
@media (max-width: 699px) {
  .settings-modal {
    display: block;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .settings-nav { border-right: none; border-bottom: 1px solid var(--border); }
  .settings-body { padding: 18px; }
  .settings-modal.pane-open .settings-nav { display: none; }
  .settings-modal:not(.pane-open) .settings-body { display: none; }
  .settings-modal:not(.pane-open) .settings-nav { display: flex; }
  /* While searching, show the aggregated results below the nav search box. */
  .settings-modal:not(.pane-open) .settings-body.is-searching { display: block; }
  .settings-back { display: inline-flex; }
  .settings-body.is-searching .settings-back { display: none !important; }
}

.usage-bar {
  width: 100%;
  height: 10px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.usage-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.usage-fill.warn { background: #d9930b; }
.usage-fill.full { background: var(--danger); }
.usage-text {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text);
}
.danger-zone .dashboard-subtitle,
.danger-zone .settings-group-title { color: var(--danger); }

/* ===== Landing & legal pages ===== */
.landing-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.btn-inline { width: auto; }
.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.landing-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}
.landing-nav-actions { display: flex; align-items: center; gap: 10px; }
.landing-main {
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}
.hero { text-align: center; padding: 40px 0 48px; }
.hero h1 {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.15;
  margin: 0 0 18px;
}
.hero-lead {
  max-width: 640px;
  margin: 0 auto 28px;
  font-size: 17px;
  color: var(--text-muted);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.landing-section { padding: 36px 0; border-top: 1px solid var(--border); }
.landing-section h2 { font-size: 24px; margin: 0 0 10px; }
.section-lead { color: var(--text-muted); margin: 0 0 24px; max-width: 680px; }
.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.compare-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.compare-card h3 { margin: 0 0 8px; font-size: 17px; }
.compare-card p { margin: 0; color: var(--text-muted); font-size: 14px; }
.feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.feature-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
}
.feature-list li i { color: var(--accent); font-size: 18px; flex-shrink: 0; }
.capacity-notice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 6px 12px;
  margin-top: 14px;
}
.landing-cta {
  text-align: center;
  padding: 44px 0 8px;
  border-top: 1px solid var(--border);
}
.landing-cta h2 { font-size: 24px; margin: 0 0 20px; }

/* Legal pages (imprint / privacy) */
.legal { max-width: 720px; margin: 0 auto; }
.legal h1 { font-size: 30px; margin: 8px 0 16px; }
.legal-section { padding: 18px 0; border-top: 1px solid var(--border); }
.legal-section h2 { font-size: 19px; margin: 0 0 10px; }
.legal-section p { margin: 0 0 12px; }
.legal-section ul { margin: 0 0 12px; padding-left: 20px; color: var(--text-muted); }
.legal-section li { margin-bottom: 6px; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.footer-love { margin: 0 0 10px; }
.footer-heart { color: var(--danger); }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
}
.footer-dot { opacity: 0.5; }
.footer-dev {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
}
.footer-dev-title { font-weight: 600; opacity: 0.85; }
.footer-dev img { display: block; height: 20px; }
.settings-dev-badge { display: inline-block; margin: 4px 0 8px; }
.settings-dev-badge img { display: block; height: 20px; }
.footer-disclaimer {
  max-width: 640px;
  margin: 0 auto;
  font-size: 12px;
  opacity: 0.85;
}
.footer-version {
  margin: 12px 0 0;
  font-size: 12px;
  opacity: 0.6;
}
.dashboard-version {
  margin: 16px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.7;
}

/* ===== Plans & billing ===== */
.plan-cards {
  display: grid;
  gap: 10px;
  margin: 14px 0 16px;
}
.plan-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.15s, background 0.15s;
}
.plan-card:hover { background: var(--row-hover); }
.plan-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--row-selected);
}
.plan-card input { margin-right: 8px; }
.plan-card-title { font-weight: 600; }
.plan-card-desc {
  display: block;
  margin-top: 4px;
  margin-left: 24px;
  font-size: 13px;
  color: var(--text-muted);
}

.plan-options {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}
/* The display:grid rule above otherwise overrides the `hidden` attribute, so
   the upgrade area stayed visible even for privileged/paid users. */
.plan-options[hidden] { display: none; }
.plan-btn[hidden] { display: none; }

.plan-warning {
  border: 1px solid var(--accent);
  background: var(--row-selected);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}
.plan-warning.danger {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}
#manage-billing-btn { margin-top: 4px; }

/* ===== Syntax highlighting (highlight.js theme, theme-aware) ===== */
.markdown pre.hljs,
.preview pre.hljs,
pre.code-file {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  overflow: auto;
  color: var(--text);
}
pre.code-file {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}
pre.code-file code,
pre.hljs code { background: transparent; padding: 0; }
.hljs-comment, .hljs-quote { color: var(--text-muted); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal,
.hljs-section, .hljs-doctag, .hljs-name, .hljs-strong { color: #c678dd; }
.hljs-string, .hljs-regexp, .hljs-addition,
.hljs-attribute, .hljs-meta .hljs-string { color: #98c379; }
.hljs-number, .hljs-bullet, .hljs-symbol, .hljs-link { color: #d19a66; }
.hljs-title, .hljs-title.function_, .hljs-built_in,
.hljs-class .hljs-title { color: #61afef; }
.hljs-attr, .hljs-variable, .hljs-template-variable,
.hljs-type, .hljs-selector-class, .hljs-selector-attr,
.hljs-selector-pseudo { color: #e5c07b; }
.hljs-tag, .hljs-deletion { color: #e06c75; }
.hljs-emphasis { font-style: italic; }
:root[data-theme='light'] .hljs-keyword,
:root[data-theme='light'] .hljs-selector-tag,
:root[data-theme='light'] .hljs-literal,
:root[data-theme='light'] .hljs-section,
:root[data-theme='light'] .hljs-name { color: #a626a4; }
:root[data-theme='light'] .hljs-string,
:root[data-theme='light'] .hljs-regexp,
:root[data-theme='light'] .hljs-addition,
:root[data-theme='light'] .hljs-attribute { color: #50a14f; }
:root[data-theme='light'] .hljs-number,
:root[data-theme='light'] .hljs-bullet,
:root[data-theme='light'] .hljs-symbol { color: #b76b01; }
:root[data-theme='light'] .hljs-title,
:root[data-theme='light'] .hljs-title.function_,
:root[data-theme='light'] .hljs-built_in { color: #4078f2; }
:root[data-theme='light'] .hljs-attr,
:root[data-theme='light'] .hljs-variable,
:root[data-theme='light'] .hljs-type,
:root[data-theme='light'] .hljs-selector-class { color: #986801; }
:root[data-theme='light'] .hljs-tag,
:root[data-theme='light'] .hljs-deletion { color: #e45649; }

/* ===== Office document viewer (Word / Excel / OpenDocument) ===== */
.viewer-pane .office-doc { width: 100%; max-width: 900px; }
.office-doc .wo-docx,
.office-doc .wo-odt {
  background: #ffffff;
  color: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 2px 12px var(--shadow);
}
.office-doc .wo-odt h1,
.office-doc .wo-odt h2,
.office-doc .wo-odt h3 { margin-top: 1em; }
.office-doc .wo-sheet { margin-bottom: 24px; overflow-x: auto; }
.office-doc .wo-sheet-title {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.office-doc .wo-sheet table {
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg-elevated);
}
.office-doc .wo-sheet th,
.office-doc .wo-sheet td {
  border: 1px solid var(--border);
  padding: 5px 9px;
  white-space: nowrap;
  color: var(--text);
}

/* ===== EPUB e-book reader ===== */
/* Fill the whole viewer pane; the reader handles its own internal layout. */
.viewer-pane:has(> .epub-reader) { padding: 0; overflow: hidden; }
.epub-reader {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  outline: none;
  /* Always a bright "paper" page so the book's dark text stays readable even
     in the app's dark theme. Side gutters keep text clear of the nav buttons. */
  background: #ffffff;
  padding: 0 56px;
}
.epub-area { flex: 1; min-width: 0; height: 100%; background: #ffffff; }
.epub-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid #d5d7dc;
  border-radius: 50%;
  background: #ffffff;
  color: #1a1a1a;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.85;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  transition: opacity 0.15s ease;
}
.epub-nav:hover { opacity: 1; }
.epub-prev { left: 10px; }
.epub-next { right: 10px; }

/* Tablet: tighter gutters. */
@media (max-width: 900px) {
  .epub-reader { padding: 0 46px; }
}

/* Mobile: smaller buttons + gutters so single-column text keeps full width. */
@media (max-width: 560px) {
  .epub-reader { padding: 0 34px; }
  .epub-nav { width: 30px; height: 30px; font-size: 1rem; }
  .epub-prev { left: 4px; }
  .epub-next { right: 4px; }
}

/* ===== Documentation page ===== */
.legal.docs { max-width: 820px; }
.docs h1 i { color: var(--accent); }
.docs-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 28px;
  padding: 14px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.docs-toc a { color: var(--accent); text-decoration: none; font-size: 14px; }
.docs-toc a:hover { text-decoration: underline; }
.docs-quote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 16px;
  font-style: italic;
  color: var(--text);
}
.docs-architecture {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 8px 0 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
}
.docs-table-wrap { margin: 8px 0 18px; }
.docs-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
.docs-table th,
.docs-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.docs-table th {
  background: var(--surface-2, rgba(127, 127, 127, 0.08));
  font-weight: 600;
}
.docs-table code { white-space: nowrap; }
.docs-warning {
  border-left: 3px solid #d9822b;
  background: rgba(217, 130, 43, 0.08);
  padding: 12px 16px;
  border-radius: 8px;
  margin: 12px 0;
}
.docs-note {
  border-left: 3px solid var(--accent);
  background: var(--bg-alt);
  padding: 12px 16px;
  border-radius: 8px;
  margin: 12px 0;
  font-size: 14px;
  color: var(--text-muted);
}

/* Category tab bar (User Documentation / Architecture / Self-Hosting) */
.docs-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 24px;
  padding: 5px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: sticky;
  top: 8px;
  z-index: 5;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.docs-tabs::-webkit-scrollbar { display: none; }
.docs-tab {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  padding: 10px 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.docs-tab .bi { font-size: 16px; }
.docs-tab:hover { color: var(--text); }
.docs-tab.active {
  background: var(--bg);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
/* Category panels: only the active one is shown */
.docs-cat { display: none; }
.docs-cat.active { display: block; animation: docsFade 0.18s ease; }
@keyframes docsFade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 560px) {
  /* Icons only would be too terse; keep labels but let the bar scroll. */
  .docs-tab { flex: 1 0 auto; padding: 9px 12px; font-size: 13px; }
  .docs-tabs { top: 0; border-radius: 10px; }
}

/* Docs code blocks: wrap on desktop, scroll (not overflow) on mobile */
.docs pre {
  position: relative;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  /* extra top padding leaves room for the copy button so it never overlaps code */
  padding: 40px 14px 12px;
  margin: 10px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* One-click copy button, pinned top-right of each code block. Always visible
   (not hover-gated) with a solid, high-contrast chip in both themes. */
.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: filter 0.15s ease, background 0.15s ease;
}
.code-copy:hover { filter: brightness(1.08); }
.code-copy.copied {
  background: var(--bg);
  color: var(--accent);
  border-color: var(--accent);
}
.docs pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  color: var(--text);
}
.docs p code,
.docs li code {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  word-break: break-word;
}

@media (max-width: 560px) {
  .docs-cta { padding: 12px 14px; font-size: 14px; }
  .docs-cta .bi:first-child { font-size: 18px; }
  .docs pre code { font-size: 12px; }
}

/* ===== Landing: notice + pricing ===== */
.text-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.text-link:hover { text-decoration: underline; }
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.pricing-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  text-align: center;
}
.pricing-card.featured { border-color: var(--accent); }
.pricing-card h3 { margin: 0 0 8px; font-size: 18px; }
.pricing-amount { font-size: 22px; font-weight: 700; color: var(--accent); margin: 0 0 8px; }
.pricing-period { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.pricing-desc { margin: 0; color: var(--text-muted); font-size: 14px; }
.pricing-grid-two {
  grid-template-columns: repeat(2, minmax(180px, 260px));
  justify-content: center;
}
@media (max-width: 480px) {
  .pricing-grid-two { grid-template-columns: 1fr; }
}
.pricing-note {
  max-width: 560px;
  margin: 16px auto 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.pricing-contact { margin-top: 20px; }

/* ===== Copy button on highlighted code blocks ===== */
pre.hljs.has-copy { position: relative; }
.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
pre.hljs.has-copy:hover .code-copy,
.code-copy:focus-visible { opacity: 1; }
.code-copy:hover { color: var(--text); border-color: var(--accent); }
.code-copy.copied { color: #2ecc71; border-color: #2ecc71; opacity: 1; }
@media (hover: none) {
  .code-copy { opacity: 1; }
  /* No hover on touch — keep the tab close button fully visible. */
  .tab .tab-close { opacity: 1; }
}

/* ===== Drop target highlight on the markdown editor ===== */
.editor-body.drop-target-editor {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}




/* ===== Calendar ===== */
.calendar-view { min-height: 0; }
.calendar-body {
  padding: 12px 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.calendar-intro {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}
.calendar-month-label {
  font-weight: 600;
  min-width: 9ch;
  text-align: center;
}
.calendar-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar-dow-cell {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar-cell {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  min-height: 54px;
}
.calendar-cell:hover { background: var(--row-hover); }
.calendar-cell.is-other-month { opacity: 0.4; }
.calendar-cell.is-today { border-color: var(--accent); }
.calendar-cell.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.calendar-cell.has-files { background: color-mix(in srgb, var(--accent) 12%, var(--bg-elevated)); }
.calendar-day-num { font-size: 12px; font-weight: 600; }
.calendar-count {
  position: absolute;
  right: 5px;
  bottom: 5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-radius: 9px;
}
.calendar-daylist {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.calendar-daylist-title { margin: 0; font-size: 14px; }
.calendar-daylist-files { display: flex; flex-direction: column; gap: 4px; }
.calendar-file {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  word-break: break-all;
}
.calendar-file:hover { background: var(--row-hover); border-color: var(--border); }
.calendar-daylist-empty { color: var(--text-muted); font-size: 13px; margin: 0; }

/* ===== Template picker ===== */
.template-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
  max-height: 50vh;
  overflow-y: auto;
}
.template-option {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
.template-option:hover { background: var(--row-hover); border-color: var(--accent); }
.template-option i { color: var(--accent); }

/* ===== Settings inline input row ===== */
.settings-row-input {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.settings-inline-input { width: 100%; max-width: 320px; }

@media (max-width: 640px) {
  .calendar-cell { min-height: 34px; padding: 4px; }
  .calendar-count { min-width: 15px; height: 15px; font-size: 10px; }
  .settings-inline-input { max-width: 100%; }
}

/* ===== PDF reader (pdf.js) ===== */
.viewer-pane:has(> .pdf-viewer) { padding: 0; overflow: hidden; }
.pdf-viewer {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
}
.pdf-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: auto;
  padding: 16px 12px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--bg-alt, #1b1b1b);
}
.pdf-page {
  position: relative;
  flex: 0 0 auto;
  max-width: 100%;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}
.pdf-canvas { display: block; }
.pdf-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}
.pdf-zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
}
.pdf-zoom-btn:hover { background: rgba(255, 255, 255, 0.18); }
.pdf-zoom-label {
  min-width: 44px;
  text-align: center;
  color: #fff;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.pdf-page-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  z-index: 2;
}

/* ---------- Kanban board ---------- */
.kanban-root {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}
.kanban-pane {
  height: 100%;
}
.kanban-board {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-height: 100%;
}
.kanban-col {
  flex: 0 0 280px;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  max-height: 100%;
}
.kanban-col-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.kanban-col-title {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  padding: 4px 6px;
}
.kanban-col-title:hover {
  border-color: var(--border);
}
.kanban-col-title:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-elevated);
}
.kanban-col-count {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding: 0 4px;
}
.kanban-col-del {
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
}
.kanban-col-del:hover {
  color: #e5534b;
}
.kanban-cards {
  flex: 1;
  min-height: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-radius: 8px;
  transition: background 0.12s ease;
}
.kanban-cards.drag-over {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.kanban-empty {
  font-size: 12px;
  padding: 8px 6px;
  text-align: center;
}
.kanban-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  word-break: break-word;
}
.kanban-card:hover {
  border-color: var(--accent);
}
.kanban-card.dragging {
  opacity: 0.5;
}
.kanban-card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.kanban-card-desc {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: pre-wrap;
}
.kanban-card-edit {
  cursor: default;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kanban-edit-title,
.kanban-edit-desc {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 8px;
  box-sizing: border-box;
  resize: vertical;
}
.kanban-edit-title:focus,
.kanban-edit-desc:focus {
  outline: none;
  border-color: var(--accent);
}
.kanban-edit-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.kanban-edit-actions .btn-primary {
  flex: 1;
}
.kanban-edit-del {
  color: #e5534b;
}
.kanban-add-card,
.kanban-add-col {
  margin-top: 8px;
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px;
  cursor: pointer;
}
.kanban-add-card:hover,
.kanban-add-col:hover {
  border-color: var(--accent);
  color: var(--text);
}
.kanban-col-add {
  background: transparent;
  border: none;
  padding: 0;
}
.kanban-col-add .kanban-add-col {
  margin-top: 0;
}
@media (max-width: 640px) {
  .kanban-root {
    padding: 10px;
  }
  .kanban-col {
    flex-basis: 82vw;
    max-width: 82vw;
  }
}

/* ---------- Kanban card meta (due date + links) ---------- */
.kanban-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
}
.kanban-due {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--text);
  white-space: nowrap;
}
.kanban-due.is-overdue {
  background: color-mix(in srgb, #e5534b 24%, transparent);
  color: #ffd7d3;
}
.kanban-cardlink {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--accent);
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kanban-cardlink:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.kanban-edit-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--text-muted);
}
.kanban-edit-link,
.kanban-edit-url,
.kanban-edit-due {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 8px;
  box-sizing: border-box;
}
.kanban-edit-link:focus,
.kanban-edit-url:focus,
.kanban-edit-due:focus {
  outline: none;
  border-color: var(--accent);
}
.calendar-file.calendar-due i {
  color: var(--accent);
}

/* ---------- Kanban editor: linked-note row (dropdown + create button) ---------- */
.kanban-edit-linkrow {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.kanban-edit-linkrow .kanban-edit-link {
  flex: 1;
  min-width: 0;
}
.kanban-edit-newnote {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  cursor: pointer;
}
.kanban-edit-newnote:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.kanban-edit-newnote:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- Kanban column drag-reordering ---------- */
.kanban-col-grip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  cursor: grab;
  padding: 0 2px;
  font-size: 15px;
  line-height: 1;
}
.kanban-col-grip:active {
  cursor: grabbing;
}
.kanban-col-grip:hover {
  color: var(--text);
}
.kanban-col.col-dragging {
  opacity: 0.5;
}
/* Insertion cue: a bright bar on the side the column will drop into. */
.kanban-col.col-drop-before {
  box-shadow: inset 3px 0 0 var(--accent);
}
.kanban-col.col-drop-after {
  box-shadow: inset -3px 0 0 var(--accent);
}

/* ===== end-to-end encrypted chat ===================================== */

.chat-root {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}
.chat-root-pane {
  flex: 1;
  min-height: 0;
  display: flex;
}
.chat-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.chat-title {
  font-weight: 600;
  color: var(--text);
}
.chat-status {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
}
.chat-status.online {
  background: #3fb950;
}
.chat-status.offline {
  background: var(--danger);
}
.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-msg {
  display: flex;
  max-width: 100%;
}
.chat-msg.in {
  justify-content: flex-start;
}
.chat-msg.out {
  justify-content: flex-end;
}
.chat-bubble {
  max-width: min(78%, 560px);
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.chat-msg.out .chat-bubble {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chat-text {
  white-space: pre-wrap;
}
.chat-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  display: block;
}
.chat-file {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-align: left;
  text-decoration: underline;
}
.chat-file-size {
  opacity: 0.7;
  font-size: 0.85em;
}
.chat-meta {
  margin-top: 4px;
  font-size: 0.72rem;
  opacity: 0.7;
}
.chat-typing {
  padding: 2px 16px 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex: 0 0 auto;
}
.chat-error {
  margin: 0 14px 6px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 0.85rem;
  flex: 0 0 auto;
}
.chat-composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}
.chat-icon-btn,
.chat-send {
  flex: 0 0 auto;
  height: 38px;
  min-width: 38px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  font-size: 1.05rem;
}
.chat-send {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chat-icon-btn:hover {
  background: var(--row-hover);
}
.chat-send:hover {
  background: var(--accent-hover);
}
.chat-input {
  flex: 1 1 auto;
  min-width: 0;
  resize: none;
  max-height: 160px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
}

/* chat settings toggle */
.settings-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  color: var(--text);
}
.settings-check input {
  margin-top: 3px;
  flex: 0 0 auto;
}

/* vault-file picker (sits above modals, below the flash toast) */
.wo-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  padding: 16px;
}
.wo-picker {
  width: min(560px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px var(--shadow);
  overflow: hidden;
}
.wo-picker-title {
  padding: 14px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.wo-picker-search {
  margin: 12px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.wo-picker-list {
  overflow-y: auto;
  padding: 0 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wo-picker-item {
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
  font: inherit;
  word-break: break-all;
}
.wo-picker-item:hover {
  background: var(--row-hover);
}
.wo-picker-group {
  padding: 10px 16px 4px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.wo-picker-empty {
  padding: 8px 16px 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.wo-launcher-row {
  display: flex;
  gap: 8px;
  margin: 8px 12px 4px;
  align-items: stretch;
}
.wo-launcher-input {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}
/* The shared .btn-primary is width:100% — override so the button hugs its
   label instead of eating the whole row and squashing the input to zero. */
.wo-launcher-start {
  width: auto;
  flex: 0 0 auto;
  white-space: nowrap;
}
@media (max-width: 480px) {
  .wo-launcher-row {
    flex-wrap: wrap;
  }
  .wo-launcher-start {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .chat-bubble {
    max-width: 88%;
  }
  .chat-log {
    padding: 12px;
  }
}

/* chat: header actions, privacy note, delete + file actions */
.chat-header-spacer {
  flex: 1 1 auto;
}
.chat-clear {
  height: 32px;
  min-width: 32px;
  font-size: 0.95rem;
}
.chat-note {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.76rem;
  color: var(--text-muted);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.chat-msg {
  align-items: center;
  gap: 6px;
}
.chat-msg-del {
  flex: 0 0 auto;
  order: 2;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease;
  padding: 4px;
  font-size: 0.9rem;
  border-radius: 6px;
}
.chat-msg.out .chat-msg-del {
  order: 0;
}
.chat-msg:hover .chat-msg-del {
  opacity: 0.75;
}
.chat-msg-del:hover {
  opacity: 1;
  color: var(--danger);
  background: var(--row-hover);
}
.chat-msg .chat-bubble {
  order: 1;
}
.chat-file-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.chat-file-btn {
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  border-radius: 7px;
  padding: 3px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  opacity: 0.9;
}
.chat-file-btn:hover {
  opacity: 1;
}

/* Touch devices have no hover — keep the per-message delete reachable */
@media (hover: none) {
  .chat-msg-del {
    opacity: 0.55;
  }
}

/* chat: image actions + block list (settings) */
.chat-img-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.chat-block-add {
  display: flex;
  gap: 8px;
  margin: 8px 0;
  align-items: stretch;
}
.chat-block-add .modal-input {
  flex: 1 1 auto;
  min-width: 0;
}
/* the shared .btn-primary is width:100% — keep the Block button compact so it
   sits inline next to the input at every width */
.chat-block-add .btn-primary {
  width: auto;
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 9px 16px;
}
.chat-block-item .btn-ghost {
  flex: 0 0 auto;
  padding: 4px 12px;
}
.chat-block-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-block-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text);
}
