/* ============================================================
   NevaiOffice — Matrix Cloud Edition
   Design system: light + dark, accents, silent reload, mobile
   ============================================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ---------- Tokens: dark (default) ---------- */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg: #0b0c0e;
  --bg-2: #0e1013;
  --surface: #14161a;
  --elev: #1a1d22;
  --hover: rgba(255,255,255,.045);
  --active: rgba(255,255,255,.08);
  --border: rgba(255,255,255,.075);
  --border-strong: rgba(255,255,255,.14);
  --text: #e9ebee;
  --text-2: #b3b8bf;
  --muted: #878e98;
  --faint: #5c636d;

  --accent: #4d8dff;
  --accent-text: #ffffff;
  --accent-weak: rgba(9,9,11,.07);
  --accent-weak-2: rgba(9,9,11,.18);

  --ok: #34c98e;
  --warn: #f5b13d;
  --danger: #f5566b;
  --danger-weak: rgba(245,86,107,.12);

  --shadow-1: 0 1px 2px rgba(0,0,0,.35);
  --shadow-2: 0 8px 28px rgba(0,0,0,.45);
  --shadow-3: 0 16px 48px rgba(0,0,0,.55);

  --r-sm: 7px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  --topbar-h: 54px;
  --sidebar-w: 248px;
  --nav-h: 58px;
  --dur: 140ms;
}


/* ---------- Light theme (perfect white mode) ---------- */
[data-theme="light"] {
  --bg: #ffffff;
  --bg-2: #f8f9fb;
  --surface: #ffffff;
  --elev: #ffffff;
  --hover: rgba(15,20,30,.045);
  --active: rgba(15,20,30,.065);
  --border: rgba(15,20,30,.085);
  --border-strong: rgba(15,20,30,.14);
  --text: #0f1419;
  --text-2: #343a44;
  --muted: #5a6472;
  --faint: #858f9e;
  --ok: #16925c;
  --warn: #b87a0a;
  --danger: #d92d4a;
  --danger-weak: rgba(217,45,74,.09);
  --shadow-1: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-2: 0 4px 16px rgba(16,24,40,.08), 0 2px 6px rgba(16,24,40,.05);
  --shadow-3: 0 16px 40px rgba(16,24,40,.12), 0 4px 12px rgba(16,24,40,.06);
}
[data-theme="light"] .topbar { background: rgba(255,255,255,.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
[data-theme="light"] .modal-backdrop { background: rgba(15,20,30,.38); }
[data-theme="light"] .palette-backdrop { background: rgba(15,20,30,.32); }
[data-theme="light"] .sb-backdrop { background: rgba(15,20,30,.28); }
[data-theme="light"] .msg-bubble { background: #f8f9fb; border-color: rgba(15,20,30,.08); }
[data-theme="light"] .sidebar { background: #fcfcfd; }
[data-theme="light"] .card { box-shadow: 0 1px 2px rgba(16,24,40,.04); }
[data-theme="light"] .card:hover { box-shadow: 0 2px 8px rgba(16,24,40,.06); }
[data-theme="light"] .sb-item.on { background: var(--accent-weak); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(15,20,30,.12); }

/* ---------- Font size & density ---------- */
html[data-fontsize="s"] body { font-size: 12.5px; }
html[data-fontsize="l"] body { font-size: 14.8px; }
body.compact { --topbar-h: 46px; }
body.compact .btn { padding: 5px 10px; font-size: 12.3px; }
body.compact .card-pad { padding: 12px; }
body.compact .sb-item { padding: 5px 10px; }
body.compact .view-pad { padding-top: 18px; }
body.compact .set-row { padding: 7px 0; }

html { height: 100%; }
body {
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#app { display: none; height: 100%; }
#app.ready { display: block; }

::selection { background: var(--accent); color: var(--accent-text); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }
img { max-width: 100%; }
svg.ic { width: 17px; height: 17px; flex: none; vertical-align: -3px; }

/* ---------- Silent boot / reduce motion — INSTANT reload ---------- */
html.booting *, html.booting *::before, html.booting *::after {
  transition: none !important;
  animation: none !important;
}
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  transition: none !important;
  animation: none !important;
}
/* Silent by default: no fade-in unless user explicitly enables motion */
html.reduce-motion .fade-in { animation: none !important; opacity: 1; }
html:not(.reduce-motion) .fade-in { animation: nvFade 160ms ease both; }
@keyframes nvFade { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }
@keyframes nvSpin { to { transform: rotate(360deg); } }
.spin { animation: nvSpin 820ms linear infinite; }
html.reduce-motion .spin { animation: nvSpin 820ms linear infinite !important; }

/* Perfect instant theme switch — no flash, no transition on colors */
html.reduce-motion { --dur: 0ms; }
html:not(.reduce-motion) { --dur: 150ms; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }

/* ============================================================
   Layout shell
   ============================================================ */
.shell { display: flex; height: 100%; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 60;
}
body.sb-collapsed .sidebar { width: 62px; }
body.sb-collapsed .sb-label,
body.sb-collapsed .sb-section-title,
body.sb-collapsed .sb-storage,
body.sb-collapsed .sb-user-meta { display: none; }
body.sb-collapsed .sb-item { justify-content: center; padding-left: 0; padding-right: 0; }
body.sb-collapsed .sb-brand { justify-content: center; padding-left: 0; padding-right: 0; }
body.sb-collapsed .main-area { margin-left: 0; }

.sb-brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
  user-select: none;
}
.sb-brand .logo-badge {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--gradient);
  display: grid; place-items: center;
  color: #fff; flex: none;
}
.sb-brand .logo-badge svg { width: 15px; height: 15px; }
.sb-brand-name { font-weight: 700; letter-spacing: -.02em; font-size: 14px; white-space: nowrap; }
.sb-brand-name em { font-style: normal; color: var(--muted); font-weight: 500; }

.sb-nav { flex: 1; overflow-y: auto; padding: 10px 10px 6px; overscroll-behavior: contain; }
.sb-section-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--faint); font-weight: 600;
  padding: 14px 10px 5px; white-space: nowrap;
}
.sb-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 8px 10px;
  border: 0; background: none; color: var(--text-2);
  border-radius: var(--r-md);
  cursor: pointer; font-size: 13.5px; font-weight: 500;
  text-align: left; white-space: nowrap;
  position: relative;
}
.sb-item:hover { background: var(--hover); color: var(--text); }
.sb-item.on { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.sb-item.on::before {
  content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 3px; background: var(--accent);
}
.sb-item .count { margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 600; }
.sb-item.danger { color: var(--danger); }
.sb-item.danger:hover { background: var(--danger-weak); }

.sb-storage {
  margin: 10px; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface);
  flex: none;
}
.sb-storage .row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.sb-storage .t { font-size: 12px; font-weight: 600; }
.sb-storage .v { font-size: 11px; color: var(--muted); }
.meter { height: 5px; border-radius: 4px; background: var(--active); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); width: 0; }

.sb-foot { border-top: 1px solid var(--border); padding: 10px; flex: none; position: relative; }
.mobile-back { display: none; }
@media (max-width: 920px) {
  .mobile-back { display: inline-grid; }
}
.sb-user {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 8px; border-radius: var(--r-md);
  background: none; border: 0; cursor: pointer; color: var(--text);
  text-align: left;
}
.sb-user:hover { background: var(--hover); }
.sb-user-meta { min-width: 0; }
.sb-user-meta b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-meta span { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gradient);
  color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; flex: none;
  overflow: hidden; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 72px; height: 72px; font-size: 26px; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, var(--surface));
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  position: relative; z-index: 50;
}
.tb-btn {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: var(--r-md);
  color: var(--text-2); cursor: pointer;
}
.tb-btn:hover { background: var(--hover); color: var(--text); }
.tb-btn.tb-acc { background: var(--accent); color: var(--accent-text); border-radius: var(--r-md); }
.tb-btn.tb-acc:hover { background: var(--accent); filter: brightness(1.08); }
.tb-spacer { flex: 1; }
.tb-avatar {
  width: 36px; height: 36px; flex: none; border: 0; background: none;
  border-radius: 50%; padding: 3px; cursor: pointer;
}
.tb-avatar:hover { background: var(--hover); }
.tb-badge {
  position: absolute; top: 3px; right: 3px;
  min-width: 15px; height: 15px; padding: 0 3px;
  display: none; place-items: center;
  font-size: 9.5px; font-weight: 700; line-height: 1;
  background: var(--danger); color: #fff;
  border-radius: 999px; border: 2px solid var(--bg);
}
.tb-badge.acc { background: var(--accent); }
#hamburgerBtn { display: none; }
#collapseBtn { display: grid; }

.global-search {
  flex: 1; max-width: 440px;
  display: flex; align-items: center; gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 13px; height: 36px;
  color: var(--muted); cursor: text;
}
.global-search:hover { border-color: var(--border-strong); }
.global-search .gs-label { white-space: nowrap; }
.global-search kbd {
  margin-left: auto; font-family: var(--mono); font-size: 10.5px;
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; color: var(--faint);
}

.sync-pill {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--muted); font-weight: 500;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: default; user-select: none; white-space: nowrap;
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.sync-dot.ok { background: var(--ok); }
.sync-dot.warn { background: var(--warn); }
.sync-dot.err { background: var(--danger); }

/* notification menu list */
.notif-menu { min-width: 250px; max-width: 320px; }
.notif-menu .menu-item { white-space: normal; }
.kbd-list { display: flex; flex-direction: column; gap: 2px; }
.kbd-row { display: flex; align-items: center; gap: 12px; padding: 7px 4px; border-bottom: 1px solid var(--border); }
.kbd-row:last-child { border-bottom: 0; }
.kbd-row > .kbd { flex: none; min-width: 96px; text-align: center; }
.kbd-row > span { color: var(--text-2); font-size: 12.5px; }

.view { flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: auto; }
.view-pad { max-width: 1160px; margin: 0 auto; padding: 26px 26px 80px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   Components
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background var(--dur), border-color var(--dur), color var(--dur);
  white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(0.5px); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.danger-soft { background: var(--danger-weak); border-color: transparent; color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: var(--r-sm); }
.btn.lg { padding: 11px 20px; font-size: 14px; border-radius: var(--r-md); }
.btn.block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.icon-btn {
  width: 30px; height: 30px; flex: none;
  display: inline-grid; place-items: center;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--accent); background: var(--accent-weak); }

.input, select.input, textarea.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13.5px;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.input::placeholder { color: var(--faint); }
textarea.input { resize: vertical; min-height: 70px; line-height: 1.55; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--active); border: 1px solid var(--border);
  transition: background var(--dur); cursor: pointer;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-1);
  transition: transform var(--dur);
}
.switch input:checked + i { background: var(--accent); border-color: transparent; }
.switch input:checked + i::after { transform: translateX(16px); }

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: none; color: var(--muted);
  font-size: 12.5px; font-weight: 600;
  padding: 6px 13px; border-radius: var(--r-sm); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); border: 1px solid var(--border); }
.seg button.on:not(:first-child) { margin-left: -1px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.card-pad { padding: 18px; }
.card h3.card-title { font-size: 13px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.card h3.card-title svg.ic { color: var(--accent); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  padding: 3px 8px; border-radius: 999px;
  background: var(--active); color: var(--text-2);
}
.badge.acc { background: var(--accent-weak); color: var(--accent); }
.badge.ok { background: rgba(52,201,142,.13); color: var(--ok); }
.badge.warn { background: rgba(245,177,61,.14); color: var(--warn); }
.badge.danger { background: var(--danger-weak); color: var(--danger); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  background: var(--active); border-radius: 999px; padding: 3px 10px; color: var(--text-2);
}

kbd.kbd { font-family: var(--mono); font-size: 10.5px; background: var(--active); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; color: var(--muted); }

.empty {
  text-align: center; padding: 56px 20px; color: var(--muted);
}
.empty .big { font-size: 34px; color: var(--faint); margin-bottom: 12px; }
.empty .big svg { width: 36px; height: 36px; }
.empty h4 { color: var(--text); font-size: 15px; margin-bottom: 5px; font-weight: 650; }
.empty p { font-size: 12.5px; max-width: 380px; margin: 0 auto 16px; }

/* ---------- Toasts ---------- */
#toasts {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 4000; pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  background: var(--elev); border: 1px solid var(--border-strong);
  color: var(--text); border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  padding: 10px 16px; font-size: 13px; font-weight: 550;
  max-width: 92vw;
  pointer-events: auto;
}
.toast svg.ic { flex: none; }
.toast.ok svg.ic { color: var(--ok); }
.toast.err svg.ic { color: var(--danger); }
.toast.warn svg.ic { color: var(--warn); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  z-index: 2000; display: grid; place-items: center; padding: 18px;
}
.modal {
  background: var(--elev); border: 1px solid var(--border-strong);
  border-radius: var(--r-xl); box-shadow: var(--shadow-3);
  width: 100%; max-width: 460px; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { max-width: 720px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 15px 18px 0;
}
.modal-head h3 { font-size: 15px; font-weight: 700; }
.modal-body { padding: 14px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 16px; }

.viewer-backdrop {
  position: fixed; inset: 0; background: var(--bg); z-index: 1500;
  display: flex; flex-direction: column;
}
.viewer-head {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  border-bottom: 1px solid var(--border); background: var(--surface);
  min-width: 0;
}
.viewer-head .fname { font-weight: 650; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-body { flex: 1; overflow: auto; background: var(--bg); display: flex; }
.viewer-body.center { display: grid; place-items: center; }

/* ---------- Context menu & dropdown ---------- */
.menu {
  position: fixed; z-index: 3000; min-width: 196px;
  background: var(--elev); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
  padding: 5px; 
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 7px 10px;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; text-align: left;
}
.menu-item:hover { background: var(--hover); }
.menu-item svg.ic { color: var(--muted); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger svg.ic { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 6px; }
.menu-head { padding: 7px 10px 4px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); }

.popover-anchor { position: relative; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 210px; z-index: 3000;
  background: var(--elev); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-2); padding: 5px;
}

/* ============================================================
   Auth screen
   ============================================================ */
.auth-wrap {
  height: 100%; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(800px 420px at 15% 0%, var(--accent-weak), transparent 65%),
    radial-gradient(700px 400px at 90% 100%, var(--accent-weak), transparent 60%),
    var(--bg);
  overflow-y: auto;
}
.auth-card { width: 100%; max-width: 396px; }
.auth-logo { display: flex; align-items: center; gap: 11px; justify-content: center; margin-bottom: 22px; user-select: none; }
.auth-logo .logo-badge {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--gradient);
  display: grid; place-items: center; color: #fff;
  box-shadow: var(--shadow-2);
}
.auth-logo .logo-badge svg { width: 21px; height: 21px; }
.auth-logo h1 { font-size: 19px; letter-spacing: -.02em; }
.auth-logo h1 em { font-style: normal; color: var(--muted); font-weight: 500; display: block; font-size: 11.5px; letter-spacing: 0; }
.auth-card .card { padding: 22px; }
.auth-tabs { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: 3px; margin-bottom: 18px; }
.auth-tabs button { flex: 1; border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 13px; padding: 8px; border-radius: var(--r-sm); cursor: pointer; }
.auth-tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); border: 1px solid var(--border); }
.auth-note { margin-top: 16px; text-align: center; font-size: 11.5px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.form-err { background: var(--danger-weak); color: var(--danger); font-size: 12.5px; font-weight: 550; border-radius: var(--r-md); padding: 9px 12px; margin-bottom: 13px; display: none; }
.form-err.show { display: block; }

.lock-wrap {
  position: fixed; inset: 0; z-index: 5000;
  background: var(--bg); display: grid; place-items: center; padding: 20px;
}
.lock-card { width: 100%; max-width: 330px; text-align: center; }
.lock-card .avatar { margin: 0 auto 14px; }
.lock-card h2 { font-size: 17px; margin-bottom: 4px; }
.lock-card p { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }

/* ============================================================
   Dashboard
   ============================================================ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card { padding: 16px; display: flex; gap: 13px; align-items: center; }
.stat-icon {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-weak); color: var(--accent);
}
.stat-icon svg { width: 19px; height: 19px; }
.stat-card b { display: block; font-size: 19px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.stat-card span { font-size: 12px; color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; align-items: start; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.quick-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 9px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px; cursor: pointer; color: var(--text); text-align: left; font-family: inherit;
}
.quick-btn:hover { border-color: var(--accent-weak-2); background: var(--hover); }
.quick-btn svg { color: var(--accent); }
.quick-btn b { font-size: 12.5px; font-weight: 650; }
.quick-btn span { font-size: 11px; color: var(--muted); }

/* ============================================================
   Files
   ============================================================ */
.files-toolbar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.crumbs { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; font-size: 13px; min-width: 0; }
.crumb {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 4px 7px; border-radius: var(--r-sm);
  white-space: nowrap;
}
.crumb:hover { color: var(--text); background: var(--hover); }
.crumb.last { color: var(--text); }
.crumb-sep { color: var(--faint); }

.grid-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
.fcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 15px 13px 12px; cursor: pointer; position: relative;
  user-select: none;
}
.fcard:hover { border-color: var(--border-strong); background: var(--hover); }
.fcard.sel { border-color: var(--accent); background: var(--accent-weak); }
.fcard .fico {
  width: 42px; height: 42px; border-radius: 11px;
  display: grid; place-items: center; margin-bottom: 10px;
  background: var(--active); color: var(--text-2);
}
.fcard .fico svg { width: 20px; height: 20px; }
.fcard b { display: block; font-size: 12.5px; font-weight: 600; line-height: 1.35; word-break: break-word; }
.fcard small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.fcard .star-flag { position: absolute; top: 9px; right: 9px; color: var(--warn); }
.thumb { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: var(--r-md); margin-bottom: 8px; background: var(--active); display: block; }

.list-files { display: flex; flex-direction: column; gap: 3px; }
.lrow {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 11px; border-radius: var(--r-md);
  cursor: pointer; user-select: none;
  border: 1px solid transparent;
}
.lrow:hover { background: var(--hover); }
.lrow.sel { background: var(--accent-weak); border-color: var(--accent-weak-2); }
.lrow .fico { width: 34px; height: 34px; border-radius: 9px; background: var(--active); color: var(--text-2); display: grid; place-items: center; flex: none; }
.lrow .fico svg { width: 16px; height: 16px; }
.lrow .lmain { flex: 1; min-width: 0; }
.lrow .lmain b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .lmain small { color: var(--muted); font-size: 11.5px; }
.lrow .lmeta { font-size: 11.5px; color: var(--muted); white-space: nowrap; flex: none; }
.lrow .star-mini { color: var(--warn); flex: none; display: inline-grid; }
.lrow .lacts { visibility: hidden; display: flex; flex: none; }
.lrow:hover .lacts, .lrow.sel .lacts { visibility: visible; }

.fico.word, .fcard .fico.word { color: #4d9fff; background: rgba(77,159,255,.13); }
.fico.excel, .fcard .fico.excel { color: #33c481; background: rgba(51,196,129,.13); }
.fico.slide, .fcard .fico.slide { color: #ffab4a; background: rgba(255,171,74,.14); }
.fico.pdf, .fcard .fico.pdf { color: #ff6b6b; background: rgba(255,107,107,.13); }
.fico.img, .fcard .fico.img { color: #b78bff; background: rgba(183,139,255,.14); }
.fico.media, .fcard .fico.media { color: #4dd4e8; background: rgba(77,212,232,.13); }
.fico.code, .fcard .fico.code { color: #7fd18c; background: rgba(127,209,140,.13); }
.fico.folder, .fcard .fico.folder { color: var(--accent); background: var(--accent-weak); }

.dropzone-global {
  outline: 2px dashed var(--accent); outline-offset: -8px;
  background: var(--accent-weak) !important;
}

.up-panel {
  position: fixed; right: 16px; bottom: 16px; z-index: 1200;
  width: 320px; max-width: calc(100vw - 32px);
  background: var(--elev); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2); overflow: hidden;
}
.up-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; font-size: 12.5px; font-weight: 700; border-bottom: 1px solid var(--border); }
.up-list { max-height: 240px; overflow-y: auto; padding: 8px 14px 12px; }
.up-item { margin-bottom: 10px; }
.up-item .r { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; gap: 10px; }
.up-item .r b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-item .r span { color: var(--muted); flex: none; }
.progress { height: 4px; background: var(--active); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.progress.done i { background: var(--ok); }
.progress.fail i { background: var(--danger); }

/* ============================================================
   Notes
   ============================================================ */
.notes-layout { display: grid; grid-template-columns: 300px 1fr; gap: 0; height: 100%; }
.notes-list { border-right: 1px solid var(--border); overflow-y: auto; padding: 12px; }
.note-item {
  padding: 11px 12px; border-radius: var(--r-md); cursor: pointer;
  border: 1px solid transparent; margin-bottom: 4px;
}
.note-item:hover { background: var(--hover); }
.note-item.on { background: var(--accent-weak); border-color: var(--accent-weak-2); }
.note-item b { display: block; font-size: 13px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item p { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.notes-editor { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.ne-head { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); flex: none; flex-wrap: wrap; }
.ne-title { border: 0; background: none; color: var(--text); font-size: 16.5px; font-weight: 700; flex: 1; min-width: 160px; letter-spacing: -.01em; }
.ne-title:focus { outline: none; }
.ne-split { flex: 1; display: grid; min-height: 0; }
.ne-split.edit { grid-template-columns: 1fr; }
.ne-split.split { grid-template-columns: 1fr 1fr; }
.ne-split.preview { grid-template-columns: 1fr; }
.ne-editor { border: 0; resize: none; background: var(--bg); color: var(--text); padding: 20px 22px; font-family: var(--mono); font-size: 13.5px; line-height: 1.7; width: 100%; height: 100%; }
.ne-editor:focus { outline: none; }
.ne-preview { border-left: 1px solid var(--border); overflow-y: auto; padding: 20px 24px; background: var(--surface); }
.ne-status { padding: 6px 14px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; flex: none; }

.md { font-size: 14px; line-height: 1.75; word-wrap: break-word; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.1em 0 .45em; letter-spacing: -.015em; line-height: 1.3; }
.md h1:first-child, .md h2:first-child, .md p:first-child { margin-top: 0; }
.md h1 { font-size: 1.65em; } .md h2 { font-size: 1.35em; } .md h3 { font-size: 1.15em; } .md h4 { font-size: 1em; }
.md p { margin: .6em 0; }
.md ul, .md ol { margin: .6em 0; padding-left: 1.5em; }
.md li { margin: .25em 0; }
.md code { font-family: var(--mono); font-size: .86em; background: var(--active); border-radius: 5px; padding: .15em .4em; }
.md pre { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: 13px 15px; overflow-x: auto; margin: .8em 0; }
.md pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.6; }
.md blockquote { border-left: 3px solid var(--accent); padding: .15em 1em; margin: .8em 0; color: var(--muted); background: var(--accent-weak); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.md table { border-collapse: collapse; margin: .8em 0; width: 100%; font-size: 13px; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.md th { background: var(--active); font-weight: 650; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }
.md a { text-decoration: underline; text-underline-offset: 2px; }
.md img { border-radius: var(--r-md); }

/* ============================================================
   Chat
   ============================================================ */
.chat-layout { display: grid; grid-template-columns: 290px 1fr; height: 100%; }
.rooms-col { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.rooms-head { padding: 12px 12px 8px; flex: none; }
.rooms-scroll { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.room-tab {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-md); border: 0; background: none;
  cursor: pointer; color: var(--text); text-align: left;
}
.room-tab:hover { background: var(--hover); }
.room-tab.on { background: var(--accent-weak); }
.room-tab .rmeta { flex: 1; min-width: 0; }
.room-tab .rmeta b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-tab .rmeta span { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: var(--active); color: var(--text-2);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  overflow: hidden;
}
.room-avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat-col { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--border); flex: none; }
.chat-head b { font-size: 14px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 18px 18px 8px; }
.msg-row { display: flex; gap: 11px; margin-bottom: 14px; }
.msg-body { min-width: 0; max-width: 640px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-head b { font-size: 12.5px; }
.msg-head time { font-size: 10.5px; color: var(--faint); }
.msg-bubble {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px var(--r-lg) var(--r-lg) var(--r-lg);
  padding: 8px 12px; font-size: 13.5px; word-break: break-word; white-space: pre-wrap;
}
.msg-file { display: flex; align-items: center; gap: 11px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px 13px; cursor: pointer; }
.msg-file:hover { border-color: var(--border-strong); }
.msg-file svg { color: var(--accent); }
.chat-input { display: flex; align-items: flex-end; gap: 8px; padding: 11px 14px; border-top: 1px solid var(--border); flex: none; }
.chat-input textarea {
  flex: 1; resize: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); color: var(--text); padding: 10px 13px;
  font-size: 13.5px; line-height: 1.45; max-height: 130px; min-height: 40px;
}
.chat-input textarea:focus { outline: none; border-color: var(--accent); }
.typing-line { padding: 0 18px 6px; font-size: 11px; color: var(--muted); min-height: 18px; flex: none; }
.day-sep { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--faint); font-size: 11px; font-weight: 600; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ============================================================
   Settings / account rows
   ============================================================ */
.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: 0; }
.set-row .info { min-width: 0; }
.set-row .info b { display: block; font-size: 13px; font-weight: 600; }
.set-row .info span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.swatch-row { display: flex; gap: 9px; flex-wrap: wrap; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 2px solid transparent;
  position: relative;
}
.swatch.on { border-color: var(--text); }
.swatch.swatch.swatch.swatch.swatch
.device-row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--border); }
.device-row:last-child { border-bottom: 0; }
.device-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--active); color: var(--text-2); display: grid; place-items: center; flex: none; }
.device-row .di { flex: 1; min-width: 0; }
.device-acts { display: flex; gap: 4px; flex: none; align-items: center; }
.device-row .di b { display: block; font-size: 13px; }
.device-row .di span { font-size: 11.5px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.feature-cols { columns: 2; column-gap: 14px; }
.feature-group { break-inside: avoid; margin-bottom: 14px; }
.feature-group h4 { font-size: 12.5px; font-weight: 700; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; color: var(--text); }
.feature-group h4 svg.ic { color: var(--accent); }
.feature-group ul { list-style: none; }
.feature-group li { font-size: 12.5px; color: var(--text-2); padding: 3.5px 0 3.5px 20px; position: relative; }
.feature-group li::before { content: ""; position: absolute; left: 4px; top: 10px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

/* ---------- Command palette ---------- */
.palette-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 3500; display: flex; justify-content: center; padding: 90px 16px 16px; }
.palette {
  width: 100%; max-width: 560px; height: fit-content; max-height: 60vh;
  background: var(--elev); border: 1px solid var(--border-strong); border-radius: var(--r-xl);
  box-shadow: var(--shadow-3); display: flex; flex-direction: column; overflow: hidden;
}
.palette input {
  border: 0; background: none; color: var(--text); font-size: 15px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.palette input:focus { outline: none; }
.palette-list { overflow-y: auto; padding: 7px; }
.pal-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; border: 0; background: none; color: var(--text); border-radius: var(--r-md); cursor: pointer; text-align: left; font-size: 13.5px; }
.pal-item:hover, .pal-item.hot { background: var(--accent-weak); }
.pal-item svg.ic { color: var(--muted); }
.pal-item small { margin-left: auto; color: var(--faint); font-size: 11px; flex: none; }

/* ---------- Details modal bits ---------- */
.kv { display: grid; grid-template-columns: 130px 1fr; row-gap: 8px; column-gap: 12px; font-size: 12.5px; }
.kv dt { color: var(--muted); font-weight: 550; }
.kv dd { word-break: break-all; }
.ver-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.ver-item:last-child { border-bottom: 0; }

/* ============================================================
   Mobile
   ============================================================ */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1100;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
  grid-template-columns: repeat(5, 1fr);
}
.mob-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: none; color: var(--muted); font-size: 10px; font-weight: 600;
  padding: 5px 2px; cursor: pointer; border-radius: var(--r-sm);
}
.mob-item.on { color: var(--accent); }
.mob-item svg { width: 20px; height: 20px; }

.sb-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 55;
  background: rgba(0,0,0,.45);
}

@media (max-width: 920px) {
  body { font-size: 13px; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    transform: translateX(-100%);
    box-shadow: 0 12px 40px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.12);
    width: 300px !important; max-width: 84vw;
    transition: transform 260ms cubic-bezier(.32,.72,0,1);
    border-radius: 0 var(--r-xl) var(--r-xl) 0;
    will-change: transform;
  }
  html.reduce-motion .sidebar { transition: none !important; }
  body.sb-open .sidebar { transform: translateX(0); }
  body.sb-open .sb-backdrop {
    display: block;
    animation: nvFade 180ms ease both;
  }
  html.reduce-motion body.sb-open .sb-backdrop { animation: none !important; }
  body.sb-collapsed .sb-label, body.sb-collapsed .sb-section-title,
  body.sb-collapsed .sb-storage, body.sb-collapsed .sb-user-meta { display: revert; }
  body.sb-collapsed .sb-item { justify-content: flex-start; padding-left: 10px; }
  body.sb-collapsed .sb-brand { justify-content: flex-start; }
  #collapseBtn { display: none !important; }
  #hamburgerBtn { display: grid; }
  .mobile-nav { display: grid; }
  .view-pad { padding: 16px 14px calc(18px + var(--nav-h) + env(safe-area-inset-bottom, 0px)); }
  .dash-grid { grid-template-columns: 1fr; }
  .notes-layout { grid-template-columns: 1fr; }
  .notes-list { border-right: 0; border-bottom: 1px solid var(--border); max-height: 36vh; }
  .notes-layout.editor-open .notes-list { display: none; }
  .ne-split.split { grid-template-columns: 1fr; }
  .ne-split.split .ne-preview { display: none; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-layout.room-open .rooms-col { display: none; }
  .chat-layout:not(.room-open) .chat-col { display: none; }
  .feature-cols { columns: 1; }
  .global-search { flex: 0 0 auto; }
  .sync-pill span.txt { display: none; }
  .up-panel { right: 10px; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px)); }
  .set-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 108px 1fr; }
  .msg-body { max-width: calc(100vw - 92px); }
  .sb-brand { height: 56px; }
}
@media (max-width: 640px) {
  .topbar { gap: 6px; padding: 0 8px; }
  .global-search { flex: 0 0 36px; width: 36px; justify-content: center; padding: 0; border-radius: 999px; }
  .global-search .gs-label, .global-search kbd { display: none; }
  .tb-hide-sm { display: none !important; }
  .sync-pill { margin-left: 0; padding: 4px 8px; }
  .page-head { gap: 10px; }
  .page-actions .btn { flex: 1; justify-content: center; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { padding: 12px; }
  .grid-files { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
  .modal { max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
  .modal-backdrop { padding: 0; }
  .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .viewer-backdrop { z-index: 1600; }
  .files-toolbar { gap: 7px; }
}
@media (max-width: 480px) {
  .page-head h1 { font-size: 18px; }
  .grid-files { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); }
}

/* Touch devices: actions must be reachable without hover */
@media (pointer: coarse) {
  .lrow .lacts { visibility: visible; }
  .fcard-menu { opacity: .7; }
}
.fcard-menu {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px;
  opacity: 0;
  background: var(--bg);
}
.fcard:hover .fcard-menu, .fcard-menu:focus { opacity: 1; }
.fcard.has-star .fcard-menu { top: auto; bottom: 8px; }

/* Print */
@media print {
  .sidebar, .topbar, .mobile-nav, .up-panel, #toasts { display: none !important; }
  .view { overflow: visible; }
  body, html { height: auto; overflow: visible; }
}

/* ============================================================
   v5 additions — new components & polish
   ============================================================ */

/* Viewport-anchored dropdown (positioned by JS) */
.dropdown.drop-viewport { position: fixed; top: 0; left: 0; max-height: min(420px, calc(100vh - 24px)); overflow-y: auto; }

/* Inputs with a leading icon */
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > svg.ic { position: absolute; left: 11px; color: var(--faint); pointer-events: none; z-index: 1; }
.input-icon > .input { padding-left: 33px; }

/* Palette search row + footer */
.pal-search { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.pal-search input { flex: 1; border: 0; background: none; color: var(--text); font-size: 15px; padding: 15px 0; }
.pal-search input:focus { outline: none; }
.palette-foot {
  display: flex; gap: 16px; padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 10.5px; color: var(--faint);
}
.palette-foot span { display: inline-flex; align-items: center; gap: 5px; }
.palette-foot .kbd { font-family: var(--mono); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; background: var(--active); }

/* Bulk selection bar */
.bulkbar {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 1300;
  display: flex; align-items: center; gap: 6px;
  background: var(--elev); border: 1px solid var(--border-strong);
  border-radius: 999px; box-shadow: var(--shadow-2);
  padding: 6px 8px 6px 14px;
  max-width: calc(100vw - 20px);
  overflow-x: auto;
}
.bulkbar .bulk-count { font-size: 12.5px; font-weight: 700; white-space: nowrap; margin-right: 4px; }
.bulkbar .btn { flex: none; }
.bulkbar .btn span.lbl { display: inline; }
@media (max-width: 720px) {
  .bulkbar { bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px)); width: calc(100vw - 20px); justify-content: space-between; }
  .bulkbar .btn span.lbl { display: none; }
}

/* Selection checkbox on rows/cards */
.sel-box {
  width: 17px; height: 17px; flex: none;
  display: none; place-items: center;
  border: 1.5px solid var(--border-strong); border-radius: 5px;
  color: transparent; background: var(--bg);
}
.lrow.sel-mode .sel-box, .fcard.sel-mode .sel-box { display: grid; }
.lrow.picked, .fcard.picked { background: var(--accent-weak); border-color: var(--accent-weak-2); }
.lrow.picked .sel-box, .fcard.picked .sel-box { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Image thumbnails in file cards */
.fcard .thumb-wrap {
  height: 84px; border-radius: var(--r-md); overflow: hidden;
  margin-bottom: 9px; background: var(--active);
  display: none; place-items: center;
}
.fcard.has-thumb .thumb-wrap { display: grid; }
.fcard.has-thumb .fico { display: none; }
.fcard.has-thumb .thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Unread dots in room list */
.room-tab { position: relative; }
.room-tab .unread-dot {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak-2);
}
.room-tab.on .unread-dot { display: none; }
.room-tab .rmeta { padding-right: 14px; }
.room-kebab { opacity: 0; }
.room-tab:hover .room-kebab, .room-kebab:focus { opacity: 1; }
@media (pointer: coarse) { .room-kebab { opacity: .65; } .room-tab .rmeta { padding-right: 30px; } }

/* Notes: pin badge */
.note-item { position: relative; }
.note-item .pin-mini { position: absolute; top: 9px; right: 9px; color: var(--accent); display: inline-grid; }
.ne-head .icon-btn.pin-on { color: var(--accent); background: var(--accent-weak); }
.notes-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.notes-count { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Storage breakdown bars */
.store-bars { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.store-bar-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; font-size: 12px; }
.store-bar-row svg.ic { color: var(--muted); }
.store-bar-row .sb-track { height: 7px; border-radius: 5px; background: var(--active); overflow: hidden; }
.store-bar-row .sb-track i { display: block; height: 100%; border-radius: 5px; }
.store-bar-row .sb-val { color: var(--muted); font-size: 11px; white-space: nowrap; }
.store-total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.store-total b { font-size: 19px; letter-spacing: -.02em; }
.store-total span { font-size: 11.5px; color: var(--muted); }

/* Security score */
.sec-score { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.sec-ring { --pct: 0; width: 74px; height: 74px; flex: none; border-radius: 50%;
  background: conic-gradient(var(--ok) calc(var(--pct) * 1%), var(--active) 0);
  display: grid; place-items: center; }
.sec-ring::before { content: ""; position: absolute; }
.sec-ring b {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--surface); display: grid; place-items: center;
  font-size: 17px; font-weight: 800; letter-spacing: -.02em;
}
.sec-checks { display: flex; flex-direction: column; gap: 7px; flex: 1; }
.sec-check { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-2); }
.sec-check svg.ic { flex: none; }
.sec-check.ok svg.ic { color: var(--ok); }
.sec-check.bad svg.ic { color: var(--warn); }

/* PWA install button pulse-free accent */
.tb-btn.tb-install { color: var(--accent); background: var(--accent-weak); }
.tb-btn.tb-install:hover { background: var(--accent-weak-2); }

/* Sidebar collapse hint tooltip-ish title handled natively */

/* Mobile: keep content above the bottom nav */
@media (max-width: 920px) {
  .main-area { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); }
}

/* Small screens: tighter viewer head */
@media (max-width: 640px) {
  .viewer-head { padding: 0 8px; gap: 4px; }
  .viewer-head .fname { font-size: 12.5px; }
  .palette-backdrop { padding: 12px; }
  .palette { max-height: 78vh; }
  .up-panel { width: calc(100vw - 20px); right: 10px; }
}

/* ============================================================
   v9 — All-in-one Hub & polish
   ============================================================ */

/* Feature launcher tiles */
.hub-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
.hub-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 13px; cursor: pointer; color: var(--text); text-align: left;
}
.hub-tile:hover { border-color: var(--accent-weak-2); }
.hub-tile .ht-ico {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--active); color: var(--text-2);
}
.hub-tile:hover .ht-ico { background: var(--accent-weak); color: var(--accent); }
.hub-tile b { font-size: 12.5px; font-weight: 650; line-height: 1.3; }
.hub-tile small { font-size: 11px; color: var(--muted); line-height: 1.35; }

/* Theme trio on hub */
.hub-themes { display: flex; gap: 8px; flex-wrap: wrap; }
.hub-theme-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-2);
  font-size: 12.5px; font-weight: 600;
}
.hub-theme-btn.on { background: var(--accent-weak); border-color: var(--accent-weak-2); color: var(--accent); }

/* Engine status dot */
.engine-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.engine-dot i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.engine-dot.ok i { background: var(--ok); box-shadow: 0 0 0 3px rgba(52,201,142,.18); }
.engine-dot.err i { background: var(--danger); box-shadow: 0 0 0 3px rgba(245,86,107,.16); }

/* Card hover affordance (silent, no motion) */
.card.hoverable:hover { border-color: var(--border-strong); }

/* Standalone PWA: respect the notch */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top, 0px); }
}

@media (max-width: 720px) {
  .hub-tiles { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
}

/* ============================================================
   v11 — Perfect polish: modern, silent, icons, unlimited power
   ============================================================ */

/* Modern card elevation — silent hover, no motion */
.card {
  transition: border-color var(--dur), box-shadow var(--dur);
}
html.reduce-motion .card { transition: none !important; }
.card:hover { border-color: var(--border-strong); }

/* Topbar: perfect glass on both themes, silent */
.topbar { transition: background var(--dur), border-color var(--dur); }
html.reduce-motion .topbar { transition: none !important; }

/* Sidebar items: silent active indicator */
.sb-item { transition: background var(--dur), color var(--dur); }
html.reduce-motion .sb-item { transition: none !important; }

/* Buttons: modern press, silent */
.btn { transition: background var(--dur), border-color var(--dur), transform 80ms ease, filter var(--dur); }
html.reduce-motion .btn { transition: none !important; }
.btn:active { transform: scale(.99); }
html.reduce-motion .btn:active { transform: none !important; }

/* Inputs: perfect focus ring */
.input, .seg, .global-search { transition: border-color var(--dur), box-shadow var(--dur), background var(--dur); }
html.reduce-motion .input, html.reduce-motion .seg, html.reduce-motion .global-search { transition: none !important; }

/* Icons: ensure every interactive element has icon alignment */
.btn .ic, .icon-btn .ic, .sb-item .ic, .hub-tile .ic, .stat-icon .ic { vertical-align: middle; }
.empty .big .ic { opacity: .9; }

/* Feature groups: more modern with subtle accent dot */
.feature-group li::before { width: 6px; height: 6px; background: var(--accent); opacity: .9; }
.feature-group h4 { letter-spacing: -.01em; }

/* Bulk bar: silent */
.bulkbar { transition: border-color var(--dur), box-shadow var(--dur); }
html.reduce-motion .bulkbar { transition: none !important; }

/* Office cards: modern thumbnail polish */
.office-card { transition: border-color var(--dur), transform var(--dur), box-shadow var(--dur); }
.office-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-1); }
html.reduce-motion .office-card:hover { transform: none !important; }

/* Hub tiles: perfect icon containers */
.hub-tile { transition: border-color var(--dur), background var(--dur), transform var(--dur); }
.hub-tile:hover { transform: translateY(-1px); }
html.reduce-motion .hub-tile:hover { transform: none !important; }

/* Scrollbars: perfect thin modern */
* { scrollbar-width: thin; }
[data-theme="light"] * { scrollbar-color: rgba(15,20,30,.14) transparent; }

/* Fix: ensure backdrop blur is silent */
.sb-backdrop { backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.palette-backdrop, .modal-backdrop { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* Fix: mobile nav perfect safe-area + silent */
.mobile-nav { transition: border-color var(--dur); }
html.reduce-motion .mobile-nav { transition: none !important; }
.mobile-nav .mob-item { transition: color var(--dur), background var(--dur); }
html.reduce-motion .mobile-nav .mob-item { transition: none !important; }

/* Fix: viewer header perfect */
.viewer-head { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* Unlimited power badge */
.power-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--gradient);
  color: var(--bg); font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; box-shadow: var(--shadow-1);
}

/* ============================================================
   v10 — Office area (full ONLYOFFICE inside the app)
   ============================================================ */
.office-editor { height: 100%; display: flex; flex-direction: column; min-width: 0; }
.oe-head {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface); min-width: 0;
}
.oe-name { font-size: 13px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.oe-frame-wrap { flex: 1; min-height: 0; background: var(--bg); position: relative; }
.oe-frame { width: 100%; height: 100%; border: 0; display: block; }
.oe-loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 13px; gap: 10px; text-align: center;
}
.oe-loading.hide { display: none; }

/* Office library */
.office-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.office-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 13px 12px; cursor: pointer; position: relative; user-select: none;
}
.office-card:hover { border-color: var(--accent-weak-2); }
.office-card .fico {
  width: 42px; height: 42px; border-radius: 11px; margin-bottom: 10px;
  display: grid; place-items: center; background: var(--accent-weak); color: var(--accent);
}
.office-card b { display: block; font-size: 12.5px; font-weight: 600; word-break: break-word; line-height: 1.35; }
.office-card small { color: var(--muted); font-size: 11px; }

/* ============================================================
   v15 — MONOCHROME EDITION (B&W design system)
   Pure black & white, glass surfaces, gradient primary,
   big radii, no logos, silent by default.
   ============================================================ */

:root {
  /* B&W Light */
  --bg: #f4f4f5;
  --bg-2: #ececee;
  --surface: #ffffff;
  --elev: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.85);
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #000000;
  --text-2: #18181b;
  --muted: #4b4b52;
  --faint: #7c7c85;

  --accent: #000000;            /* primary = pure black */
  --accent-text: #ffffff;
  --accent-weak: rgba(0, 0, 0, .06);
  --accent-weak-2: rgba(0, 0, 0, .16);

  /* reads as SOLID black, not gray */
  --gradient: linear-gradient(135deg, #000000, #17171a);
  --blur: blur(16px);
  --shadow-1: 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-2: 0 4px 24px rgba(0, 0, 0, .08);
  --shadow-3: 0 16px 48px rgba(0, 0, 0, .14);

  /* semantic kept functional; danger allowed as the single color */
  --ok: #18181b;
  --warn: #71717a;
  --danger: #dc2626;
  --danger-weak: rgba(220, 38, 38, .09);

  --r-sm: 10px; --r-md: 12px; --r-lg: 20px; --r-xl: 24px;
}

[data-theme="dark"] {
  --bg: #000000;
  --bg-2: #0a0a0b;
  --surface: #18181b;
  --elev: #1c1c1f;
  --surface-glass: rgba(24, 24, 27, 0.85);
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #ffffff;
  --text-2: #d4d4d8;
  --muted: #a1a1aa;
  --faint: #71717a;

  --accent: #ffffff;
  --accent-text: #000000;
  --accent-weak: rgba(255, 255, 255, .08);
  --accent-weak-2: rgba(255, 255, 255, .2);

  --gradient: linear-gradient(135deg, #ffffff, #d4d4d8);
  --shadow-1: 0 1px 3px rgba(0, 0, 0, .5);
  --shadow-2: 0 4px 24px rgba(0, 0, 0, .6);
  --shadow-3: 0 16px 48px rgba(0, 0, 0, .75);
}

/* ---------- Primary = gradient ink ---------- */
.btn.primary,
.tb-btn.tb-acc {
  background: var(--gradient);
  color: var(--bg);
  border-color: transparent;
}
.btn.primary:hover { background: var(--gradient); filter: brightness(1.12); }
.btn.danger { background: var(--danger); }
.btn.danger-soft { background: var(--danger-weak); color: var(--danger); }

/* power badge follows the gradient */
.power-badge { background: var(--gradient); }

/* ---------- Glass surfaces + bigger radii everywhere ---------- */
.card,
.modal,
.menu,
.dropdown,
.up-panel,
.palette,
.toast,
.sidebar,
.topbar,
.mobile-nav {
  border-radius: var(--r-lg);
}
.card, .up-panel, .mobile-nav, .modal {
  background: var(--surface-glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-2);
}
[data-theme="light"] .card { box-shadow: var(--shadow-2); }
.card:hover { box-shadow: var(--shadow-2); border-color: var(--border-strong); }

.stat-card {
  background: var(--surface-glass);
  backdrop-filter: var(--blur);
  border-radius: var(--r-xl);
  min-height: 118px;
  flex-direction: column;
  text-align: center;
  gap: 6px;
}
.stat-icon { width: 44px; height: 44px; border-radius: 14px; background: var(--accent-weak); color: var(--accent); margin: 0 0 2px; }
.stat-card b { font-size: 26px; font-weight: 800; letter-spacing: -.03em; }

.quick-btn, .hub-tile, .feature-item, .office-card {
  border-radius: 16px;
  background: var(--surface);
}
.quick-btn:hover, .hub-tile:hover { transform: none; }   /* silent */

.hub-tile .ht-ico { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-weak); color: var(--accent); }
.hub-tile:hover .ht-ico { background: var(--accent-weak-2); color: var(--accent); }

/* inputs & buttons */
.btn { height: auto; padding: 11px 18px; border-radius: var(--r-md); font-weight: 600; }
.btn.sm { padding: 8px 12px; }
.icon-btn { width: 34px; height: 34px; border-radius: var(--r-md); }
.tb-btn { width: 38px; height: 38px; border-radius: var(--r-md); }
.input { border-radius: var(--r-md); background: var(--surface); }
.global-search { background: var(--surface-glass); backdrop-filter: var(--blur); border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.seg { border-radius: var(--r-md); background: var(--surface); }
.seg button.on { background: var(--bg-2); box-shadow: none; }

/* sidebar */
.sidebar {
  background: var(--surface-glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-2);
}
.sb-brand { display: none !important; }            /* no logo anywhere */
.sb-item { border-radius: var(--r-md); padding: 11px 12px; font-weight: 500; }
.sb-item.on { background: var(--gradient); color: var(--bg); }
.sb-item.on::before { display: none; }
.sb-item.on svg.ic { color: var(--bg); }
.sb-storage { border-radius: var(--r-lg); background: var(--surface); }
.meter > i { background: var(--gradient); }
.avatar { background: var(--gradient); border-radius: 14px; }
.avatar.lg { border-radius: 20px; }

/* topbar */
.topbar { background: var(--surface-glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.sync-pill { border-radius: 999px; background: var(--surface); }
.tb-badge { background: var(--danger); }

/* toggles — example style (checked = ink) */
.switch { width: 50px; height: 28px; }
.switch i { border-radius: 999px; background: var(--border-strong); border: none; }
.switch i::after { width: 20px; height: 20px; top: 4px; left: 4px; background: var(--bg); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(22px); background: var(--bg); }

/* badges/chips mono */
.badge.acc { background: var(--accent-weak); color: var(--accent); }
.badge.ok { background: var(--accent-weak); color: var(--accent); }
.badge.warn { background: rgba(113,113,122,.14); color: var(--warn); }
.chip { background: var(--active); }

/* status dots: solid vs hollow (B&W language) */
.engine-dot.ok i, .sync-dot.ok { background: var(--accent); box-shadow: none; }
.engine-dot.err i, .sync-dot.err {
  background: transparent;
  border: 2px solid var(--muted);
  box-shadow: none;
  width: 8px; height: 8px;
}

/* ---------- Office area: ROUNDED frame matching cards ---------- */
.oe-frame-wrap {
  margin: 14px;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.oe-head {
  margin: 14px 14px 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-glass);
  backdrop-filter: var(--blur);
}
.office-editor { padding: 0 6px 6px; }
.oe-frame { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.oe-loading { border-radius: var(--r-lg); background: var(--surface-glass); }

.office-card { border-radius: 16px; }
.office-lib-grid { gap: 12px; }

/* viewer + modals rounding */
.viewer-head { background: var(--surface-glass); backdrop-filter: var(--blur); }
.viewer-backdrop { background: var(--bg); }
.bulkbar { border-radius: 999px; background: var(--surface-glass); backdrop-filter: var(--blur); }

/* auth & lock: no icon logo, plain wordmark */
.auth-logo .logo-badge { display: none !important; }
.lock-card .avatar { background: var(--gradient) !important; }

/* mobile nav active = ink */
.mob-item.on { color: var(--accent); }

/* selection / bulk in mono */
.lrow.picked, .fcard.picked { background: var(--accent-weak); border-color: var(--accent-weak-2); }
.lrow.picked .sel-box, .fcard.picked .sel-box { background: var(--accent); border-color: var(--accent); color: var(--bg); }

/* swatch rows are meaningless in B&W → hidden */
.swatch-row, .swatch { display: none !important; }

/* feature list bullet mono */
.feature-group li::before { background: var(--accent); opacity: .85; }
.feature-group h4 svg.ic, .card h3.card-title svg.ic { color: var(--accent); }

/* scrollbars neutral */
::-webkit-scrollbar-thumb { background: var(--border-strong); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #d4d4d8; }

/* focus ring stays visible on both themes */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================
   v16 — COLLAPSED SIDEBAR V2 ("icon dock" + mini labels)
   ============================================================ */

/* --- Rail geometry --- */
body.sb-collapsed .sidebar { width: 88px; }
body.sb-collapsed .sb-nav { padding: 10px 8px 6px; }

/* --- Nav items become vertical tiles --- */
body.sb-collapsed .sb-item {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 58px;
  padding: 10px 4px;
  border-radius: 14px;
  position: relative;
}
body.sb-collapsed .sb-item svg.ic { width: 21px; height: 21px; margin: 0; }

/* mini label under the icon (was display:none in old rules) */
body.sb-collapsed .sb-label {
  display: block !important;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .03em;
  line-height: 1;
  opacity: .85;
}
body.sb-collapsed .sb-item.on .sb-label { opacity: 1; }

/* active tile: gradient + inner ring depth */
body.sb-collapsed .sb-item.on {
  background: var(--gradient);
  color: var(--bg);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), var(--shadow-1);
}
[data-theme="dark"] body.sb-collapsed .sb-item.on {
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25), var(--shadow-1);
}
body.sb-collapsed .sb-item:not(.on):hover { box-shadow: inset 0 0 0 1px var(--border-strong); }

/* counts become tiny corner dots (text kept for a11y/tooltip) */
body.sb-collapsed .sb-item .count {
  position: absolute;
  top: 7px; right: 9px;
  min-width: 8px; height: 8px;
  padding: 0;
  font-size: 0;
  background: var(--danger);
  border-radius: 999px;
  overflow: hidden;
  color: transparent;
}
body.sb-collapsed .sb-item.on .count { background: var(--bg); }

/* --- Section titles -> hairline dividers --- */
body.sb-collapsed .sb-section-title {
  height: 1px;
  width: 32px;
  margin: 12px auto 10px;
  padding: 0;
  font-size: 0;
  background: var(--border-strong);
  opacity: .6;
}

/* --- Storage: micro vertical meter + hover title --- */
body.sb-collapsed .sb-storage {
  padding: 10px 4px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  cursor: help;
}
body.sb-collapsed .sb-storage .row { display: none; }
body.sb-collapsed .sb-storage .meter {
  width: 6px;
  height: 40px;
  margin: 0 auto;
  border-radius: 99px;
  position: relative;
  background: var(--active);
}
body.sb-collapsed .sb-storage .meter > i {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%;
  height: var(--pct, 30%);
  border-radius: 99px;
}

/* --- Footer avatar centered --- */
body.sb-collapsed .sb-user {
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
}

/* collapse button mirrors direction */
#collapseBtn svg { transition: none; }
html:not(.reduce-motion) #collapseBtn svg { transition: transform 160ms ease; }
body.sb-collapsed #collapseBtn svg { transform: scaleX(-1); }

/* ============================================================
   v16 mobile — drawer must ignore dock styling completely
   ============================================================ */
@media (max-width: 920px) {
  body.sb-collapsed .sidebar { width: 300px !important; max-width: 84vw; }
  body.sb-collapsed .sb-nav { padding: 10px 10px 6px; }
  body.sb-collapsed .sb-item,
  body.sb-collapsed .sb-item.on {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 11px;
    min-height: 0;
    padding: 11px 12px;
    border-radius: var(--r-md);
    box-shadow: none;
  }
  body.sb-collapsed .sb-item svg.ic { width: 17px; height: 17px; }
  body.sb-collapsed .sb-label {
    display: inline !important;
    max-width: none;
    font-size: 13.5px;
    letter-spacing: 0;
    opacity: 1;
    line-height: inherit;
  }
  body.sb-collapsed .sb-section-title {
    height: auto; width: auto; margin: 14px 10px 5px;
    font-size: 10.5px; background: none; opacity: 1;
  }
  body.sb-collapsed .sb-item .count {
    position: static; min-width: 0; width: auto; height: auto;
    font-size: 11px; color: var(--muted); background: none;
    margin-left: auto; overflow: visible;
  }
  body.sb-collapsed .sb-storage { background: var(--surface); border: 1px solid var(--border); padding: 12px; cursor: default; }
  body.sb-collapsed .sb-storage .row { display: flex; }
  body.sb-collapsed .sb-storage .meter { width: auto; height: 5px; margin: 0; }
  body.sb-collapsed .sb-storage .meter > i { position: static; height: 100%; width: var(--pct, 30%); }
  body.sb-collapsed .sb-user { flex-direction: row; align-items: center; gap: 10px; padding: 7px 8px; }
}


/* ============================================================
   v17 — STRICT MONOCHROME: no color anywhere in the GUI
   ============================================================ */

/* semantic colors become ink (danger included — B&W GUI) */
:root {
  --ok: #000000;
  --warn: #52525b;
  --danger: #000000;
  --danger-weak: rgba(0, 0, 0, .07);
}
[data-theme="dark"] {
  --ok: #f4f4f5;
  --warn: #a1a1aa;
  --danger: #ffffff;
  --danger-weak: rgba(255, 255, 255, .1);
}

/* file-type icon tiles lose their rainbow */
.fico.word, .fico.excel, .fico.slide, .fico.pdf, .fico.img,
.fico.media, .fico.code, .fcard .fico.word, .fcard .fico.excel,
.fcard .fico.slide, .fcard .fico.pdf, .fcard .fico.img,
.fcard .fico.media, .fcard .fico.code {
  color: var(--text-2) !important;
  background: var(--active) !important;
}
.office-card .fico { color: var(--accent); background: var(--accent-weak); }

/* stars / pins neutral */
.star-mini, .star-flag { color: var(--muted); }
.note-item .pin-mini { color: var(--accent); }

/* badges all mono */
.badge.danger, .badge.warn { background: var(--active); color: var(--text-2); }

/* progress + upload states mono */
.progress.fail i { background: var(--muted); }
.progress.done i { background: var(--accent); }

/* toasts mono icons */
.toast.err svg.ic, .toast.warn svg.ic { color: var(--muted); }

/* danger buttons read as strong ink */
.btn.danger { background: var(--gradient); }
.btn.danger-soft { background: var(--danger-weak); color: var(--text); border: 1px solid var(--border-strong); }

/* selection dot on collapsed dock: ink instead of red */
body.sb-collapsed .sb-item .count { background: var(--muted); }
body.sb-collapsed .sb-item.on .count { background: var(--bg); }

/* ============================================================
   v21 — Office head: always-visible back + external tab
   ============================================================ */
.oe-head { flex-wrap: wrap; row-gap: 6px; }
.oe-name { min-width: 80px; }
@media (max-width: 640px) {
  .oe-head { padding: 8px 10px; }
  .oe-name { max-width: 40vw; }
  .engine-dot .txt { display: none; }      /* dot-only status on phones */
}

/* ============================================================
   v22 — Mobile bottom-sheet menus + dock contrast fix
   ============================================================ */

/* ---- Bottom sheet (≤640px) ---- */
.nv-sheet-layer { position: fixed; inset: 0; z-index: 3200; }
.nv-sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
[data-theme="light"] .nv-sheet-backdrop { background: rgba(15,20,30,.32); }
.nv-sheet {
  position: absolute; left: 10px; right: 10px;
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  max-height: 70vh;
  background: var(--surface-glass);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  overflow: hidden;
}
html:not(.reduce-motion) .nv-sheet-layer .nv-sheet { animation: nvSheetUp 200ms cubic-bezier(.32,.72,0,1) both; }
@keyframes nvSheetUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.nv-sheet-handle {
  width: 40px; height: 4px; border-radius: 99px;
  background: var(--border-strong);
  margin: 10px auto 2px; flex: none;
}
.nv-sheet-body { overflow-y: auto; padding: 6px 8px calc(10px + env(safe-area-inset-bottom, 0px)); }
.nv-sheet-body .menu-item { padding: 13px 12px; font-size: 14px; border-radius: 12px; }
.nv-sheet-body .menu-item svg.ic { width: 18px; height: 18px; }

/* desktop popover width cap (long labels can't exceed screen) */
.dropdown.drop-viewport, .menu {
  max-width: min(320px, calc(100vw - 16px));
}

/* ---- Collapsed dock: guaranteed label contrast on click/hover/active ---- */
/* active = SOLID ink + gradient top strip (gradient no longer carries text) */
body.sb-collapsed .sb-item.on {
  background: var(--accent);
  color: var(--bg);
}
body.sb-collapsed .sb-item.on::after {
  content: "";
  position: absolute; top: 0; left: 12px; right: 12px; height: 3px;
  border-radius: 0 0 6px 6px;
  background: var(--gradient);
  opacity: .9;
}
body.sb-collapsed .sb-item.on svg.ic,
body.sb-collapsed .sb-item.on .sb-label { color: var(--bg) !important; opacity: 1 !important; }

/* inactive interactions always readable */
body.sb-collapsed .sb-item:hover,
body.sb-collapsed .sb-item:focus-visible,
body.sb-collapsed .sb-item:active { color: var(--text); }
body.sb-collapsed .sb-item:hover svg.ic,
body.sb-collapsed .sb-item:focus-visible svg.ic { color: var(--text); }

/* drawer revert layer keeps same guarantees */
@media (max-width: 920px) {
  body.sb-collapsed .sb-item.on { background: var(--accent-weak); color: var(--accent); }
  body.sb-collapsed .sb-item.on::after { display: none; }
  body.sb-collapsed .sb-item.on svg.ic,
  body.sb-collapsed .sb-item.on .sb-label { color: var(--accent) !important; }
}

/* sheets above everything incl bulkbar/up panel */
.nv-sheet-layer { z-index: 3400; }


/* ============================================================
   v23 — sidebar layout integrity + boxed topbar cluster
   ============================================================ */
.sb-nav { padding-bottom: 14px; }
.sb-foot { padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)); }
@media (max-height: 720px) {
  .sidebar { overflow-y: auto; }
}
/* last item never kisses the edge */
.sb-nav .sb-item:last-child { margin-bottom: 4px; }

/* topbar icon cluster: boxed like the reference design */
.topbar .tb-btn:not(.tb-acc) {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.topbar .tb-btn:not(.tb-acc):hover {
  border-color: var(--border-strong);
  background: var(--hover);
}
.topbar .tb-btn.tb-install { border-color: transparent; }

/* ============================================================
   v24 — TRUE BLACK light mode
   ============================================================ */
[data-theme="light"] {
  --border: #e8e8ea;
  --border-strong: #c9c9ce;
}
/* primary buttons: pure black, crisp */
.btn.primary, .tb-btn.tb-acc { box-shadow: 0 2px 10px rgba(0,0,0,.22); }
.btn.primary:hover { filter: none; background: #000; }
/* collapsed dock active tile: pure black */
body.sb-collapsed .sb-item.on { background: #000; }
body.sb-collapsed .sb-item.on::after { background: #fff; opacity: .25; }
/* sidebar active (expanded) in light: black pill */
.sb-item.on { color: var(--bg); }
[data-theme="light"] .sb-item.on { background: var(--accent); color: #fff; }
[data-theme="light"] .sb-item.on svg.ic { color: #fff; }
/* selection / toggles pure black */
.switch input:checked + i { background: #000; }
.lrow.picked, .fcard.picked { border-color: rgba(0,0,0,.35); }
/* meter fill solid black */
.meter > i { background: #000 !important; }
body.sb-collapsed .sb-storage .meter > i { background: #000 !important; }


/* ============================================================
   v26 — Login screen on mobile
   ============================================================ */
.auth-div { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
@media (max-width: 520px) {
  .auth-wrap {
    padding: 16px;
    padding-top: max(24px, env(safe-area-inset-top, 0px));
    align-items: flex-start;          /* card stays reachable with keyboard open */
  }
  .auth-logo { margin-bottom: 16px; }
  .auth-logo h1 { font-size: 21px; }
  .auth-card .card { padding: 18px 16px; border-radius: var(--r-xl); }
  .btn.lg.block { padding: 13px 16px; font-size: 14.5px; }   /* thumb-friendly */
  .auth-div { margin-bottom: 12px; }
  .auth-note { line-height: 1.6; max-width: 300px; margin-inline: auto; }
}
