@font-face {
  font-family: "Geist";
  src: url("fonts/Geist-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("fonts/Geist-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("fonts/GeistMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("fonts/GeistMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --ink: #000000;
  --ink-2: #111111;
  --grey: #666666;
  --grey-2: #999999;
  --rule: #e5e5e5;
  --accent: #ff4f00;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --gutter: 24px;
  --side: max(32px, env(safe-area-inset-left));
  --side-r: max(32px, env(safe-area-inset-right));
  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

h1,
h2,
p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- grid */

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: max(40px, env(safe-area-inset-top)) var(--side-r) max(32px, env(safe-area-inset-bottom)) var(--side);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gutter);
}

/* ---------------------------------------------------------------- header */

.masthead {
  align-items: baseline;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--ink);
}

.wordmark {
  grid-column: 1 / span 3;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
}

.tagline {
  grid-column: 5 / span 7;
  color: var(--grey);
}

.version {
  grid-column: 12;
  justify-self: end;
  font-size: 11px;
  color: var(--grey-2);
}

/* ---------------------------------------------------------------- sections */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  margin-bottom: 16px;
}

.label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--grey);
}

.note,
.hint {
  font-size: 11px;
  color: var(--grey-2);
}

.main {
  padding: 32px 0 40px;
  border-bottom: 1px solid var(--rule);
}

.editor {
  grid-column: 1 / span 4;
  min-width: 0;
}

.diagram {
  grid-column: 5 / span 8;
  min-width: 0;
}

/* ---------------------------------------------------------------- editor */

.source {
  display: block;
  width: 100%;
  min-height: 360px;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--bg);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  -webkit-appearance: none;
  appearance: none;
}

.source:focus {
  outline: none;
  border-color: var(--ink);
}

.source.has-errors {
  border-color: var(--accent);
}

.errors {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  color: var(--accent);
  font-size: 12px;
}

.errors li + li {
  margin-top: 4px;
}

.reference {
  margin-top: 24px;
  border-top: 1px solid var(--rule);
  padding-top: 12px;
}

.reference summary {
  cursor: pointer;
  min-height: 40px;
  display: flex;
  align-items: center;
  list-style: none;
}

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

.reference summary::after {
  content: "+";
  margin-left: 8px;
}

.reference[open] summary::after {
  content: "\2212";
}

.reference pre {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--grey);
  white-space: pre-wrap;
}

/* ---------------------------------------------------------------- controls */

.btn,
.select {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover,
.select:hover {
  background: var(--ink);
  color: var(--bg);
}

.btn:focus-visible,
.select:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

.select {
  padding-right: 28px;
  background-image: none;
}

.examples {
  position: relative;
  display: inline-block;
}

.examples::after {
  content: "\2193";
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 11px;
  pointer-events: none;
}

.examples:hover::after {
  color: var(--bg);
}

/* ---------------------------------------------------------------- diagram */

.canvas {
  border: 1px solid var(--rule);
  min-height: 360px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.canvas svg {
  display: block;
  max-width: 100%;
  height: auto;
  flex: none;
}

.canvas.is-scroll {
  justify-content: flex-start;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.canvas.is-scroll svg {
  max-width: none;
}

.sm text {
  font-family: var(--mono);
}

.sm-state.is-current .sm-box {
  stroke: var(--accent);
  stroke-width: 2;
}

.sm-state.is-current .sm-box-inner {
  stroke: var(--accent);
}

.sm-state.is-current .sm-name {
  fill: var(--accent);
}

/* ---------------------------------------------------------------- lower row */

.lower {
  padding-top: 32px;
}

.panel {
  grid-column: span 4;
  min-width: 0;
}

.panel + .panel {
  border-left: 1px solid var(--rule);
  padding-left: calc(var(--gutter) / 2);
  margin-left: calc(var(--gutter) / -2);
}

.current-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.current {
  font-size: 20px;
  color: var(--accent);
}

.event-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.btn-event {
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
}

.btn-event .guard,
.btn-event .to {
  color: var(--grey);
  white-space: pre;
}

.btn-event:hover .guard,
.btn-event:hover .to {
  color: var(--grey-2);
}

.trace {
  list-style: none;
  margin: 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--rule);
  max-height: 260px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.8;
  color: var(--ink-2);
}

.trace li {
  white-space: pre;
  overflow-x: auto;
}

.trace .is-note {
  color: var(--grey);
}

.none {
  color: var(--grey-2);
  font-size: 12px;
}

/* ---------------------------------------------------------------- checks */

.check + .check {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}

.check-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.check-title {
  font-size: 13px;
}

.count {
  font-size: 13px;
}

.count.zero {
  color: var(--grey-2);
}

.check-items {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
  color: var(--ink-2);
}

.events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.events-table th {
  text-align: left;
  font-weight: 400;
  font-size: 11px;
  color: var(--grey-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--rule);
}

.events-table td {
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.events-table td.none {
  color: var(--grey-2);
}

/* ---------------------------------------------------------------- export */

.export-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.clipboard-fallback {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}

/* ---------------------------------------------------------------- footer */

.footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 11px;
  color: var(--grey-2);
}

.footer p {
  grid-column: 1 / -1;
}

/* ---------------------------------------------------------------- mobile */

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

@media (max-width: 760px) {
  :root {
    --gutter: 16px;
    --side: max(16px, env(safe-area-inset-left));
    --side-r: max(16px, env(safe-area-inset-right));
  }

  .page {
    padding-top: max(24px, env(safe-area-inset-top));
  }

  .masthead {
    row-gap: 8px;
  }

  .wordmark {
    grid-column: 1 / span 10;
    font-size: 28px;
  }

  .version {
    grid-column: 11 / span 2;
  }

  .wordmark,
  .version {
    grid-row: 1;
  }

  .tagline {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .main {
    padding-top: 24px;
    row-gap: 32px;
  }

  .editor,
  .diagram,
  .panel {
    grid-column: 1 / -1;
  }

  .source {
    font-size: 16px;
    min-height: 280px;
  }

  .canvas {
    min-height: 0;
    padding: 8px;
  }

  .lower {
    padding-top: 0;
  }

  .panel,
  .panel + .panel {
    border-left: 0;
    margin-left: 0;
    padding: 24px 0;
  }

  .panel + .panel {
    border-top: 1px solid var(--rule);
  }

  .export-buttons {
    grid-template-columns: 1fr 1fr;
  }

  .btn,
  .select {
    min-height: 44px;
  }
}
