/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; transition: grid-template-columns var(--t-base) var(--ease); }
.shell.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column;
  padding: var(--sp-4) var(--sp-3); gap: var(--sp-2); overflow: hidden; z-index: 30;
}
/* The teal wash behind the nav tinted every label differently depending on how far down it sat. Flat. */
/* the sidebar is dark in both themes, so its text stays light regardless of --on-solid */
.brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-2) var(--sp-4); color: var(--sidebar-text-active); position: relative; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; flex: none; }
.brand-mark img { width: 30px; height: auto; display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { font-weight: var(--fw-semi); font-size: var(--fs-md); letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { font-size: var(--fs-xs); opacity: .7; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 3px; position: relative; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--sidebar-text); font-weight: 500; font-size: var(--fs-sm);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); position: relative; white-space: nowrap;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav a:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text-active); }
.nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-text-active); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
/* one rail element slides between items (shell.js positions it); the per-item ::before is the no-JS fallback */
.nav a.active::before { content: ""; position: absolute; inset-inline-start: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--sidebar-rail); }
.nav.has-rail a.active::before { display: none; }
.nav-items { display: contents; }
.nav .nav-rail { position: absolute; inset-inline-start: -12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--sidebar-rail); transition: top .32s var(--ease-spring), height .2s var(--ease); pointer-events: none; box-shadow: 0 0 10px rgba(180,224,39,.45); }
[dir="rtl"] .nav .nav-rail { border-radius: 3px 0 0 3px; }
.nav a { transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
[dir="rtl"] .nav a.active::before { border-radius: 3px 0 0 3px; }
/* the count badge carried white on coral-500 at 2.8:1 — unreadable at 11px */
.nav .badge-count { margin-inline-start: auto; background: var(--lime); color: var(--on-lime); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; min-width: 20px; text-align: center; }
.nav-sub { display: flex; flex-direction: column; gap: 2px; padding-inline-start: 34px; overflow: hidden; max-height: 0; transition: max-height var(--t-base) var(--ease); }
.nav-group.open .nav-sub { max-height: 200px; }
.nav-sub a { padding: 7px 10px; font-size: var(--fs-sm); font-weight: 400; opacity: .9; } .nav-sub a::before { display: none; }
.sidebar-foot { margin-top: auto; position: relative; display: flex; flex-direction: column; gap: var(--sp-2); }
.sidebar-user { display: flex; align-items: center; gap: var(--sp-3); padding: 10px 12px; border-radius: var(--r-md); background: rgba(255,255,255,.06); color: var(--sidebar-text-active); }
.sidebar-user .who { min-width: 0; } .sidebar-user .who b { display: block; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .sidebar-user .who span { font-size: var(--fs-xs); opacity: .7; }
.collapse-btn { color: var(--sidebar-text); padding: 8px 12px; border-radius: var(--r-sm); display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); } .collapse-btn:hover { background: var(--sidebar-hover-bg); color: var(--on-solid); }
.shell.collapsed .brand-name, .shell.collapsed .brand-sub, .shell.collapsed .nav a span, .shell.collapsed .sidebar-user .who, .shell.collapsed .collapse-btn span, .shell.collapsed .nav-sub, .shell.collapsed .badge-count { display: none; }
.shell.collapsed .nav a { justify-content: center; padding: 11px; } .shell.collapsed .brand { justify-content: center; } .shell.collapsed .sidebar-user { justify-content: center; }
.shell.collapsed .collapse-btn { justify-content: center; } .shell.collapsed .collapse-btn svg { transform: scaleX(-1); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-6);
  background: var(--topbar-bg); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%); border-bottom: 1px solid var(--border);
}
.topbar .search { flex: 1; max-width: 520px; position: relative; }
.topbar .search input { width: 100%; height: var(--control-h); border-radius: var(--r-xs); border: 1px solid var(--border); background: var(--surface); padding: 0 36px; transition: box-shadow var(--t-fast), border-color var(--t-fast); }
.topbar .search input:focus { border-color: var(--brand); box-shadow: var(--ring); }
.topbar .search svg { position: absolute; inset-inline-start: 11px; top: 9px; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.topbar .search kbd { position: absolute; inset-inline-end: 9px; top: 8px; font-size: 11px; color: var(--text-4); border: 1px solid var(--border); border-radius: var(--r-xs); padding: 1px 6px; background: var(--surface-2); }
.search-results { position: absolute; top: 46px; inset-inline: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: var(--sp-2); z-index: var(--z-tooltip); max-height: 420px; overflow: auto; }
.search-results .group { font-size: var(--fs-xs); color: var(--text-4); text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px 4px; }
.search-results a { display: flex; align-items: center; gap: var(--sp-2); padding: 8px 10px; border-radius: var(--r-sm); color: var(--text); } .search-results a:hover { background: var(--surface-hover); }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-2); }
.icon-btn { width: var(--control-h); height: var(--control-h); border-radius: var(--r-xs); display: grid; place-items: center; color: var(--text-2); position: relative; transition: background var(--t-fast), color var(--t-fast); }
.icon-btn:hover { background: var(--surface-3); color: var(--text); } .icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot { position: absolute; top: 8px; inset-inline-end: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--rose-500); box-shadow: 0 0 0 2px var(--surface); }
.icon-btn .dot.pulse { animation: pulse-dot 1.6s var(--ease) infinite; }
.lang-toggle { height: var(--control-h); padding: 0 10px; border-radius: var(--r-xs); font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); background: var(--surface-3); }
.lang-toggle:hover { color: var(--brand-ink); background: var(--brand-soft); }
.ai-pill { display: inline-flex; align-items: center; gap: 6px; height: var(--control-h); padding: 0 10px; border-radius: var(--r-xs); font-size: var(--fs-xs); font-weight: 600; background: var(--ai-soft); color: var(--ai-strong); }
.ai-pill.off { background: var(--surface-3); color: var(--text-3); } .ai-pill svg { width: 16px; height: 16px; }

/* Page rhythm. Content gets room to breathe at the edges (24px) and a consistent 24px between blocks, but the
   header itself is compact: a title, a line of context, and the actions — not a hero. The eyebrow used to be
   brand-coloured and uppercase, which made every screen open with a shout; it is a quiet label now. */
.page { padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-6); animation: page-in var(--t-slow) var(--ease-out) both; max-width: 1600px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-2xl); font-weight: var(--fw-semi); }
.page-head h1 svg.ic { width: 20px; height: 20px; color: var(--text-3); }
.page-head .eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-4); margin-bottom: 3px; }
.page-head .sub { color: var(--text-3); font-size: var(--fs-sm); margin-top: 3px; max-width: 76ch; }
.page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* notifications panel */
.notif-panel { position: fixed; top: calc(var(--topbar-h) + 6px); inset-inline-end: 20px; width: 380px; max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); z-index: var(--z-menu); animation: drop-in var(--t-base) var(--ease-out) both; }
.notif-panel header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.notif { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background var(--t-fast); } .notif:hover { background: var(--surface-hover); }
.notif.unread { background: var(--brand-soft); } .notif .ico { width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.notif .ico svg { width: 18px; height: 18px; } .notif b { display: block; font-size: var(--fs-sm); } .notif p { font-size: var(--fs-xs); color: var(--text-3); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; } .sidebar { position: fixed; inset-inline-start: 0; width: var(--sidebar-w); transform: translateX(calc(-100% * var(--dir, 1))); transition: transform var(--t-base) var(--ease); }
  [dir="rtl"] .sidebar { --dir: -1; } .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .page { padding: var(--sp-4); } .topbar { padding: 0 var(--sp-4); }
  .shell.collapsed .brand-name, .shell.collapsed .nav a span, .shell.collapsed .sidebar-user .who { display: block; }
}

/* ---------- presence: who is around, and your own status ---------- */
.presence-bar { display: flex; align-items: center; gap: 10px; }
.who-online { display: flex; align-items: center; }
.who-online .avatar.xs { width: 26px; height: 26px; font-size: 9.5px; border: 2px solid var(--surface); margin-inline-start: -7px; position: relative; }
.who-online .avatar.xs:first-child { margin-inline-start: 0; }
.who-online .avatar.more { background: var(--surface-3); color: var(--text-2); font-weight: 700; }
.who-online .avatar::after { content: ""; position: absolute; inset-block-end: -1px; inset-inline-end: -1px; width: 9px; height: 9px;
  border-radius: 50%; border: 2px solid var(--surface); background: var(--text-4); }
.who-online .avatar.p-online::after { background: var(--success); }
.who-online .avatar.p-away::after   { background: var(--warning); }
.who-online .avatar.p-busy::after   { background: var(--danger); }

.my-presence { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); }
.my-presence:hover { border-color: var(--brand); color: var(--brand); }
.my-presence .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-4); flex: none; }
.my-presence.p-online .dot, .my-presence.p-auto .dot { background: var(--success); }
.my-presence.p-away .dot { background: var(--warning); }
.my-presence.p-busy .dot { background: var(--danger); }
@media (max-width: 1100px) { .who-online { display: none; } .hide-sm { display: none; } }
