:root,
html[data-theme="dark"] {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --bg: #0d1220;
  --bg-glow: #222d56;
  --topbar-bg: #090d18;
  --surface: #151c2c;
  --surface-alt: #1b2438;
  --surface-subtle: #111726;
  --border: #283248;
  --border-strong: #384664;
  --ink: #eef2fb;
  --ink-secondary: #cdd6e8;
  --muted: #97a4bc;
  --eyebrow: #9aa7ff;
  --blue: #6378ff;
  --blue-hover: #798bff;
  --blue-soft: #222c4e;
  --blue-border: #3d4e88;
  --green: #38b883;
  --green-soft: #173329;
  --green-border: #2c614b;
  --amber: #eab869;
  --amber-soft: #262018;
  --amber-border: #52422b;
  --code-bg: #0a0f1c;
  --code-border: #25314a;
  --code-gutter-bg: #0e1526;
  --code-gutter-ink: #5c6b87;
  --code-ink: #e6ecf8;
  --inline-code-bg: #222c44;
  --inline-code-ink: #c6d2ff;
  --tok-keyword: #9db0ff;
  --tok-string: #8ce0b3;
  --tok-comment: #7686a3;
  --tok-builtin: #73c7f5;
  --tok-number: #f5b971;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.26);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-glow: #e3e8ff;
  --topbar-bg: #10172a;
  --surface: #ffffff;
  --surface-alt: #f7f9fd;
  --surface-subtle: #f1f4fa;
  --border: #e1e6f0;
  --border-strong: #cbd4e6;
  --ink: #162238;
  --ink-secondary: #2e3d59;
  --muted: #647189;
  --eyebrow: #485cc7;
  --blue: #4663e6;
  --blue-hover: #3551cf;
  --blue-soft: #eef1ff;
  --blue-border: #ccd5ff;
  --green: #1f825d;
  --green-soft: #eaf8f2;
  --green-border: #bce5d4;
  --amber: #9b6314;
  --amber-soft: #fff9ef;
  --amber-border: #edd8b4;
  --code-bg: #f8fafc;
  --code-border: #d0d9e5;
  --code-gutter-bg: #edf2f7;
  --code-gutter-ink: #64748b;
  --code-ink: #0f172a;
  --inline-code-bg: #eef2ff;
  --inline-code-ink: #2b3e8e;
  --tok-keyword: #601fcf;
  --tok-string: #047857;
  --tok-comment: #64748b;
  --tok-builtin: #0369a1;
  --tok-number: #b45309;
  --shadow: 0 8px 24px rgba(24, 39, 75, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 82% 0, var(--bg-glow) 0, transparent 36rem),
    var(--bg);
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 3px solid #8095ff;
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 max(4vw, calc((100vw - 1440px) / 2));
  color: #eef2ff;
  background: var(--topbar-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 760;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(145, 160, 255, 0.4);
  border-radius: 10px;
  color: #e0e5ff;
  background: linear-gradient(145deg, #5d72f5, #3142a8);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.92rem;
  font-weight: 800;
}

.brand-accent {
  color: #8d9bff;
}

.brand-tag {
  margin-left: 0.35rem;
  padding: 0.16rem 0.48rem;
  border-radius: 99px;
  background: rgba(130, 147, 255, 0.18);
  color: #c2ccff;
  font-size: 0.68rem;
  font-weight: 680;
  vertical-align: middle;
}

.topbar-actions,
.account {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #dce5f3;
  font-size: 0.86rem;
}

.account .email {
  color: #c5d0e3;
}

.guest-pill {
  padding: 0.3rem 0.65rem;
  border: 1px solid rgba(154, 167, 255, 0.28);
  border-radius: 99px;
  background: rgba(99, 120, 255, 0.12);
  color: #cbd4ff;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Buttons */
.button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.58rem 1rem;
  color: #ffffff;
  background: var(--blue);
  font-size: 0.86rem;
  font-weight: 680;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.button:hover {
  background: var(--blue-hover);
  transform: translateY(-1px);
}

.button.secondary {
  color: var(--ink-secondary);
  background: var(--surface-alt);
  border-color: var(--border-strong);
}

.topbar .button.secondary {
  color: #dde5f4;
  background: #1a2338;
  border-color: #323f5c;
}

.button.secondary:hover {
  border-color: var(--blue);
  color: var(--ink);
  background: var(--blue-soft);
}

.button.compact-btn {
  min-height: 34px;
  padding: 0.38rem 0.75rem;
  border-radius: 8px;
  font-size: 0.78rem;
}

.button.is-completed-btn {
  border-color: var(--green-border);
  color: var(--green);
  background: var(--green-soft);
}

.button.next-inline-btn {
  background: var(--green);
  color: #ffffff;
}

.button:disabled {
  opacity: 0.62;
  cursor: wait;
  transform: none;
}

/* Layout */
main {
  width: min(1440px, 94vw);
  margin: 1.4rem auto 3rem;
}

.mobile-nav-bar {
  display: none;
  margin-bottom: 1rem;
}

.mobile-nav-toggle {
  width: 100%;
  justify-content: space-between;
  text-align: left;
  font-weight: 700;
}

.study-layout {
  display: grid;
  grid-template-columns: minmax(275px, 320px) minmax(0, 1fr);
  gap: 1.35rem;
  align-items: start;
}

.panel,
.content-card,
.exercise-card,
.onboarding-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.eyebrow {
  display: block;
  color: var(--eyebrow);
  font-size: 0.68rem;
  font-weight: 780;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.05rem;
}

.sidebar-heading {
  padding: 0.15rem 0.35rem 0.7rem;
}

.sidebar-heading h2 {
  margin: 0.3rem 0 0;
  color: var(--ink);
  font-size: 1.12rem;
  letter-spacing: -0.025em;
}

.overall-progress {
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.progress-copy strong {
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 700;
}

.progress-meter {
  display: block;
  width: 100%;
  height: 7px;
  border: 0;
  overflow: hidden;
  border-radius: 99px;
  background: var(--border);
  appearance: none;
  -webkit-appearance: none;
}

.progress-meter::-webkit-progress-bar {
  background: var(--border);
  border-radius: 99px;
}

.progress-meter::-webkit-progress-value {
  border-radius: 99px;
  background: linear-gradient(90deg, var(--blue), #96a4ff);
  transition: width 0.3s ease;
}

.sidebar-search {
  margin-top: 0.75rem;
}

.sidebar-search-input {
  width: 100%;
  min-height: 36px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface-subtle);
  color: var(--ink);
  font-size: 0.78rem;
}

.sidebar-search-input::placeholder {
  color: var(--muted);
}

.track-quick-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.track-pill-tab {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.42rem 0.5rem;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 680;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.14s ease;
}

.track-pill-tab:hover {
  border-color: var(--blue-border);
  color: var(--ink);
}

.track-pill-tab.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--ink);
}

.track-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.empty-search {
  padding: 0.85rem;
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.track-group {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
  transition: border-color 0.15s ease;
}

.track-group.active {
  border-color: var(--blue-border);
  background: var(--surface);
}

.track-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 0;
  padding: 0.72rem 0.8rem;
  color: var(--ink-secondary);
  background: transparent;
  text-align: left;
}

.track-button:hover,
.track-button.selected {
  color: var(--ink);
  background: var(--blue-soft);
}

.track-copy {
  display: grid;
  gap: 0.16rem;
}

.track-badge {
  color: var(--eyebrow);
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.track-copy strong {
  font-size: 0.88rem;
  font-weight: 730;
}

.track-copy small {
  color: var(--muted);
  font-size: 0.72rem;
}

.track-chevron {
  color: var(--muted);
  font-size: 0.95rem;
}

.lesson-list {
  display: grid;
  gap: 0.2rem;
  padding: 0.35rem 0.4rem 0.55rem;
  border-top: 1px solid var(--border);
}

.lesson-button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.6rem;
  border: 0;
  border-radius: 9px;
  padding: 0.48rem 0.55rem;
  color: var(--muted);
  background: transparent;
  text-align: left;
  transition: background 0.14s ease, color 0.14s ease;
}

.lesson-button:hover {
  color: var(--ink);
  background: var(--surface-alt);
}

.lesson-button.selected {
  color: var(--ink);
  background: var(--blue-soft);
  box-shadow: inset 3px 0 0 var(--blue);
  font-weight: 650;
}

.lesson-marker {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.68rem;
  font-weight: 750;
}

.lesson-button.completed .lesson-marker {
  border-color: var(--green-border);
  color: var(--green);
  background: var(--green-soft);
}

.lesson-copy {
  display: grid;
  min-width: 0;
  gap: 0.1rem;
}

.lesson-name {
  overflow: hidden;
  font-size: 0.78rem;
  line-height: 1.32;
  text-overflow: ellipsis;
}

.lesson-status {
  color: var(--green);
  font-size: 0.66rem;
  font-weight: 650;
}

/* Onboarding Guide Card */
.onboarding-card {
  margin-bottom: 1.2rem;
  padding: 1.1rem 1.3rem;
  border-color: var(--blue-border);
  background: linear-gradient(125deg, var(--surface) 35%, var(--blue-soft));
}

.onboarding-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.onboarding-header h2 {
  margin: 0.25rem 0 0;
  font-size: 1.03rem;
  letter-spacing: -0.02em;
}

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

.onboarding-step {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.72rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
}

.step-badge {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  border-radius: 99px;
  background: var(--blue);
  color: #ffffff;
  font-size: 0.74rem;
  font-weight: 800;
}

.onboarding-step strong {
  display: block;
  font-size: 0.83rem;
  margin-bottom: 0.2rem;
}

.onboarding-step p {
  margin: 0;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.45;
}

/* Main Lesson Area */
.main-column,
.lesson-main {
  min-width: 0;
}

.lesson-heading {
  padding: 0.2rem 0.1rem 1rem;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.breadcrumb-track {
  color: var(--eyebrow);
}

.breadcrumb-divider {
  opacity: 0.5;
}

h1.lesson-title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.5rem, 3.1vw, 2.1rem);
  letter-spacing: -0.04em;
  line-height: 1.18;
}

.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.jump-btn {
  margin-left: auto;
}

.status-pill {
  border: 1px solid var(--blue-border);
  border-radius: 99px;
  padding: 0.24rem 0.65rem;
  color: var(--eyebrow);
  background: var(--blue-soft);
  font-size: 0.72rem;
  font-weight: 720;
}

.status-pill.is-complete {
  border-color: var(--green-border);
  color: var(--green);
  background: var(--green-soft);
}

/* Content Card & Rich Description */
.content-card {
  padding: clamp(1.15rem, 2.5vw, 1.7rem);
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.section-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 11px;
  font-size: 0.78rem;
  font-weight: 800;
}

.lesson-icon {
  color: var(--eyebrow);
  background: var(--blue-soft);
  border: 1px solid var(--blue-border);
}

.exercise-icon {
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid var(--amber-border);
}

.section-heading h2,
.editor-heading h3 {
  margin: 0.2rem 0 0;
  color: var(--ink);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.lesson-description {
  color: var(--ink-secondary);
  font-size: 0.95rem;
  line-height: 1.75;
}

.lesson-description p {
  margin: 0 0 0.95rem;
}

.description-list {
  margin: 0.3rem 0 1.1rem;
  padding-left: 1.35rem;
}

.description-list li {
  margin-bottom: 0.45rem;
  line-height: 1.65;
}

.inline-code {
  padding: 0.14rem 0.42rem;
  border-radius: 6px;
  background: var(--inline-code-bg);
  color: var(--inline-code-ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85em;
  font-weight: 600;
}

.description-code-block {
  margin: 0.75rem 0 1.1rem;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--code-border);
  border-radius: 10px;
  background: var(--code-bg);
  color: var(--code-ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.6;
}

/* Symbol Glossary Card */
.glossary-card {
  margin: 1.1rem 0;
  border: 1px solid var(--blue-border);
  border-radius: 12px;
  background: var(--surface-subtle);
  overflow: hidden;
}

.glossary-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.95rem;
  background: var(--blue-soft);
  color: var(--ink);
  font-size: 0.85rem;
  cursor: pointer;
  list-style: none;
}

.glossary-summary::-webkit-details-marker {
  display: none;
}

.glossary-sub {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
}

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.65rem;
  padding: 0.85rem;
}

.glossary-item {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.glossary-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.glossary-sym-list {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.glossary-sym {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: var(--inline-code-bg);
  border: 1px solid var(--blue-border);
  color: var(--inline-code-ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.glossary-name {
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
}

.glossary-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

/* Mental Model Visual Diagrams (SVGs) */
.diagram-card {
  margin: 1.15rem 0;
  padding: 1.1rem 1.25rem 1.25rem;
  border: 1px solid var(--blue-border);
  border-radius: 12px;
  background: var(--surface);
}

.diagram-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.95rem;
}

.diagram-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.diagram-title {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 700;
}

.diagram-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.diagram-mobile-hint {
  display: none;
  margin-top: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background: var(--surface-subtle);
  border: 1px dashed var(--blue-border);
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 600;
  width: fit-content;
}

.diagram-viewport {
  width: 100%;
  overflow-x: auto;
  padding: 0.2rem 0;
  -webkit-overflow-scrolling: touch;
}

.diagram-svg {
  display: block;
  max-width: 100%;
  height: auto;
  min-width: 580px;
  margin: 0 auto;
}

/* Curiosity Experiments — Didática Alex Mux */
.curiosity-card {
  margin: 1.15rem 0;
  padding: 1.1rem 1.25rem 1.25rem;
  border: 1px solid var(--amber-border);
  border-radius: 12px;
  background: var(--surface);
}

.curiosity-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.95rem;
}

.curiosity-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.curiosity-title {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 700;
}

.curiosity-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.curiosity-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.curiosity-item {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.95rem 1.05rem;
  border-radius: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.curiosity-trigger,
.curiosity-reaction,
.curiosity-lesson {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.86rem;
  line-height: 1.5;
}

.curiosity-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.pill-trigger {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid var(--amber-border);
}

.pill-reaction {
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

html[data-theme="light"] .pill-reaction {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fca5a5;
}

.pill-lesson {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.curiosity-action {
  color: var(--ink);
  font-size: 0.88rem;
}

.curiosity-error {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82rem;
  color: #ff8b9e;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  word-break: break-all;
}

html[data-theme="light"] .curiosity-error {
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.curiosity-text {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 0.86rem;
}

/* SVG Element styling matching Themes */
.diag-node {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 1.5;
}

.diag-entry {
  fill: var(--blue-soft);
  stroke: var(--blue);
  stroke-width: 1.5;
}

.diag-decision {
  fill: var(--amber-soft);
  stroke: var(--amber);
  stroke-width: 1.5;
}

.diag-result {
  fill: var(--green-soft);
  stroke: var(--green-border);
  stroke-width: 1.5;
}

.diag-result-primary {
  fill: var(--blue-soft);
  stroke: var(--blue-border);
}

.diag-group-box {
  fill: var(--surface-subtle);
  stroke: var(--border);
  stroke-width: 1;
}

.diag-block-1 {
  fill: var(--surface);
  stroke: var(--blue-border);
  stroke-width: 1.5;
}

.diag-block-2 {
  fill: var(--surface);
  stroke: var(--green-border);
  stroke-width: 1.5;
}

.diag-block-3 {
  fill: var(--surface);
  stroke: var(--amber-border);
  stroke-width: 1.5;
}

.diag-header-bar {
  fill: var(--surface-subtle);
}

.diag-bar-1 { fill: var(--blue-soft); }
.diag-bar-2 { fill: var(--green-soft); }
.diag-bar-3 { fill: var(--amber-soft); }

.diag-edge {
  fill: none;
  stroke: var(--blue);
  stroke-width: 1.8;
}

.diag-edge-green {
  stroke: var(--green);
}

.diag-edge-amber {
  stroke: var(--amber);
}

.diag-edge-ptr {
  stroke: var(--blue);
  stroke-dasharray: 4 3;
}

.diag-text {
  fill: var(--ink);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  text-anchor: middle;
}

.diag-text[text-anchor="start"],
.diag-sub[text-anchor="start"] {
  text-anchor: start;
}

.diag-bold {
  font-weight: 700;
}

.diag-bar-text {
  font-size: 11px;
}

.diag-code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  fill: var(--ink);
}

.diag-sub {
  fill: var(--muted);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 11px;
  text-anchor: middle;
}

.diag-label {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 700;
  fill: var(--ink-secondary);
}

.diag-label.diag-green { fill: var(--green); }
.diag-label.diag-amber { fill: var(--amber); }

.diag-caption {
  fill: var(--muted);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 11.5px;
  font-style: italic;
  text-anchor: middle;
}

.diag-blue { fill: var(--blue); }
.diag-green { fill: var(--green); }

html[data-theme="light"] .diag-text,
html[data-theme="light"] .diag-code {
  fill: #162238;
}
html[data-theme="light"] .diag-sub {
  fill: #334155;
}
html[data-theme="light"] .diag-label {
  fill: #1e293b;
}
html[data-theme="light"] .diag-caption {
  fill: #475569;
}

/* Source Code Examples with Collapsible Height & Syntax Highlighting */
.source-file {
  margin: 1rem 0 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.source-file.is-test-file {
  border-style: dashed;
}

.source-summary {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.9rem;
  color: var(--ink-secondary);
  background: var(--surface-alt);
  cursor: pointer;
  list-style: none;
}

.source-summary::-webkit-details-marker {
  display: none;
}

.source-summary::after {
  margin-left: 0.5rem;
  color: var(--muted);
  content: "▾";
  font-size: 0.95rem;
}

.source-file:not([open]) .source-summary::after {
  content: "▸";
}

.file-symbol {
  display: grid;
  min-width: 30px;
  height: 26px;
  padding: 0 0.35rem;
  place-items: center;
  border-radius: 6px;
  color: var(--eyebrow);
  background: var(--blue-soft);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.62rem;
  font-weight: 800;
}

.file-name {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}

.file-action {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.74rem;
}

.file-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.code-block-container {
  position: relative;
}

.code-viewer {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  overflow-x: auto;
  border-top: 1px solid var(--code-border);
  background: var(--code-bg);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.6rem;
  tab-size: 4;
}

.code-viewer.is-collapsible.is-collapsed {
  max-height: 460px;
  overflow-y: hidden;
}

.code-expand-bar {
  display: flex;
  justify-content: center;
  padding: 0.55rem;
  border-top: 1px solid var(--code-border);
  background: var(--surface-alt);
}

.code-expand-btn {
  width: 100%;
  max-width: 360px;
}

.code-gutter {
  display: flex;
  flex-direction: column;
  padding: 1rem 0.6rem 1rem 0;
  border-right: 1px solid var(--code-border);
  background: var(--code-gutter-bg);
  color: var(--code-gutter-ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.6rem;
  text-align: right;
  user-select: none;
}

.line-num {
  display: block;
  height: 1.6rem;
  font-size: 0.8rem;
  line-height: 1.6rem;
}

.code-example {
  margin: 0;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  color: var(--code-ink);
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.6rem;
  white-space: pre;
}

.code-line {
  display: inline;
  line-height: 1.6rem;
}

.tok-keyword {
  color: var(--tok-keyword);
  font-weight: 650;
}

.tok-string {
  color: var(--tok-string);
}

.tok-comment {
  color: var(--tok-comment);
  font-style: italic;
}

.tok-builtin {
  color: var(--tok-builtin);
}

.tok-number {
  color: var(--tok-number);
}

/* Exercise Section & Side-by-Side Split Playground */
.exercise-card {
  margin-top: 1.25rem;
  padding: clamp(1.15rem, 2.5vw, 1.7rem);
  border-color: var(--amber-border);
  background: linear-gradient(155deg, var(--surface) 45%, var(--amber-soft));
}

.exercise-prompt {
  border: 1px solid var(--amber-border);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
}

.prompt-header-row {
  margin-bottom: 0.65rem;
}

.prompt-label {
  display: inline-block;
  color: var(--amber);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.prompt-title {
  margin: 0.25rem 0 0;
  color: var(--ink);
  font-size: 1.12rem;
  letter-spacing: -0.02em;
}

.exercise-text {
  color: var(--ink-secondary);
  font-size: 0.94rem;
  line-height: 1.7;
}

.exercise-text p {
  margin: 0 0 0.75rem;
}

.criteria-box {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-subtle);
}

.criteria-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.criteria-header strong {
  font-size: 0.84rem;
  color: var(--ink);
}

.criteria-hint {
  font-size: 0.74rem;
  color: var(--muted);
}

.criteria-list {
  display: grid;
  gap: 0.42rem;
}

.criteria-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.44rem 0.6rem;
  border-radius: 8px;
  color: var(--ink-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  line-height: 1.5;
  cursor: pointer;
}

.criteria-item input[type="checkbox"] {
  margin-top: 0.22rem;
  accent-color: var(--green);
}

/* Hint Ladder (Progressive 3-level hints) */
.hint-ladder {
  margin-top: 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--blue-border);
  border-radius: 12px;
  background: var(--surface);
}

.hint-ladder-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.85rem;
}

.hint-ladder-title {
  color: var(--blue);
  font-size: 0.95rem;
}

.hint-ladder-sub {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.hint-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.hint-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-subtle);
  overflow: hidden;
}

.hint-card.is-locked {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.75rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.hint-card-lock {
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: var(--surface-subtle);
  font-size: 0.75rem;
  color: var(--muted);
}

.hint-card.is-open-able summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.87rem;
  color: var(--ink);
  user-select: none;
}

.hint-card.is-open-able summary:hover {
  background: var(--surface-subtle);
}

.hint-card-body {
  padding: 0.85rem 1rem 1rem;
  border-top: 1px solid var(--border);
}

.hint-card-body .tip-text {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--ink);
}

.hint-card-body .code-viewer {
  margin-top: 0.65rem;
}

.criteria-item.is-checked {
  border-color: var(--green-border);
  background: var(--green-soft);
  color: var(--ink);
}

.hint-accordion {
  margin-top: 0.9rem;
  border: 1px solid var(--blue-border);
  border-radius: 10px;
  background: var(--blue-soft);
  overflow: hidden;
}

.hint-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.62rem 0.9rem;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 680;
  cursor: pointer;
  list-style: none;
}

.hint-summary::-webkit-details-marker {
  display: none;
}

.hint-body {
  padding: 0.75rem 0.95rem 0.9rem;
  border-top: 1px solid var(--blue-border);
  background: var(--surface);
  color: var(--ink-secondary);
  font-size: 0.85rem;
  line-height: 1.65;
}

.hint-body p {
  margin: 0 0 0.55rem;
}

.hint-body p:last-child {
  margin-bottom: 0;
}

/* Split Playground Panel */
.editor-panel {
  margin-top: 1.1rem;
  padding: clamp(1rem, 2.2vw, 1.35rem);
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: var(--surface);
}

.editor-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.9rem;
}

.editor-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.playground-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 1fr);
  gap: 1.1rem;
  align-items: start;
}

.editor-column,
.output-column {
  min-width: 0;
  position: relative;
}

/* Badge e Toast de Digitação Manual Obrigatória (Anti-Paste) */
.paste-guard-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid var(--amber);
  user-select: none;
}

.paste-guard-toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--amber);
  padding: 0.75rem 1.1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.35);
  z-index: 60;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.paste-guard-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

.editor-shell.paste-blocked {
  animation: paste-shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  border-color: var(--amber) !important;
}

@keyframes paste-shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
  40%, 60% { transform: translate3d(3px, 0, 0); }
}

.editor-shell {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  height: 360px;
  border: 1px solid var(--code-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--code-bg);
}

.editor-gutter-viewport {
  height: 100%;
  overflow: hidden;
  border-right: 1px solid var(--code-border);
  background: var(--code-gutter-bg);
  user-select: none;
}

.editor-gutter {
  display: flex;
  flex-direction: column;
  padding: 0.95rem 0.6rem 1.9rem 0;
  color: var(--code-gutter-ink);
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.6rem;
}

.editor-code-stack {
  position: relative;
  min-width: 0;
  height: 100%;
}

.editor-highlight,
.editor-textarea {
  box-sizing: border-box;
  margin: 0;
  border: 0;
  padding: 0.95rem 1.05rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.6rem;
  letter-spacing: 0;
  tab-size: 4;
  white-space: pre;
  word-spacing: 0;
}

.editor-highlight {
  position: absolute;
  inset: 0;
  overflow: hidden;
  /* folga extra para acompanhar a rolagem mesmo com a barra horizontal do textarea */
  padding-bottom: calc(0.95rem + 24px);
  padding-right: calc(1.05rem + 24px);
  color: var(--code-ink);
  pointer-events: none;
}

.editor-textarea {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  resize: none;
  overflow: auto;
  /* texto invisível: quem aparece é a camada de realce; o cursor continua visível */
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--code-ink);
  background: transparent;
}

.editor-textarea::selection {
  background: rgba(124, 146, 255, 0.35);
}

.editor-textarea:focus-visible {
  outline: none;
}

.editor-shell:focus-within {
  box-shadow: 0 0 0 2px var(--blue);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.output-header h4 {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.output-status {
  padding: 0.16rem 0.55rem;
  border-radius: 99px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 680;
}

.output-status.is-running {
  border-color: var(--blue-border);
  background: var(--blue-soft);
  color: var(--eyebrow);
}

.output-status.is-ok {
  border-color: var(--green-border);
  background: var(--green-soft);
  color: var(--green);
}

.output-status.is-err {
  border-color: #843b48;
  background: #2b131b;
  color: #ffb8c0;
}

html[data-theme="light"] .output-status.is-err {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #b91c1c;
}

.output {
  display: block;
  min-height: 330px;
  max-height: 360px;
  overflow-y: auto;
  margin: 0;
  padding: 0.95rem 1.05rem;
  border: 1px solid var(--code-border);
  border-radius: 10px;
  color: var(--code-ink);
  background: var(--code-bg);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.output.error {
  border-color: #843b48;
  color: #ffd0d5;
  background: #1f1016;
}

.output.success {
  border-color: #2f6e55;
  color: #ccf8df;
  background: #0e1f1a;
}

.output.notice {
  border-color: var(--blue-border);
  color: #d6deff;
}

html[data-theme="light"] .output.error {
  border-color: #fca5a5;
  color: #991b1b;
  background: #fef2f2;
}

html[data-theme="light"] .output.success {
  border-color: #86efac;
  color: #14532d;
  background: #f0fdf4;
}

html[data-theme="light"] .output.notice {
  border-color: #bfdbfe;
  color: #1e40af;
  background: #eff6ff;
}

.beginner-tip-box {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--amber-border);
  border-radius: 10px;
  background: var(--amber-soft);
  color: var(--ink);
}

.beginner-tip-box.is-success {
  border-color: var(--green-border);
  background: var(--green-soft);
}

.beginner-tip-box.is-success .tip-title {
  color: var(--green);
}

.beginner-tip-box.is-success .compact-btn {
  margin-top: 0.6rem;
}

.completion-row {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--code-border);
}

.tip-title {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--amber);
  font-size: 0.83rem;
}

.tip-text {
  margin: 0.25rem 0 0;
  font-size: 0.84rem;
  line-height: 1.52;
}

/* Bottom Navigation */
.lesson-navigation {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 1.2rem 0 0;
}

.nav-previous,
.nav-next {
  max-width: min(49%, 460px);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0.72rem 1rem;
  color: var(--ink-secondary);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-previous:hover,
.nav-next:hover {
  border-color: var(--blue);
  color: var(--ink);
  background: var(--blue-soft);
}

.nav-next {
  margin-left: auto;
}

.loading {
  padding: 4rem 1rem;
  color: var(--muted);
  text-align: center;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem max(4vw, calc((100vw - 1440px) / 2));
  color: var(--muted);
  font-size: 0.76rem;
  border-top: 1px solid var(--border);
}

/* Responsive Media Queries */
@media (max-width: 1120px) {
  .playground-grid {
    grid-template-columns: 1fr;
  }
  .output {
    min-height: 150px;
    max-height: 280px;
  }
}

@media (max-width: 980px) {
  .study-layout {
    grid-template-columns: minmax(230px, 270px) minmax(0, 1fr);
    gap: 1rem;
  }
  .onboarding-steps {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  main {
    width: min(100% - 24px, 680px);
    margin: 1rem auto 2rem;
  }
  .topbar {
    min-height: 60px;
    padding: 0 14px;
  }
  .brand-tag,
  .account .email,
  .guest-pill {
    display: none;
  }
  .mobile-nav-bar {
    display: block;
  }
  .study-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .sidebar {
    display: none;
    position: static;
    max-height: none;
    margin-bottom: 0.5rem;
  }
  .sidebar.is-open {
    display: block;
  }
  .onboarding-header {
    flex-direction: column;
  }
  .jump-btn {
    margin-left: 0;
  }
  .file-action,
  .glossary-sub {
    display: none;
  }
  .diagram-mobile-hint {
    display: inline-block;
  }
  /* Guia rápido compacto: o título da aula precisa aparecer na 1ª tela. */
  .onboarding-card {
    padding: 0.85rem 1rem;
  }
  .onboarding-header h2 {
    font-size: 1rem;
  }
  .onboarding-steps {
    gap: 0.4rem;
  }
  .onboarding-step {
    padding: 0.5rem 0.7rem;
  }
  .onboarding-step p {
    display: none;
  }
  .editor-shell {
    height: 300px;
  }
  footer {
    flex-direction: column;
    padding: 1rem 14px;
  }
}

@media (max-width: 480px) {
  .topbar .compact-btn {
    padding: 0.45rem 0.7rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }
  .lesson-navigation {
    flex-direction: column;
  }
  .nav-previous,
  .nav-next {
    max-width: 100%;
    width: 100%;
    text-align: center;
  }
}

/* ==========================================================================
   AI Tutor Chat Widget (Gopher Tutor)
   ========================================================================== */

.chat-fab {
  position: fixed;
  bottom: 22px;
  right: 24px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--blue) 0%, #4f46e5 100%);
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(37, 51, 140, 0.42);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
  user-select: none;
}

.chat-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(37, 51, 140, 0.52);
}

.chat-fab:active {
  transform: translateY(0);
}

.chat-fab .chat-fab-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.55);
  backdrop-filter: blur(3px);
  z-index: 1080;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
}

.chat-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 100vw;
  background: var(--surface);
  border-left: 1px solid var(--border-strong);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.38);
}

.chat-drawer.open {
  transform: translateX(0);
}

.chat-header {
  padding: 14px 18px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue-soft);
  border: 1px solid var(--blue-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.chat-title-group h3 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-status-pill {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-status-pill::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-btn-icon {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-btn-icon:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}

.chat-context-badge {
  padding: 8px 16px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-context-badge strong {
  color: var(--ink-secondary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 90%;
  padding: 12px 15px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.52;
  word-break: break-word;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--blue);
  color: #ffffff;
  border-bottom-right-radius: 3px;
  box-shadow: 0 4px 12px rgba(99, 120, 255, 0.25);
}

.chat-bubble.bot {
  align-self: flex-start;
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}

.chat-bubble.error {
  align-self: center;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: #f87171;
  font-size: 0.82rem;
  text-align: center;
  width: 100%;
}

.chat-bubble p {
  margin: 0 0 8px 0;
}

.chat-bubble p:last-child {
  margin-bottom: 0;
}

.chat-bubble ul,
.chat-bubble ol {
  margin: 6px 0;
  padding-left: 20px;
}

.chat-bubble li {
  margin-bottom: 4px;
}

.chat-bubble pre {
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 8px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  color: var(--code-ink);
}

.chat-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  background: var(--inline-code-bg);
  color: var(--inline-code-ink);
  padding: 2px 5px;
  border-radius: 4px;
}

.chat-typing-indicator {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-bottom-left-radius: 3px;
}

.chat-typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: chatBounce 1.4s infinite ease-in-out both;
}

.chat-typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.chat-typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes chatBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.chat-input-container {
  padding: 14px 16px;
  background: var(--surface-alt);
  border-top: 1px solid var(--border);
}

.chat-input-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-textarea {
  flex: 1;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.88rem;
  resize: none;
  height: 42px;
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s ease;
  line-height: 1.4;
}

.chat-textarea:focus {
  border-color: var(--blue);
}

.chat-send-btn {
  background: var(--blue);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  height: 42px;
  padding: 0 16px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.15s ease;
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--blue-hover);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-cooldown-notice {
  font-size: 0.76rem;
  color: var(--amber);
  margin-top: 6px;
  display: none;
  text-align: center;
}

@media (max-width: 768px) {
  .chat-drawer {
    width: 100vw;
    border-left: none;
  }
  .chat-fab {
    bottom: 18px;
    right: 18px;
    padding: 10px 16px;
    font-size: 0.86rem;
  }
}

/* ==========================================================================
   Exercise Criteria Feedback & Checklist
   ========================================================================== */

.output-status.is-pending {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.beginner-tip-box.is-pending {
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
}

.criteria-checklist {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.criteria-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.criteria-item.is-met {
  border-left: 4px solid #10b981;
  color: var(--text);
}

.criteria-item.is-pending {
  border-left: 4px solid #f59e0b;
  color: var(--text-muted);
}

.criteria-icon {
  font-weight: 700;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

.criteria-item.is-met .criteria-icon {
  color: #10b981;
}

.criteria-item.is-pending .criteria-icon {
  color: #f59e0b;
}

.criteria-label {
  flex: 1;
  line-height: 1.35;
}


/* ==========================================================================
   Coffee Donation & Student Feedback Modals
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1080;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%) scale(0.96);
  width: 520px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.45);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.modal-dialog.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.modal-header {
  padding: 16px 20px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header-icon {
  font-size: 1.35rem;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-intro {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted-bright);
}

.support-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.support-card {
  padding: 16px;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.support-card:hover {
  border-color: var(--border-strong);
}

.support-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.support-method-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.support-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  letter-spacing: 0.02em;
}

.pix-badge {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.stripe-badge {
  background: rgba(99, 102, 241, 0.16);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.support-method-desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.pix-key-display {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
}

.pix-key-code {
  font-family: var(--font-mono, monospace);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent, #60a5fa);
  flex: 1;
  letter-spacing: 0.05em;
}

.btn-copy-pix {
  background: var(--blue, #2563eb);
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn-copy-pix:hover {
  filter: brightness(1.15);
}

.btn-copy-pix.copied {
  background: #10b981;
}

.pix-hint, .stripe-hint {
  font-size: 0.75rem;
  color: var(--muted);
}

.btn-stripe-donate {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.18s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  text-decoration: none;
}

.btn-stripe-donate:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

/* Feedback Form */
.feedback-lesson-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.78rem;
  color: var(--accent, #60a5fa);
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.25);
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 500;
  width: fit-content;
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
}

.required-star {
  color: #ef4444;
}

.feedback-select, .feedback-input, .feedback-textarea {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color 0.18s ease;
}

.feedback-select:focus, .feedback-input:focus, .feedback-textarea:focus {
  border-color: var(--accent, #60a5fa);
  outline: none;
}

.feedback-textarea {
  resize: vertical;
  min-height: 90px;
}

.feedback-status {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.4;
  display: none;
}

.feedback-status.info {
  display: block;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.25);
  color: #93c5fd;
}

.feedback-status.success {
  display: block;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
}

.feedback-status.error {
  display: block;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.feedback-submit-btn {
  width: 100%;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 600;
}

/* Action Buttons */
.btn-coffee {
  background: rgba(245, 158, 11, 0.12) !important;
  border-color: rgba(245, 158, 11, 0.35) !important;
  color: #fbbf24 !important;
}

.btn-coffee:hover {
  background: rgba(245, 158, 11, 0.22) !important;
  border-color: rgba(245, 158, 11, 0.6) !important;
}

.btn-feedback {
  background: rgba(99, 102, 241, 0.12) !important;
  border-color: rgba(99, 102, 241, 0.35) !important;
  color: #a5b4fc !important;
}

.btn-feedback:hover {
  background: rgba(99, 102, 241, 0.22) !important;
  border-color: rgba(99, 102, 241, 0.6) !important;
}

.footer-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.footer-action-btn {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--muted-bright);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.footer-action-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

@media (max-width: 768px) {
  .footer-actions {
    flex-wrap: wrap;
  }
  .modal-dialog {
    width: 92vw;
    padding: 0;
  }
}
