:root {
  --bg-base: #0f111a;
  --bg-surface: #1a1d29;
  --bg-elevated: #242837;
  --border-color: #2e3348;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-glow: rgba(139, 92, 246, 0.2);
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-code: 'JetBrains Mono', 'Fira Code', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.4);
}

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

body {
  font-family: var(--font-ui);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 0 15px var(--accent-glow); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--border-color); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-elevated); }
.btn-icon { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; font-size: 1rem; }
.btn-icon:hover { color: var(--text-primary); }

/* Display is handled by inline styles in HTML */
#auth-screen {
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  background: radial-gradient(circle at top right, rgba(139, 92, 246, 0.15), transparent 50%), var(--bg-base);
}
.auth-card {
  background: var(--bg-surface);
  padding: 3rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.auth-icon { font-size: 3rem; margin-bottom: 1rem; }
.auth-card h1 { font-size: 1.75rem; margin-bottom: 0.5rem; }
.auth-card p { color: var(--text-secondary); margin-bottom: 2rem; font-size: 0.95rem; }
.input-group { display: flex; gap: 10px; margin-bottom: 1rem; }
.input-group input {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
}
.input-group input:focus { border-color: var(--accent); }
.error-msg { color: var(--error); font-size: 0.85rem; min-height: 1.2em; }

/* Display is handled by inline styles in HTML */
#app-screen {
  width: 100%;
  height: 100vh;
}
.sidebar {
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  flex-shrink: 0;
}
.sidebar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.sidebar-header h2 { font-size: 1.2rem; color: var(--accent); }
.nav-menu { display: flex; flex-direction: column; gap: 8px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  font-family: var(--font-ui);
}
.nav-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.nav-item.active { background: var(--accent); color: white; }
.nav-icon { font-size: 1.2rem; }

.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.content-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.lessons-panel { flex: 1; overflow-y: auto; padding: 2rem; border-bottom: 1px solid var(--border-color); }
.lessons-container { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.5rem; }
.lesson-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}
.lesson-card h3 { color: var(--accent); margin-bottom: 0.75rem; font-size: 1.2rem; }
.lesson-card p { color: var(--text-secondary); margin-bottom: 1rem; }
.lesson-card code { background: var(--bg-base); padding: 2px 6px; border-radius: 4px; font-family: var(--font-code); font-size: 0.9em; color: var(--accent); }
.example-box {
  background: var(--bg-base);
  border-left: 3px solid var(--accent);
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-family: var(--font-code);
  font-size: 0.9rem;
  white-space: pre-wrap;
}
.challenge-text {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--success);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  margin-bottom: 1rem;
}
.load-btn { margin-top: 0.5rem; }

.resources-header { margin-bottom: 1.5rem; }
.resources-header h2 { color: var(--accent); margin-bottom: 0.5rem; }
.resources-header p { color: var(--text-secondary); }
.resource-card a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 600;
  display: block;
  margin-bottom: 0.5rem;
}
.resource-card a:hover { color: var(--accent); }

.playground-panel {
  height: 45vh;
  min-height: 350px;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  flex-shrink: 0;
}
.playground-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}
.playground-title { display: flex; align-items: center; gap: 1rem; }
.playground-title h3 { font-size: 1rem; font-weight: 600; }
.status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
}
.status-badge.loading { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.status-badge.success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.status-badge.error { background: rgba(239, 68, 68, 0.2); color: var(--error); }
.playground-actions { display: flex; gap: 10px; }

.editor-container { flex: 1; position: relative; overflow: hidden; }
#code-editor {
  width: 100%;
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  border: none;
  padding: 1rem 1.5rem;
  font-family: var(--font-code);
  font-size: 0.95rem;
  line-height: 1.6;
  resize: none;
  outline: none;
}

.terminal-container {
  height: 160px;
  background: #05070a;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}
.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1.5rem;
  background: var(--bg-surface);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}
.terminal-output {
  flex: 1;
  padding: 1rem 1.5rem;
  font-family: var(--font-code);
  font-size: 0.9rem;
  color: #e2e8f0;
  overflow-y: auto;
  white-space: pre-wrap;
  margin: 0;
}
.terminal-output .error-text { color: var(--error); }

.loop-warning {
  padding: 0.6rem 1.5rem;
  background: rgba(245, 158, 11, 0.1);
  border-top: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--warning);
  font-size: 0.8rem;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

@media (max-width: 768px) {
  #app-screen { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 1rem;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .sidebar-header { margin-bottom: 0; margin-right: 1rem; }
  .nav-menu { flex-direction: row; gap: 4px; }
  .nav-item { padding: 8px 12px; font-size: 0.85rem; white-space: nowrap; }
  .nav-icon { display: none; }
  .lessons-panel { padding: 1rem; }
  .playground-panel { height: 55vh; }
}