/* ── 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;
  --sidebar-w: 340px;
}

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;
}
h3 { font-size: 1rem; font-weight: 600; }
p  { color: var(--text-muted); font-size: 0.875rem; }
em { font-style: italic; color: var(--text); }

/* ── Screen switching ──────────────────────────────────────────── */
.screen[hidden]  { display: none !important; }
#screen-login:not([hidden]) { display: flex; }
#screen-lab:not([hidden])   { display: flex; }

/* ── Login ─────────────────────────────────────────────────────── */
#screen-login {
  min-height: 100vh;
  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);
}

.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; }
.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); }
.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.375rem 0.75rem; 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; }

/* ── Lab split layout ──────────────────────────────────────────── */
.lab-split {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.lab-sidebar {
  width: var(--sidebar-w);
  min-width: 260px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(13,17,23,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.875rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

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

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

.status-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-green   { background: var(--success); box-shadow: 0 0 5px 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 {
  margin: 0 0.75rem 0;
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  background: rgba(124,58,237,0.08);
  border: 1px solid rgba(124,58,237,0.25);
  border-radius: var(--radius);
  padding: 0.75rem;
}
.auth-banner[hidden] { display: none; }
.auth-banner-icon { font-size: 1.25rem; flex-shrink: 0; line-height: 1; }
.auth-banner strong { display: block; margin-bottom: 0.2rem; font-size: 0.85rem; color: var(--text); }
.auth-banner p { font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; }

/* ── Sidebar sections ──────────────────────────────────────────── */
.sidebar-section {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 0.75rem;
}

.section-heading {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.625rem;
}

/* ── Exercise list ─────────────────────────────────────────────── */
.exercises-list { display: flex; flex-direction: column; gap: 0.5rem; }

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

.ex-num {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.45;
  line-height: 1.2;
  flex-shrink: 0;
  width: 1.8rem;
}

.ex-body { flex: 1; min-width: 0; }
.ex-title { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.2rem; }
.ex-body > p { font-size: 0.78rem; line-height: 1.45; margin-bottom: 0.4rem; }

.ex-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tag {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Setup notes ───────────────────────────────────────────────── */
.setup-notes ol {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.setup-notes li { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }
.setup-notes li strong { color: var(--text); }

/* ── Step list ─────────────────────────────────────────────────── */
.step-list {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.4rem;
}
.step-list li { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }
.step-list li strong { color: var(--text); }
.step-list pre {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 0.75rem;
  color: #a5d6ff;
  margin: 0.3rem 0 0;
  overflow-x: auto;
  white-space: pre;
}

/* ── Exercise labels ────────────────────────────────────────────── */
.ex-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.35rem;
}
.ex-badge {
  background: var(--accent-lt);
  color: #a78bfa;
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 6px;
  padding: 0.1rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: 'SF Mono', Consolas, monospace;
  flex-shrink: 0;
}
.ex-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.3rem;
}

/* ── Diagrams ───────────────────────────────────────────────────── */
.diagram {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.625rem;
}
.diag-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
}
.diag-col { display: flex; flex-direction: column; gap: 0.4rem; }
.diag-box {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.4rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--text);
}
.diag-box span { display: block; font-weight: 400; color: var(--text-muted); font-size: 0.68rem; }
.diag-blue   { background: rgba(56,139,253,0.1);  border-color: rgba(56,139,253,0.3);  color: #79c0ff; }
.diag-purple { background: rgba(124,58,237,0.12); border-color: rgba(124,58,237,0.35); color: #c084fc; }
.diag-green  { background: rgba(63,185,80,0.1);   border-color: rgba(63,185,80,0.3);   color: #7ee787; }
.diag-arrow  { color: var(--text-muted); font-size: 0.85rem; flex-shrink: 0; }
.diag-modes  { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.5rem; }
.diag-mode   { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: var(--text-muted); }

/* ── Shortcuts table ────────────────────────────────────────────── */
.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.shortcuts-table td {
  padding: 0.3rem 0.4rem;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(48,54,61,0.5);
  vertical-align: middle;
}
.shortcuts-table td:first-child { white-space: nowrap; }
.shortcuts-table tr:last-child td { border-bottom: none; }

/* ── Module tabs ────────────────────────────────────────────────── */
.day-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}
.day-tab {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.day-tab:hover { background: var(--surface2); color: var(--text); }
.day-tab.active { background: var(--accent-lt); border-color: rgba(124,58,237,0.4); color: #c084fc; }

/* ── Module content ─────────────────────────────────────────────── */
.module-content[hidden] { display: none !important; }

/* ── Day / module header ────────────────────────────────────────── */
.day-header {
  padding: 0.75rem 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.day-badge {
  display: inline-block;
  background: var(--accent-lt);
  color: #a78bfa;
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 4px;
  padding: 0.08rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.day-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

/* ── Prompt block ───────────────────────────────────────────────── */
.prompt-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  margin-top: 0.5rem;
}
.prompt-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a78bfa;
  margin-bottom: 0.35rem;
}
.prompt-block pre {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 0.75rem;
  color: #a5d6ff;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

/* ── VS Code iframe pane ───────────────────────────────────────── */
.lab-editor {
  flex: 1;
  position: relative;
  background: #1e1e1e;
  overflow: hidden;
}

#editor-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 1;
}
#editor-placeholder.hidden { display: none; }

.placeholder-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 280px;
}
.placeholder-inner h3 { color: var(--text); font-size: 1.1rem; }
.placeholder-inner p { font-size: 0.875rem; color: var(--text-muted); line-height: 1.55; }
.placeholder-inner p strong { color: var(--text); }

.placeholder-inner .ring {
  width: 40px; height: 40px;
  border: 3px solid var(--surface2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#vscode-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: none;
}
#vscode-frame.visible { display: block; }

/* ── Quota bar ──────────────────────────────────────────────────── */
.quota-card {
  margin: 0 1rem 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.78rem;
}
.quota-row { display: flex; justify-content: space-between; margin-bottom: 0.4rem; }
.quota-label { color: var(--text-muted); }
.quota-detail { color: var(--text); font-variant-numeric: tabular-nums; }
.quota-bar-bg { height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; }
.quota-bar-fill { height: 100%; background: #238636; border-radius: 2px; transition: width 0.4s ease, background 0.4s; }
.quota-bar-fill.warn  { background: #9e6a03; }
.quota-bar-fill.limit { background: #da3633; }
