:root {
  --navy: #10162f;
  --navy-2: #1b2332;
  --brand: #3a10e5;
  --brand-hover: #2d0cb8;
  --cream: #fff7ed;
  --paper: #f6f5f3;
  --ink: #10162f;
  --muted: #5c6778;
  --line: #e6e2dc;
  --editor: #0d1117;
  --terminal: #0b0e14;
  --ok: #0a7a3e;
  --danger: #c62828;
  --gold: #c2410c;
}

html, body { background: var(--navy); color: #fff; }

body.theme-public {
  min-height: 100vh;
  background: var(--navy);
  color: #f4f1ea;
}

body.theme-app {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

body.theme-admin {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

body.theme-ide {
  height: 100vh;
  overflow: hidden;
  background: var(--navy);
  color: #fff;
}

.text-cyanx, .text-volt, .text-mag { color: var(--brand); }
.bg-cyanx { background: var(--brand); color: #fff; }

.icon {
  width: 1.15em;
  height: 1.15em;
  display: inline-block;
  flex-shrink: 0;
  vertical-align: -0.2em;
}
.icon-sm { width: 1rem; height: 1rem; }
.icon-lg { width: 1.35rem; height: 1.35rem; }
.icon-xl { width: 1.75rem; height: 1.75rem; }
.icon-box {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(58, 16, 229, 0.1);
  color: var(--brand);
}
.theme-public .icon-box {
  background: rgba(255,255,255,.08);
  color: #c4b5fd;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.btn-brand {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
.btn-brand:hover { background: var(--brand-hover); }

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e6e2dc;
  overflow: hidden;
}
.theme-public .progress-track { background: rgba(255,255,255,.12); }
.progress-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
}

.rank-bronze { color: #c9844a; }
.rank-silver { color: #64748b; }
.rank-gold { color: #c2410c; }
.rank-platinum { color: #0f766e; }
.rank-diamond { color: #1d4ed8; }
.rank-master { color: #6d28d9; }
.rank-grandmaster { color: #3a10e5; }

.page-enter { animation: rise .28s ease both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  min-width: 260px;
  max-width: 360px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(16, 22, 47, .12);
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--ok); }

.skeleton {
  background: linear-gradient(90deg, #eee, #f7f7f7, #eee);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px;
  height: 48px;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Catalog / dashboard cards on light chrome */
.theme-app .card,
.theme-admin .card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.field {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  outline: none;
}
.field:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(58, 16, 229, 0.12);
}
.field::placeholder { color: #7a8494; }
textarea.field { min-height: 96px; resize: vertical; }
select.field { appearance: auto; }
.field-label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--ink);
}
.btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 600;
}
.btn-ghost:hover { background: #f6f5f3; }
.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid #f1c0c0;
  font-weight: 600;
}
.btn-danger:hover { background: #fff5f5; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
}
.admin-table td {
  padding: 0.8rem 0.85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.admin-table tr:hover td { background: #faf9f7; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: #f6f5f3;
  color: var(--ink);
}
.badge-ok { background: #e8f6ee; color: var(--ok); }
.badge-warn { background: #fff4e5; color: #c2410c; }
.badge-danger { background: #fdecec; color: var(--danger); }
.badge-brand { background: #eee9ff; color: var(--brand); }

/* Fullscreen Codecademy-style workspace */
.ide-app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--navy);
}

.ide-topbar {
  height: 52px;
  flex: 0 0 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.ide-app > .ide-workspace,
.ide-app > [data-match] {
  flex: 1;
  min-height: 0;
}
.ide-app > [data-match] {
  display: flex;
  flex-direction: column;
}
.ide-app > [data-match] > .ide-workspace {
  flex: 1;
  min-height: 0;
}

.ide-workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 38%) 6px minmax(360px, 1fr);
}

.ide-instructions {
  min-width: 240px;
  background: var(--cream);
  color: var(--ink);
  overflow: auto;
  padding: 28px 28px 40px;
}

.ide-instructions h1,
.ide-instructions h2,
.ide-instructions h3 { color: var(--navy); }

.ide-resizer {
  background: #d7d0c4;
  cursor: col-resize;
}
.ide-resizer:hover { background: var(--brand); }

.ide-code {
  min-width: 280px;
  display: flex;
  flex-direction: column;
  background: var(--editor);
  min-height: 0;
}

.ide-tabs {
  display: flex;
  align-items: stretch;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  height: 36px;
}
.ide-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  font-family: "Source Code Pro", ui-monospace, monospace;
  font-size: 12px;
  color: #c9d1d9;
  background: var(--editor);
  border-right: 1px solid #30363d;
}
.ide-tab::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: #f1e05a;
}
.ide-tab[data-lang="php"]::before { background: #4f5d95; }
.ide-tab[data-lang="python"]::before { background: #3572a5; }
.ide-tab[data-lang="html"]::before { background: #e34c26; }
.ide-tab[data-lang="css"]::before { background: #563d7c; }
.ide-tab[data-lang="sql"]::before { background: #e38c00; }
.ide-tab[data-lang="java"]::before { background: #b07219; }

.ide-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
}

.ide-cm {
  flex: 1;
  min-height: 0;
}

.ide-terminal {
  flex: 0 0 190px;
  display: flex;
  flex-direction: column;
  background: var(--terminal);
  border-top: 1px solid #30363d;
  min-height: 140px;
}
.ide-terminal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  height: 32px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  font-size: 12px;
  color: #8b949e;
}
.ide-terminal-body {
  flex: 1;
  overflow: auto;
  padding: 10px 12px;
  font-family: "Source Code Pro", ui-monospace, monospace;
  font-size: 12.5px;
  color: #c9d1d9;
}

.ide-status {
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-family: "Source Code Pro", ui-monospace, monospace;
}

.cm-s-1v1code.CodeMirror {
  height: 100%;
  background: var(--editor);
  color: #e6edf3;
  font-family: "Source Code Pro", ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.55;
}
.cm-s-1v1code .CodeMirror-gutters {
  background: var(--editor);
  border-right: 1px solid #21262d;
}
.cm-s-1v1code .CodeMirror-linenumber { color: #484f58; }
.cm-s-1v1code .CodeMirror-cursor { border-left: 2px solid #79c0ff; }
.cm-s-1v1code .CodeMirror-selected { background: #274472; }
.cm-s-1v1code .CodeMirror-activeline-background { background: #161b22; }
.cm-s-1v1code span.cm-comment { color: #8b949e; }
.cm-s-1v1code span.cm-keyword { color: #ff7b72; }
.cm-s-1v1code span.cm-string { color: #a5d6ff; }
.cm-s-1v1code span.cm-number { color: #79c0ff; }
.cm-s-1v1code span.cm-def { color: #d2a8ff; }
.cm-s-1v1code span.cm-variable { color: #e6edf3; }
.cm-s-1v1code span.cm-property { color: #79c0ff; }
.cm-s-1v1code span.cm-operator { color: #ff7b72; }

.test-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid #21262d;
}
.test-row.ok { color: #3fb950; }
.test-row.fail { color: #f85149; }

.ide-countdown {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(16, 22, 47, .88);
  font-size: 96px;
  font-weight: 700;
  color: #fff;
}

@media (max-width: 900px) {
  .ide-workspace { grid-template-columns: 1fr; grid-template-rows: 42vh 6px 1fr; }
  .ide-resizer { cursor: row-resize; }
  body.theme-ide { overflow: auto; height: auto; }
  .ide-app { height: auto; min-height: 100vh; }
  .ide-cm { min-height: 320px; }
}
