*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-base);
}

.hidden {
  display: none !important;
}

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

.sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: var(--space-5) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-primary);
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  text-decoration: none;
  cursor: pointer;
  margin-bottom: var(--space-1);
  color: inherit;
}

.nav-item:hover:not(.nav-item--soon) {
  background: var(--bg-hover);
}

.nav-item--active {
  background: var(--bg-hover);
}

.nav-item--soon {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.nav-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.nav-label {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.2;
}

.nav-label--muted {
  color: var(--text-muted);
}

.nav-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.2;
}

.nav-badge {
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 1px 6px;
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
}

.nav-icon--muted {
  color: var(--text-muted);
}

.sidebar-status {
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-3);
  margin-top: auto;
}

.status-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--text-xs);
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}

.status-toggle:hover {
  color: var(--text-secondary);
}

.status-content {
  max-height: 300px;
  overflow-y: auto;
  display: none;
}

.status-content.open {
  display: block;
}

.status-text {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  padding: var(--space-2) var(--space-3);
  margin: 0;
  line-height: 1.5;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.sidebar-auth {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.sidebar-auth-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-auth-dot.connected {
  background: var(--success);
  box-shadow: 0 0 6px rgba(52, 201, 126, 0.5);
}

.main-wrap {
  flex: 1;
  margin-left: 220px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  min-height: 56px;
}

.breadcrumb {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.breadcrumb-sub {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.main-content {
  flex: 1;
  padding: var(--space-6);
  overflow: auto;
}

.main-content--flush {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (max-width: 768px) {
  .sidebar {
    width: 56px;
  }

  .sidebar-brand,
  .nav-content,
  .nav-badge,
  .sidebar-status,
  .sidebar-auth-text {
    display: none;
  }

  .main-wrap {
    margin-left: 56px;
  }
}
