.app {
  max-width: none;
  width: 100%;
  height: 100vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0; 
}

.site-context-bar {
  position: relative;
  z-index: 30;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
}

.site-context-inner {
  min-height: 0;
  padding: 6.4px 10px 6.4px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--topbar-brand-text);
  text-decoration: none;
  min-width: 0;
}

.site-brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
}

.site-brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.site-brand-label {
  font-family: "Bricolage Grotesque", "DM Sans", sans-serif;
  font-size: 22.4px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
}

.site-context-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  font-size: 11px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--topbar-badge-text);
  padding: 6px 8px;
  border: 1px solid var(--topbar-badge-border);
  border-radius: 12px;
  background: var(--topbar-badge-bg);
  transform: translateY(-1px);
}

.site-context-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 2.4vw, 48px);
}

.site-context-nav a {
  color: #9aa8bc;
  text-decoration: none;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.1;
  transition: color 120ms ease;
}

.site-context-nav a:hover,
.site-context-nav a:focus-visible {
  color: #e7f0ff;
}

.site-context-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid rgba(120, 189, 255, 0.35);
  background: linear-gradient(180deg, #58b5fd 0%, #3798e0 100%);
  color: #001225;
  text-decoration: none;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.site-context-cta:hover,
.site-context-cta:focus-visible {
  filter: brightness(1.05);
}

.site-context-accent {
  display: none;
}

.workspace {
  --tree-width: 280px;
  flex: 1;
  display: flex;
  min-height: 0;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tree-panel {
  flex: 0 0 var(--tree-width);
  width: var(--tree-width);
  min-width: 180px;
  max-width: 70vw;
  border-right: 0;
}

.content-panel {
  flex: 1 1 auto;
  min-width: 0;
  border-left: 0;
  position: relative;
}

.workspace.tree-collapsed .tree-panel,
.workspace.tree-collapsed #panelDivider {
  display: none;
}

.workspace.content-expanded .tree-panel,
.workspace.content-expanded #panelDivider,
.workspace.content-expanded #tocDivider,
.workspace.content-expanded .toc-panel,
.workspace.content-expanded .tree-toggle-btn,
.workspace.content-expanded .toc-toggle-btn {
  display: none;
}

.workspace.toc-collapsed #tocDivider,
.workspace.toc-collapsed .toc-panel {
  display: none;
}

.workspace.toc-unavailable #tocDivider,
.workspace.toc-unavailable .toc-toggle-btn {
  display: none;
}

.content-layout {
  --toc-width: 260px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.panel-divider {
  flex: 0 0 6px;
  cursor: col-resize;
  background: linear-gradient(
    90deg,
    transparent calc(50% - 0.5px),
    var(--border) calc(50% - 0.5px),
    var(--border) calc(50% + 0.5px),
    transparent calc(50% + 0.5px)
  );
  border-left: 0;
  box-shadow: none;
  user-select: none;
  touch-action: none;
}

.panel-divider:focus {
  outline: none;
  background: linear-gradient(
    90deg,
    transparent calc(50% - 0.5px),
    var(--border) calc(50% - 0.5px),
    var(--border) calc(50% + 0.5px),
    transparent calc(50% + 0.5px)
  );
}

body.resizing-panels {
  cursor: col-resize;
}

body.resizing-panels * {
  user-select: none;
}

#viewerTitle {
  margin: 0;
  position: relative;
  padding: 8px 260px 8px 90px;
  min-height: 46px;
  box-sizing: border-box;
  font-size: 14px;
  line-height: 1.2;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--title-bg);
}

#viewerTitle.breadcrumb-compact {
  padding-top: 6px;
  padding-bottom: 6px;
  min-height: 40px;
  line-height: 1.1;
}

.sidebar-toggle {
  position: absolute;
  top: 8px;
  left: 10px;
  z-index: 4;
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--control-bg);
  color: inherit;
  border-radius: 8px;
  cursor: pointer;
}

.content-expand-toggle {
  top: 10px;
  left: auto;
  right: 10px;
}

.sidebar-toggle svg {
  width: 14px;
  height: 14px;
  display: block;
}

.sidebar-toggle:hover {
  background: var(--tree-hover);
}

.sidebar-toggle:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 0;
}

.sidebar-toggle::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  transform: none;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  transition: opacity 120ms ease;
}

.tree-toggle-btn::after {
  left: 0;
  right: auto;
  top: calc(100% + 8px);
  transform: none;
  text-align: left;
}

.theme-toggle-btn {
  left: auto;
  right: 10px;
}

.toc-toggle-btn {
  left: auto;
  right: 12px;
  top: 12px;
  z-index: 3;
}

.sidebar-toggle:hover::after,
.sidebar-toggle:focus-visible::after {
  opacity: 1;
}

.site-context-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.repo-home-menu-wrap {
  position: relative;
  display: inline-flex;
}

.site-theme-btn,
.repo-home-btn {
  position: relative;
  z-index: 2;
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--control-bg);
  color: var(--text);
  cursor: pointer;
}

.site-theme-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.repo-home-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.site-theme-btn:hover,
.repo-home-btn:hover {
  background: var(--tree-hover);
}

.site-theme-btn:focus-visible,
.repo-home-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 0;
}

.site-theme-btn::after,
.repo-home-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  transform: none;
  z-index: 2000;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  transition: opacity 120ms ease;
}

.site-theme-btn:hover::after,
.site-theme-btn:focus-visible::after,
.repo-home-btn:hover::after,
.repo-home-btn:focus-visible::after {
  opacity: 1;
}

.repo-home-menu-wrap.open .repo-home-btn::after {
  opacity: 0;
}

.repo-home-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  z-index: 12;
  display: none;
  flex-direction: column;
  gap: 2px;
}

.repo-home-menu-wrap.open .repo-home-menu {
  display: flex;
}

.repo-home-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.2;
}

.repo-home-menu a:hover,
.repo-home-menu a:focus-visible {
  background: var(--tree-hover);
  outline: none;
}

.meta {
  position: absolute;
  top: 8px;
  right: 10px;
  padding: 0;
  border: 0;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  z-index: 4;
}

.meta-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.meta-edit-btn {
  border: 1px solid var(--line);
  background: var(--control-bg);
  color: var(--text);
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 120ms ease;
}

.meta-copy-btn {
  border: 1px solid var(--line);
  background: var(--control-bg);
  color: var(--text);
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease;
}

#viewerTitle .title-copy-btn {
  position: absolute;
  top: 8px;
  left: 46px;
  z-index: 20;
}

#viewerTitle.breadcrumb-compact .title-copy-btn {
  top: 6px;
}

.meta-edit-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.meta-copy-btn:hover {
  background: var(--tree-hover);
}

.meta-edit-btn:hover {
  background: var(--tree-hover);
}

.meta-copy-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 0;
}

.meta-edit-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 0;
}

.meta-copy-btn::after {
  content: none;
}

.meta-edit-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  transform: none;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  transition: opacity 120ms ease;
}

.meta-edit-btn:hover::after,
.meta-edit-btn:focus-visible::after {
  opacity: 1;
}

.meta-copy-btn.copied {
  color: var(--accent-2);
}

.meta-copy-btn.copy-failed {
  color: #ff786c;
}

.meta-refresh-btn {
  border: 1px solid var(--line);
  background: var(--control-bg);
  color: var(--text);
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease;
}

.meta-expand-btn {
  border: 1px solid var(--line);
  background: var(--control-bg);
  color: var(--text);
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease;
}

.meta-refresh-btn:hover {
  background: var(--tree-hover);
}

.meta-expand-btn:hover {
  background: var(--tree-hover);
}

.meta-refresh-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 0;
}

.meta-expand-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 0;
}

.meta-refresh-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  transform: none;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  transition: opacity 120ms ease;
}

.meta-expand-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  transform: none;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  transition: opacity 120ms ease;
}

.meta-refresh-btn:hover::after,
.meta-refresh-btn:focus-visible::after {
  opacity: 1;
}

.meta-expand-btn:hover::after,
.meta-expand-btn:focus-visible::after {
  opacity: 1;
}

.meta-refresh-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.meta-expand-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.theme-toggle-btn::after,
.repo-home-btn::after,
.meta-copy-btn::after,
.meta-edit-btn::after,
.meta-refresh-btn::after,
.meta-expand-btn::after {
  left: auto;
}

.theme-toggle-btn::after {
  right: 0;
}

.repo-home-btn::after {
  right: 0;
}

.meta-copy-btn::after {
  right: auto;
  left: auto;
}

.meta-refresh-btn::after {
  right: 0;
}

.meta-edit-btn::after {
  right: 0;
}

.meta-expand-btn::after {
  right: 0;
}

.meta-error-icon {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 99, 86, 0.35);
  color: #ff786c;
  background: rgba(255, 99, 86, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.meta-error-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.copy-confirmation {
  position: absolute;
  z-index: 5;
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid rgba(66, 160, 96, 0.45);
  background: rgba(18, 30, 22, 0.96);
  color: #d9f1e0;
  font-size: 12px;
  line-height: 1.2;
  opacity: 0;
  transform: translate(-2px, -50%);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.copy-confirmation.visible {
  opacity: 1;
  transform: translate(0, -50%);
}

.copy-confirmation.error {
  border-color: rgba(255, 120, 108, 0.45);
  background: rgba(49, 20, 20, 0.96);
  color: #ffd1cc;
}

.copy-tooltip {
  position: fixed;
  z-index: 2000;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  transition: opacity 120ms ease;
}

.copy-tooltip.visible {
  opacity: 1;
}

@keyframes page-load-bar {
  0% {
    transform: translateX(-34%);
  }
  100% {
    transform: translateX(34%);
  }
}

@media (max-width: 900px) {
  .site-context-inner {
    min-height: 0;
    padding: 8px;
    gap: 10px;
  }

  .site-brand-icon {
    width: 21px;
    height: 21px;
  }

  .site-brand-logo {
    width: 28px;
    height: 28px;
  }

  .site-brand-label {
    font-size: 16.8px;
    line-height: 1;
  }

  .site-context-badge {
    display: none;
  }

  .site-context-nav {
    display: none;
  }

  .site-context-cta {
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 10px;
  }

  .site-context-accent {
    height: 8px;
  }

  .workspace {
    display: block;
  }

  .tree-panel {
    width: 100%;
    max-width: none;
    min-width: 0;
    border-right: 1px solid var(--border);
  }

  .content-panel {
    border-left: 1px solid var(--border);
  }

  .content-layout {
    display: block;
  }

  #viewerTitle {
    padding-left: 90px;
    padding-right: 190px;
  }

  .theme-toggle-btn {
    right: 8px;
  }

  .meta {
    right: 8px;
  }

  .panel-divider {
    display: none;
  }

  .toc-toggle-btn {
    display: none;
  }
}
