/* ==========================================================================
   ClawDeck · global.css
   Design foundation for deck.medkronos.com — an OpenClaw command deck.
   Inspired by the AME design system (ame.medkronos.com).

   Contents
   1.  Design tokens (custom properties)
   2.  Themes — dark (default) + light, explicit [data-theme] + system pref
   3.  Reset
   4.  Base elements & typography
   5.  Scrollbars · selection · focus
   6.  App shell — topbar · subtopbar · double sidebar · content
   7.  Panels & placeholders
   8.  Responsive / mobile
   9.  Reduced motion
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  /* ---- Brand palette ------------------------------------------------
     Same companion scheme as AME: -light / -dark / -muted / -hover / -bright
  ------------------------------------------------------------------------ */
  --color-primary: #2e86ab;          /* deck blue */
  --color-primary-light: #d6e9f3;
  --color-primary-dark: #1b5e7d;
  --color-primary-muted: #6fa8c2;
  --color-primary-hover: #1b5e7d;
  --color-primary-bright: #2e86ab;

  --color-secondary: #14b8a6;        /* teal — agent/live accent */
  --color-secondary-light: #d1f2eb;
  --color-secondary-dark: #0e8577;
  --color-secondary-muted: #58c2b4;
  --color-secondary-hover: #0e8577;
  --color-secondary-bright: #0e8577;

  --color-accent: #f0b429;           /* amber — attention/high yield */
  --color-accent-light: #fcf3cf;
  --color-accent-dark: #b7860b;
  --color-accent-muted: #d9bb5f;
  --color-accent-hover: #d69e12;
  --color-accent-bright: #8a6508;

  --color-success: #27ae60;
  --color-success-light: #d5f5e3;
  --color-success-dark: #1e8449;
  --color-success-muted: #6fbd8f;

  --color-warning: #e67e22;
  --color-warning-light: #fdebd0;
  --color-warning-dark: #af601a;
  --color-warning-muted: #e3a264;

  --color-danger: #e74c3c;
  --color-danger-light: #fadbd8;
  --color-danger-dark: #a93226;
  --color-danger-muted: #d98880;

  --color-info: #2980b9;
  --color-info-light: #d6eaf8;
  --color-info-dark: #1f618d;
  --color-info-muted: #6c9fc0;

  /* ---- Geometry ------------------------------------------------------ */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --space-2xs: 0.25rem;
  --space-xs:  0.5rem;
  --space-sm:  0.75rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2.5rem;

  /* ---- Typography ---------------------------------------------------- */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo,
               Consolas, monospace;
  --font-xs:  0.72rem;
  --font-sm:  0.82rem;
  --font-md:  0.925rem;
  --font-lg:  1.1rem;
  --font-xl:  1.45rem;
  --font-xxl: 2rem;

  /* ---- Motion --------------------------------------------------------- */
  --transition-fast: 120ms;
  --transition-med:  220ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* ---- Shell geometry -------------------------------------------------- */
  --topbar-h: 52px;
  --sidebar-main-w: 210px;
  --sidebar-ctx-w: 260px;
  --sidebar-main-w-collapsed: 58px;

  /* ---- Z-index scale ---------------------------------------------------- */
  --z-sidebar: 40;
  --z-topbar: 50;
  --z-popup: 80;
  --z-toast: 90;
}


/* --------------------------------------------------------------------------
   2. Themes — dark is the default command-deck look
   -------------------------------------------------------------------------- */
:root, [data-theme="dark"] {
  color-scheme: dark;

  --bg-app:       #0d1420;   /* deep navy */
  --bg-primary:   #111a2a;   /* surfaces */
  --bg-secondary: #182338;   /* raised surfaces */
  --bg-tertiary:  #1f2d47;   /* hover/active */
  --bg-inset:     #0a101b;   /* wells, code, inputs */

  --text-primary: #e8edf5;
  --text-secondary: #aebdd2;
  --text-muted:   #6e7f99;

  --border:        #243350;
  --border-strong: #35496e;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.45);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.55);

  --topbar-bg: rgba(13,20,32,0.85);
  --sidebar-bg: #0f1826;
  --overlay: rgba(4,8,15,0.66);

  --color-primary-bright: #7cc0de;
  --color-secondary-bright: #4fd1c0;
  --color-accent-bright: #f3c95c;
}

[data-theme="light"] {
  color-scheme: light;

  --bg-app:       #f2f5f9;
  --bg-primary:   #ffffff;
  --bg-secondary: #f7f9fc;
  --bg-tertiary:  #edf1f7;
  --bg-inset:     #eef2f7;

  --text-primary: #16202e;
  --text-secondary: #44546a;
  --text-muted:   #7d8ca0;

  --border:        #dde4ee;
  --border-strong: #b9c5d6;

  --shadow-sm: 0 1px 2px rgba(20,30,50,0.08);
  --shadow-md: 0 4px 14px rgba(20,30,50,0.10);
  --shadow-lg: 0 12px 40px rgba(20,30,50,0.16);

  --topbar-bg: rgba(255,255,255,0.88);
  --sidebar-bg: #fbfcfe;
  --overlay: rgba(20,30,50,0.35);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) { /* only if theme not explicitly chosen */ }
}


/* --------------------------------------------------------------------------
   3. Reset
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }

img, picture, video, canvas, svg { display: block; max-width: 100%; }
/* …but inline stroke ICONS live inside text runs (step trails, queue title,
   text buttons, menu items) — as blocks they push the label onto a new line.
   Every icon carries aria-hidden="true" (registry + hand-written alike), so
   that attribute is the inline-icon marker. Flex/grid parents don't care. */
svg[aria-hidden="true"] { display: inline-block; }
input, button, textarea, select { font: inherit; color: inherit; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }


/* --------------------------------------------------------------------------
   4. Base elements & typography
   -------------------------------------------------------------------------- */
body {
  font-family: var(--font-sans);
  font-size: var(--font-md);
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: var(--font-xl); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: var(--font-lg); font-weight: 650; }
h3 { font-size: var(--font-md); font-weight: 650; }

a { color: var(--color-primary-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, kbd {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
code { padding: 0.1em 0.4em; }
pre { padding: var(--space-sm) var(--space-md); overflow: auto; }
pre code { padding: 0; border: 0; background: transparent; }

.muted  { color: var(--text-muted); }
.small  { font-size: var(--font-sm); }
.tiny   { font-size: var(--font-xs); }
.mono   { font-family: var(--font-mono); }
.right  { text-align: right; }
.inline { display: inline; }
.hidden { display: none !important; }


/* --------------------------------------------------------------------------
   5. Scrollbars · selection · focus
   -------------------------------------------------------------------------- */
::selection { background: var(--color-primary); color: #fff; }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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


/* --------------------------------------------------------------------------
   6. App shell — topbar · subtopbar · double sidebar · content
   -------------------------------------------------------------------------- */
.topbar {
  position: fixed; inset: 0 0 auto 0;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 0 var(--space-md);
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-topbar);
}
.topbar-brand {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--font-md);
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
}
.topbar-brand:hover { text-decoration: none; }
.brand-text { font-weight: 700; }

/* breadcrumb — current screen shown in the topbar instead of the content */
.topbar-crumb {
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 0;
  font-size: var(--font-md);
  color: var(--text-secondary);
  white-space: nowrap;
}
.crumb-sep { color: var(--text-muted); opacity: 0.7; }
.crumb-label {
  font-weight: 650;
  overflow: hidden; text-overflow: ellipsis;
  max-width: 34vw;
}
.topbar-crumb .phase-tag { flex-shrink: 0; }

.topbar-spacer { flex: 1; }
.topbar-right { display: flex; align-items: center; gap: var(--space-xs); }
.notif-dd { position: relative; }

/* account dropdown (topbar, far right) */
.account-dd { position: relative; }
.avatar-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: 0; padding: 2px;
  cursor: pointer; color: var(--text-muted);
}
.avatar {
  display: grid; place-items: center;
  width: 1.9em; height: 1.9em;
  border-radius: 50%;
  background: var(--color-primary-dark);
  color: #fff; font-weight: 700; font-size: var(--font-sm);
}
[data-theme="light"] .avatar { background: var(--color-primary); }
.dd-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  width: 230px;
  background: var(--bg-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: calc(var(--z-topbar) + 2);
  overflow: hidden;
}
.dd-head {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  font-size: var(--font-sm); color: var(--text-muted);
}
.dd-item {
  display: block; width: 100%; text-align: left;
  padding: 0.55em var(--space-md);
  background: none; border: 0;
  color: var(--text-primary);
  font-size: var(--font-sm);
  cursor: pointer; text-decoration: none;
}
.dd-item:hover { background: var(--bg-tertiary); text-decoration: none; }
/* stroke SVGs inside text buttons/menu items sit on the text baseline */
.dd-item svg, .btn svg { vertical-align: -0.15em; }
.dd-danger { color: var(--color-danger); }

.agent-picker {
  display: inline-flex; align-items: center; gap: var(--space-xs);
  padding: 0.3em 0.9em;
  font-size: var(--font-sm);
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
.agent-picker:hover { border-color: var(--border-strong); }
.agent-picker strong { color: var(--text-primary); }
.agent-picker .ap-label {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: left;
}
.agent-picker .ap-caret {
  width: 13px; height: 13px; flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}
.agent-picker.open .ap-caret { transform: rotate(90deg); }   /* > → ⌄ */
.agent-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-secondary);
  box-shadow: 0 0 6px var(--color-secondary);
}
.caret { font-size: 0.8em; color: var(--text-muted); }
.caret svg { display: block; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-main-w) var(--sidebar-ctx-w) 1fr;
  padding-top: var(--topbar-h);
  height: 100dvh;
}
/* embed=1 bare shell (?embed=1, e.g. Projects "AI coding" iframe):
   no topbar, no main rail — context sidebar + content only. */
body.embed .shell {
  grid-template-columns: var(--sidebar-ctx-w) 1fr;
  padding-top: 0;
}
@media (min-width: 821px) {
  body.embed .shell > .sidebar-context { grid-area: 1 / 1; }
  body.embed .shell > .ctx-resizer { grid-area: 1 / 1; }   /* shares the ctx column, like normal mode */
  body.embed .shell > .content { grid-area: 1 / 2; }
}
body.embed .sidebar-context { border-left: 0; }
/* explicit tracks (desktop grid only): the ctx-resizer SHARES column 2
   with the context sidebar, so every child needs a definite cell —
   otherwise auto-placement skips the occupied track and shoves the
   aside/content one column over. Mobile keeps auto placement (1-col). */
@media (min-width: 821px) {
  .shell > .sidebar-main { grid-area: 1 / 1; }
  .shell > .sidebar-context { grid-area: 1 / 2; }
  .shell > .content { grid-area: 1 / 3; }
}

/* desktop toggles (JS body classes) */
@media (min-width: 821px) {
  body.ctx-hidden .shell { grid-template-columns: var(--sidebar-main-w) 0 1fr; }
  body.ctx-hidden .sidebar-context { display: none; }
  body.main-collapsed .shell { grid-template-columns: var(--sidebar-main-w-collapsed) var(--sidebar-ctx-w) 1fr; }
  body.main-collapsed.ctx-hidden .shell { grid-template-columns: var(--sidebar-main-w-collapsed) 0 1fr; }
  body.main-collapsed .navlabel { display: none; }
  body.main-collapsed .navitem { justify-content: center; }
  /* footer becomes an icon rail: dot-only gateway indicator + vertical user box */
  body.main-collapsed .sidebar-statusrow { justify-content: center; padding: 0; }
  body.main-collapsed .sidebar-statusrow .connstate { font-size: 0; }
  body.main-collapsed .sidebar-statusrow .connstate::before { content: "●"; font-size: var(--font-sm); }
  body.main-collapsed .sidebar-statusrow .versiontag { display: none; }
  body.main-collapsed .accountbox {
    flex-direction: column; align-items: center;
    gap: var(--space-2xs); padding: var(--space-2xs);
  }
  body.main-collapsed .accountbox-id { justify-content: center; }
  body.main-collapsed .accountbox-name { display: none; }
  body.main-collapsed .btn-joined { flex-direction: column; width: 100%; }
  body.main-collapsed .joined-half { width: 100%; }
  body.main-collapsed .joined-half + .joined-half { border-left: 0; border-top: 1px solid var(--border); }
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  min-height: 0;
}
.sidebar-main {
  display: flex; flex-direction: column;
  padding: var(--space-sm) var(--space-xs);
  gap: 2px;
  z-index: var(--z-sidebar);
}
.sidebar-context {
  display: flex; flex-direction: column;
  padding: var(--space-sm);
}

/* --- sidebar 2 drag-resizer ---------------------------------------------
   Shares grid track 2 with .sidebar-context, straddling its right edge.
   Desktop/tablet grid layout only — hidden in mobile drawer mode.
   Width bounds + persistence live in app.js (per-section localStorage). */
.ctx-resizer {
  grid-area: 1 / 2;
  justify-self: end;
  width: 9px; margin-right: -5px;   /* hit area straddles the border */
  cursor: col-resize;
  touch-action: none;
  z-index: calc(var(--z-sidebar) + 2);
  position: relative;
}
.ctx-resizer::after {
  content: ""; position: absolute; inset: 0 auto 0 3px;
  width: 3px; border-radius: 3px;
  background: transparent;
  transition: background var(--transition-fast);
}
.ctx-resizer:hover::after,
body.ctx-resizing .ctx-resizer::after { background: var(--color-secondary); }
body.ctx-resizing { cursor: col-resize; user-select: none; }
/* keep iframes/content from swallowing pointer events mid-drag */
body.ctx-resizing .content { pointer-events: none; }
body.ctx-hidden .ctx-resizer { display: none; }
@media (max-width: 820px) {
  .ctx-resizer { display: none; }   /* sidebar 2 is a right drawer there */
}

.navitem {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 0.55em 0.75em;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--font-sm);
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.navitem:hover { background: var(--bg-tertiary); color: var(--text-primary); text-decoration: none; }
.navitem.active {
  background: var(--color-primary-dark);
  color: #fff;
}
[data-theme="light"] .navitem.active { background: var(--color-primary-light); color: var(--color-primary-dark); }
.navicon { width: 1.4em; text-align: center; font-size: 1.05em; }

.sidebar-footer {
  margin-top: auto;
  padding: var(--space-sm) var(--space-2xs) 0;
}

/* gateway status · version — one row, spaced apart */
.sidebar-statusrow {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-xs);
  padding: 0 var(--space-2xs);
  margin-bottom: var(--space-xs);
}

/* account box: avatar + name left, [theme | settings] joined halves right */
.accountbox {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-xs);
  padding: var(--space-2xs);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xs);
}
.accountbox-id { display: flex; align-items: center; gap: var(--space-xs); min-width: 0; }
.accountbox-name {
  font-size: var(--font-sm); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* context sidebar nav items (e.g. VPS: Logging/Terminal/Quick settings) */
.ctx-item {
  display: flex; align-items: center; gap: var(--space-xs);
  padding: 0.5em 0.6em;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--font-sm);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.ctx-item:hover { background: var(--bg-tertiary); color: var(--text-primary); text-decoration: none; }
.ctx-item.active { background: var(--color-primary-dark); color: #fff; }
[data-theme="light"] .ctx-item.active { background: var(--color-primary-light); color: var(--color-primary-dark); }
.connstate { font-size: var(--font-xs); color: var(--text-muted); }
.connstate.ok  { color: var(--color-success); }
.connstate.err { color: var(--color-danger); }

.ctx-head {
  font-size: var(--font-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--space-2xs) var(--space-2xs) var(--space-xs);
}
.ctx-body { flex: 1; overflow-y: auto; min-height: 0; }
.ctx-actions {
  display: flex; gap: var(--space-xs);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
  margin-top: var(--space-sm);
}

.content {
  overflow-y: auto;
  min-height: 0;
  padding: var(--space-lg);
  display: flex; flex-direction: column;
}
/* chats panel: composer flush with the bottom — no dead space */
.content:has(.panel[data-panel="chats"].active) { padding-bottom: 0; }


/* --------------------------------------------------------------------------
   7. Panels & placeholders
   -------------------------------------------------------------------------- */
.panel { display: none; }
.panel.active {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
  animation: panel-in var(--transition-med) var(--ease-out);
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.phase-tag {
  font-size: var(--font-xs);
  font-weight: 700;
  padding: 0.15em 0.6em;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.placeholder-box {
  background: var(--bg-primary);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  max-width: 720px;
  display: flex; flex-direction: column; gap: var(--space-sm);
}


/* --------------------------------------------------------------------------
   8. Responsive / mobile
   -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  .shell { grid-template-columns: var(--sidebar-main-w-collapsed) var(--sidebar-ctx-w) 1fr; }
  /* same specificity as the global body.ctx-hidden rule above, but LATER in
     the cascade — without it, hiding sidebar 2 would widen the auto-collapsed
     icon rail back to full width on medium screens. */
  body.ctx-hidden .shell { grid-template-columns: var(--sidebar-main-w-collapsed) 0 1fr; }
  .navlabel { display: none; }
  .sidebar-main { align-items: stretch; }
  .navitem { justify-content: center; }
  /* icon rail footer (same treatment as the manual collapse). Scoped under
     .sidebar-main to OUTSPECIFY the ui.css base rules (.btn-joined /
     .joined-half), which load later and would otherwise win the cascade —
     that left the theme/settings buttons at 2em, clipped by overflow:hidden. */
  .sidebar-main .sidebar-statusrow { justify-content: center; padding: 0; }
  .sidebar-main .connstate { font-size: 0; }
  .sidebar-main .connstate::before { content: "●"; font-size: var(--font-sm); }
  .sidebar-main .versiontag { display: none; }
  .sidebar-main .accountbox {
    flex-direction: column; align-items: center;
    gap: var(--space-2xs); padding: var(--space-2xs);
  }
  .sidebar-main .accountbox-id { justify-content: center; }
  .sidebar-main .accountbox-name { display: none; }
  .sidebar-main .btn-joined { flex-direction: column; width: 100%; }
  .sidebar-main .joined-half { width: 100%; }
  .sidebar-main .joined-half + .joined-half { border-left: 0; border-top: 1px solid var(--border); }
}

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; padding-top: var(--topbar-h); }
  .crumb-label { max-width: 22vw; }
  .topbar-crumb .phase-tag { display: none; }
  .sidebar-main {
    position: fixed;
    top: var(--topbar-h); bottom: 0; left: 0;
    width: min(78vw, 300px);
    transform: translateX(-105%);
    transition: transform var(--transition-med) var(--ease-out);
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar-main { transform: none; }
  .navlabel { display: inline; }
  .navitem { justify-content: flex-start; }
  /* the mobile drawer is wide again → restore the full footer.
     Scoped under .sidebar-main to outspecify the ≤1080px icon-rail block
     above (both media queries match at once below 820px). */
  .sidebar-main .sidebar-statusrow { justify-content: space-between; padding: 0 var(--space-2xs); }
  .sidebar-main .connstate { font-size: var(--font-xs); }
  .sidebar-main .connstate::before { content: none; }
  .sidebar-main .versiontag { display: inline; }
  .sidebar-main .accountbox { flex-direction: row; justify-content: space-between; gap: var(--space-xs); }
  .sidebar-main .accountbox-name { display: inline; }
  .sidebar-main .btn-joined { flex-direction: row; width: auto; }
  .sidebar-main .joined-half { width: 2em; }
  .sidebar-main .joined-half + .joined-half { border-left: 1px solid var(--border); border-top: 0; }

  .sidebar-context {
    position: fixed;
    top: var(--topbar-h); bottom: 0; right: 0;
    width: min(82vw, 320px);
    transform: translateX(105%);
    transition: transform var(--transition-med) var(--ease-out);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-sidebar);
  }
  body.ctx-open .sidebar-context { transform: none; }

  .content { padding: var(--space-md); }
  .brand-text { display: none; }

  /* embed stays a static two-pane shell even on small screens */
  body.embed .shell { padding-top: 0; grid-template-columns: var(--sidebar-ctx-w) 1fr; }
  body.embed .sidebar-context {
    position: static; transform: none; width: auto; box-shadow: none;
  }
}


/* --------------------------------------------------------------------------
   9. Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
