:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --panel: #ffffff;
  --panel-strong: #eef5f3;
  --text: #172126;
  --muted: #5e6d73;
  --line: #d8e2e0;
  --brand: #123c40;
  --brand-2: #0f6b66;
  --blue: #245e9f;
  --green: #247653;
  --amber: #b06418;
  --red: #b2433b;
  --violet: #6857a6;
  --shadow: 0 16px 40px rgba(26, 45, 49, 0.10);
  --radius: 8px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111817;
  --panel: #17201f;
  --panel-strong: #1d2a28;
  --text: #eef6f4;
  --muted: #a5b8b4;
  --line: #2b3f3b;
  --brand: #56b8ac;
  --brand-2: #72d4bd;
  --blue: #7fb3f1;
  --green: #79d2a2;
  --amber: #e0aa62;
  --red: #ea8b82;
  --violet: #b9a8ff;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.55;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--brand-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre,
textarea.code-editor {
  font-family: var(--mono);
}

pre {
  white-space: pre-wrap;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 50;
  transform: translateY(-150%);
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  padding: 0.7rem 1rem;
}

.skip-link:focus {
  transform: translateY(0);
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 1.05rem;
  z-index: 20;
}

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  color: var(--text);
  margin-bottom: 1.2rem;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong {
  display: block;
  font-size: 1.05rem;
}

.brand small,
.profile-summary small,
.meta-pill,
.eyebrow,
.tiny-note {
  color: var(--muted);
}

.main-nav {
  display: grid;
  gap: 0.35rem;
}

.nav-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0.65rem 0.75rem;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  background: var(--panel-strong);
  color: var(--text);
}

.nav-item.is-active {
  box-shadow: inset 3px 0 0 var(--brand-2);
}

.nav-item svg,
.icon-button svg,
.button svg,
.meta-pill svg,
.callout svg,
.tool-icon svg,
.practice-kind svg,
.result-banner svg {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
}

.sidebar-spacer {
  flex: 1;
}

.profile-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  padding: 0.85rem;
}

.profile-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 36px;
  gap: 0.65rem;
  align-items: center;
}

.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--brand-2);
  color: #fff;
  font-weight: 800;
}

.xp-track {
  height: 8px;
  margin: 0.8rem 0 0.35rem;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line), transparent 10%);
}

.xp-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--amber);
  transition: width 180ms ease;
}

.page-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  min-height: 82px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg), var(--panel) 72%);
  backdrop-filter: blur(14px);
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
}

.topbar h1,
.topbar p,
h2,
h3,
p {
  margin-top: 0;
}

.topbar h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.15;
}

.eyebrow {
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  min-width: 0;
}

.icon-button,
.button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
}

.icon-button:hover,
.button-secondary:hover,
.backup-action:hover {
  border-color: color-mix(in srgb, var(--brand-2), var(--line) 45%);
  background: var(--panel-strong);
  text-decoration: none;
}

.mobile-menu-button {
  display: none;
}

.runtime-chip,
.points-chip,
.meta-pill,
.command-category,
.lesson-index {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  padding: 0.35rem 0.65rem;
  white-space: nowrap;
}

.runtime-chip {
  max-width: 220px;
  color: var(--muted);
}

.status-dot {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 999px;
  background: var(--amber);
}

.runtime-chip.is-ready .status-dot {
  background: var(--green);
}

.runtime-chip.is-error .status-dot {
  background: var(--red);
}

main {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.35rem 0 3rem;
}

.portal-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 1rem clamp(1rem, 3vw, 2rem);
  text-align: center;
}

.hero-band,
.section-band,
.sql-runner,
.lesson-detail,
.reference-band {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 1rem;
  align-items: stretch;
  overflow: hidden;
  margin-bottom: 1rem;
}

.hero-content {
  padding: clamp(1.2rem, 3vw, 2.2rem);
}

.hero-content h2 {
  max-width: 11ch;
  margin-bottom: 0.8rem;
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: 0.98;
}

.hero-content p {
  max-width: 68ch;
  color: var(--muted);
}

.hero-actions,
.detail-actions,
.filter-row,
.runner-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.hero-visual {
  min-height: 320px;
  border-left: 1px solid var(--line);
  background: var(--panel-strong);
  padding: 1rem;
}

.learning-photo {
  position: relative;
  min-height: 320px;
  margin: 0;
  overflow: hidden;
  background: #dfe7e4;
  padding: 0;
}

.learning-photo img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
}

.learning-photo figcaption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 48px;
  background: rgba(13, 30, 31, 0.88);
  color: #f4fbf9;
  padding: 0.7rem 0.85rem;
  font-size: 0.86rem;
  font-weight: 750;
}

.learning-photo figcaption svg {
  width: 1.05rem;
  height: 1.05rem;
  color: #8ed8ca;
}

.modeling-photo img {
  object-position: center;
}

.db-board {
  display: grid;
  height: 100%;
  min-height: 292px;
  align-content: center;
  gap: 0.8rem;
}

.db-table-mini {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}

.db-table-mini strong {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--brand-2), transparent 88%);
  padding: 0.5rem 0.65rem;
}

.db-table-mini span {
  display: block;
  border-bottom: 1px solid var(--line);
  padding: 0.38rem 0.65rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.86rem;
}

.db-table-mini span:last-child {
  border-bottom: 0;
}

.relation-line {
  justify-self: center;
  display: grid;
  grid-template-columns: auto 88px auto;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-weight: 800;
}

.relation-line::before,
.relation-line::after {
  content: "";
  height: 2px;
  background: var(--brand-2);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.62rem 0.9rem;
  font-weight: 750;
}

.button:hover {
  text-decoration: none;
}

.button-primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.button-primary:hover {
  background: color-mix(in srgb, var(--brand), #000 12%);
}

.button-secondary {
  background: var(--panel);
}

.button-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--brand-2);
}

.button[disabled] {
  cursor: wait;
  opacity: 0.7;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card,
.lesson-card,
.practice-card,
.command-card,
.achievement-card,
.tool-card,
.source-card,
.schema-card,
.definition-card,
.model-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 1rem;
}

.stat-card strong {
  display: block;
  margin-bottom: 0.15rem;
  font-size: 1.45rem;
}

.stat-card small {
  color: var(--muted);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin: 1.6rem 0 0.8rem;
}

.section-heading h2 {
  margin-bottom: 0.1rem;
}

.section-heading p {
  max-width: 72ch;
  margin-bottom: 0;
  color: var(--muted);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.card-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lesson-card,
.practice-card,
.command-card,
.achievement-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 210px;
  transition: border-color 140ms ease, transform 140ms ease;
}

.lesson-card[role="button"]:hover,
.practice-card[role="button"]:hover,
.command-card[role="button"]:hover {
  border-color: var(--brand-2);
  transform: translateY(-1px);
}

.lesson-card h3,
.practice-card h3,
.command-card h3,
.achievement-card h3 {
  margin: 0.45rem 0 0.35rem;
  font-size: 1.05rem;
}

.lesson-card p,
.practice-card p,
.command-card p,
.achievement-card p,
.tool-card p,
.source-card p,
.definition-card p {
  color: var(--muted);
}

.lesson-state {
  position: absolute;
  right: 0.8rem;
  top: 0.8rem;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.lesson-state.is-done {
  border-color: color-mix(in srgb, var(--green), transparent 20%);
  background: color-mix(in srgb, var(--green), transparent 84%);
  color: var(--green);
}

.lesson-index {
  align-self: flex-start;
  font-weight: 800;
  color: var(--brand-2);
}

.lesson-meta,
.exercise-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: auto;
  padding-top: 0.85rem;
}

.difficulty-easy {
  color: var(--green);
}

.difficulty-medium {
  color: var(--blue);
}

.difficulty-plus {
  color: var(--violet);
}

.module-block {
  border-left: 4px solid var(--brand-2);
  padding: 0.2rem 0 1rem 1rem;
  margin-bottom: 1rem;
}

.module-block h2 {
  margin-bottom: 0.25rem;
}

.progress-line {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-line span {
  display: block;
  height: 100%;
  background: var(--brand-2);
}

.lesson-detail {
  overflow: hidden;
}

.lesson-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
  padding: clamp(1rem, 3vw, 1.6rem);
}

.lesson-head h2 {
  margin-bottom: 0.4rem;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  line-height: 1.05;
}

.lesson-body {
  display: grid;
  gap: 1rem;
  padding: clamp(1rem, 3vw, 1.6rem);
}

.content-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.78fr);
  gap: 1rem;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
}

.content-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.content-section.is-full {
  grid-template-columns: 1fr;
}

.content-section h3 {
  margin-bottom: 0.35rem;
}

.objective-list,
.plain-list {
  display: grid;
  gap: 0.45rem;
  margin: 0.65rem 0 0;
  padding-left: 1.1rem;
}

.code-block,
.schema-preview,
.console-output {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f1718;
  color: #edf7f4;
  margin: 0;
  padding: 0.85rem;
  overflow-x: auto;
  font-size: 0.88rem;
}

:root[data-theme="dark"] .code-block,
:root[data-theme="dark"] .schema-preview,
:root[data-theme="dark"] .console-output {
  background: #0b1111;
}

.callout {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 0.6rem;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  padding: 0.8rem;
}

.callout p {
  margin-bottom: 0;
}

.callout.is-warning {
  border-color: color-mix(in srgb, var(--amber), var(--line) 45%);
}

.quiz-panel,
.practice-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  padding: 1rem;
}

.choice-list {
  display: grid;
  gap: 0.55rem;
  margin: 0.8rem 0;
}

.choice-list label,
.model-option {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0.65rem 0.75rem;
}

.result-banner {
  display: none;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 0.7rem;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem;
  margin-top: 0.85rem;
}

.result-banner.is-visible {
  display: grid;
}

.result-banner.is-success {
  border-color: color-mix(in srgb, var(--green), var(--line) 35%);
  background: color-mix(in srgb, var(--green), transparent 88%);
}

.result-banner.is-error {
  border-color: color-mix(in srgb, var(--red), var(--line) 35%);
  background: color-mix(in srgb, var(--red), transparent 88%);
}

.result-banner p {
  margin-bottom: 0;
}

.filter-row {
  margin-bottom: 0.8rem;
}

.filter-row .button.is-active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.practice-kind {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.sql-runner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 0;
  overflow: hidden;
}

.sql-intro-band {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
  overflow: hidden;
  margin-bottom: 1rem;
}

.sql-intro-copy {
  display: grid;
  align-content: center;
  gap: 1rem;
  padding: clamp(1rem, 3vw, 1.6rem);
}

.sql-intro-copy p:last-child {
  margin-bottom: 0;
}

.sql-learning-photo {
  min-height: 310px;
  border-left: 1px solid var(--line);
}

.runner-main,
.runner-side {
  padding: clamp(1rem, 3vw, 1.35rem);
}

.runner-side {
  border-left: 1px solid var(--line);
  background: var(--panel-strong);
}

.code-editor {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f1718;
  color: #edf7f4;
  padding: 0.85rem;
  line-height: 1.45;
  tab-size: 2;
}

.runner-tabs {
  display: flex;
  gap: 0.4rem;
  margin: 1rem 0 0.65rem;
  overflow-x: auto;
  padding-bottom: 0.1rem;
}

.runner-tab {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  padding: 0.45rem 0.7rem;
  font-weight: 700;
}

.runner-tab.is-active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.runner-panel {
  display: none;
}

.runner-panel.is-active {
  display: block;
}

.sql-coach {
  border-left: 4px solid var(--brand-2);
  background: var(--panel-strong);
  padding: 0.9rem 1rem;
}

.sql-coach.is-idle {
  border-left-color: var(--line);
}

.sql-coach > p {
  margin: 0.75rem 0 0;
  color: var(--muted);
}

.sql-coach-head,
.sql-coach-head > div,
.local-badge {
  display: flex;
  align-items: center;
}

.sql-coach-head {
  justify-content: space-between;
  gap: 0.75rem;
}

.sql-coach-head > div {
  gap: 0.55rem;
}

.sql-coach-head > div > svg {
  width: 1.35rem;
  height: 1.35rem;
  color: var(--brand-2);
}

.sql-coach-head span span,
.sql-coach-head small,
.sql-coach-head strong {
  display: block;
}

.sql-coach-head small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.local-badge {
  flex: 0 0 auto;
  gap: 0.35rem;
  min-height: 30px;
  border: 1px solid color-mix(in srgb, var(--green), var(--line) 60%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--green), transparent 90%);
  color: var(--green);
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.local-badge svg {
  width: 0.95rem;
  height: 0.95rem;
}

.coach-checklist {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
}

.coach-checklist li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 0.6rem;
  border-top: 1px solid var(--line);
  padding: 0.75rem 0;
}

.coach-checklist li:last-child {
  padding-bottom: 0;
}

.coach-checklist li > svg {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.15rem;
}

.coach-checklist li.is-success > svg {
  color: var(--green);
}

.coach-checklist li.is-warning > svg {
  color: var(--amber);
}

.coach-checklist li.is-info > svg {
  color: var(--blue);
}

.coach-checklist strong,
.coach-checklist span {
  display: block;
}

.coach-checklist span {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.data-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: var(--panel-strong);
  font-size: 0.85rem;
}

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

.schema-grid {
  display: grid;
  gap: 0.75rem;
}

.schema-card h3 {
  margin-bottom: 0.3rem;
}

.schema-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.schema-fields code {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  padding: 0.2rem 0.45rem;
  font-size: 0.78rem;
}

.diagram-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0.85rem;
}

.erm-analysis-board {
  display: grid;
  justify-items: center;
  gap: 0.7rem;
}

.analysis-source {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  line-height: 1.9;
}

.analysis-source strong,
.analysis-source em {
  border-bottom: 3px solid var(--brand-2);
  font-style: normal;
}

.analysis-source em {
  border-color: var(--amber);
}

.erm-analysis-board > svg {
  color: var(--brand-2);
}

.analysis-result {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.analysis-result > div {
  min-width: 0;
  border-left: 1px solid var(--line);
  padding: 0.65rem;
  text-align: center;
}

.analysis-result > div:first-child {
  border-left: 0;
}

.analysis-result small,
.analysis-result strong {
  display: block;
}

.analysis-result small {
  color: var(--muted);
  font-size: 0.7rem;
}

.analysis-result strong {
  overflow-wrap: anywhere;
  font-family: var(--mono);
}

.cardinality-atlas {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.cardinality-atlas > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.1rem 0.65rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0.75rem;
}

.cardinality-atlas > div:nth-child(even) {
  border-right: 0;
}

.cardinality-atlas > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.cardinality-atlas strong {
  grid-row: 1 / 3;
  align-self: center;
  min-width: 58px;
  color: var(--brand-2);
  font-family: var(--mono);
  font-size: 1.05rem;
}

.cardinality-atlas span,
.cardinality-atlas small {
  min-width: 0;
}

.cardinality-atlas span {
  font-weight: 800;
}

.cardinality-atlas small {
  color: var(--muted);
}

.mn-comparison {
  display: grid;
  justify-items: center;
  gap: 0.55rem;
}

.mn-comparison > svg {
  color: var(--brand-2);
}

.mn-state {
  width: 100%;
  border-left: 4px solid var(--amber);
  background: var(--panel-strong);
  padding: 0.7rem;
}

.mn-state.is-solved {
  border-left-color: var(--green);
}

.diagram-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.mn-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.mn-row strong {
  border: 1px solid var(--brand-2);
  background: var(--panel);
  padding: 0.35rem 0.55rem;
  font-family: var(--mono);
}

.mn-row b {
  color: var(--brand-2);
  font-family: var(--mono);
}

.mn-state small {
  display: block;
  color: var(--muted);
  text-align: center;
}

.diagram-practice-panel {
  background: var(--panel);
}

.diagram-practice-canvas {
  margin: 1rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  padding: 0.85rem;
}

.diagram-practice-canvas figcaption {
  margin-bottom: 0.8rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.diagram-chain {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(130px, 0.7fr) minmax(180px, 1.1fr) minmax(130px, 0.7fr) minmax(150px, 1fr);
  align-items: center;
  gap: 0.55rem;
}

.diagram-entity-box {
  min-width: 0;
  overflow: hidden;
  border: 2px solid var(--brand-2);
  border-radius: var(--radius);
  background: var(--panel);
}

.diagram-entity-box header {
  display: flex;
  justify-content: space-between;
  gap: 0.45rem;
  background: color-mix(in srgb, var(--brand-2), transparent 82%);
  padding: 0.55rem;
}

.diagram-entity-box header strong {
  overflow-wrap: anywhere;
  font-family: var(--mono);
}

.diagram-entity-box header small {
  align-self: center;
  color: var(--muted);
  font-size: 0.62rem;
  text-align: right;
}

.diagram-entity-box > div > span,
.diagram-entity-box .diagram-select-wrap {
  display: block;
  border-top: 1px solid var(--line);
  padding: 0.38rem 0.55rem;
  font-family: var(--mono);
  font-size: 0.74rem;
}

.diagram-select-wrap > span {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.62rem;
  font-weight: 800;
}

.diagram-select-wrap select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  padding: 0.35rem;
  font-family: var(--mono);
  font-size: 0.7rem;
}

.diagram-relation-control {
  position: relative;
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  text-align: center;
}

.diagram-relation-control::before {
  content: "";
  position: absolute;
  top: 0.65rem;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--brand-2);
}

.diagram-relation-control > span {
  position: relative;
  width: max-content;
  max-width: 100%;
  justify-self: center;
  background: var(--panel-strong);
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.diagram-relation-control .diagram-select-wrap {
  position: relative;
  background: var(--panel-strong);
}

.er-diagram {
  display: grid;
  gap: 0.8rem;
}

.workflow-diagram {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, auto));
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.workflow-node {
  display: grid;
  justify-items: center;
  gap: 0.2rem;
  min-width: 96px;
  text-align: center;
}

.workflow-node svg {
  width: 28px;
  height: 28px;
  color: var(--brand-2);
}

.workflow-node span,
.query-patterns span {
  color: var(--muted);
  font-size: 0.78rem;
}

.workflow-arrow {
  color: var(--line);
}

.query-patterns {
  display: grid;
  gap: 0.55rem;
}

.query-patterns > div {
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(0, 1fr);
  align-items: center;
  gap: 0.7rem;
  border-bottom: 1px solid var(--line);
  padding: 0.25rem 0 0.55rem;
}

.query-patterns > div:last-child {
  border-bottom: 0;
  padding-bottom: 0.25rem;
}

.query-patterns code {
  color: var(--blue);
  font-weight: 800;
}

.date-function-visual {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 0.6rem;
  background: var(--panel-strong);
}

.date-value {
  display: grid;
  justify-items: center;
  border-bottom: 3px solid var(--brand-2);
  padding: 0.45rem;
}

.date-value span {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 800;
}

.date-value small {
  color: var(--muted);
  font-weight: 800;
}

.date-separator {
  color: var(--muted);
  font-size: 1.5rem;
  font-weight: 800;
}

.entity-box {
  border: 2px solid var(--brand-2);
  border-radius: var(--radius);
  overflow: hidden;
}

.entity-box strong {
  display: block;
  background: color-mix(in srgb, var(--brand-2), transparent 82%);
  padding: 0.5rem 0.65rem;
}

.entity-box span {
  display: block;
  border-top: 1px solid var(--line);
  padding: 0.35rem 0.65rem;
  font-family: var(--mono);
  font-size: 0.86rem;
}

.relationship {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.relationship::before,
.relationship::after {
  content: "";
  height: 2px;
  background: var(--line);
}

.normalform-flow {
  display: grid;
  gap: 0.55rem;
}

.normalform-step {
  border-left: 4px solid var(--brand-2);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 0.7rem;
}

.command-category {
  width: max-content;
  color: var(--blue);
  font-weight: 800;
  font-size: 0.8rem;
}

.command-card pre {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--text);
  margin: 0.6rem 0 0;
  padding: 0.65rem;
}

.achievement-card {
  min-height: 170px;
}

.achievement-card.is-locked {
  opacity: 0.62;
}

.achievement-icon,
.tool-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--brand-2);
}

.tool-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 0.8rem;
}

.start-sequence {
  display: grid;
  grid-template-columns: minmax(190px, 0.6fr) minmax(0, 2fr);
  align-items: stretch;
  overflow: hidden;
  border: 1px solid #28595b;
  border-radius: var(--radius);
  background: #123c40;
  color: #fff;
  margin-bottom: 0.9rem;
}

.start-sequence-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
}

.start-sequence-head svg {
  width: 32px;
  height: 32px;
  color: #78d8cb;
}

.start-sequence-head span,
.start-sequence-head strong {
  display: block;
}

.start-sequence-head span {
  color: #abd9d3;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.start-sequence ol {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
  background: #18494d;
}

.start-sequence li {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: center;
  gap: 0.15rem 0.55rem;
  min-width: 0;
  border-left: 1px solid #35666a;
  padding: 0.85rem;
}

.start-sequence li > span {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  color: #78a7a5;
  font-family: var(--mono);
  font-size: 0.7rem;
}

.start-sequence li > svg {
  align-self: center;
  width: 22px;
  height: 22px;
  color: #78d8cb;
}

.start-sequence li div,
.start-sequence li strong,
.start-sequence li small {
  min-width: 0;
}

.start-sequence li strong,
.start-sequence li small {
  display: block;
}

.start-sequence li strong {
  font-size: 0.84rem;
}

.start-sequence li small {
  overflow-wrap: anywhere;
  color: #bcd4d1;
  font-size: 0.7rem;
}

.tool-illustration {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 190px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 0.65rem;
}

.stick-art {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: #182123;
  color: #f4fbfa;
  padding: 1rem;
}

.stick-device {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  border: 1px solid #446467;
  border-right: 8px solid #64bdb2;
  background: #243234;
  padding: 0.75rem;
}

.stick-device > svg {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  color: #78d8cb;
}

.stick-device strong,
.stick-device span {
  display: block;
}

.stick-device strong {
  font-size: 0.86rem;
}

.stick-device span,
.stick-launcher span {
  color: #aac4c2;
  font-size: 0.66rem;
}

.stick-launcher {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.25rem;
  border-left: 1px solid #35484a;
}

.play-disc {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 3px solid #b9d0cd;
  border-radius: 50%;
  background: #f2f6f5;
  color: #123c40;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.play-disc svg {
  width: 26px;
  height: 26px;
}

.launcher-art,
.workbench-art {
  background: #e7efed;
  color: #172126;
}

.mock-window-bar {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  height: 30px;
  border-bottom: 1px solid #b9cac7;
  background: #f8fbfa;
  padding: 0 0.65rem;
  font-size: 0.66rem;
}

.mock-window-bar > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8ca09d;
}

.mock-window-bar strong {
  overflow: hidden;
  margin-left: 0.3rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.launcher-body {
  display: grid;
  grid-template-columns: 0.8fr 1.7fr;
  height: calc(100% - 30px);
}

.launcher-category {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.2rem;
  border-right: 1px solid #b9cac7;
  background: #d7e5e2;
  text-align: center;
}

.launcher-category svg {
  color: #b06418;
}

.launcher-category span {
  font-size: 0.72rem;
  font-weight: 800;
}

.launcher-category small {
  color: #5e6d73;
  font-size: 0.62rem;
}

.launcher-list {
  display: grid;
  align-content: center;
  gap: 0.45rem;
  padding: 0.65rem;
}

.launcher-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0 0.45rem;
  border: 1px solid #c4d2d0;
  background: #f8fbfa;
  padding: 0.45rem;
}

.launcher-row.is-active {
  border-color: #0f6b66;
  background: #d8efea;
}

.launcher-row svg {
  grid-row: 1 / 3;
  color: #0f6b66;
}

.launcher-row strong {
  overflow: hidden;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.launcher-row span,
.service-status {
  color: #5e6d73;
  font-size: 0.6rem;
}

.service-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: #247653;
}

.service-status svg {
  width: 15px;
  height: 15px;
}

.workbench-toolbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  height: 29px;
  border-bottom: 1px solid #b9cac7;
  background: #dbe7e4;
  padding: 0 0.55rem;
  color: #405052;
}

.workbench-toolbar svg {
  width: 14px;
  height: 14px;
}

.workbench-toolbar span {
  margin-left: auto;
  font-size: 0.6rem;
  font-weight: 800;
}

.workbench-canvas {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px minmax(0, 1.2fr);
  align-items: center;
  height: calc(100% - 59px);
  padding: 0.75rem;
}

.model-table {
  overflow: hidden;
  border: 1px solid #3f7777;
  background: #fff;
  font-family: var(--mono);
  font-size: 0.57rem;
}

.model-table strong,
.model-table span {
  display: block;
  padding: 0.22rem 0.35rem;
}

.model-table strong {
  background: #2d6969;
  color: #fff;
  font-family: var(--sans);
  font-size: 0.65rem;
}

.model-table strong svg {
  width: 11px;
  height: 11px;
  vertical-align: middle;
}

.model-table span + span {
  border-top: 1px solid #e2e9e7;
}

.model-table b {
  color: #b06418;
}

.model-relation {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.2rem;
  color: #0f6b66;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 800;
}

.model-relation svg {
  width: 100%;
}

.source-card {
  display: flex;
  flex-direction: column;
  min-height: 180px;
}

.source-card .button {
  margin-top: auto;
  width: max-content;
}

.definition-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.definition-card h3 {
  margin-bottom: 0.25rem;
}

.backup-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0.9rem 0;
}

.backup-summary div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  padding: 0.75rem;
}

.backup-summary strong,
.backup-summary small {
  display: block;
}

.backup-summary small {
  color: var(--muted);
}

.backup-actions {
  display: grid;
  gap: 0.65rem;
}

.backup-action {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 0.75rem;
  text-align: left;
}

.backup-action small {
  display: block;
  color: var(--muted);
}

.backup-action-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--panel-strong);
}

.profile-dialog {
  width: min(560px, calc(100% - 2rem));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 0;
}

.profile-dialog::backdrop {
  background: rgba(9, 18, 19, 0.55);
}

.profile-dialog form {
  padding: 1.25rem;
}

.dialog-heading {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 0.8rem;
}

.dialog-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--brand-2);
}

.profile-dialog label {
  display: block;
  margin: 0.9rem 0 0.35rem;
  font-weight: 800;
}

.profile-dialog input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 0.7rem 0.8rem;
}

.profile-dialog input[aria-invalid="true"] {
  border-color: var(--red);
}

.profile-example {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.85rem;
  border-left: 3px solid var(--brand-2);
  background: var(--panel-strong);
  padding: 0.65rem 0.75rem;
}

.profile-example code {
  color: var(--brand-2);
  font-size: 1.05rem;
  font-weight: 850;
}

.profile-example span,
.field-hint {
  color: var(--muted);
}

.field-hint {
  display: block;
  margin-top: 0.45rem;
  line-height: 1.45;
}

.field-error {
  min-height: 1.35rem;
  margin: 0.3rem 0 0;
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 700;
}

.profile-dialog .dialog-actions {
  margin-top: 0.85rem;
}

.toast-region {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  display: grid;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 0.7rem 0.9rem;
}

.toast.is-xp {
  border-color: color-mix(in srgb, var(--amber), var(--line) 35%);
}

.toast.is-error {
  border-color: color-mix(in srgb, var(--red), var(--line) 35%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand-2), transparent 35%);
  outline-offset: 2px;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, calc(100vw - 3rem));
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .mobile-backdrop {
    position: fixed;
    inset: 0;
    z-index: 18;
    display: none;
    background: rgba(7, 12, 13, 0.45);
  }

  .mobile-backdrop.is-visible {
    display: block;
  }

  .mobile-menu-button {
    display: inline-grid;
  }
}

@media (max-width: 900px) {
  .hero-band,
  .content-section,
  .sql-runner,
  .sql-intro-band {
    grid-template-columns: 1fr;
  }

  .hero-visual,
  .runner-side,
  .sql-learning-photo {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .card-grid,
  .card-grid.two,
  .definition-grid,
  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .runtime-chip {
    display: none;
  }

  .start-sequence {
    grid-template-columns: 1fr;
  }

  .start-sequence-head {
    border-bottom: 1px solid #35666a;
  }

  .diagram-chain {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .diagram-relation-control {
    min-height: 92px;
    align-content: center;
    justify-items: center;
  }

  .diagram-relation-control::before {
    top: 0;
    bottom: 0;
    left: 50%;
    right: auto;
    width: 2px;
    height: auto;
  }

  .diagram-relation-control > span,
  .diagram-relation-control .diagram-select-wrap {
    width: min(240px, 100%);
  }
}

@media (max-width: 640px) {
  main {
    width: min(100% - 1rem, 1180px);
    padding-top: 0.75rem;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .topbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .hero-content h2 {
    max-width: 12ch;
  }

  .card-grid,
  .card-grid.two,
  .definition-grid,
  .stat-strip,
  .backup-summary {
    grid-template-columns: 1fr;
  }

  .hero-actions .button,
  .detail-actions .button,
  .runner-actions .button {
    width: 100%;
  }

  .profile-dialog .dialog-actions .button {
    flex: 1 1 140px;
  }

  .sql-coach-head {
    align-items: flex-start;
  }

  .exercise-meta .meta-pill {
    max-width: 100%;
    white-space: normal;
  }

  .lesson-head {
    grid-template-columns: 1fr;
  }

  .workflow-diagram {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .workflow-node {
    grid-template-columns: auto minmax(0, 1fr);
    justify-items: start;
    min-width: 0;
    text-align: left;
  }

  .workflow-node svg {
    grid-row: 1 / 3;
  }

  .workflow-arrow {
    justify-self: center;
    transform: rotate(90deg);
  }

  .query-patterns > div {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .analysis-result,
  .cardinality-atlas {
    grid-template-columns: 1fr;
  }

  .analysis-result > div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .analysis-result > div:first-child {
    border-top: 0;
  }

  .cardinality-atlas > div,
  .cardinality-atlas > div:nth-child(even),
  .cardinality-atlas > div:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .cardinality-atlas > div:last-child {
    border-bottom: 0;
  }

  .start-sequence ol {
    grid-template-columns: 1fr;
  }

  .start-sequence li {
    border-top: 1px solid #35666a;
    border-left: 0;
  }

  .start-sequence li:first-child {
    border-top: 0;
  }

  .tool-card {
    grid-template-columns: 1fr;
  }

  .tool-illustration {
    min-height: 200px;
  }

  .toast-region {
    left: 0.5rem;
    right: 0.5rem;
  }
}
