/* ── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface2:  #21262d;
  --border:    #30363d;
  --text:      #e6edf3;
  --text-muted:#8b949e;
  --accent:    #7c3aed;
  --accent-lt: rgba(124,58,237,0.15);
  --success:   #3fb950;
  --warn:      #d29922;
  --danger:    #e74c3c;
  --radius:    10px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; font-size: 15px; line-height: 1.5; }

a { color: var(--accent); }
code { background: var(--surface2); padding: 2px 6px; border-radius: 4px; font-family: 'SF Mono', Consolas, monospace; font-size: 0.85em; }
kbd { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-family: monospace; font-size: 0.8em; }
h2 { font-size: 1.1rem; font-weight: 600; color: var(--text); }
h3 { font-size: 1rem; font-weight: 600; color: var(--text); }
p  { color: var(--text-muted); font-size: 0.9rem; }

/* ── Screen switching ──────────────────────────────────────────── */
.screen { min-height: 100vh; }
.screen[hidden] { display: none; }

/* ── Login ─────────────────────────────────────────────────────── */
#screen-login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: radial-gradient(ellipse at top, rgba(124,58,237,0.08) 0%, transparent 60%), var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2.5rem 2rem;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.login-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.login-sub {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.75rem;
  line-height: 1.6;
}

.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.25rem; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.field input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.625rem 0.875rem;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus { border-color: var(--accent); }
.field-hint { font-size: 0.78rem; color: var(--text-muted); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:not(:disabled):hover { filter: brightness(1.12); }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-editor   { background: var(--accent-lt); color: #a78bfa; border: 1px solid rgba(124,58,237,0.35); font-family: 'SF Mono', Consolas, monospace; }
.btn-ghost    { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-full     { width: 100%; justify-content: center; padding: 0.75rem; font-size: 1rem; }
.btn-sm       { padding: 0.4rem 0.875rem; font-size: 0.82rem; }

/* ── Messages ──────────────────────────────────────────────────── */
.msg { padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.875rem; margin-bottom: 1rem; }
.msg-error   { background: rgba(231,76,60,0.12); border: 1px solid rgba(231,76,60,0.3); color: #e74c3c; }
.msg-success { background: rgba(63,185,80,0.12); border: 1px solid rgba(63,185,80,0.3); color: #3fb950; }

/* ── Topbar ────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: rgba(13,17,23,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-logo { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 0.95rem; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

.user-chip {
  background: var(--accent-lt);
  color: #a78bfa;
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 20px;
  padding: 0.2rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: 'SF Mono', Consolas, monospace;
}

/* ── Lab main ──────────────────────────────────────────────────── */
.lab-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ── Environment card ──────────────────────────────────────────── */
.env-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.env-left    { display: flex; align-items: center; gap: 0.875rem; }
.env-info    { display: flex; flex-direction: column; }
.env-title   { font-weight: 600; font-size: 0.95rem; }
.env-sub     { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.1rem; }
.env-actions { display: flex; align-items: center; gap: 0.625rem; }

.status-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-green   { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot-grey    { background: var(--text-muted); }
.dot-red     { background: var(--danger); }
.dot-pulse   { background: var(--warn); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Auth banner ───────────────────────────────────────────────── */
.auth-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  background: rgba(124,58,237,0.08);
  border: 1px solid rgba(124,58,237,0.25);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}
.auth-banner-icon { font-size: 1.5rem; flex-shrink: 0; }
.auth-banner strong { display: block; margin-bottom: 0.3rem; font-size: 0.95rem; }
.auth-banner p { font-size: 0.875rem; color: var(--text-muted); line-height: 1.5; }

/* ── Section heading ───────────────────────────────────────────── */
.section-heading { margin-bottom: 1rem; font-size: 1rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Exercises grid ────────────────────────────────────────────── */
.exercises-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.ex-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  transition: border-color 0.15s;
}
.ex-card:hover { border-color: rgba(124,58,237,0.4); }

.ex-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.5;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.ex-body { flex: 1; }
.ex-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 0.4rem; }
.ex-body > p { font-size: 0.85rem; line-height: 1.55; margin-bottom: 0.75rem; }

.ex-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Setup notes ───────────────────────────────────────────────── */
.setup-notes {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.setup-notes h3 { margin-bottom: 1rem; }
.setup-notes ol { padding-left: 1.4rem; display: flex; flex-direction: column; gap: 0.5rem; }
.setup-notes li { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; }
.setup-notes li strong { color: var(--text); }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .env-card    { flex-direction: column; align-items: flex-start; }
  .login-card  { padding: 2rem 1.25rem; }
  .topbar      { padding: 0 1rem; }
  .lab-main    { padding: 1.5rem 1rem 3rem; }
}
