/* ─── Variables & Reset ──────────────────────────────────────────────── */
:root {
  --primary:        #0f172a;
  --primary-hover:  #1e293b;
  --accent:         #2563eb;
  --accent-light:   #eff6ff;
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --bg:             #f8fafc;
  --surface:        #ffffff;
  --border:         #e2e8f0;
  --border-focus:   #93c5fd;
  --text:           #0f172a;
  --text-secondary: #64748b;
  --text-muted:     #94a3b8;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:         0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:      0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --radius:         8px;
  --radius-sm:      4px;
  --radius-lg:      12px;
  --radius-xl:      16px;
  --transition:     0.18s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, textarea, select { font-family: inherit; outline: none; }
svg { display: block; }
img { max-width: 100%; }

/* Page transition */
#app { animation: fadeIn .22s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Typography ─────────────────────────────────────────────────────── */
h1 { font-size: 2rem;    font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.5rem;  font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.125rem;font-weight: 600; line-height: 1.4; }
h4 { font-size: 1rem;    font-weight: 600; }

/* ─── Layout helpers ──────────────────────────────────────────────────── */
.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.gap-6  { gap: 24px; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }

/* ─── Header / Navigation ────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 0;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
  white-space: nowrap;
  min-width: 200px;
}

.logo-icon {
  width: 30px;
  height: 30px;
  background: var(--primary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.nav-item {
  position: relative;
}
.nav-item .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.nav-caret {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: .8rem;
  line-height: 1;
  opacity: .72;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
}
.nav-caret:hover,
.nav-caret:focus-visible {
  background: rgba(15, 23, 42, .08);
  opacity: 1;
  outline: none;
}
.nav-link.active .nav-caret:hover,
.nav-link.active .nav-caret:focus-visible {
  background: rgba(255, 255, 255, .18);
}
.nav-item.open .nav-caret { opacity: 1; }
.nav-item.open .nav-caret { transform: rotate(180deg); }
.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translate(-50%, 4px);
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.10);
  padding: 6px;
  display: none;
  z-index: 100;
}
.nav-item.open .nav-dropdown { display: block; }
.nav-dropdown-item {
  display: block;
  padding: 8px 12px;
  font-size: .82rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.nav-dropdown-item:hover {
  background: var(--bg);
  color: var(--text);
}

.nav-link {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
}
.nav-link:hover { color: var(--text); background: var(--bg); }
.nav-link.active {
  color: var(--surface);
  background: var(--primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
  justify-content: flex-end;
}

.header-help-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  transition: background var(--transition), color var(--transition);
}
.header-help-btn:hover { background: var(--bg); color: var(--text); }

.user-badge {
  font-size: .8rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.profile-menu {
  position: relative;
}
.profile-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.profile-trigger:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 4px;
  border-radius: 999px;
}
.profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 80;
  min-width: 150px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
}
.profile-menu.open .profile-dropdown {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.profile-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: .84rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.profile-dropdown-item:hover {
  background: var(--bg);
  color: var(--primary);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: .8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity var(--transition);
}
.avatar:hover { opacity: .85; }

.avatar-group {
  display: flex;
  align-items: center;
}
.avatar-group .avatar {
  border: 2px solid var(--surface);
  margin-left: -8px;
}
.avatar-group .avatar:first-child { margin-left: 0; }
.team-avatar-menu {
  position: relative;
}
.avatar-group-trigger {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 999px;
}
.avatar-group-trigger:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 4px;
}
.team-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 90;
  width: 280px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
}
.team-avatar-menu.open .team-dropdown {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: 1.5px solid var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); background: var(--bg); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid transparent;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn.active,
.btn[aria-pressed="true"] {
  background: var(--accent-light);
  border-color: var(--border-focus);
  color: var(--accent);
}

.btn-accent {
  background: var(--accent);
  color: white;
  border: 1.5px solid var(--accent);
}
.btn-accent:hover { background: #1d4ed8; border-color: #1d4ed8; }

.btn-danger {
  background: var(--danger);
  color: white;
  border: 1.5px solid var(--danger);
}
.delete-component-btn[disabled],
.delete-wire-btn[disabled],
.clear-wires-btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
}
.delete-component-btn.delete-ready,
.delete-wire-btn.delete-ready {
  color: var(--danger);
  border-color: #fecaca;
  background: #fef2f2;
}
.delete-component-btn.delete-ready:hover,
.delete-wire-btn.delete-ready:hover {
  color: white;
  border-color: var(--danger);
  background: var(--danger);
}

.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-lg { padding: 13px 28px; font-size: .95rem; }
.btn-xl { padding: 16px 36px; font-size: 1rem; letter-spacing: .03em; }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; min-width: 36px; min-height: 36px; }

/* ─── Form elements ───────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: .875rem; font-weight: 500; color: var(--text); }

.form-input {
  width: 100%;
  padding: 11px 14px 11px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input.no-icon { padding-left: 14px; }

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}
.input-suffix {
  position: absolute;
  right: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
}
.input-suffix:hover { color: var(--text); }

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .875rem;
  cursor: pointer;
  user-select: none;
}
.form-checkbox input[type="checkbox"] {
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  accent-color: var(--primary);
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-link {
  font-size: .875rem;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}
.form-link:hover { text-decoration: underline; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: .8rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-sm { padding: 14px 16px; border-radius: var(--radius); }
.card-flat { box-shadow: none; }

/* ─── Progress bar ────────────────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .4s ease;
}
.progress-fill.green { background: var(--success); }

/* ─── Badge / Tag ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: var(--accent-light); color: var(--accent); }
.badge-gray    { background: #f1f5f9; color: var(--text-secondary); }

/* ─── Online status dot ────────────────────────────────────────────────── */
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.online  { background: var(--success); }
.status-dot.offline { background: var(--border); }
.status-dot.remote  { background: var(--warning); }

/* ─── Footer ───────────────────────────────────────────────────────────── */
.app-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  text-align: center;
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: auto;
}
.footer-links {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 6px;
}
.footer-links a {
  font-size: .78rem;
  color: var(--text-muted);
  transition: color var(--transition);
}
.footer-links a:hover { color: var(--text); }

/* ═══════════════════════════════════════════════════════════════════════
   PAGE: WELCOME
═══════════════════════════════════════════════════════════════════════ */
.welcome-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.welcome-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.welcome-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 12px;
}

.welcome-main h1 { font-size: 2.4rem; }
.welcome-tagline {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: .06em;
}
.welcome-subtitle { font-size: .9rem; color: var(--text-muted); margin-bottom: 8px; }

.role-cards {
  display: flex;
  gap: 20px;
  margin: 20px 0;
  flex-wrap: wrap;
  justify-content: center;
}

.role-card {
  width: 240px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.role-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.role-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.role-card h2 { font-size: 1rem; }
.role-card p { font-size: .82rem; color: var(--text-muted); line-height: 1.5; }

.shared-access-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 40px;
  text-align: center;
  max-width: 500px;
  width: 100%;
}
.shared-access-box h3 { font-size: 1rem; margin-bottom: 4px; }
.shared-access-box p { font-size: .83rem; color: var(--text-muted); margin-bottom: 14px; }

/* ═══════════════════════════════════════════════════════════════════════
   PAGE: LOGIN / AUTH
═══════════════════════════════════════════════════════════════════════ */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-back {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .875rem;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
  padding: 14px 28px 6px;
}
.auth-back:hover { color: var(--text); }

.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow);
}

.auth-card h1 { text-align: center; font-size: 1.75rem; margin-bottom: 6px; }
.auth-subtitle { text-align: center; color: var(--text-secondary); font-size: .875rem; margin-bottom: 28px; }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.01em; }
.auth-brand-tagline { color: var(--text-muted); font-size: .85rem; margin: 0; }

.auth-form { display: flex; flex-direction: column; gap: 18px; }

.google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.google-btn:hover { border-color: #4285f4; background: #f0f4ff; box-shadow: var(--shadow-sm); }

.auth-footer-note {
  text-align: center;
  font-size: .83rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

.form-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════
   PAGE: ABOUT
═══════════════════════════════════════════════════════════════════════ */
.about-hero {
  padding: 72px 0 56px;
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
}
.about-hero h1 { font-size: 2.6rem; margin-bottom: 16px; }
.about-hero p { font-size: 1rem; color: var(--text-secondary); line-height: 1.7; margin-bottom: 28px; }

.about-hero-image {
  width: 100%;
  max-width: 480px;
  height: 180px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin: 24px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.section-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; }
.section-subtitle { font-size: .9rem; color: var(--text-secondary); margin-bottom: 28px; }

.mvv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 56px;
}
.mvv-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.mvv-icon { font-size: 1.6rem; margin-bottom: 12px; }
.mvv-card h3 { font-size: .95rem; margin-bottom: 8px; }
.mvv-card p, .mvv-card ul { font-size: .83rem; color: var(--text-secondary); line-height: 1.6; }
.mvv-card ul { padding-left: 16px; }
.mvv-card li { margin-bottom: 3px; }

.team-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 56px;
  align-items: center;
}
.team-desc p { font-size: .9rem; color: var(--text-secondary); line-height: 1.7; margin-bottom: 20px; }
.team-roles { display: flex; flex-direction: column; gap: 12px; }
.team-role {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.team-role-icon { font-size: 1.3rem; margin-top: 1px; }
.team-role h4 { font-size: .875rem; margin-bottom: 2px; }
.team-role p { font-size: .8rem; color: var(--text-muted); }

.impact-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 56px;
}
.impact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}
.impact-card .impact-icon { font-size: 1.8rem; margin-bottom: 10px; }
.impact-card .impact-number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.impact-card .impact-label { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }

/* ═══════════════════════════════════════════════════════════════════════
   PAGE: DASHBOARD
═══════════════════════════════════════════════════════════════════════ */
.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 0;
  flex: 1;
}

.dashboard-main {
  padding: 28px 28px 28px 32px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.dashboard-sidebar {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.welcome-banner {
  background: var(--primary);
  color: white;
  border-radius: var(--radius-lg);
  padding: 24px 28px;
}
.welcome-banner h2 {
  font-size: 1.4rem;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.welcome-banner p { font-size: .87rem; opacity: .8; margin-bottom: 18px; }
.welcome-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.welcome-btn-primary {
  padding: 9px 18px;
  background: white;
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}
.welcome-btn-primary:hover { background: #f0f0f0; }
.welcome-btn-outline {
  padding: 9px 18px;
  background: transparent;
  color: white;
  border: 1.5px solid rgba(255,255,255,.4);
  border-radius: var(--radius-sm);
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.welcome-btn-outline:hover { border-color: white; background: rgba(255,255,255,.1); }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-header h3 { font-size: 1rem; }

.lesson-card {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
}
.lesson-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.lesson-card-thumb {
  width: 120px;
  flex-shrink: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border);
  font-size: 2rem;
}

.lesson-card-body {
  flex: 1;
  padding: 16px 20px;
}
.lesson-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.lesson-card-body h4 { font-size: .95rem; margin-bottom: 4px; }
.lesson-card-body p { font-size: .8rem; color: var(--text-secondary); margin-bottom: 12px; }
.lesson-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.lesson-progress-row .progress-bar { flex: 1; }
.lesson-progress-pct { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }
.dashboard-section-action {
  border-color: var(--border);
  padding: 6px 12px;
  flex-shrink: 0;
}
.section-header .dashboard-section-action {
  margin-left: 12px;
}
.continue-lab-thumb {
  background: #f8fafc;
}
.continue-lab-thumb .circuit-mini-svg {
  width: 96px;
  height: auto;
}

/* Team Chat */
.team-chat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-messages {
  flex: 1;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 180px;
  max-height: 240px;
  overflow-y: auto;
}
.chat-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  flex-shrink: 0;
}
.chat-msg-body {}
.chat-msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}
.chat-msg-name { font-size: .78rem; font-weight: 600; }
.chat-msg-time { font-size: .72rem; color: var(--text-muted); }
.chat-msg-text { font-size: .83rem; color: var(--text-secondary); line-height: 1.5; }

.chat-input-row {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: .83rem;
  background: var(--bg);
  transition: border-color var(--transition);
}
.chat-input:focus { border-color: var(--accent); }
.chat-send-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition);
}
.chat-send-btn:hover { background: var(--primary-hover); }

/* Sidebar widgets */
.sidebar-section {}
.sidebar-section-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.team-status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.team-status-card.compact {
  box-shadow: var(--shadow-lg);
}
.team-status-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: .83rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.team-member-list { padding: 8px 0; }
.team-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  transition: background var(--transition);
}
.team-member:hover { background: var(--bg); }
.team-member-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition), color var(--transition);
}
.team-member:hover .team-member-remove { opacity: 1; }
.team-member-remove:hover { background: #fee2e2; color: #dc2626; }
.team-member-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 600;
  position: relative;
  flex-shrink: 0;
}
.team-member-avatar .status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  border: 1.5px solid var(--surface);
  width: 10px;
  height: 10px;
}
.team-member-info { flex: 1; }
.team-member-name { font-size: .83rem; font-weight: 500; }
.team-member-role { font-size: .75rem; color: var(--text-muted); }
.team-member-badge {
  font-size: .7rem;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
}

.team-actions-row {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.team-remove-action {
  color: var(--danger);
}
.team-remove-action:hover {
  border-color: var(--danger);
  background: #fef2f2;
}
.member-remove-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.member-remove-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.member-remove-meta {
  flex: 1;
  min-width: 0;
}

/* Lab shortcut sidebar */
.lab-shortcut-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.lab-shortcut-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: .83rem;
  font-weight: 600;
}
.lab-shortcut-diagram {
  position: relative;
  padding: 14px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  border-bottom: 1px solid var(--border);
}
.lab-shortcut-body {
  padding: 12px 14px;
  font-size: .78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  border-bottom: 1px solid var(--border);
}
.lab-shortcut-footer {
  padding: 10px 14px;
}

/* ═══════════════════════════════════════════════════════════════════════
   PAGE: LESSON
═══════════════════════════════════════════════════════════════════════ */
.lesson-page-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  flex: 1;
}
.lesson-page-layout-single {
  display: block;
}

.lesson-main {
  padding: 28px 28px 100px 32px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.lesson-page-layout-single .lesson-main {
  border-right: none;
}

.lesson-header-block { margin-bottom: 4px; }
.lesson-header-block .lesson-num {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 6px;
}
.lesson-header-block h2 { font-size: 1.5rem; margin-bottom: 8px; }
.lesson-header-block p { font-size: .9rem; color: var(--text-secondary); line-height: 1.6; }
.lesson-summary-line {
  margin-top: 8px;
  max-width: 760px;
}

.slide-viewer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.slide-content {
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  padding: 40px;
}
.slide-title {
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
}
.slide-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.slide-arrow {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: .9rem;
  transition: all var(--transition);
}
.slide-arrow:hover { background: var(--primary); color: white; border-color: var(--primary); }
.slide-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}
.slide-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.slide-dot.active { background: var(--primary); width: 18px; border-radius: 99px; }

.lesson-enter-lab {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  justify-content: center;
  margin: 0 -32px -100px;
}

/* ═══════════════════════════════════════════════════════════════════════
   PAGE: LAB OVERVIEW
═══════════════════════════════════════════════════════════════════════ */
.lab-home-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.lab-page-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  flex: 1;
}
.lab-task-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.lab-task-page-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  flex: 1;
}
.lab-main {
  padding: 28px 28px 112px 32px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.lab-task-main {
  padding: 26px 28px 112px 32px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.lab-back-link {
  align-self: flex-start;
}
.lab-task-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.lab-task-hero h2 {
  margin: 4px 0 8px;
  font-size: 1.7rem;
  line-height: 1.2;
}
.lab-task-hero p {
  margin: 0;
  max-width: 680px;
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: .94rem;
}
.lab-task-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}
.lab-list-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.lab-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 190px;
  padding: 0;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.lab-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.lab-card.active {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.lab-card-index {
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.lab-card-body {
  padding: 15px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1;
}
.lab-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lab-card h3 {
  font-size: .98rem;
  line-height: 1.3;
}
.lab-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: .82rem;
  line-height: 1.55;
}
.lab-task-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.lab-task-panel.standalone {
  box-shadow: var(--shadow-sm);
}
.lab-task-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.lab-task-header h3 {
  font-size: 1.08rem;
  margin-top: 3px;
}
.lab-task-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr .95fr;
  gap: 0;
}
.lab-task-section {
  padding: 18px 20px;
  border-right: 1px solid var(--border);
}
.lab-task-section:last-child { border-right: none; }
.lab-task-section-title {
  font-size: .76rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.lab-task-focus p {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: .88rem;
  line-height: 1.65;
}
.lab-checkpoint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #ecfdf5;
  color: #047857;
  font-size: .82rem;
  line-height: 1.45;
}
.lab-component-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lab-component-chip {
  padding: 6px 9px;
  border-radius: 99px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: .78rem;
  font-weight: 600;
}
.lab-hint-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: .82rem;
  line-height: 1.65;
}
.lab-hint-list li + li { margin-top: 6px; }
.lab-start-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, .06);
}
.lab-start-summary {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.lab-start-summary span {
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.lab-start-summary strong {
  color: var(--text);
  font-size: .92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lab-start-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════════════
   PAGE: SIMULATION LAB
═══════════════════════════════════════════════════════════════════════ */
.sim-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.sim-header {
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 52px;
  gap: 16px;
}
.sim-header-left { display: flex; align-items: center; gap: 12px; flex: 1; }
.sim-header-center { display: flex; align-items: center; gap: 4px; }
.sim-header-right { display: flex; align-items: center; gap: 10px; flex: 1; justify-content: flex-end; }
.sim-back-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.sim-back-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.sim-project-title {
  font-size: .83rem;
  color: var(--text-secondary);
}
.sim-project-title span { font-weight: 600; color: var(--text); }

.sim-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

/* Component panel */
.component-panel {
  width: 150px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.comp-panel-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  padding: 4px 6px 10px;
}
.comp-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: var(--radius);
  cursor: grab;
  transition: background var(--transition);
  border: 1.5px solid transparent;
  user-select: none;
}
.comp-item:hover {
  background: var(--accent-light);
  border-color: var(--border-focus);
}
.comp-item:active { cursor: grabbing; opacity: .7; }
.comp-item svg { pointer-events: none; }
.comp-item-label { font-size: .72rem; font-weight: 500; color: var(--text-secondary); text-align: center; }

/* Canvas area */
.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.canvas-title {
  font-size: .83rem;
  font-weight: 600;
  flex: 1;
}
.wire-mode-hint {
  margin-left: auto;
  font-size: .75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

#circuit-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: default;
  min-width: 0;
  max-width: 100%;
}

#circuit-svg {
  width: 100%;
  height: 100%;
  background: var(--bg);
  background-image:
    radial-gradient(circle, #cbd5e1 1px, transparent 1px);
  background-size: 24px 24px;
}

.canvas-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* Live stats panel */
.stats-panel {
  width: 200px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.stats-panel-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}
.task-intro-panel {
  width: 240px;
  gap: 16px;
}
.task-brief {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-brief-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.task-brief-title { font-size: 1rem; font-weight: 600; margin: 2px 0 0; }
.task-brief-desc { font-size: .82rem; color: var(--text-secondary); line-height: 1.5; margin: 0; }
.task-brief-section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-top: 4px;
}
.task-brief-list {
  margin: 0;
  padding-left: 18px;
  font-size: .8rem;
  color: var(--text-secondary);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.task-reminder {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.task-reminder-title {
  font-size: .72rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.task-reminder p {
  margin: 0;
  color: var(--text-secondary);
  font-size: .8rem;
  line-height: 1.5;
}
.live-stats-compact {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stat-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.stat-label { font-size: .72rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-unit { font-size: .8rem; font-weight: 500; color: var(--text-secondary); }
.stat-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.ai-hint-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 12px;
  font-size: .78rem;
  line-height: 1.5;
}
.ai-hint-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: .78rem;
  color: #92400e;
  margin-bottom: 6px;
}

.canvas-feedback {
  position: absolute;
  left: 16px;
  top: 14px;
  z-index: 5;
  max-width: min(460px, calc(100% - 32px));
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255,255,255,.94);
  color: var(--text-secondary);
  font-size: .8rem;
  line-height: 1.4;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}
.canvas-feedback.success {
  border-color: #a7f3d0;
  background: rgba(236,253,245,.96);
  color: #065f46;
}
.canvas-feedback.warning {
  border-color: #fde68a;
  background: rgba(255,251,235,.96);
  color: #92400e;
}
.canvas-feedback.info {
  border-color: #bfdbfe;
  background: rgba(239,246,255,.96);
  color: #1d4ed8;
}

/* Advanced sim layout */
.adv-sim-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

.branches-panel {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.branches-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.branch-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.branch-card:hover { border-color: var(--accent); }
.branch-card.active { border-color: var(--primary); background: var(--bg); }
.branch-card-name {
  font-size: .83rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}
.branch-card-desc { font-size: .75rem; color: var(--text-muted); }
.branch-delete-btn {
  margin-top: -6px;
  color: var(--danger);
  border-color: #fecaca;
  background: #fff;
}
.branch-delete-btn:hover:not(:disabled) {
  color: white;
  border-color: var(--danger);
  background: var(--danger);
}
.branch-delete-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.peer-panel {
  width: 210px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.peer-panel-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.peer-group-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--transition);
}
.peer-group-card:hover { box-shadow: var(--shadow-sm); }
.peer-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  font-weight: 600;
}
.peer-group-thumb {
  padding: 10px;
  background: var(--bg);
}
.peer-group-name { font-size: .78rem; font-weight: 500; padding: 8px 12px; color: var(--text-secondary); }

.peer-inspire-link {
  font-size: .78rem;
  color: var(--accent);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.peer-inspire-link:hover { text-decoration: underline; }

/* Collab bar */
.collab-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: .78rem;
  color: var(--text-secondary);
}
.collab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }

/* ═══════════════════════════════════════════════════════════════════════
   PAGE: PRESENTATION
═══════════════════════════════════════════════════════════════════════ */
.pres-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
  color: white;
  overflow-x: hidden;
}

.pres-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.pres-header h2 { font-size: 1rem; opacity: .9; }
.pres-presenter { font-size: .83rem; opacity: .6; }

.pres-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  flex: 1;
  gap: 0;
  min-width: 0;
}

.pres-stage {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid rgba(255,255,255,.1);
  min-width: 0;
}
.pres-circuit-frame {
  background: white;
  border-radius: var(--radius-lg);
  padding: 32px;
  flex: 1;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  overflow: hidden;
}

.pres-step-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: rgba(255,255,255,.05);
  border-radius: var(--radius);
  padding: 14px 20px;
}
.pres-step-text { flex: 1; font-size: .87rem; line-height: 1.5; opacity: .85; }
.pres-step-nav { display: flex; gap: 8px; align-items: center; }
.pres-step-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid rgba(255,255,255,.3);
  background: transparent;
  color: white;
  transition: all var(--transition);
}
.pres-step-btn:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.6); }
.pres-step-btn.primary {
  background: white;
  color: var(--primary);
  border-color: white;
}
.pres-step-btn.primary:hover { background: #f0f0f0; }
.pres-progress-dots { display: flex; gap: 5px; }
.pres-pdot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.3);
  cursor: pointer;
}
.pres-pdot.active { background: white; }

.pres-sidebar {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  min-width: 0;
}
.pres-notes-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  opacity: .5;
  margin-bottom: 10px;
}
.pres-note-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,.07);
  font-size: .83rem;
  opacity: .8;
  line-height: 1.5;
}
.pres-note-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.pres-qa { background: rgba(255,255,255,.04); border-radius: var(--radius-lg); padding: 16px; }
.pres-qa-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  opacity: .5;
  margin-bottom: 12px;
}
.pres-comment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}
.pres-comment {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,.07);
  font-size: .8rem;
  opacity: .75;
  line-height: 1.5;
}
.pres-comment-name { font-weight: 600; opacity: 1; margin-bottom: 2px; font-size: .78rem; }

.pres-comment-input {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: .83rem;
  color: white;
  width: 100%;
  margin-top: 12px;
}
.pres-comment-input::placeholder { color: rgba(255,255,255,.35); }
.pres-comment-input:focus { border-color: rgba(255,255,255,.4); outline: none; }

/* ═══════════════════════════════════════════════════════════════════════
   PAGE: LESSONS REFERENCE
═══════════════════════════════════════════════════════════════════════ */
.reference-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  flex: 1;
  gap: 0;
}

.reference-main {
  padding: 28px 28px 40px 32px;
  border-right: 1px solid var(--border);
}

.reference-header { margin-bottom: 22px; }
.reference-header h2 { font-size: 1.6rem; margin-bottom: 4px; }
.reference-header p { font-size: .87rem; color: var(--text-secondary); }
.ref-progress-section {
  margin-bottom: 22px;
}
.progress-widget-wide {
  padding: 16px;
}

.reference-filters {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--surface);
  flex: 1;
  min-width: 200px;
  transition: border-color var(--transition);
}
.search-box:focus-within { border-color: var(--accent); }
.search-box input {
  border: none;
  background: none;
  font-size: .875rem;
  flex: 1;
}

.filter-select {
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .83rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition);
}
.filter-select:focus { border-color: var(--accent); }

.clear-filters-btn {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 500;
  background: none;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
}
.clear-filters-btn:hover { border-color: var(--danger); color: var(--danger); }

.ref-topic-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
}
.ref-topic-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .83rem;
  transition: background var(--transition);
  font-weight: 500;
}
.ref-topic-item:hover { background: var(--bg); }
.ref-topic-item.active { background: var(--accent-light); color: var(--accent); }
.ref-topic-count {
  background: var(--bg);
  border-radius: 99px;
  padding: 1px 7px;
  font-size: .72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.ref-lesson-list { display: flex; flex-direction: column; gap: 10px; }
.ref-lesson-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow: hidden;
}
.ref-lesson-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

/* Course cover thumbnail */
.lesson-cover {
  width: 130px;
  min-height: 100%;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity var(--transition);
  min-height: 110px;
}
.lesson-cover:hover { opacity: .88; }

.lesson-cover-play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.88);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.lesson-cover:hover .lesson-cover-play {
  transform: scale(1.1);
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
.ref-lesson-body { flex: 1; }
.ref-lesson-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 5px;
}
.ref-lesson-body h4 { font-size: .9rem; margin-bottom: 4px; }
.ref-lesson-body p { font-size: .8rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 8px; }
.ref-lesson-stats {
  display: flex;
  gap: 12px;
  font-size: .75rem;
  color: var(--text-muted);
  align-items: center;
}
.ref-lesson-action { flex-shrink: 0; align-self: center; }

.reference-sidebar {
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}
.ref-side-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.ref-material-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: opacity var(--transition);
}
.ref-material-item:hover { opacity: .75; }
.ref-material-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
}
.ref-material-name { font-size: .83rem; font-weight: 500; }
.ref-material-type { font-size: .75rem; color: var(--text-muted); }

.ref-history-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.ref-history-item:hover .ref-history-name { color: var(--accent); }
.ref-history-name { font-size: .83rem; font-weight: 500; transition: color var(--transition); }
.ref-history-meta { font-size: .75rem; color: var(--text-muted); }

/* Learning progress widget */
.progress-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
}
.progress-widget-title { font-size: .83rem; font-weight: 600; margin-bottom: 10px; }
.progress-widget-pct { font-size: 1.6rem; font-weight: 700; color: var(--primary); margin-bottom: 8px; }

/* ═══════════════════════════════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
  animation: fadeIn .18s ease;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}
.modal-box.modal-wide { max-width: 640px; }
.modal-box.modal-chat { max-width: 720px; }
.modal-chat-body {
  padding: 16px 20px 20px;
}
.modal-chat-body .team-chat {
  max-height: min(620px, 72vh);
}
.modal-chat-body .chat-messages {
  min-height: 280px;
  max-height: 420px;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { padding: 16px 24px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* Add component modal */
.add-comp-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.add-comp-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.add-comp-item:hover { border-color: var(--accent); background: var(--accent-light); }
.add-comp-item.selected { border-color: var(--primary); background: var(--bg); }
.add-comp-item svg { pointer-events: none; }
.add-comp-item span { font-size: .7rem; font-weight: 500; color: var(--text-secondary); text-align: center; }

.comp-categories {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.comp-cat-item {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: .83rem;
  cursor: pointer;
  transition: background var(--transition);
  font-weight: 500;
  color: var(--text-secondary);
}
.comp-cat-item:hover { background: var(--bg); color: var(--text); }
.comp-cat-item.active { background: var(--primary); color: white; }

.empty-state {
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .85rem;
  text-align: center;
  background: var(--bg);
}
.empty-state.compact { padding: 18px; }

/* ═══════════════════════════════════════════════════════════════════════
   TOAST / NOTIFICATIONS
═══════════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  animation: toastIn .2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.warning { background: var(--warning); color: var(--primary); }
.toast.error { background: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════════════
   CIRCUIT SVG ELEMENTS
═══════════════════════════════════════════════════════════════════════ */
.circuit-wire {
  fill: none;
  stroke: #374151;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.circuit-wire.animated {
  stroke-dasharray: 8 5;
  animation: flowCurrent 0.6s linear infinite;
}
.circuit-wire.warn { stroke: var(--danger); stroke-dasharray: 4 4; }
.circuit-wire.selected {
  stroke: var(--accent);
  stroke-width: 4;
  filter: drop-shadow(0 0 5px rgba(37, 99, 235, .35));
}
.circuit-wire-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 18;
  stroke-linecap: round;
  stroke-linejoin: round;
  cursor: pointer;
  pointer-events: stroke;
}

@keyframes flowCurrent {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -13; }
}

.comp-body {
  fill: white;
  stroke: #374151;
  stroke-width: 1.5;
}
.comp-terminal {
  fill: white;
  stroke: #374151;
  stroke-width: 1.5;
  cursor: crosshair;
  transition: fill .12s;
}
.comp-terminal:hover,
.comp-terminal.hovered { fill: #bfdbfe; stroke: var(--accent); }
.comp-terminal.active { fill: var(--accent); stroke: var(--accent); }
.comp-terminal.wiring-enabled {
  stroke-width: 2;
  filter: drop-shadow(0 0 4px rgba(37,99,235,.32));
}
.comp-terminal.warn {
  fill: #fee2e2;
  stroke: var(--danger);
  stroke-width: 2.2;
}

.comp-group {
  cursor: move;
}
.comp-group:hover .comp-outline { fill: #f8fafc; }
.comp-outline { fill: transparent; }

.bulb-lit { fill: #fef08a; }
.bulb-glow {
  filter: drop-shadow(0 0 8px #fbbf24) drop-shadow(0 0 16px #f59e0b);
}

.comp-label-text {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  fill: #64748b;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}

.comp-selected .comp-outline {
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  fill: #eff6ff;
}

.temp-wire-line {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  fill: none;
  pointer-events: none;
}

.snapshot-circuit-svg {
  width: min(100%, 760px);
  height: 100%;
  min-height: 280px;
}
.snapshot-circuit-svg .comp-outline {
  fill: rgba(255,255,255,.72);
  stroke: #cbd5e1;
}
.snapshot-comp {
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════
   MISC / UTILITIES
═══════════════════════════════════════════════════════════════════════ */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-sm { font-size: .83rem; }
.text-xs { font-size: .75rem; }
.font-semibold { font-weight: 600; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.py-12 { padding-top: 48px; padding-bottom: 48px; }
.w-full { width: 100%; }

.page-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Slide animations for circuit diagram in lesson */
.slide-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}
.lesson-visual-card {
  min-width: 300px;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 12px 16px;
}
.lesson-visual-label {
  align-self: flex-start;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.lesson-visual-caption {
  max-width: 360px;
  margin: 0;
  color: var(--text-secondary);
  font-size: .84rem;
  line-height: 1.55;
  text-align: center;
}

.circuit-mini-svg {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.08));
}

/* Responsive tweaks */
@media (max-width: 900px) {
  .app-header,
  .sim-header {
    height: auto;
    min-height: 52px;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .header-logo,
  .header-right,
  .sim-header-left,
  .sim-header-right {
    min-width: 0;
    flex: 1 1 auto;
  }
  .main-nav,
  .sim-header-center {
    order: 3;
    width: 100%;
    justify-content: center;
    overflow-x: auto;
  }
  .user-badge { display: none; }

  .dashboard-layout { grid-template-columns: 1fr; }
  .dashboard-sidebar { border-top: 1px solid var(--border); border-right: none; }
  .dashboard-main,
  .lesson-main,
  .lab-main,
  .lab-task-main,
  .reference-main {
    padding: 22px 18px 88px;
    border-right: none;
  }
  .lesson-page-layout,
  .lab-page-layout,
  .lab-task-page-layout,
  .reference-layout {
    grid-template-columns: 1fr;
  }
  .lab-task-hero {
    flex-direction: column;
    padding: 20px;
  }
  .lab-task-badges {
    justify-content: flex-start;
  }
  .lab-list-grid,
  .lab-task-grid {
    grid-template-columns: 1fr;
  }
  .lab-task-section {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .lab-task-section:last-child { border-bottom: none; }
  .lab-start-bar {
    padding: 12px 18px;
  }
  .slide-content {
    min-height: 260px;
    padding: 22px 12px;
  }
  .lesson-enter-lab {
    margin: 0;
    padding: 12px 16px;
  }

  .sim-body,
  .adv-sim-body {
    flex-direction: column;
    overflow: auto;
  }
  .canvas-area {
    order: 1;
    min-height: 560px;
    overflow: visible;
  }
  .canvas-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }
  .canvas-title {
    flex: 1 1 180px;
  }
  .wire-mode-hint {
    flex: 1 1 100%;
    margin-left: 0;
    white-space: normal;
  }
  #circuit-canvas-container {
    min-height: 430px;
    height: 58vh;
  }
  .component-panel {
    order: 3;
    width: 100%;
    flex-direction: row;
    align-items: stretch;
    gap: 8px;
    overflow-x: auto;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 10px 12px;
  }
  .comp-panel-title {
    min-width: 96px;
    display: flex;
    align-items: center;
    padding: 0 8px 0 2px;
  }
  .comp-item {
    min-width: 86px;
    justify-content: center;
  }
  .stats-panel {
    order: 2;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }
  .stats-panel-title,
  .ai-hint-box,
  .task-reminder,
  .stats-panel .canvas-bottom-bar {
    grid-column: 1 / -1;
  }
  .branches-panel {
    order: 1;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    align-items: stretch;
    overflow-x: auto;
  }
  .branches-panel .branches-title {
    min-width: 116px;
    align-items: center;
  }
  .branch-card {
    min-width: 180px;
  }
  .adv-sim-body .canvas-area {
    order: 2;
  }
  .peer-panel {
    order: 3;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .peer-panel > .stats-panel,
  .peer-panel > div:first-child,
  .peer-inspire-link {
    grid-column: 1 / -1;
  }
  .pres-body {
    grid-template-columns: 1fr;
  }
  .pres-stage {
    padding: 18px;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,.1);
  }
  .pres-circuit-frame {
    min-height: 360px;
    padding: 18px;
  }
  .pres-sidebar {
    padding: 18px;
  }
  .pres-stage > div[style*="justify-content:space-between"] {
    flex-wrap: wrap;
    gap: 10px;
  }
  .mvv-grid { grid-template-columns: 1fr; }
  .impact-grid { grid-template-columns: repeat(2, 1fr); }
  .team-section { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  h1 { font-size: 1.7rem; }
  h2 { font-size: 1.25rem; }
  .btn {
    padding: 9px 13px;
  }
  .app-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .app-header .header-logo {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }
  .app-header .header-right {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }
  .app-header .main-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    order: initial;
    justify-content: flex-start;
    padding-bottom: 2px;
  }
  .app-header .nav-link {
    padding: 6px 10px;
    font-size: .82rem;
  }
  .sim-project-title {
    max-width: none;
    font-size: .78rem;
  }
  .sim-header-left,
  .sim-header-right {
    flex: 1 1 100%;
  }
  .sim-header-right {
    justify-content: space-between;
  }
  .avatar-group .avatar {
    width: 28px;
    height: 28px;
  }
  .canvas-area {
    min-height: 530px;
  }
  .canvas-title {
    flex: 1 1 100%;
  }
  #circuit-canvas-container {
    min-height: 380px;
    height: 56vh;
  }
  .canvas-feedback {
    left: 10px;
    top: 10px;
    max-width: calc(100% - 20px);
    font-size: .76rem;
  }
  .stats-panel,
  .peer-panel {
    grid-template-columns: 1fr;
  }
  .lab-start-bar {
    align-items: stretch;
    flex-direction: column;
  }
  .lab-start-summary strong {
    white-space: normal;
  }
  .lab-card {
    min-height: 0;
  }
  .component-panel {
    position: sticky;
    bottom: 0;
    z-index: 20;
    box-shadow: 0 -4px 14px rgba(15,23,42,.08);
  }
  .comp-item {
    min-width: 78px;
    padding: 9px 7px;
  }
  .branch-card {
    min-width: 166px;
  }
  .slide-diagram svg {
    max-width: 100%;
    height: auto;
  }
  .pres-header {
    flex-wrap: wrap;
    gap: 10px;
  }
  .pres-circuit-frame {
    min-height: 300px;
    width: 100%;
    max-width: 354px;
    align-self: flex-start;
  }
  .snapshot-circuit-svg {
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: 250px;
  }
  .pres-step-bar {
    padding: 12px 14px;
  }
  .pres-step-btn {
    flex: 1 1 120px;
  }
}
