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

:root {
  --bg: #f8f9fa;
  --sidebar-bg: #111827;
  --sidebar-text: #f3f4f6;
  --text: #1f2937;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-coral: #f43f5e;
  --accent-moss: #10b981;
  --accent-purple: #8b5cf6;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  min-height: 100vh;
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 290px;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex-shrink: 0;
  transition: all 0.3s ease;
  z-index: 100;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  font-size: 2rem;
  font-weight: bold;
  color: var(--accent);
}

.eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sidebar h1 {
  font-size: 1.4rem;
  line-height: 1.2;
}

.sidebar h1 em {
  font-style: normal;
  color: var(--accent);
}

.sidebar-copy {
  font-size: 0.82rem;
  color: #9ca3af;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 1.5rem;
  cursor: pointer;
}

.pomodoro-card {
  background: #1e293b;
  border: 1px solid #334155;
  padding: 0.85rem;
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pomo-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#pomoStatus {
  font-size: 0.75rem;
  background: #2563eb;
  padding: 0.1rem 0.5rem;
  border-radius: 0.25rem;
}

.pomo-display {
  font-size: 1.75rem;
  font-weight: bold;
  font-family: monospace;
  text-align: center;
  color: #f8fafc;
}

.pomo-actions {
  display: flex;
  gap: 0.5rem;
}

.pomo-actions button {
  flex: 1;
  background: #334155;
  color: white;
  border: none;
  padding: 0.35rem;
  border-radius: 0.25rem;
  cursor: pointer;
}

.pomo-actions button:hover {
  background: #475569;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-link {
  background: transparent;
  border: none;
  color: #9ca3af;
  padding: 0.65rem 0.85rem;
  text-align: left;
  font-size: 0.9rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
  background-color: #1f2937;
  color: #ffffff;
}

.storage-badge {
  margin-top: auto;
  background: #1e293b;
  padding: 0.65rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid #334155;
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  display: inline-block;
}

.main-content {
  flex: 1;
  padding: 2rem 2.5rem;
  overflow-y: auto;
  max-width: 1400px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

button, .file-button {
  background-color: #ffffff;
  border: 1px solid var(--border);
  padding: 0.45rem 0.8rem;
  border-radius: 0.375rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background-color 0.2s;
  display: inline-flex;
  align-items: center;
}

button:hover, .file-button:hover {
  background-color: #f3f4f6;
}

.file-button input {
  display: none;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.hero {
  background: var(--card-bg);
  padding: 1.75rem 2rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1.5rem;
}

.hero h2 {
  font-size: 1.6rem;
  margin: 0.4rem 0;
}

.hero-stamp {
  text-align: center;
  background-color: #eff6ff;
  padding: 1rem;
  border-radius: 50%;
  width: 105px;
  height: 105px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.hero-stamp b {
  font-size: 1.4rem;
  color: var(--accent);
}

.achievements-card {
  background: var(--card-bg);
  padding: 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.achievements-card h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
}

.badge-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.85rem 0.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.3s ease;
}

.badge-item.locked {
  opacity: 0.4;
  filter: grayscale(100%);
}

.badge-icon {
  font-size: 1.75rem;
}

.badge-item b {
  font-size: 0.82rem;
}

.badge-item small {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.global-progress-card {
  background: var(--card-bg);
  padding: 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.global-progress-card .card-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metrics article {
  background: var(--card-bg);
  padding: 1.1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
}

.metric-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metrics b {
  font-size: 1.25rem;
}

.sub-text {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0.65rem 0;
}

.bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.bar.large {
  height: 14px;
  border-radius: 7px;
}

.bar.stage-bar {
  width: 120px;
  height: 8px;
}

.bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.bar.coral i { background: var(--accent-coral); }
.bar.moss i { background: var(--accent-moss); }
.bar.purple i { background: var(--accent-purple); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.stage-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pill {
  background: #e5e7eb;
  padding: 0.2rem 0.65rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.level-title {
  font-size: 1.1rem;
  margin: 1.5rem 0 1rem 0;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.task-list, .challenge-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.task-item {
  background: var(--card-bg);
  padding: 1.1rem 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.task-item-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.task-item-header input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  cursor: pointer;
}

.task-item-header label {
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.task-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  padding-left: 2rem;
}

.code-box {
  background: #1e293b;
  color: #f8fafc;
  padding: 0.85rem;
  border-radius: 0.375rem;
  font-family: monospace;
  font-size: 0.82rem;
  margin-left: 2rem;
  white-space: pre-wrap;
  overflow-x: auto;
}

.notes-container {
  margin-left: 2rem;
  margin-top: 0.25rem;
}

.notes-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 0.82rem;
  font-family: var(--font);
  background: #f8fafc;
}

.playground-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  min-height: 450px;
}

.editor-box, .preview-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#codeEditor {
  width: 100%;
  flex: 1;
  background: #1e293b;
  color: #f8fafc;
  font-family: monospace;
  font-size: 0.88rem;
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  resize: vertical;
  min-height: 350px;
}

#codePreview {
  width: 100%;
  flex: 1;
  background: #ffffff;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  min-height: 350px;
}

.validator-card {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#jsonInput {
  width: 100%;
  height: 180px;
  font-family: monospace;
  padding: 1rem;
  border-radius: 0.375rem;
  border: 1px solid var(--border);
}

.validation-output {
  padding: 1rem;
  border-radius: 0.375rem;
  font-weight: 600;
  display: none;
}

.validation-output.success {
  display: block;
  background: #d1fae5;
  color: #065f46;
}

.validation-output.error {
  display: block;
  background: #ffe4e6;
  color: #9f1239;
}

.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.resource-card {
  background: var(--card-bg);
  padding: 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.72rem;
  font-weight: bold;
  width: fit-content;
}

.html-tag { background: #dbeafe; color: #1e40af; }
.json-tag { background: #ffe4e6; color: #9f1239; }
.css-tag { background: #d1fae5; color: #065f46; }

.resource-card a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  margin-top: auto;
}

.resource-card a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; padding: 1rem; }
  .menu-toggle { display: block; }
  nav { display: none; }
  nav.open { display: flex; }
  .main-content { padding: 1.25rem 1rem; }
  .playground-container { grid-template-columns: 1fr; }
  .task-desc, .code-box, .notes-container { padding-left: 0; margin-left: 0; }
}