:root {
  --rd-primary: var(--ds-primary, #FF9000);
  --rd-primary-fg: var(--ds-primary-foreground, #ffffff);
  --rd-primary-soft: color-mix(in srgb, var(--rd-primary) 16%, transparent);
  --rd-secondary: var(--ds-secondary, #FF4C4C);
  --rd-bg: var(--ds-bg-1, #F9FAFB);
  --rd-surface: var(--ds-bg-2, #FFFFFF);
  --rd-ink: var(--ds-fg-1, #212121);
  --rd-ink-2: var(--ds-fg-2, #7F7F7A);
  --rd-ink-3: var(--ds-fg-3, #9A9A97);
  --rd-ink-4: var(--ds-fg-4, #ABABAB);
  --rd-border: var(--ds-border-2, #E4E4E7);
  --rd-destructive: var(--ds-destructive, #DC2626);
  --rd-warning: var(--ds-warning, #FFE066);
  --rd-radius: 12px;
  --rd-radius-small: 8px;
  --rd-font: "Montserrat", "Segoe UI", system-ui, -apple-system, sans-serif;
  --rd-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --rd-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.06);
  --rd-topbar-h: 56px;
  --rd-sidebar-w: 232px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  height: 100vh;
  font-family: var(--rd-font);
  background: var(--rd-bg);
  color: var(--rd-ink);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--rd-primary); }

button { font-family: inherit; }

/* ---------- app shell (sidebar + main) ---------- */

.app-shell {
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.app-shell.locked .app-sidebar,
.app-shell.locked .app-topbar { display: none; }

.login-gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--rd-surface);
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius);
  box-shadow: var(--rd-shadow);
  padding: 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.login-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--rd-primary);
  color: var(--rd-primary-fg);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 24px;
}

.login-title { margin: 0; font-size: 22px; font-weight: 700; }
.login-lede { margin: 0; color: var(--rd-ink-3); font-size: 14px; line-height: 1.6; }
.login-cta { margin-top: 6px; }

.app-sidebar {
  flex: 0 0 var(--rd-sidebar-w);
  width: var(--rd-sidebar-w);
  background: var(--rd-surface);
  border-right: 1px solid var(--rd-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 12px;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--rd-ink);
  padding: 6px 8px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--rd-border);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--rd-primary);
  color: var(--rd-primary-fg);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  flex: 0 0 auto;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.back-to-projects {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--rd-ink-3);
  font-weight: 600;
  font-size: 12.5px;
  padding: 7px 8px;
  margin-bottom: 2px;
  border-radius: var(--rd-radius-small);
}

.back-to-projects:hover { color: var(--rd-ink); background: var(--rd-bg); }

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.app-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--rd-ink-2);
  font-weight: 600;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: var(--rd-radius-small);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.app-nav a .nav-icon {
  flex: 0 0 auto;
  width: 18px;
  text-align: center;
  color: var(--rd-ink-4);
  font-size: 13px;
}

.app-nav a .nav-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.2;
}

.app-nav a .nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-nav a .nav-hint {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--rd-ink-4);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.app-nav a:hover { color: var(--rd-ink); background: var(--rd-bg); }

.app-nav a.active {
  color: var(--rd-primary-fg);
  background: var(--rd-primary);
}

.app-nav a.active .nav-icon,
.app-nav a.active .nav-hint { color: var(--rd-primary-fg); opacity: 0.72; }

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--rd-ink-4);
  padding: 10px 12px 4px;
}

.nav-sep {
  height: 1px;
  background: var(--rd-border);
  margin: 8px 10px;
}

.nav-sep-flows { margin: 6px 10px 8px; }

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- top bar ---------- */

.app-topbar {
  flex: 0 0 auto;
  height: var(--rd-topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--rd-surface);
  border-bottom: 1px solid var(--rd-border);
  position: relative;
  z-index: 30;
}

.sidebar-toggle {
  display: none;
  border: 1px solid var(--rd-border);
  background: transparent;
  color: var(--rd-ink-2);
  font-size: 16px;
  line-height: 1;
  padding: 5px 10px;
  border-radius: var(--rd-radius-small);
  cursor: pointer;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
  font-size: 13.5px;
}

.breadcrumb .crumb {
  color: var(--rd-ink-3);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.breadcrumb a.crumb:hover { color: var(--rd-ink); text-decoration: underline; }

.breadcrumb .crumb-current { color: var(--rd-ink); font-weight: 700; }

.breadcrumb .crumb-sep { color: var(--rd-ink-4); flex: 0 0 auto; }

.topbar-spacer { flex: 1; min-width: 8px; }

.header-status {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}

.auth-slot { display: flex; align-items: center; gap: 8px; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--rd-ink-2);
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--rd-primary-soft);
  color: var(--rd-primary);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  flex: 0 0 auto;
}

.user-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #C4C4C4;
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.health-dot[data-state="ok"] { background: #22C55E; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }
.health-dot[data-state="warn"] { background: var(--rd-warning); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2); }
.health-dot[data-state="down"] { background: var(--rd-destructive); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18); }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 35;
}

.sidebar-backdrop[hidden] { display: none; }

/* ---------- buttons / chips / badges ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--rd-border);
  background: var(--rd-surface);
  color: var(--rd-ink-2);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--rd-radius-small);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn:hover { border-color: var(--rd-ink-4); color: var(--rd-ink); }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--rd-primary);
  border-color: var(--rd-primary);
  color: var(--rd-primary-fg);
}

.btn-primary:hover { filter: brightness(1.08); color: var(--rd-primary-fg); border-color: var(--rd-primary); }

.btn-ghost { border-color: transparent; background: transparent; }

.btn-small { padding: 5px 10px; font-size: 12px; }

.theme-toggle { font-size: 15px; line-height: 1; padding: 5px 9px; color: var(--rd-ink-2); }
.theme-toggle:hover { color: var(--rd-ink); background: var(--rd-bg); border-color: var(--rd-border); }

.btn-danger-ghost { border-color: transparent; background: transparent; color: var(--rd-destructive); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--rd-ink-3);
  background: var(--rd-bg);
  border: 1px solid var(--rd-border);
  border-radius: 999px;
  padding: 3px 10px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.chip-mono { font-family: var(--rd-mono); font-weight: 500; }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2.5px 10px;
  white-space: nowrap;
}

.badge-success { background: #DCFCE7; color: #016630; }
.badge-error { background: #FFE2E2; color: #9F0712; }
.badge-info { background: #DBEAFE; color: #193CB8; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-purple { background: #F3E8FF; color: #6E11B0; }
.badge-neutral { background: #E5E7EB; color: #374151; }

.lock-chip {
  background: #FEF3C7;
  border-color: #FDE68A;
  color: #92400E;
}

/* ---------- layout ---------- */

.view-root {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.view-root.full {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-title { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }

.page-subtitle { margin: 4px 0 0; color: var(--rd-ink-3); font-size: 13.5px; }

.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- states ---------- */

.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 64px 24px;
  text-align: center;
  color: var(--rd-ink-3);
}

.state-block .state-title { font-size: 16px; font-weight: 700; color: var(--rd-ink-2); }

.state-block .state-hint { font-size: 13px; max-width: 460px; }

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--rd-border);
  border-top-color: var(--rd-primary);
  border-radius: 50%;
  animation: rd-spin 0.8s linear infinite;
}

@keyframes rd-spin { to { transform: rotate(360deg); } }

/* ---------- toolbar + stage (canvas / time machine / ds) ---------- */

.toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--rd-surface);
  border-bottom: 1px solid var(--rd-border);
  flex-wrap: wrap;
}

.toolbar-title {
  font-size: 15.5px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.toolbar-subtitle {
  color: var(--rd-ink-3);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

.toolbar-spacer { flex: 1; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  color: var(--rd-ink-3);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--rd-radius-small);
}

.back-link:hover { background: var(--rd-bg); color: var(--rd-ink); }

.stage {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--rd-bg);
}

.stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.stage iframe.canvas-frame-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  background: var(--rd-surface);
}

.stage-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--rd-bg);
  color: var(--rd-ink-3);
  font-size: 13px;
  font-weight: 600;
  z-index: 5;
}

/* ---------- projects grid ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--rd-surface);
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius);
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}

.project-card:hover {
  box-shadow: var(--rd-shadow);
  transform: translateY(-2px);
  border-color: var(--rd-ink-4);
}

.project-thumb {
  position: relative;
  height: 190px;
  background:
    radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--rd-primary) 14%, transparent), transparent 60%),
    var(--rd-bg);
  overflow: hidden;
  border-bottom: 1px solid var(--rd-border);
}

.project-thumb iframe {
  position: absolute;
  top: 14px;
  left: 50%;
  border: 0;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.12);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s;
}

.project-thumb iframe.loaded { opacity: 1; }

.thumb-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--rd-ink-4);
}

.thumb-placeholder-mark { font-size: 28px; font-weight: 800; line-height: 1; }

.thumb-placeholder-hint { font-size: 12px; font-weight: 600; color: var(--rd-ink-3); }

.project-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }

.project-card-name { font-size: 16px; font-weight: 700; margin: 0; overflow-wrap: anywhere; }

.project-card-desc {
  margin: 0;
  color: var(--rd-ink-3);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.project-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
}

.app-thumb {
  height: 140px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--rd-primary) 22%, transparent), transparent 60%),
    var(--rd-bg);
  border-bottom: 1px solid var(--rd-border);
}

.app-thumb-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--rd-primary);
  color: var(--rd-primary-fg);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
}

/* ---------- time machine ---------- */

.tm-strip {
  flex: 0 0 auto;
  background: var(--rd-surface);
  border-bottom: 1px solid var(--rd-border);
  padding: 14px 18px 10px;
  overflow-x: auto;
}

.tm-track {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-width: min-content;
  position: relative;
}

.tm-track::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 30px;
  right: 30px;
  height: 2px;
  background: var(--rd-border);
}

.tm-item {
  position: relative;
  flex: 0 0 auto;
  width: 148px;
  padding: 0 8px;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-family: inherit;
}

.tm-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--rd-surface);
  border: 3px solid var(--rd-ink-4);
  z-index: 1;
  transition: border-color 0.15s, transform 0.15s;
}

.tm-item:hover .tm-dot { border-color: var(--rd-primary); }

.tm-item.selected .tm-dot {
  border-color: var(--rd-primary);
  background: var(--rd-primary);
  transform: scale(1.15);
}

.tm-date { font-size: 11px; color: var(--rd-ink-4); font-weight: 600; }

.tm-user { font-size: 12.5px; font-weight: 700; color: var(--rd-ink-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tm-task {
  font-size: 11.5px;
  color: var(--rd-ink-3);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-item.selected .tm-user { color: var(--rd-primary); }

.tm-more {
  align-self: center;
  margin: 0 10px;
  flex: 0 0 auto;
}

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

.tm-stage { flex: 1; min-width: 0; position: relative; background: var(--rd-bg); }

.tm-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }

.tm-panel {
  flex: 0 0 320px;
  border-left: 1px solid var(--rd-border);
  background: var(--rd-surface);
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tm-panel h3 { margin: 0; font-size: 14px; font-weight: 800; overflow-wrap: anywhere; }

.tm-panel-section { display: flex; flex-direction: column; gap: 6px; }

.tm-panel-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--rd-ink-4);
}

.tm-panel-value { font-size: 13px; color: var(--rd-ink-2); overflow-wrap: anywhere; }

.file-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  font-family: var(--rd-mono);
  color: var(--rd-ink-2);
  padding: 3px 0;
  overflow-wrap: anywhere;
}

.file-status {
  flex: 0 0 18px;
  text-align: center;
  font-weight: 700;
  border-radius: 4px;
  font-size: 11px;
  line-height: 18px;
}

.file-status[data-status="A"] { background: #DCFCE7; color: #016630; }
.file-status[data-status="M"] { background: #DBEAFE; color: #193CB8; }
.file-status[data-status="D"] { background: #FFE2E2; color: #9F0712; }
.file-status[data-status="?"] { background: #E5E7EB; color: #374151; }

/* ---------- sessions ---------- */

.session-group { margin-bottom: 28px; }

.session-group-title {
  font-size: 14px;
  font-weight: 800;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-group-title .avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--rd-primary-soft);
  color: var(--rd-primary);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.session-card {
  background: var(--rd-surface);
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.session-task { font-size: 14.5px; font-weight: 700; flex: 1; min-width: 200px; overflow-wrap: anywhere; }

.session-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--rd-ink-3);
  font-size: 12.5px;
}

.ephemeral-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FEF3C7;
  border: 1px solid #FDE68A;
  color: #92400E;
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: var(--rd-radius-small) var(--rd-radius-small) 0 0;
  border-bottom: 0;
}

.session-preview {
  border: 1px solid #FDE68A;
  border-radius: 0 0 var(--rd-radius-small) var(--rd-radius-small);
  overflow: hidden;
  position: relative;
  height: 68vh;
  background: var(--rd-bg);
}

.session-preview iframe { width: 100%; height: 100%; border: 0; background: #fff; }

/* ---------- ds view ---------- */

.ds-changelog {
  flex: 0 0 auto;
  max-height: 40vh;
  overflow-y: auto;
  background: var(--rd-surface);
  border-bottom: 1px solid var(--rd-border);
  padding: 16px 22px;
  font-size: 13px;
}

.ds-changelog .md-code {
  background: #0F172A;
  color: #E2E8F0;
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 12px;
  font-family: var(--rd-mono);
}

.ds-changelog .md-inline-code {
  font-family: var(--rd-mono);
  font-size: 12px;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ---------- toasts ---------- */

.toast-stack {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  max-width: 380px;
}

.toast {
  background: #1E293B;
  color: #F1F5F9;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 16px;
  border-radius: var(--rd-radius-small);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.25);
  animation: rd-toast-in 0.25s ease-out;
}

.toast-error { background: #7F1D1D; }
.toast-success { background: #14532D; }

.toast.out { opacity: 0; transition: opacity 0.3s; }

@keyframes rd-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 30px rgba(15, 23, 42, 0.15);
  }
  .app-shell.sidebar-open .app-sidebar { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; align-items: center; }
}

.branch-slot { flex: 0 0 auto; }
.branch-selector { position: relative; display: inline-flex; }
.branch-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius-small);
  background: var(--rd-bg);
  color: var(--rd-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  max-width: 260px;
  transition: border-color 0.15s, background 0.15s;
}
.branch-trigger:hover { border-color: var(--rd-ink-3); }
.branch-selector.is-session .branch-trigger {
  border-color: var(--rd-primary);
  background: var(--rd-primary-soft);
  color: var(--rd-primary);
}
.branch-icon { font-size: 13px; line-height: 1; opacity: 0.85; }
.branch-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.branch-caret { font-size: 10px; opacity: 0.6; }
.branch-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  width: 300px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 6px;
  background: var(--rd-surface);
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius);
  box-shadow: var(--rd-shadow);
}
.branch-group-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--rd-ink-4);
  padding: 8px 10px 4px;
}
.branch-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--rd-radius-small);
  background: transparent;
  color: var(--rd-ink-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.branch-option:hover { background: var(--rd-bg); color: var(--rd-ink); }
.branch-option.active { background: var(--rd-primary); color: var(--rd-primary-fg); }
.branch-option.active .branch-option-sub { color: var(--rd-primary-fg); opacity: 0.85; }
.branch-option-icon { font-size: 13px; line-height: 1; opacity: 0.8; }
.branch-option-text { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.branch-option-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.branch-option-sub { font-size: 11px; color: var(--rd-ink-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.branch-empty { padding: 8px 10px; font-size: 12.5px; color: var(--rd-ink-4); }

@media (max-width: 860px) {
  .app-topbar { gap: 10px; padding: 0 14px; }
  .tm-panel { display: none; }
  .toolbar-title, .toolbar-subtitle { max-width: 200px; }
  .page { padding: 20px 14px 40px; }
  .user-name { display: none; }
  .breadcrumb .crumb { max-width: 140px; }
  .branch-label { display: none; }
  .branch-popover { width: 260px; }
}
