:root {
  --lab-shell-bg: #ffffff;
  --lab-shell-surface: rgba(255, 255, 255, 0.96);
  --lab-shell-surface-strong: #ffffff;
  --lab-shell-border: rgba(148, 163, 184, 0.18);
  --lab-shell-text: #0f172a;
  --lab-shell-muted: #475569;
  --lab-shell-subtle: #64748b;
  --lab-shell-accent: #2563eb;
  --lab-shell-shadow: 0 18px 42px rgba(15, 23, 42, 0.06);
  --lab-shell-shadow-soft: 0 12px 24px rgba(15, 23, 42, 0.04);
}

.lab-dir-actions {
  display: grid;
  gap: 8px;
  padding: 14px 0 0;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.lab-dir-actions--flex {
  margin-top: auto;
}

.lab-dir-sidebar {
  position: relative;
  padding-bottom: 124px;
}

.lab-dir-actions--absolute {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
}

.lab-dir-actions--floating {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9998;
  width: clamp(220px, 16vw, 280px);
  border-radius: 22px;
  border: 1px solid var(--lab-shell-border);
  background: var(--lab-shell-surface-strong);
  box-shadow: var(--lab-shell-shadow-soft);
  backdrop-filter: blur(18px);
  border-top: none;
  padding: 12px;
}

.lab-dir-btn,
.lab-shell-chip,
.lab-shell-nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(248, 250, 252, 0.96);
  color: var(--lab-shell-muted);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.lab-dir-btn:hover,
.lab-shell-chip:hover,
.lab-shell-nav-toggle:hover {
  transform: translateY(-1px);
  background: #ffffff;
  color: var(--lab-shell-text);
  border-color: rgba(37, 99, 235, 0.2);
}

.lab-dir-btn.lab-dir-home,
.lab-shell-chip.is-home {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  border-color: transparent;
  color: #ffffff;
}

.lab-dir-btn.lab-dir-home:hover,
.lab-shell-chip.is-home:hover {
  color: #ffffff;
}

.lab-shell-nav-toggle {
  width: 54px;
  min-width: 54px;
  padding: 0;
  flex-shrink: 0;
}

.lab-shell-navicon {
  display: grid;
  gap: 4px;
}

.lab-shell-navicon span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.lab-dir-btn:focus-visible,
.lab-shell-chip:focus-visible,
.lab-shell-nav-toggle:focus-visible,
.lab-dir-close:focus-visible,
.lab-dir-link:focus-visible,
.lab-dir-clickable:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.55);
  outline-offset: 2px;
}

.lab-dir-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
}

.lab-dir-overlay.is-open {
  display: block;
}

.lab-dir-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}

.lab-dir-panel {
  position: relative;
  width: min(1180px, calc(100vw - 40px));
  margin: 40px auto;
  background: var(--lab-shell-surface-strong);
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: var(--lab-shell-shadow);
  max-height: calc(100dvh - 80px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lab-dir-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.9));
}

.lab-dir-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--lab-shell-text);
}

.lab-dir-subtitle {
  font-size: 13px;
  color: var(--lab-shell-subtle);
  margin-top: 4px;
}

.lab-dir-close {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.12);
  font-size: 22px;
  line-height: 1;
  color: var(--lab-shell-subtle);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.lab-dir-close:hover {
  color: var(--lab-shell-text);
  background: rgba(148, 163, 184, 0.18);
  transform: translateY(-1px);
}

.lab-dir-body {
  padding: 18px 24px 24px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  background: #ffffff;
}

.lab-dir-group {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 20px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.82), rgba(255, 255, 255, 0.98));
}

.lab-dir-group-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--lab-shell-text);
}

.lab-dir-group-desc {
  font-size: 12px;
  color: var(--lab-shell-subtle);
  margin: 4px 0 12px;
  line-height: 1.6;
}

.lab-dir-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.lab-dir-link {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #ffffff;
  color: var(--lab-shell-muted);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.55;
  transition: transform 0.18s ease, border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.lab-dir-link:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.2);
  color: var(--lab-shell-accent);
  background: rgba(239, 246, 255, 0.9);
}

.lab-dir-link.is-current {
  border-color: rgba(37, 99, 235, 0.32);
  background: rgba(219, 234, 254, 0.82);
  color: #1e3a8a;
  font-weight: 700;
}

.lab-dir-open {
  overflow: hidden;
}

.lab-dir-clickable {
  cursor: pointer;
}

body.lab-shell-page {
  display: flex;
  align-items: stretch;
  min-height: 100dvh;
  width: auto;
  overflow-x: hidden;
  background: var(--lab-shell-bg);
  color: var(--lab-shell-text);
}

body.lab-shell-page .side,
body.lab-shell-page .sb {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100dvh;
  width: clamp(84px, 6.4vw, 96px);
  padding: 14px 8px 14px;
  gap: 14px;
  border-right: 1px solid var(--lab-shell-border);
  background: #ffffff;
  box-shadow: none;
  backdrop-filter: none;
}

body.lab-shell-page .main {
  display: grid;
  align-content: start;
  min-width: 0;
  min-height: 100dvh;
  padding: clamp(18px, 1.8vw, 26px) clamp(16px, 1.9vw, 28px) clamp(22px, 2.4vw, 34px);
}

body.lab-shell-page .main.no-sb {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.55) transparent;
}

body.lab-shell-page .side-hd {
  display: none !important;
}

body.lab-shell-page .side .side-tabs,
body.lab-shell-page .sb .side-tabs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 10px 0 0;
}

body.lab-shell-page .side .side-nav,
body.lab-shell-page .sb .side-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: auto;
  padding: 14px 0 0;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
}

body.lab-shell-page .nb,
body.lab-shell-page .sb button,
body.lab-shell-page .side a.nb,
body.lab-shell-page .sb a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 56px;
  padding: 10px 6px;
  border: 1px solid transparent;
  border-radius: 16px;
  color: var(--lab-shell-subtle);
  background: transparent;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

body.lab-shell-page .nb:hover,
body.lab-shell-page .sb button:hover,
body.lab-shell-page .side a.nb:hover,
body.lab-shell-page .sb a:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(37, 99, 235, 0.16);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
}

body.lab-shell-page .nb.on,
body.lab-shell-page .sb button.on {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.14), rgba(14, 165, 233, 0.1));
  border-color: rgba(37, 99, 235, 0.2);
  color: var(--lab-shell-text);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.08);
}

body.lab-shell-page .nb svg,
body.lab-shell-page .sb button svg,
body.lab-shell-page .side a.nb svg,
body.lab-shell-page .sb a svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.lab-shell-page .pnl,
body.lab-shell-page .pnl.on {
  width: 100%;
  max-width: none;
}

body.lab-shell-page .pnl.on {
  animation: none;
  opacity: 1;
  transform: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  gap: clamp(22px, 2.6vw, 34px);
}

body.lab-shell-page .pnl > .g,
body.lab-shell-page .pnl > div {
  min-width: 0;
}

body.lab-shell-page .lab-shell-mobilebar,
body.lab-shell-page .lab-shell-backdrop {
  display: none;
}

body.lab-shell-page .lab-shell-mobilebar {
  position: fixed;
  left: 12px;
  right: 12px;
  top: 12px;
  z-index: 1201;
  display: none;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--lab-shell-shadow-soft);
  backdrop-filter: blur(18px);
}

.lab-shell-mobilecopy {
  min-width: 0;
  display: flex;
  align-items: center;
}

.lab-shell-mobiletitle {
  color: var(--lab-shell-text);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lab-shell-mobileeyebrow,
.lab-shell-mobilesubtitle {
  display: none;
}

.lab-shell-mobileactions {
  display: inline-flex;
  gap: 8px;
}

body.lab-shell-page .side .side-tabs,
body.lab-shell-page .sb .side-tabs {
  padding-top: 16px;
}

.lab-shell-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1198;
  border: 0;
  background: rgba(15, 23, 42, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
}

@media (max-width: 1024px) {
  body.lab-shell-page {
    display: block;
    padding-top: 84px;
  }

  .lab-dir-actions--floating {
    left: 50%;
    right: auto;
    bottom: max(14px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(calc(100vw - 28px), 240px);
    padding: 10px;
  }

  body.lab-shell-page .lab-shell-mobilebar {
    display: grid;
  }

  body.lab-shell-page .side,
  body.lab-shell-page .sb {
    position: fixed;
    inset: 0 auto 0 0;
    align-items: stretch;
    width: min(320px, calc(100vw - 52px));
    height: 100dvh;
    transform: translateX(-110%);
    transition: transform 0.28s ease;
    z-index: 1200;
    overflow-y: auto;
    padding: 88px 16px 24px;
  }

  body.lab-shell-page .side .side-tabs,
  body.lab-shell-page .side .side-nav {
    align-items: stretch;
  }

  body.lab-shell-page .side .side-nav {
    padding-top: 16px;
    border-top: 1px solid rgba(148, 163, 184, 0.16);
  }

  body.lab-shell-page .side .nb,
  body.lab-shell-page .sb button,
  body.lab-shell-page .sb a,
  body.lab-shell-page .side a.nb {
    width: 100%;
    min-height: 56px;
    height: auto;
    justify-content: flex-start;
    flex-direction: row;
    gap: 12px;
    padding: 14px 16px;
    text-align: left;
  }

  body.lab-shell-page .side .nb span,
  body.lab-shell-page .sb button span,
  body.lab-shell-page .sb a span {
    display: inline;
  }

  body.lab-shell-page .side .nb svg,
  body.lab-shell-page .sb button svg,
  body.lab-shell-page .sb a svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  body.lab-shell-page .side-hd {
    padding: 0 8px 16px;
    text-align: left;
  }

  body.lab-shell-page .main {
    min-height: calc(100dvh - 84px);
    padding: 26px 16px 24px;
  }

  body.lab-shell-page .pnl.on {
    padding: 0;
    border-radius: 0;
    gap: 18px;
  }

  body.lab-shell-page.lab-shell-nav-open .side,
  body.lab-shell-page.lab-shell-nav-open .sb {
    transform: translateX(0);
  }

  body.lab-shell-page.lab-shell-nav-open .lab-shell-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .lab-dir-panel {
    width: calc(100vw - 24px);
    margin: 12px auto;
    max-height: calc(100dvh - 24px);
    border-radius: 22px;
  }

  .lab-dir-header {
    padding: 16px 18px;
  }

  .lab-dir-body {
    padding: 14px 18px 18px;
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1680px) {
  .lab-dir-btn,
  .lab-shell-chip,
  .lab-shell-nav-toggle {
    min-height: 48px;
    padding: 12px 14px;
    font-size: 15px;
  }

  body.lab-shell-page .side,
  body.lab-shell-page .sb {
    width: 104px;
  }

  body.lab-shell-page .side-hd {
    font-size: 12px;
    padding: 0 10px 28px;
  }

  body.lab-shell-page .nb,
  body.lab-shell-page .sb button {
    width: 64px;
    height: 64px;
    gap: 6px;
    font-size: 12px;
  }

  body.lab-shell-page .nb svg,
  body.lab-shell-page .sb button svg {
    width: 22px;
    height: 22px;
  }

  body.lab-shell-page .main {
    padding: 24px 28px 34px;
  }

  body.lab-shell-page .pnl.on {
    padding: 0;
    gap: 34px;
  }

  .lab-dir-actions--floating {
    right: 28px;
    bottom: 28px;
    width: 280px;
  }

  .lab-dir-panel {
    width: min(1460px, calc(100vw - 80px));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
