* {
  box-sizing: border-box;
}
:root {
  font:
    14px/1.6 ui-sans-serif,
    system-ui,
    sans-serif;
  color: #23342d;
  background: #f6f7f3;
}
body {
  margin: 0;
}
button,
input,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
  padding: 7px 12px;
  border: 1px solid #cbd5cc;
  border-radius: 6px;
  background: white;
  color: inherit;
}
button:hover,
button[aria-pressed="true"] {
  background: #e9f3e9;
  border-color: #7c9e7d;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid #2c7650;
  outline-offset: 3px;
}
a {
  color: #286541;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 30px;
  border-bottom: 1px solid #dce2dc;
  background: white;
}
.brand {
  text-decoration: none;
  font-size: 21px;
  font-weight: 650;
}
.brand span {
  font-size: 13px;
  font-weight: 400;
  color: #687b6a;
  margin-left: 12px;
}
nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}
main {
  max-width: 1700px;
  margin: auto;
  padding: 24px;
}
/* The explorer (proof-explorer.mjs): every source, by folder, beside the
   workspace; closed, a narrow rail. */
.page {
  display: flex;
  align-items: flex-start;
}
.page > main {
  flex: 1;
  min-width: 0;
}
.explorer {
  position: sticky;
  top: 0;
  flex: 0 0 290px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid #dce2dc;
  background: white;
}
.explorer-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 10px 6px;
  padding: 6px 8px;
  border-color: transparent;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #50745b;
}
.explorer-chevron::before {
  content: "‹";
  font-size: 18px;
  line-height: 1;
}
.explorer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 16px;
  font-size: 14px;
}
.explorer-more {
  margin: 14px 6px 0;
  font-size: 12px;
}
.explorer.collapsed {
  flex-basis: 46px;
}
.explorer.collapsed .explorer-body {
  display: none;
}
.explorer.collapsed .explorer-toggle {
  flex-direction: column;
  justify-content: flex-start;
  margin: 10px 6px;
  padding: 8px 4px;
}
.explorer.collapsed .explorer-label {
  writing-mode: vertical-rl;
}
.explorer.collapsed .explorer-chevron {
  order: -1;
}
.explorer.collapsed .explorer-chevron::before {
  content: "›";
}
body.embedded .explorer {
  display: none;
}
@media (max-width: 950px) {
  .page {
    display: block;
  }
  .explorer {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid #dce2dc;
  }
  .explorer-body {
    max-height: 55vh;
  }
  .explorer.collapsed .explorer-toggle {
    flex-direction: row;
    justify-content: space-between;
    width: calc(100% - 20px);
    margin: 6px 10px;
    padding: 6px 8px;
  }
  .explorer.collapsed .explorer-label {
    writing-mode: horizontal-tb;
  }
  .explorer.collapsed .explorer-chevron {
    order: 0;
  }
  .explorer .explorer-chevron::before {
    content: "⌃";
  }
  .explorer.collapsed .explorer-chevron::before {
    content: "⌄";
  }
}
.introduction {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
h1 {
  font-size: 26px;
  line-height: 1.2;
  margin: 8px 0;
  overflow-wrap: anywhere;
}
h2 {
  font-size: 15px;
  margin: 0;
}
p {
  margin: 8px 0;
}
.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #50745b;
}
.introduction > div > p:last-child,
.hint {
  color: #657b6c;
}
.hint {
  font-size: 12px;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 20px 0;
}
.primary {
  background: #286541;
  color: white;
  border-color: #286541;
}
.primary:hover {
  background: #1e5133;
}
#status {
  font-size: 12px;
  color: #3b6a49;
}
#dirty {
  color: #865b20;
  font-size: 12px;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 30vw);
  gap: 16px;
  align-items: start;
}
.panel {
  border: 1px solid #dce2dc;
  border-radius: 10px;
  padding: 18px;
  background: white;
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.panel-head button {
  padding: 4px 9px;
  font-size: 12px;
}
.inspector {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: auto;
}
.source-column { min-width: 0; }
pre,
code,
textarea,
.source-line {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  background: #f5f7f2;
  padding: 10px;
  border-radius: 5px;
  margin: 10px 0;
}
#inspect-type {
  font-size: 13px;
  background: #edf5e9;
}
#inspect-description {
  font-size: 13px;
}
/* A declared type: its constructors and its eliminator's clause types. */
#inspect-signature:not([hidden]) {
  margin: 10px 0;
}
/* A square's boundary (L2.8): its corners at the corners, its edges between. */
.square-boundary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: center;
  justify-items: center;
  margin: 6px 0 10px;
}
.square-boundary code { overflow-wrap: anywhere; text-align: center; }
.square-boundary .square-edge { color: #346447; }
.square-boundary .square-face {
  width: 100%;
  min-height: 2.5em;
  border: 1px solid currentColor;
  opacity: 0.35;
}
.signature-list {
  padding: 0;
  margin: 6px 0 14px;
  list-style: none;
}
.signature-list li {
  margin: 6px 0;
  overflow-wrap: anywhere;
}
.signature-list code {
  font-size: 12px;
}
.signature-list small {
  display: block;
  color: #5d6758;
}
#rewrite-trace:not([hidden]) {
  display: grid;
  gap: 6px;
  margin: 10px 0;
}
#rewrite-trace button {
  text-align: left;
}
#freeze-simp:not([hidden]) {
  margin: 6px 0 12px;
}
.result {
  margin-top: 16px;
  padding: 14px 18px;
  background: #edf5e9;
  border: 1px solid #c6dccb;
  border-radius: 8px;
}
.result button {
  font-weight: 600;
  padding: 2px 5px;
}
.result small {
  display: block;
  color: #58745e;
}
#diagnostic {
  white-space: pre-wrap;
  border: 1px solid #d8ada4;
  background: #fff2ed;
  color: #813725;
  padding: 14px;
  border-radius: 6px;
  margin-bottom: 16px;
}
#editor {
  width: 100%;
  min-height: 650px;
  resize: vertical;
  padding: 14px;
  border: 1px solid #ccd5ce;
  border-radius: 5px;
  font-size: 13px;
  line-height: 1.8;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}
#generated-panel .source-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
#read-source, #generated-source {
  overflow: auto;
  padding: 8px 0;
  max-height: 78vh;
}
.source-line {
  display: flex;
  min-height: 25px;
  line-height: 25px;
  font-size: 12px;
  white-space: pre;
}
.line-number {
  flex: none;
  width: 34px;
  border: 0;
  background: none;
  color: #8a998c;
  border-radius: 0;
  text-align: right;
  padding: 0 8px 0 0;
  line-height: 25px;
  user-select: none;
}
.line-code {
  flex: 1;
  min-width: max-content;
  padding: 0 6px;
  border-left: 2px solid transparent;
}
.source-line.active .line-code {
  background: #edf5e9;
  border-left-color: #6e997a;
}
.reference {
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  font: inherit;
  line-height: inherit;
  color: #216142;
  text-decoration: underline;
  text-decoration-color: #abc3a7;
  text-underline-offset: 3px;
}
.reference:hover {
  background: #dcedd4;
}
.keyword {
  color: #735689;
  font-weight: 600;
}
.reference.keyword {
  text-decoration-color: #b7a7c4;
}
.macro {
  color: #98531c;
  font-weight: 600;
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: #cba888;
  text-underline-offset: 3px;
}
.comment {
  color: #7c8d80;
}
.locals-title {
  font-size: 12px;
  margin-top: 16px;
}
.local {
  display: block;
  text-align: left;
  width: 100%;
  font-size: 12px;
  margin: 5px 0;
  overflow-wrap: anywhere;
}
.local small {
  display: block;
  color: #63766b;
}
details {
  border-top: 1px solid #edf0eb;
  margin-top: 16px;
  padding-top: 12px;
}
summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.help {
  margin-top: 18px;
}
.help code {
  background: #f0f3eb;
  padding: 1px 4px;
}
.help p {
  font-size: 13px;
}
/* The quick reference: one checked example per construct. Its examples are
   checked and made inspectable by reference/examples.mjs, as in the language
   reference, so the rules below mirror language.css. */
.help h3 {
  margin: 26px 0 4px;
  font-size: 15px;
}
.help nav.quick-topics {
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 13px;
}
.help h4 {
  margin: 18px 0 2px;
  font-size: 13px;
}
.quick-entry p {
  margin: 2px 0 6px;
}
.help pre code {
  padding: 0;
  background: none;
}
.example-token {
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
  color: #216142;
  text-decoration: underline;
  text-decoration-color: #abc3a7;
  text-underline-offset: 3px;
}
.example-token.keyword { text-decoration-color: #b7a7c4; }
.example-token:hover,
.example-token:focus-visible,
.example-module:hover,
.example-module:focus-visible {
  background: #dcedd4;
  outline: none;
}
.example-module {
  color: inherit;
  text-decoration-color: #9fb89b;
  text-underline-offset: 3px;
}
.example-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 16px;
  margin: -4px 0 8px;
  font-size: 12px;
  color: #627468;
}
.example-bar a { color: #346447; }
/* A name clicked in an example opens the kernel inspector beside the page,
   or over it on a narrow screen. */
.inspector-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #fff;
  border-left: 1px solid #d7e0d7;
  box-shadow: -8px 0 24px rgb(30 50 35 / 12%);
}
@media (min-width: 1100px) {
  .inspector-drawer { width: min(760px, 48vw); }
}
.inspector-drawer[hidden] { display: none; }
.drawer-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid #d7e0d7;
  font-size: 14px;
}
.drawer-head strong { margin-right: auto; }
.drawer-head a { color: #346447; }
.inspector-drawer iframe {
  width: 100%;
  height: 100%;
  border: 0;
}
#kernel-expression,
#kernel-type {
  max-height: 220px;
  overflow: auto;
}
.kernel-term {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 14px;
  margin: 12px 0 20px;
  background: #f5f7f2;
  border-radius: 8px;
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.kernel-term-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.kernel-term-label button {
  padding: 5px 8px;
  font-size: 12px;
}
.kernel-term.typeset {
  white-space: normal;
  font: 1.15rem math;
  padding: 20px 14px;
  max-height: min(65vh, 640px);
}
.kernel-term math {
  /* Give the formula its intrinsic width. Constraining a MathML block to the
     narrow inspector can squeeze nested rows differently across browsers.
     Overflow belongs to the enclosing scroll box, including the first glyph. */
  width: max-content;
  min-width: 100%;
  margin: 0;
  text-align: left;
  white-space: nowrap;
}
.math-reference {
  color: #356747;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: #aac2a6;
  text-underline-offset: 3px;
}
.math-reference:hover, .math-reference:focus-visible {
  color: #163f27;
  background: #e5efdf;
  outline: 2px solid #aac2a6;
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
@media (max-width: 950px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  .inspector {
    grid-column: 1/-1;
    position: static;
    max-height: none;
  }
}
@media (max-width: 650px) {
  header {
    padding: 12px 16px;
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }
  main {
    padding: 16px;
  }
  .introduction {
    display: block;
  }
  .workspace {
    display: flex;
    flex-direction: column;
  }
  .workspace > .panel,
  .source-column {
    width: 100%;
  }
  .inspector {
    position: static;
  }
  .brand span {
    display: none;
  }
  nav {
    font-size: 12px;
  }
  #editor {
    min-height: 530px;
  }
  .source-line {
    font-size: 11px;
  }
  .result {
    overflow-wrap: anywhere;
  }
  h1 {
    font-size: 23px;
  }
  .toolbar button {
    font-size: 12px;
  }
}

select {
  max-width: 320px;
  padding: 8px;
  border: 1px solid #cbd5cc;
  border-radius: 6px;
  background: white;
  color: inherit;
  font: inherit;
}
#source-file {
  font-size: 12px;
  overflow-wrap: anywhere;
}
.source-link {
  display: inline-block;
  padding: 7px 12px;
  border: 1px solid #a5bfa7;
  border-radius: 6px;
  text-decoration: none;
  margin: 8px 0;
}
.source-options {
  font-size: 12px;
}
.result {
  max-height: 230px;
  overflow: auto;
}
.result > div {
  overflow-wrap: anywhere;
}
#kernel-premises {
  overflow-wrap: anywhere;
}
@media (max-width: 650px) {
  select {
    max-width: 100%;
  }
  .toolbar label {
    width: 100%;
  }
}

/* Keep long mathematical declarations readable without horizontal scrolling. */
.source-line {
  white-space: pre-wrap;
  align-items: flex-start;
}
.line-code {
  min-width: 0;
  overflow-wrap: anywhere;
}

.lint-warning {
  margin: 0.2rem 0;
  color: #7a5a12;
}

.axiom-dependencies {
  display: block;
  margin: 0.45rem 0 0.8rem;
  font-size: 0.85rem;
  color: var(--muted, #607368);
}

/* The check's progress, a slim bar above the source it is checking. */
.check-loader {
  display: flex;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 10px 0 12px;
  border: 1px solid #d7e3d7;
  border-radius: 8px;
  background: #f1f6ee;
  font-size: 12px;
}
.check-loader[hidden] { display: none; }
.check-loader strong { font-size: 13px; }
.check-loader p { margin: 2px 0 0; color: #607368; line-height: 1.45; }
.check-spinner {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border: 3px solid #d0dfce;
  border-top-color: #426c47;
  border-radius: 50%;
  animation: checking-spin 0.9s linear infinite;
}
@keyframes checking-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .check-spinner { animation: none; }
}

.check-loader > div { flex: 1; min-width: 0; }
#check-detail { overflow-wrap: anywhere; white-space: pre-line; }
#check-progress { display: block; width: 100%; height: 6px; margin-top: 8px; accent-color: #426c47; }

/* Before anything is inspected: what the inspector is for, and nothing else. */
.inspector-empty { margin: 4px 0 12px; color: #526459; font-size: 13px; line-height: 1.6; }
.inspector:not(.empty) .inspector-empty,
.inspector.empty #kernel-terms,
.inspector.empty #inspect-type,
.inspector.empty #kernel-details,
.inspector.empty #kernel-details + .hint { display: none; }
#inspect-type:empty { display: none; }

/* The current page, in the main navigation. */
nav a[aria-current] { font-weight: 600; text-decoration: none; }

.compiler-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin: 10px 0 16px;
  font-size: 12px;
  color: #657b6c;
}
.compiler-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#kernel-context, #kernel-axioms {
  margin: 16px 0 24px;
}
#kernel-context-list, #kernel-axioms-list {
  padding: 0;
  margin: 8px 0;
  list-style: none;
}
.kernel-context-row {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  margin: 8px 0;
}
.kernel-context-row > span {
  padding-top: 8px;
}
.kernel-context-type.kernel-term {
  min-width: 0;
  max-height: 140px;
  overflow: auto;
  margin: 0;
  padding: 8px;
}

#kernel-binder-options {
  display: block;
  margin-top: 10px;
}
#kernel-binder-options[hidden] {
  display: none;
}

.proof-navigation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}
#proof-count {
  color: #657b6c;
  font-size: 12px;
}
@media (max-width: 650px) {
  .proof-navigation select { width: 100%; min-width: 0; }
}

/* Keep local contexts compact and make long judgements readable on demand. */
.inspector .panel-head h2 { overflow-wrap: anywhere; margin-right: auto; }
#kernel-local-definitions { margin: 12px 0 20px; }
#kernel-local-links { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 10px 0; }
#kernel-identity-options { display: block; margin-top: 10px; }
#kernel-identity-options[hidden] { display: none; }
@media (min-width: 951px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(350px, 30vw); }
  .workspace.inspector-wide { grid-template-columns: minmax(0, 1fr) minmax(480px, 48vw); }
}


#inspect-parameters {
  margin: 0 0 16px;
}
#inspect-parameters summary {
  cursor: pointer;
  color: var(--muted);
}
.statement-parameter {
  margin: 8px 0;
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

/* Embedded in a reference page: only the checked source and the inspector. */
body.embedded > header, body.embedded .introduction, body.embedded .toolbar,
body.embedded .compiler-options, body.embedded #source-notice, body.embedded #development-note,
body.embedded #puncture-note, body.embedded #complex-note, body.embedded #language-guide,
body.embedded footer, body.embedded #repl-panel { display: none; }
/* Embedded, the name the reader clicked opens, not the file's last declaration. */
body.embedded .not-embedded { display: none; }
.context-entry { flex: none; margin: 1px 5px; padding: 0 5px; font-size: 11px; line-height: 22px; }
#context-panel select { width: 100%; margin-top: 5px; }
#context-panel fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.context-path { overflow-wrap: anywhere; }
body.embedded main { padding-top: 12px; }
body.embedded .workspace { grid-template-columns: minmax(0, 1fr); }

/* The checked term comes first in the inspector: context, expression, type. */
#kernel-terms { margin: 4px 0 18px; }
#kernel-terms[hidden] { display: none; }
/* Embedded, the inspector comes before the source it inspects. */
body.embedded .workspace > .inspector { order: -1; }

/* A macro's expansion, shown at once on hover or focus (token-tips.mjs). */
.token-tip {
  position: fixed;
  z-index: 60;
  max-width: min(36rem, calc(100vw - 16px));
  padding: 5px 9px;
  border-radius: 6px;
  background: #23342d;
  color: #f6f7f3;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
  pointer-events: none;
  box-shadow: 0 4px 14px rgb(0 0 0 / 18%);
}
.token-tip[hidden] {
  display: none;
}
