.debug-page .page-hero {
  min-height: auto;
  padding-block: 72px 46px;
}

.debug-page .page-hero-copy {
  max-width: 860px;
}

.debug-workbench {
  margin-bottom: 80px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.debug-intro {
  max-width: 920px;
  margin-bottom: 20px;
}

.debug-intro h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.6vw, 2rem);
}

.debug-intro p {
  margin: 8px 0 0;
  color: var(--muted);
}

.debug-language-control {
  display: flex;
  align-items: end;
  gap: 18px;
  margin: 0 0 20px;
  padding: 14px 16px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.debug-language-control label {
  display: grid;
  flex: 0 0 min(100%, 280px);
  gap: 7px;
  color: var(--text);
  font-size: .78rem;
  font-weight: 850;
}

.debug-language-control select {
  width: 100%;
  min-height: 44px;
  padding: 0 38px 0 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font: inherit;
}

.debug-language-control select:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

.debug-language-control p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: .78rem;
}

.debug-language-description {
  min-width: 0;
  flex: 1 1 420px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.debug-language-description button {
  min-height: 44px;
  flex: 0 0 auto;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 850;
}

.debug-language-description button:hover {
  border-color: var(--cyan);
}

.debug-language-description button:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

.debug-reference-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.debug-editor-grid,
.debug-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.debug-editor-panel,
.debug-result-panel {
  min-width: 0;
  overflow: hidden;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.debug-panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.debug-panel-heading h3 {
  margin: 0;
  font-size: .95rem;
}

.debug-panel-heading span {
  color: var(--muted);
  font-size: .72rem;
}

.debug-file-drop {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 58px;
  margin: 12px;
  padding: 10px 14px;
  color: var(--steel);
  background: var(--surface);
  border: 2px dashed var(--line-strong);
  border-radius: 11px;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 800;
  text-align: center;
}

.debug-file-drop.is-dragover {
  color: var(--text);
  background: color-mix(in srgb, var(--cyan) 13%, var(--surface));
  border-color: var(--cyan);
}

.debug-file-drop.is-unsupported {
  color: #a2163b;
  background: #fff0f4;
  border-color: #c43d5d;
}

html[data-theme="dark"] .debug-file-drop.is-unsupported {
  color: #ffd8e2;
  background: #3b1f2b;
  border-color: #ff8eaa;
}

.debug-file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.debug-editor-label {
  display: grid;
  gap: 7px;
  padding: 0 12px 12px;
  color: var(--text);
  font-size: .76rem;
  font-weight: 800;
}

.debug-editor {
  width: 100%;
  min-height: 380px;
  resize: vertical;
  padding: 16px;
  color: #e9edf7;
  background: #171827;
  border: 1px solid #363a50;
  border-radius: 11px;
  font: 14px/1.7 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  tab-size: 2;
  white-space: pre;
}

.debug-editor:focus-visible,
.debug-file-drop:focus-within {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}
.debug-editor.is-dragover {
  border-color: var(--cyan);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--cyan) 35%, transparent);
  background: color-mix(in srgb, var(--cyan) 7%, var(--surface));
}

.debug-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
}

.debug-actions button,
.debug-navigation button {
  min-height: 44px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 850;
}

.debug-actions .debug-compare {
  color: #fff;
  background: #5148c5;
  border-color: #5148c5;
}

.debug-actions button:hover,
.debug-navigation button:hover:not(:disabled) {
  border-color: var(--cyan);
}

.debug-actions button:focus-visible,
.debug-navigation button:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

.debug-actions-status {
  min-width: min(100%, 280px);
  color: var(--muted);
  font-size: .78rem;
}

.debug-syntax-tool {
  margin-bottom: 80px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.debug-syntax-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
}

.debug-syntax-heading .eyebrow {
  margin: 0 0 4px;
}

.debug-syntax-heading h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.6vw, 2rem);
}

.debug-syntax-heading div > p:last-child {
  max-width: 760px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: .8rem;
}

.debug-syntax-language-control {
  margin-top: 20px;
}

.debug-syntax-language-control > p {
  flex: 1 1 420px;
  margin: 0;
}

.debug-syntax-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: 16px;
}

.debug-syntax-editor {
  min-height: 350px;
}

.debug-syntax-output {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.debug-syntax-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.debug-syntax-actions button,
.debug-syntax-line {
  min-height: 44px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 850;
}

.debug-syntax-actions .debug-compare {
  color: #fff;
  background: #5148c5;
  border-color: #5148c5;
}

.debug-syntax-actions span {
  flex: 1 1 220px;
  color: var(--muted);
  font-size: .78rem;
}

.debug-syntax-actions button:hover,
.debug-syntax-line:hover {
  border-color: var(--cyan);
}

.debug-syntax-actions button:focus-visible,
.debug-syntax-line:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

.debug-syntax-result {
  flex: 1 1 auto;
  min-width: 0;
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.debug-syntax-result h3 {
  margin: 0;
  font-size: .92rem;
}

.debug-syntax-summary {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: .78rem;
}

.debug-syntax-summary[data-state="success"] {
  color: #176b4d;
  font-weight: 800;
}

.debug-syntax-summary[data-state="warning"] {
  color: #9b2344;
  font-weight: 800;
}

html[data-theme="dark"] .debug-syntax-summary[data-state="success"] {
  color: #9ee9cd;
}

html[data-theme="dark"] .debug-syntax-summary[data-state="warning"] {
  color: #ffb4c6;
}

.debug-syntax-issues {
  display: grid;
  gap: 8px;
  margin: 13px 0 0;
  padding: 0;
  list-style: none;
}

.debug-syntax-issues:empty {
  display: none;
}

.debug-syntax-issues li {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 10px;
  background: color-mix(in srgb, #c43d5d 8%, var(--surface));
  border: 1px solid color-mix(in srgb, #c43d5d 38%, var(--line));
  border-radius: 10px;
}

.debug-syntax-line {
  min-height: 36px;
  padding: 0 9px;
  color: #8d1736;
  border-color: #c43d5d;
  font-size: .75rem;
}

html[data-theme="dark"] .debug-syntax-line {
  color: #ffd8e2;
  background: #3b1f2b;
  border-color: #ff8eaa;
}

.debug-syntax-issues strong {
  display: block;
  color: var(--text);
  font-size: .8rem;
}

.debug-syntax-issues p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .75rem;
}

.debug-syntax-note {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: .73rem;
}

.debug-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 22px 0 12px;
  padding: 16px 18px;
  color: var(--text);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.debug-summary strong {
  font-size: 1rem;
}

.debug-summary p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: .78rem;
}

.debug-navigation {
  display: flex;
  gap: 8px;
}

.debug-navigation button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.debug-result-grid {
  --diff-bg: #fff0f2;
  --diff-border: #c43d5d;
  --diff-text: #8d1736;
}

html[data-theme="dark"] .debug-result-grid {
  --diff-bg: #3b1f2b;
  --diff-border: #ff8eaa;
  --diff-text: #ffd8e2;
}

.debug-result-panel {
  background: #171827;
  border-color: #363a50;
}

.debug-result-panel .debug-panel-heading {
  color: #eef1f8;
  background: #202235;
  border-color: #363a50;
}

.debug-result-panel .debug-panel-heading span {
  color: #b4bbcb;
}

.debug-diff-lines {
  max-height: 580px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: diff-line;
  scroll-padding-block: 32px;
}

.debug-diff-line {
  min-height: 30px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  border-bottom: 1px solid #292c40;
  color: #e7ebf5;
  font: 13px/1.65 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.debug-diff-line:last-child {
  border-bottom: 0;
}

.debug-line-number {
  padding: 5px 9px;
  color: #9ea7ba;
  background: #202235;
  border-right: 1px solid #363a50;
  text-align: right;
  user-select: none;
}

.debug-line-code {
  min-width: 0;
  padding: 5px 10px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.debug-diff-line.is-different {
  background: var(--diff-bg);
  box-shadow: inset 4px 0 0 var(--diff-border);
}

.debug-diff-line.is-different .debug-line-number {
  color: var(--diff-text);
  background: color-mix(in srgb, var(--diff-bg) 88%, #171827);
  border-color: var(--diff-border);
}

.debug-diff-line.is-different .debug-line-code {
  color: var(--diff-text);
}

.debug-diff-line.is-current {
  outline: 3px solid var(--diff-border);
  outline-offset: -3px;
}

.debug-diff-mark {
  padding: 0;
  color: var(--diff-text);
  background: color-mix(in srgb, var(--diff-border) 22%, transparent);
  border-bottom: 2px solid var(--diff-border);
}

.debug-missing-line {
  color: var(--diff-text);
  font-style: italic;
}

.debug-help {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.debug-help article {
  padding: 16px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.debug-help h3 {
  margin: 0;
  font-size: .88rem;
}

.debug-help p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: .78rem;
}

.debug-example-dialog:not([open]),
.debug-confirm-dialog:not([open]) {
  display: none;
}

.debug-example-dialog,
.debug-confirm-dialog {
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 36px 90px rgb(0 0 0 / .4);
}

.debug-example-dialog {
  width: min(1120px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
}

.debug-example-dialog::backdrop,
.debug-confirm-dialog::backdrop {
  background: rgb(3 10 17 / .72);
  backdrop-filter: blur(7px);
}

.debug-example-dialog-shell {
  max-height: calc(100dvh - 30px);
  overflow: auto;
}

.debug-example-dialog header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 20px 22px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.debug-example-dialog .eyebrow,
.debug-confirm-dialog .eyebrow {
  margin: 0 0 5px;
}

.debug-example-dialog h2,
.debug-confirm-dialog h2 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.8rem);
  line-height: 1.25;
}

.debug-example-dialog header p:last-child {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: .78rem;
}

.debug-dialog-close {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--text);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  font-size: 1.5rem;
}

.debug-dialog-close:focus-visible,
.debug-example-actions button:focus-visible,
.debug-confirm-actions button:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

.debug-example-notice {
  margin: 20px 22px 0;
  padding: 14px 16px;
  color: var(--text);
  background: color-mix(in srgb, var(--cyan) 9%, var(--paper-2));
  border: 1px solid color-mix(in srgb, var(--cyan) 32%, var(--line));
  border-radius: 12px;
}

.debug-example-notice strong {
  font-size: .84rem;
}

.debug-example-notice p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: .76rem;
}

.debug-example-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 22px;
}

.debug-example-grid section {
  min-width: 0;
}

.debug-example-grid h3 {
  margin: 0 0 8px;
  font-size: .88rem;
}

.debug-example-grid pre {
  min-height: 260px;
  max-height: 48vh;
  overflow: auto;
  margin: 0;
  padding: 16px;
  color: #edf0f7;
  background: #171827;
  border: 1px solid #363a50;
  border-radius: 12px;
  font: 13px/1.7 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre;
}

.debug-example-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 22px 22px;
}

.debug-example-actions button,
.debug-confirm-actions button {
  min-height: 44px;
  padding: 0 16px;
  color: var(--text);
  background: var(--paper-2);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 850;
}

.debug-example-actions .debug-example-replace,
.debug-confirm-actions #debugReplaceConfirm {
  color: #fff;
  background: #5148c5;
  border-color: #5148c5;
}

.debug-confirm-dialog {
  width: min(540px, calc(100% - 28px));
}

.debug-confirm-dialog > div {
  padding: 24px;
}

.debug-confirm-dialog > div > p:not(.eyebrow) {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .84rem;
}

.debug-confirm-dialog > div > p strong {
  color: var(--text);
}

.debug-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.debug-simulator-guide {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 80px;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.debug-simulator-guide h2 { margin: 0; font-size: clamp(1.2rem, 2vw, 1.7rem); }
.debug-simulator-guide .eyebrow { margin: 0 0 4px; }
.debug-simulator-guide p:last-child { max-width: 760px; margin: 6px 0 0; color: var(--muted); font-size: .8rem; }
.debug-simulator-guide > a { flex: 0 0 auto; min-height: 46px; display: inline-flex; align-items: center; padding: 0 16px; color: #fff; background: #5148c5; border-radius: 10px; font-weight: 850; text-decoration: none; }

@media (max-width: 820px) {
  .debug-simulator-guide { align-items: stretch; flex-direction: column; }
  .debug-simulator-guide > a { justify-content: center; }
  .debug-editor-grid,
  .debug-result-grid,
  .debug-syntax-layout,
  .debug-help {
    grid-template-columns: 1fr;
  }

  .debug-editor {
    min-height: 300px;
  }

  .debug-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .debug-language-control {
    align-items: stretch;
    flex-direction: column;
  }

  .debug-language-description {
    align-items: flex-start;
    flex-direction: column;
  }

  .debug-example-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .debug-workbench {
    padding: 14px;
    border-radius: 18px;
  }

  .debug-actions,
  .debug-navigation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .debug-actions .debug-compare,
  .debug-actions-status {
    grid-column: 1 / -1;
  }

  .debug-syntax-tool {
    padding: 14px;
    border-radius: 18px;
  }

  .debug-syntax-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .debug-syntax-actions span {
    grid-column: 1 / -1;
  }

  .debug-syntax-issues li {
    grid-template-columns: 1fr;
  }

  .debug-syntax-line {
    width: max-content;
  }

  .debug-language-description button {
    width: 100%;
  }

  .debug-example-dialog header {
    padding: 16px;
  }

  .debug-example-notice {
    margin: 14px 14px 0;
  }

  .debug-example-grid {
    padding: 14px;
  }

  .debug-example-actions,
  .debug-confirm-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .debug-example-actions {
    padding: 0 14px 14px;
  }

  .debug-editor {
    min-height: 260px;
    padding: 12px;
    font-size: 12px;
  }
}
