:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #20252d;
  --muted: #667085;
  --line: #d7dde7;
  --soft: #f5f7fb;
  --panel: #ffffff;
  --accent: #0d7c66;
  --accent-dark: #075f4e;
  --warn: #a85510;
  --bad: #b42318;
  --good: #067647;
  --blue: #2364aa;
  --shadow: 0 14px 40px rgba(22, 34, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef2f6;
  color: var(--ink);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: #17202b;
  color: #f8fafc;
  min-height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: #0d7c66;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.panel-head h3,
.challenge-list h2,
.skill-panel h2,
.results-grid h3 {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
}

.brand p {
  margin-top: 2px;
  color: #b9c2cf;
  font-size: 14px;
}

.profile-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.profile-panel label {
  color: #dbe3ed;
  font-size: 13px;
  font-weight: 800;
}

.profile-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.auth-stack {
  display: grid;
  gap: 8px;
}

.auth-stack input {
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

.auth-stack input::placeholder {
  color: #b9c2cf;
}

.profile-row button {
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: #31c48d;
  color: #102017;
  font-weight: 800;
}

.profile-panel p {
  margin: 0;
  color: #b9c2cf;
  font-size: 12px;
  line-height: 1.35;
}

.score-panel {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.score-panel > div {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.metric-label {
  display: block;
  color: #b9c2cf;
  font-size: 12px;
}

.score-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.skill-panel,
.adaptive-panel,
.filter-panel,
.challenge-list {
  min-height: 0;
}

.skill-panel h2,
.adaptive-panel h2,
.filter-panel h2,
.challenge-list h2 {
  margin-bottom: 10px;
  font-size: 14px;
  color: #dbe3ed;
}

.adaptive-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.adaptive-panel h2 {
  margin-bottom: 0;
}

.adaptive-panel p {
  margin: 0;
  color: #b9c2cf;
  font-size: 12px;
  line-height: 1.4;
}

.adaptive-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.adaptive-metrics > div {
  min-width: 0;
  padding: 9px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
}

.adaptive-metrics strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: #f8fafc;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adaptive-panel button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: #31c48d;
  color: #102017;
  font-weight: 900;
}

.filter-panel {
  display: grid;
  gap: 8px;
}

.filter-panel select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

.filter-panel select option {
  background: #ffffff;
  color: #20252d;
}

.filter-panel p {
  margin: 0;
  color: #b9c2cf;
  font-size: 12px;
  line-height: 1.35;
}

.skill-map {
  display: grid;
  gap: 9px;
}

.skill-row {
  display: grid;
  grid-template-columns: 74px 1fr 42px;
  align-items: center;
  gap: 8px;
  color: #dbe3ed;
  font-size: 12px;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.bar span {
  display: block;
  height: 100%;
  background: #31c48d;
}

.challenge-list {
  overflow: auto;
}

.site-footer {
  display: grid;
  gap: 6px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: #b9c2cf;
  font-size: 12px;
  line-height: 1.35;
}

.site-footer a,
.about-nav a {
  color: #d9fbe8;
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover,
.about-nav a:hover {
  text-decoration: underline;
}

#challengeList {
  display: grid;
  gap: 6px;
  padding-right: 4px;
}

.challenge-button {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  color: #f8fafc;
  text-align: left;
}

.challenge-button.active {
  border-color: #31c48d;
  background: rgba(49, 196, 141, 0.16);
}

.challenge-button.done {
  color: #d9fbe8;
}

.challenge-button span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-level {
  color: #b9c2cf;
  font-size: 11px;
}

.mini-level.missed {
  color: #fbbf24;
}

.empty-filter {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  color: #b9c2cf;
  font-size: 13px;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px;
  min-width: 0;
}

.topbar,
.query-layout,
.results-grid {
  display: grid;
  gap: 18px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: start;
}

.difficulty {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #dff7ed;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.topbar h2 {
  margin-top: 9px;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.actions {
  display: flex;
  gap: 8px;
}

.nav-button,
.primary-button,
.secondary-button {
  border: 1px solid transparent;
  border-radius: 7px;
  min-height: 38px;
}

.nav-button {
  min-width: 116px;
  padding: 0 14px;
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
  font-weight: 800;
}

.primary-nav {
  background: #101923;
  border-color: #101923;
  color: #ffffff;
}

.primary-button {
  padding: 0 18px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  padding: 0 14px;
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

.schema-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.table-card,
.editor-panel,
.feedback-panel,
.result-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.table-card {
  overflow: hidden;
}

.table-title {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  background: #fafbfe;
  font-weight: 800;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 9px 11px;
  border-bottom: 1px solid #e9edf3;
  text-align: left;
  vertical-align: top;
}

th {
  color: #475467;
  background: #fbfcfe;
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.query-layout,
.results-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.editor-panel,
.feedback-panel {
  min-width: 0;
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h3,
.results-grid h3 {
  font-size: 16px;
}

textarea {
  width: 100%;
  min-height: 138px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #101923;
  color: #f8fafc;
  line-height: 1.55;
  font-family: "Cascadia Code", Consolas, monospace;
}

textarea:focus {
  border-color: #31c48d;
  box-shadow: 0 0 0 3px rgba(49, 196, 141, 0.16);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.attempt-badge {
  color: var(--muted);
  font-size: 13px;
}

.feedback {
  display: grid;
  gap: 10px;
}

.feedback-item {
  padding: 11px 12px;
  border-left: 4px solid var(--blue);
  border-radius: 7px;
  background: #f4f8ff;
}

.feedback-item.good {
  border-color: var(--good);
  background: #ecfdf3;
}

.feedback-item.bad {
  border-color: var(--bad);
  background: #fff1f0;
}

.feedback-item.warn {
  border-color: var(--warn);
  background: #fff7ed;
}

.feedback-item.info {
  border-color: var(--blue);
  background: #eef6ff;
}

.feedback-item strong {
  display: block;
  margin-bottom: 3px;
}

.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
}

.next-question-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.empty-state {
  color: var(--muted);
}

.result-box {
  min-height: 128px;
  overflow: auto;
}

.result-box.empty-state {
  display: grid;
  place-items: center;
  padding: 16px;
}

.answer-code {
  padding: 12px;
  border-radius: 8px;
  background: #101923;
  color: #f8fafc;
  font-family: "Cascadia Code", Consolas, monospace;
  white-space: pre-wrap;
}

.about-page {
  min-height: 100vh;
  padding: 28px;
  background: #eef2f6;
}

.about-nav {
  max-width: 860px;
  margin: 0 auto 18px;
}

.about-nav a {
  color: var(--accent-dark);
}

.about-panel {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.about-panel h1 {
  margin: 10px 0 14px;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: 0;
}

.about-panel h2 {
  margin: 24px 0 8px;
  font-size: 18px;
}

.about-panel p {
  margin: 0;
  color: #475467;
  font-size: 16px;
  line-height: 1.65;
}

@media (max-width: 980px) {
  .app-shell,
  .query-layout,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    max-height: none;
  }

  .challenge-list {
    max-height: 230px;
  }
}

@media (max-width: 620px) {
  .workspace,
  .sidebar,
  .about-page {
    padding: 16px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar h2 {
    font-size: 22px;
  }

  .score-panel {
    grid-template-columns: 1fr;
  }

  .about-panel {
    padding: 20px;
  }

  .about-panel h1 {
    font-size: 28px;
  }
}
