:root {
  --mist: #e9edf1;
  --panel: #ffffff;
  --ink: #1b2430;
  --muted: #5b6878;
  --line: #cfd6de;
  --error: #c8102e;
  --warning: #b7791f;
  --focus: #2f5da8;
  --error-wash: rgb(200 16 46 / 0.1);
  --warning-wash: rgb(183 121 31 / 0.12);

  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --code: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --code-size: 14px;
  --code-line: 22px;
  --pad: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --mist: #12181f;
    --panel: #1a222b;
    --ink: #dce3ea;
    --muted: #8a97a6;
    --line: #2c3743;
    --error: #ff6b7a;
    --warning: #e8b04b;
    --focus: #7ea6e8;
    --error-wash: rgb(255 107 122 / 0.14);
    --warning-wash: rgb(232 176 75 / 0.14);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--mist);
  color: var(--ink);
  font: 15px/1.5 var(--ui);
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-underline-offset: 3px; }
a:hover { color: var(--focus); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

code { font-family: var(--code); font-size: 0.92em; }

/* Header */

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 24px 16px;
}

.top h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.top p {
  margin: 4px 0 0;
  max-width: 62ch;
  color: var(--muted);
}

.top nav {
  display: flex;
  gap: 18px;
  align-items: baseline;
  white-space: nowrap;
}

.version { color: var(--muted); font-family: var(--code); font-size: 13px; }

/* Layout */

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr);
  gap: 16px;
  padding: 0 24px 24px;
}

.editor-pane, .results-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Editor: a textarea over a backdrop that draws the underlines, beside a gutter. */

.editor {
  flex: 1;
  min-height: 320px;
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.editor:focus-within { border-color: var(--focus); }

.gutter {
  flex: none;
  padding: var(--pad) 10px var(--pad) 14px;
  font: var(--code-size) / var(--code-line) var(--code);
  color: var(--muted);
  text-align: right;
  user-select: none;
  overflow: hidden;
  border-right: 1px solid var(--line);
}

.gutter span { display: block; }
.gutter .error { color: var(--error); font-weight: 700; }
.gutter .warning { color: var(--warning); font-weight: 700; }

.field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.backdrop, .field textarea {
  margin: 0;
  padding: var(--pad);
  border: 0;
  font: var(--code-size) / var(--code-line) var(--code);
  font-variant-ligatures: none;
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
}

.backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: transparent;
  pointer-events: none;
}

.field textarea {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  resize: none;
  background: transparent;
  color: var(--ink);
  caret-color: var(--ink);
  overflow: auto;
  outline: none;
}

.backdrop mark {
  color: transparent;
  border-radius: 2px;
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-skip-ink: none;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}

.backdrop mark.error { background: var(--error-wash); text-decoration-color: var(--error); }
.backdrop mark.warning { background: var(--warning-wash); text-decoration-color: var(--warning); }
.backdrop mark.active { outline: 2px solid currentColor; }
.backdrop mark.active.error { outline-color: var(--error); }
.backdrop mark.active.warning { outline-color: var(--warning); }

.status {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 2px 0;
  font-size: 13px;
  color: var(--muted);
}

/* Results */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  appearance: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 8px 12px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

.count {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--line);
  color: var(--ink);
  font-size: 12px;
  text-align: center;
}

.panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-top: 12px;
}

.problems {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.problems button {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--sev);
  border-radius: 6px;
  cursor: pointer;
}

.problems button:hover { border-color: var(--sev); }
.problems .error { --sev: var(--error); }
.problems .warning { --sev: var(--warning); }

.where {
  grid-row: span 2;
  font: 13px/1.7 var(--code);
  color: var(--muted);
}

.rule { font-weight: 650; }
.rule .severity { color: var(--sev); font-weight: 600; }
.message { color: var(--muted); }

.empty {
  margin: 8px 2px;
  color: var(--muted);
}

.tree {
  margin: 0;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 13px/1.6 var(--code);
  white-space: pre;
  overflow: auto;
}

.failure {
  margin: 0 24px 24px;
  padding: 12px 14px;
  border-left: 4px solid var(--error);
  background: var(--panel);
}

@media (max-width: 820px) {
  /* Stacked: let the page scroll instead of fitting the viewport. */
  html, body { height: auto; }
  .top { flex-direction: column; align-items: flex-start; padding: 16px; }
  .workspace { flex: none; grid-template-columns: 1fr; padding: 0 16px 16px; }
  .editor { min-height: 360px; }
  .results-pane { min-height: 300px; }
  .hint { display: none; }
}
