*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #f8f9fa;
  --surface: #fff;
  --editor-bg: #fcfcfd;
  --border: #d0d7de;
  --text: #1f2328;
  --muted: #656d76;
  --accent: #0969da;
  --accent-soft: rgba(9, 105, 218, 0.1);
  --pass: #1a7f37;
  --pass-soft: rgba(26, 127, 55, 0.12);
  --fail: #cf222e;
  --fail-soft: rgba(207, 34, 46, 0.1);
  --code-bg: #eef1f4;
  --sidebar-bg: #eef1f4;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji";
  --sidebar-w: 15rem;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(31, 35, 40, 0.06);
  --transition: 0.15s ease;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --editor-bg: #0d1117;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --accent-soft: rgba(88, 166, 255, 0.12);
  --pass: #3fb950;
  --pass-soft: rgba(63, 185, 80, 0.12);
  --fail: #f85149;
  --fail-soft: rgba(248, 81, 73, 0.12);
  --code-bg: #21262d;
  --sidebar-bg: #010409;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 1000;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  border: none;
  padding: 0;
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

body.is-loading .panes {
  opacity: 0.55;
  pointer-events: none;
}

body.is-loading .progress-pill::after {
  content: "";
  width: 0.75rem;
  height: 0.75rem;
  margin-left: 0.35rem;
  border: 2px solid var(--muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

body.resizing {
  cursor: col-resize;
  user-select: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.55rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 100;
  overflow: visible;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow: visible;
}

.toolbar-start {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.icon-btn {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.icon-btn svg {
  width: 1.1rem;
  height: 1.1rem;
}

.icon-btn .theme-icon-sun {
  display: none;
}

[data-theme="dark"] .icon-btn .theme-icon-moon {
  display: none;
}

[data-theme="dark"] .icon-btn .theme-icon-sun {
  display: block;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a.icon-btn {
  text-decoration: none;
}

[data-tip] {
  position: relative;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 0.45rem);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.35rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  color: #fff;
  background: #24292f;
  border-radius: 5px;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition), visibility var(--transition);
  z-index: 500;
}

.toolbar [data-tip]::after,
.reset-menu-trigger[data-tip]::after {
  bottom: auto;
  top: calc(100% + 0.45rem);
}

[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

[data-theme="dark"] [data-tip]::after {
  color: #24292f;
  background: #f0f6fc;
}

.logo {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  cursor: pointer;
}

.logo:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--code-bg);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.mode-chapter .progress-pill {
  color: var(--text);
}

body.mode-chapter .progress-pill.complete {
  background: var(--pass-soft);
  color: var(--pass);
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  flex-shrink: 0;
  overflow: visible;
}

.toolbar-actions .progress-pill {
  margin-right: 0.15rem;
}

.toolbar-actions .progress-pill + .toolbar-group {
  padding-left: 0.5rem;
  border-left: 1px solid var(--border);
}

.reset-menu {
  position: relative;
}

.reset-menu-trigger {
  list-style: none;
  font: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.reset-menu-trigger::-webkit-details-marker {
  display: none;
}

.reset-menu-trigger:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.reset-menu[open] .reset-menu-trigger {
  border-color: var(--accent);
  color: var(--accent);
}

.reset-menu-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 10.5rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(31, 35, 40, 0.12);
}

[data-theme="dark"] .reset-menu-panel {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.reset-menu-panel button {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.45rem 0.65rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.reset-menu-panel button:hover {
  background: var(--code-bg);
  color: var(--accent);
}

.reset-menu-panel button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

body.mode-home .reset-menu {
  display: none;
}

body.mode-playground .reset-menu #reset-exercise {
  display: none;
}

.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: flex-basis 0.2s, width 0.2s, opacity 0.2s;
}

body.sidebar-collapsed .sidebar {
  flex-basis: 0;
  width: 0;
  border-right: none;
  opacity: 0;
  pointer-events: none;
}

.sidebar-inner {
  width: var(--sidebar-w);
  height: 100%;
  overflow-y: auto;
  padding: 0.75rem;
}

.chapter-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-panel {
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.sidebar-label {
  list-style: none;
  cursor: pointer;
  padding: 0.35rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  user-select: none;
}

.sidebar-label::-webkit-details-marker {
  display: none;
}

.sidebar-label::before {
  content: "▸ ";
  font-size: 0.65rem;
  transition: transform var(--transition);
  display: inline-block;
}

.sidebar-panel[open] > .sidebar-label::before {
  transform: rotate(90deg);
}

.sidebar-exercises {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.35rem 0.55rem 0.15rem;
}

.chapter-link {
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.chapter-link:hover {
  background: var(--code-bg);
}

.chapter-link.active {
  border-color: var(--accent);
  background: var(--code-bg);
  color: var(--accent);
  font-weight: 600;
}

.chapter-link.home-link {
  font-weight: 600;
}

.chapter-link.playground-link {
  margin-top: 0.25rem;
}

.chapter-link.practice-link {
  margin-top: 0.25rem;
}

.sidebar-label:focus-visible,
.chapter-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

body.mode-home .progress-pill,
body.mode-playground .progress-pill {
  color: var(--accent);
  background: var(--accent-soft);
}

body.mode-home .editor-pane,
body.mode-home .pane-resizer,
body.mode-home .mobile-tabs {
  display: none;
}

body.mode-home .panes {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

body.mode-home .exercise-panes {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

body.mode-home .preview-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

body.mode-home .preview-pane .pane-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

body.mode-home .preview-pane .pane-body::-webkit-scrollbar {
  display: block;
  width: 8px;
}

body.mode-home .preview-pane .pane-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

body.mode-home .preview-pane .pane-title,
body.mode-home .preview-pane-header {
  display: none;
}

body.mode-home .preview-content {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0 1rem;
  font-family: var(--sans);
  font-size: 0.84rem;
  line-height: 1.5;
  text-align: left;
}

body.mode-home .home-banner {
  position: relative;
  width: 100%;
  max-width: none;
  margin: 0 0 1.5rem;
  padding: 2rem 1.5rem 1.75rem;
  text-align: center;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

body.mode-home .home-banner::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), #79c0ff 50%, var(--accent));
}

body.mode-home .home-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 80% at 50% -30%, var(--accent-soft), transparent 65%);
  pointer-events: none;
}

body.mode-home .home-eyebrow {
  position: relative;
  z-index: 1;
  display: inline-block;
  margin: 0.85rem 0 0;
  padding: 0.22rem 0.65rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}

body.mode-home .home-title {
  position: relative;
  z-index: 1;
  margin: 0 auto 0.5rem;
  max-width: 28rem;
  font-size: clamp(1.65rem, 4vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

body.mode-home .home-lead {
  position: relative;
  z-index: 1;
  margin: 0 auto 0.4rem;
  max-width: 32rem;
  font-size: 0.92rem;
  color: var(--text);
}

body.mode-home .home-desc {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  max-width: 32rem;
  font-size: 0.8rem;
  color: var(--muted);
}

body.mode-home .home-cta {
  position: relative;
  z-index: 1;
  margin: 1.15rem 0 0;
}

body.mode-home .home-get-started-btn {
  display: inline-block;
  padding: 0.55rem 1.35rem;
  border-radius: 6px;
  background: var(--accent);
  color: #fff !important;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: filter var(--transition), transform var(--transition);
}

body.mode-home .home-get-started-btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  text-decoration: none;
}

body.mode-home .home-get-started-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

body.mode-home .home-body {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 1.25rem 1rem;
  font-size: 0.84rem;
}

body.mode-home .home-body h2 {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 1.35rem 0 0.5rem;
}

body.mode-home .home-body h2:first-child {
  margin-top: 0;
}

body.mode-home .home-body p {
  margin: 0 0 0.85rem;
}

body.mode-home .home-list {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

body.mode-home .home-list li {
  margin: 0.35rem 0;
  padding-left: 0.1rem;
}

body.mode-home .home-list li::marker {
  color: var(--accent);
}

body.mode-home .home-steps {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

body.mode-home .home-steps li {
  margin: 0.4rem 0;
  padding-left: 0.15rem;
}

body.mode-home .home-steps li::marker {
  color: var(--accent);
  font-weight: 600;
}

body.mode-home .home-note {
  margin: 1.25rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}

.noscript-fallback {
  max-width: 40rem;
  margin: 2rem auto;
  padding: 0 1.5rem;
  font-family: var(--sans);
  line-height: 1.5;
}

.noscript-fallback h1 {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}

.noscript-fallback h2 {
  font-size: 1.1rem;
  margin: 1.25rem 0 0.5rem;
}

.noscript-fallback ul {
  padding-left: 1.25rem;
}

.noscript-fallback a {
  color: var(--accent);
}

body.mode-home .preview-content a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.site-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.45rem 1rem;
  font-size: 0.7rem;
  line-height: 1.3;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a strong {
  font-weight: 700;
  color: var(--text);
}

.site-footer a:hover strong {
  color: var(--accent);
}

.site-footer-heart {
  flex-shrink: 0;
  color: #e85d75;
}

.exercise-badge.static {
  cursor: default;
}

.exercise-badge.static:hover {
  border-color: var(--border);
  background: var(--bg);
}

body.mode-practice .editor-pane .pane-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.exercise-badge {
  font: inherit;
  font-size: 0.75rem;
  font-family: var(--mono);
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.exercise-badge:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.exercise-badge.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.exercise-badge:hover {
  border-color: var(--accent);
}

.exercise-badge.pass {
  border-color: var(--pass);
  color: var(--pass);
  background: var(--pass-soft);
}

.exercise-badge.fail {
  border-color: var(--fail);
  color: var(--fail);
  background: var(--fail-soft);
}

.exercise-badge.free {
  border-color: var(--muted);
  color: var(--muted);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

body.mode-chapter .lesson-pane {
  flex: 1;
  display: flex;
}

body.mode-practice .panes {
  flex-direction: column;
}

body.mode-practice .lesson-pane {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  border-bottom: 1px solid var(--border);
}

body.mode-practice #lesson-body {
  flex: 0 1 auto;
  max-height: 6.5rem;
  overflow-y: auto;
}

body.mode-practice .lesson-view {
  padding: 0;
}

body.mode-practice .lesson-section.practice-intro {
  padding: 0.75rem 1.25rem;
  margin: 0;
}

body.mode-practice .lesson-section.practice-intro h1 {
  font-size: 1.1rem;
  margin: 0 0 0.35rem;
}

body.mode-practice .lesson-section.practice-intro p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

body.mode-practice .exercise-panes {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

body.mode-practice .editor-pane,
body.mode-practice .preview-pane {
  flex: 1 1 50%;
  min-width: 0;
}

body.mode-practice .editor-pane .pane-body,
body.mode-practice .preview-pane .pane-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.mode-practice #editor {
  flex: 1;
  min-height: 0;
  height: auto;
  resize: none;
  field-sizing: normal;
  overflow: auto;
}

body.mode-practice .preview-content.practice-target {
  border-left: 3px solid var(--accent);
}

.practice-target .practice-hint-target {
  cursor: help;
  border-radius: 3px;
}

.practice-target .practice-hint-target.practice-hint-active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: var(--accent-soft);
}

.practice-hint-popover {
  position: fixed;
  z-index: 700;
  max-width: min(24rem, calc(100vw - 1rem));
  padding: 0.5rem 0.65rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.35;
  white-space: pre-wrap;
  color: #fff;
  background: #24292f;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(31, 35, 40, 0.2);
  pointer-events: none;
}

[data-theme="dark"] .practice-hint-popover {
  color: #24292f;
  background: #f0f6fc;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

body.support-prompt-pending::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
  z-index: 850;
  pointer-events: none;
}

body.support-prompt-pending::after {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: 2rem;
  height: 2rem;
  margin: -1rem 0 0 -1rem;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: support-prompt-spin 0.7s linear infinite;
  z-index: 851;
  pointer-events: none;
}

@keyframes support-prompt-spin {
  to {
    transform: rotate(360deg);
  }
}

body.mode-practice .progress-pill {
  color: var(--text);
}

body.mode-practice .progress-pill.complete {
  background: var(--pass-soft);
  color: var(--pass);
}

body.mode-chapter .exercise-panes,
body.mode-chapter .mobile-tabs {
  display: none;
}

body.mode-home .lesson-pane {
  display: none;
}

body.mode-playground .panes {
  flex-direction: column;
}

body.mode-playground .lesson-pane {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  border-bottom: 1px solid var(--border);
}

body.mode-playground #lesson-body {
  flex: 0 0 auto;
  overflow: visible;
}

body.mode-playground .lesson-view {
  padding: 0;
}

body.mode-playground .lesson-section.playground-intro {
  padding: 0.75rem 1.25rem;
  margin: 0;
}

body.mode-playground .lesson-section.playground-intro h1 {
  font-size: 1.1rem;
  margin: 0 0 0.35rem;
}

body.mode-playground .lesson-section.playground-intro p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

body.mode-playground .exercise-panes {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.exercise-panes {
  display: flex;
  align-items: stretch;
  min-width: 0;
}

body.mode-home .exercise-panes,
body.mode-playground .exercise-panes,
body.mode-practice .exercise-panes {
  flex: 1;
  min-height: 0;
}

.lesson-view {
  padding: 1rem 0 2rem;
}

.lesson-section {
  width: 100%;
  margin: 0 0 0.5rem;
  padding: 1.15rem 1.25rem;
  box-sizing: border-box;
}

.format-hint {
  margin: 0.75rem 0 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.format-hint summary {
  list-style: none;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  background: var(--code-bg);
}

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

.format-hint summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform var(--transition);
}

.format-hint[open] summary::before {
  transform: rotate(90deg);
}

.format-hint summary:hover {
  color: var(--accent);
}

.format-hint pre {
  margin: 0;
  border-radius: 0;
  border-top: 1px solid var(--border);
}

.exercise-block {
  margin: 1.5rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
  background: var(--surface);
}

.exercise-block.focused {
  box-shadow: 0 0 0 2px var(--accent-soft);
  border-color: var(--accent);
}

.exercise-block-head {
  padding: 0.35rem 0.75rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--code-bg);
}

.exercise-block-panes {
  display: flex;
  min-height: 7rem;
}

.exercise-editor {
  flex: 1;
  min-width: 0;
  min-height: 7rem;
  width: 100%;
  border: none;
  border-right: 1px solid var(--border);
  padding: 0.75rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  background: var(--editor-bg);
  color: var(--text);
  field-sizing: content;
}

.exercise-editor:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.exercise-preview {
  flex: 1;
  min-width: 0;
  min-height: 7rem;
  overflow: auto;
  padding: 0.75rem;
  font-size: 0.9rem;
  background: var(--surface);
}

.exercise-preview.empty {
  color: var(--muted);
  font-style: italic;
}

.exercise-preview-target {
  border-left: 3px solid var(--accent);
  background: var(--bg);
}

.exercise-block-match .exercise-editor {
  border-right: 1px solid var(--border);
}

.exercise-block-practice .exercise-block-panes,
.exercise-block-practice .exercise-editor,
.exercise-block-practice .exercise-preview {
  min-height: 12rem;
}

@media (max-width: 768px) {
  .exercise-block-panes {
    flex-direction: column;
  }

  .exercise-editor {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.panes {
  flex: 1;
  display: flex;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.editor-pane {
  flex: 0 0 auto;
  flex-basis: 50%;
}

.preview-pane {
  flex: 1;
}

.pane-resizer {
  flex: 0 0 6px;
  cursor: col-resize;
  background: var(--border);
  transition: background var(--transition);
  position: relative;
}

.pane-resizer::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 2px;
  height: 2rem;
  border-radius: 1px;
  background: var(--muted);
  opacity: 0.5;
}

.pane-resizer:hover,
.pane-resizer:focus-visible {
  background: var(--accent);
  outline: none;
}

.pane-title {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 1rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: transparent;
  border-bottom: none;
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
}

.pane-header {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 2.25rem;
  height: 2.25rem;
  box-sizing: border-box;
}

.editor-pane-header {
  border-left: 3px solid var(--accent);
}

.preview-pane-header {
  border-left: 3px solid var(--muted);
}

.practice-pane-tabs {
  display: none;
  align-items: stretch;
  flex: 1;
  min-width: 0;
}

body.mode-practice .practice-pane-tabs {
  display: flex;
}

.practice-pane-tab {
  display: inline-flex;
  align-items: center;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0 1rem;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  transition: color var(--transition), border-color var(--transition);
}

.practice-pane-tab:hover {
  color: var(--text);
}

.practice-pane-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.practice-pane-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

body.mode-practice .editor-pane-header .pane-title {
  display: none;
}

body.mode-practice .editor-pane.show-user-preview #editor {
  display: none;
}

.practice-user-preview {
  flex: 1;
  min-height: 0;
  padding: 1rem 1.25rem;
  overflow: auto;
  box-sizing: border-box;
}

.practice-user-preview[hidden] {
  display: none !important;
}

.practice-preview-empty {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

.pane-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.pane-body::-webkit-scrollbar {
  display: none;
}

.editor-pane .pane-title {
  border-left: none;
}

.preview-pane .pane-title {
  border-left: none;
}

#editor {
  flex: 0 0 auto;
  width: 100%;
  resize: none;
  border: none;
  padding: 1rem 1.15rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--editor-bg);
  tab-size: 2;
  overflow: visible;
  field-sizing: content;
  min-height: 12rem;
}

#editor:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.preview-content {
  overflow: visible;
  padding: 1.15rem 1.35rem;
  background: var(--surface);
  font-family: var(--sans);
  line-height: 1.5;
}

.preview-content img[alt="Logo"],
.exercise-preview img[alt="Logo"] {
  max-width: 3rem;
  height: auto;
}

.preview-content a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.preview-content a:hover {
  text-decoration-thickness: 2px;
}

.preview-content.empty {
  color: var(--muted);
  font-family: var(--sans);
  font-style: italic;
}

.preview-content h1,
.preview-content h2,
.preview-content h3 {
  font-family: var(--sans);
  line-height: 1.3;
  margin-top: 1.25em;
  margin-bottom: 0.5em;
}

.preview-content h1:first-child,
.preview-content h2:first-child {
  margin-top: 0;
}

.preview-content code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.preview-content pre {
  background: var(--code-bg);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  overflow-x: auto;
}

.preview-content pre code.hljs {
  background: transparent;
  color: inherit;
}

.preview-content pre code {
  background: none;
  padding: 0;
}

.preview-content blockquote {
  margin: 0.75em 0;
  padding-left: 1em;
  border-left: 4px solid var(--border);
  color: var(--muted);
}

.preview-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.75em 0;
}

.preview-content th,
.preview-content td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.65rem;
  text-align: left;
}

.preview-content th[align="right"],
.preview-content td[align="right"] {
  text-align: right;
}

.preview-content th[align="center"],
.preview-content td[align="center"] {
  text-align: center;
}

.preview-content th {
  background: var(--code-bg);
}

.mobile-tabs {
  display: none;
}

@media (max-width: 768px) {
  .sidebar-backdrop:not([hidden]) {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 200;
    top: 3rem;
    left: 0;
    bottom: 0;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  }

  body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
    opacity: 1;
    pointer-events: none;
  }

  body:not(.sidebar-collapsed) .sidebar {
    pointer-events: auto;
  }

  .pane-resizer {
    display: none;
  }

  .editor-pane {
    flex: 1 !important;
    flex-basis: auto !important;
  }

  .preview-pane {
    display: none;
  }

  .panes.show-preview .exercise-panes .editor-pane {
    display: none;
  }

  .panes.show-preview .exercise-panes .preview-pane {
    display: flex;
    flex: 1;
  }

  body.mode-home .exercise-panes .preview-pane {
    display: flex;
    flex: 1;
  }

  .mobile-tabs {
    display: flex;
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
  }

  .mobile-tabs .tab {
    flex: 1;
    padding: 0.7rem;
    border: none;
    background: transparent;
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--muted);
    min-height: 2.75rem;
  }

  .mobile-tabs .tab.active {
    color: var(--accent);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--accent);
  }

  .mobile-tabs .tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }
}

.exercise-editor::placeholder,
#editor::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

.support-modal {
  width: min(22rem, calc(100vw - 2rem));
  padding: 1.35rem 1.35rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(31, 35, 40, 0.18);
}

.support-modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.support-modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  line-height: 1.3;
}

.support-modal-body {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.support-modal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.support-modal-star {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.support-modal-star:hover {
  filter: brightness(1.05);
}

.support-modal-later {
  font: inherit;
  font-size: 0.82rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.support-modal-later:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.support-modal-close {
  margin-left: auto;
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.15rem 0.45rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.support-modal-close:hover {
  color: var(--text);
  background: var(--code-bg);
}
