@font-face {
  font-family: "Uiua386";
  src: url("fonts/Uiua386.ttf?v=2981576508ab2db1") format("truetype");
  font-display: swap;
}

:root {
  --mono: "Uiua386", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #5a5a5a;
  --border: #d9d9d9;
  --accent: #2d6cdf;
  --pass: #1a7f37;
  --fail: #c62828;
  --code-bg: #f6f6f6;
  --sidebar-bg: #f6f7f9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --fg: #ececec;
    --muted: #a0a0a0;
    --border: #33363e;
    --accent: #6ea8fe;
    --pass: #3fb950;
    --fail: #f85149;
    --code-bg: #1d1f26;
    --sidebar-bg: #1a1c22;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  line-height: 1.5;
}

h1 {
  margin-top: 0;
  margin-bottom: 0.25rem;
}

a {
  color: var(--accent);
}

.layout {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

.content {
  flex: 1;
  min-width: 0;
  max-width: 960px;
  margin: 0;
  padding: 0.75rem 1rem 2rem 3rem;
}

/* Left-hand accordion menu: one <details> per year. */
.sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 18rem;
  height: 100vh;
  overflow-y: auto;
  padding: 1rem 0 2rem;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  font-size: 0.9rem;
}

.sidebar .site-title {
  display: block;
  padding: 0.25rem 1rem 0.75rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--fg);
  text-decoration: none;
}

.accordion summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

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

.accordion summary::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

.accordion[open] > summary::before {
  transform: rotate(45deg);
}

.accordion summary:hover {
  background: var(--code-bg);
}

.accordion ul {
  list-style: none;
  margin: 0;
  padding: 0 0 0.5rem;
}

.accordion li a {
  display: block;
  padding: 0.25rem 1rem 0.25rem 2.25rem;
  color: var(--fg);
  text-decoration: none;
}

.accordion li a:hover {
  background: var(--code-bg);
}

.accordion li a[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
  background: var(--code-bg);
  box-shadow: inset 3px 0 0 var(--accent);
}

@media (max-width: 800px) {
  .layout {
    flex-direction: column;
    align-items: stretch;
  }

  .sidebar {
    position: static;
    flex: none;
    height: auto;
    max-height: 50vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .content {
    margin: 0;
  }
}

.site-header p {
  color: var(--muted);
}

.hint code {
  background: var(--code-bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.hint {
  color: var(--muted);
}

.editor textarea {
  width: 100%;
  height: 10rem;
  resize: vertical;
}

/* Stack the read-only, syntax-highlighted <pre> and the real (transparent)
   textarea in the same grid cell so they always line up. The textarea's
   size is the source of truth (it's user-resizable); app.js keeps the
   <pre>'s height and scroll position matching it. */
.code-editor {
  display: grid;
}

.code-editor > * {
  grid-area: 1 / 1;
}

.code-editor pre.code-highlight,
.code-editor textarea {
  margin: 0;
  padding: 0.75rem;
  font-family: var(--mono);
  font-size: 1.4rem;
  line-height: 1.5;
  border: 1px solid var(--border);
  border-radius: 6px;
  tab-size: 2;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.code-editor pre.code-highlight {
  background: var(--code-bg);
  color: var(--fg);
  overflow: auto;
  pointer-events: none;
  user-select: none;
}

.code-editor pre.code-highlight code {
  font: inherit;
  white-space: inherit;
  word-wrap: inherit;
}

.code-editor textarea {
  background: transparent;
  color: transparent;
  caret-color: var(--fg);
  border-color: transparent;
}

/* Hint that Cmd/Ctrl-click opens a glyph's docs, as on the official pad. */
.code-editor textarea.ctrl-held {
  cursor: pointer;
}

/* Glyph colors, matching the official Uiua pad (https://www.uiua.org/pad). */
.module {
  color: #d7be8c;
}

.noadic-function {
  color: #ed5e6a;
}

.monadic-function {
  color: #95d16a;
}

.dyadic-function {
  color: #54b0fc;
}

.triadic-function {
  color: #8078f1;
}

.tetradic-function {
  color: #f590c8;
}

.pentadic-function {
  color: #f870a0;
}

.hexadic-function {
  color: #ff5080;
}

.monadic-modifier {
  color: #f0c36f;
}

.dyadic-modifier {
  color: #cc6be9;
}

.triadic-modifier {
  color: #40f0a0;
}

.number-literal {
  color: #f08050;
}

.comment-span {
  color: #888;
}

@media (prefers-color-scheme: dark) {
  .stack-function {
    color: #d1daec;
  }

  .string-literal-span {
    color: #20f9fc;
  }

  .strand-span {
    color: #fff8;
  }
}

@media (prefers-color-scheme: light) {
  .stack-function {
    color: #344;
  }

  .string-literal-span {
    color: #1c9;
  }

  .strand-span {
    color: #0008;
  }
}

.actions {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

button {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem 1.1rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

.shortcut-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

#status {
  color: var(--muted);
  font-size: 0.9rem;
}

.results {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.5rem;
}

.test-result {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.test-result.pass {
  border-color: var(--pass);
}

.test-result.fail {
  border-color: var(--fail);
}

.test-result .icon {
  font-weight: bold;
}

.test-result.pass .icon {
  color: var(--pass);
}

.test-result.fail .icon {
  color: var(--fail);
}

.test-result .detail {
  flex: 1;
}

.test-result .test-code {
  margin: 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.test-result .icon {
  min-width: 1em;
}

.test-result .message {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.85rem;
  white-space: pre-wrap;
  margin-top: 0.2rem;
}

.summary {
  font-weight: 600;
}

.attribution {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}

.attribution a {
  color: inherit;
}

pre.diagram {
  overflow-x: auto;
  line-height: 1.2;
  margin: 0.75rem 0;
}
