@font-face {
  font-family: "OpenMono";
  src: url("/fonts/OpenMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-stretch: 100%;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: "OpenMono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  background: #000;
  color: #b4c6bc;
  --muted: #82988c;
  --line: #527d65;
  --mint: #d6ffe6;
  --phosphor: #8dffb0;
  --glow: 0 0 2px #baffd533, 0 0 10px #66ff9b38, 0 0 22px #36d9771a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: #000;
  background-image: radial-gradient(ellipse at 50% 0, #06100a 0, #000 65%);
}
h1, h2, h3, pre, code, button, input, select, textarea, option, optgroup { font: inherit; }
h1, h2, h3, p, pre { margin: 0 0 1rem; }
h1 { color: var(--mint); text-shadow: var(--glow); }
.crab {
  display: inline-block;
  white-space: pre;
  color: #ffad66;
  text-shadow: 0 0 3px #ff9a4a55, 0 0 12px #ff842b33;
  font-variant-ligatures: none;
  font-feature-settings: "calt" 0, "liga" 0;
}
h2, h3 { color: #c4dece; }
code { color: #dcebe2; }
a { color: #a0dbb6; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a, button, input, select, textarea, input::file-selector-button {
  transition: color 140ms ease, border-color 140ms ease, text-shadow 140ms ease, box-shadow 140ms ease;
}
a:hover, button:hover { text-decoration: underline; }
a:hover { color: var(--mint); text-shadow: var(--glow); }
:focus-visible { outline: 2px solid var(--phosphor); outline-offset: 4px; }
::selection { color: #effff4; background: #285d3d; text-shadow: none; }
.shell { max-width: 90ch; margin: auto; padding: 16px 12px; }
main, section, form, details { min-width: 0; }
h1, h2, p, label, summary, .notice { overflow-wrap: anywhere; }
.skip-link { position: absolute; z-index: 2; left: 12px; top: -100px; background: #000; }
.skip-link:focus { top: 8px; }
.divider { white-space: pre; color: var(--line); }
.progress { white-space: normal; color: #a1b7a9; }
/* Only the calendar uses the full viewport; other pages retain the 90ch shell. */
.shell:has(.calendar-page) { max-width: none; }
.calendar-page {
  min-height: calc(100vh - 32px);
  min-height: calc(100dvh - 32px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}
.calendar-heading h1, .calendar-heading p { margin-bottom: 4px; }
.calendar-heading p:last-child { margin-bottom: 0; }
.calendar-nav { display: grid; min-width: 0; }
.calendar-art {
  display: grid;
  grid-template-rows: auto auto 1fr;
  width: 100%;
  min-width: 0;
  margin: 0;
  border: 1px dashed var(--line);
  border-spacing: 0;
  color: var(--line);
}
.calendar-month { padding: 4px; text-align: center; }
.calendar-art thead { display: block; }
.calendar-art tr { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-art tbody { display: grid; grid-template-rows: repeat(5, minmax(44px, 1fr)); }
.calendar-art th, .calendar-art td {
  min-width: 0;
  padding: 0;
  border-top: 1px dashed var(--line);
}
.calendar-art th { padding: 4px 0; font-weight: normal; }
.calendar-art th + th, .calendar-art td + td { border-left: 1px dashed var(--line); }
.calendar-art td { display: flex; }
.calendar-art th, .calendar-art td { position: relative; }
.calendar-art th::before, .calendar-art td::before {
  content: "+" / "";
  position: absolute;
  top: -0.75em;
  left: -0.3em;
  color: var(--line);
  pointer-events: none;
}
.calendar-day, .calendar-inactive {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  white-space: pre;
}
.calendar-art, .divider, .progress {
  font-variant-ligatures: none;
  font-feature-settings: "calt" 0, "liga" 0;
}
.calendar-month { color: var(--mint); text-shadow: var(--glow); }
.calendar-inactive { color: #718779; }
.calendar-day {
  color: var(--mint);
  text-decoration: none;
  text-shadow: var(--glow);
}
.calendar-day.is-saved {
  color: #f0d39a;
  text-shadow: 0 0 2px #ffe4ae26, 0 0 12px #e9b65a33;
}
.calendar-day:hover, .calendar-day:focus-visible {
  color: var(--phosphor);
  background: #153824;
  text-decoration: none;
  box-shadow: 0 0 12px #65ff9a24;
  outline: 1px solid var(--phosphor);
  outline-offset: 0;
}
.exercise-nav, .section-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 1rem; }
.section-bar h2 { margin: 0; }
.code-panel {
  max-width: 100%;
  overflow: auto;
  white-space: pre;
  tab-size: 4;
  padding: 12px;
  color: #dcebe2;
  text-shadow: none;
}
.tok-comment { color: #869c90; }
.tok-keyword { color: #a0e9bc; }
.tok-string { color: #e8d4a3; }
.tok-number { color: #efcd95; }
.tok-type, .tok-lifetime { color: #90d9d9; }
.tok-function { color: #d6efdf; }
.tok-macro { color: #b1c6ed; }
.solution-form { padding: 12px; margin-bottom: 1rem; }
.notice { border: 1px solid var(--line); padding: 12px; }
.notice[role="status"], .notice.success, .success {
  color: #b4efc6;
  border-color: #75b88b;
  text-shadow: 0 0 10px #66ff9b26;
}
.failure { color: #efb4a1; border-color: #bc826e; border-style: dashed; text-shadow: none; }
.solution-section { margin-top: 1rem; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 1rem; min-width: 0; }
.help { margin: 0; }
.help, .last-updated, .submission-time { color: var(--muted); }
input, textarea, select, button {
  color: #dcebe2;
  background: #000;
  border: 0;
  border-radius: 0;
  padding: 0;
  min-width: 0;
  max-width: 100%;
  accent-color: var(--phosphor);
}
input[type="text"], textarea, select { padding: 8px; }
input[type="text"] { width: min(100%, 40ch); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { width: 100%; resize: vertical; tab-size: 4; }
input[type="file"] { width: 100%; }
input::file-selector-button {
  font: inherit;
  color: #bceacc;
  background: #000;
  border: 1px solid var(--line);
  border-top-color: #75a688;
  border-radius: 0;
  padding: 0 4px;
  margin-right: 8px;
  cursor: pointer;
}
button { color: #bceacc; cursor: pointer; margin-bottom: 1rem; text-align: left; padding: 6px 12px; }
.code-panel, .solution-form, .submission, input[type="text"], textarea, select, button {
  border: 1px solid var(--line);
  border-top-color: #75a688;
}
.code-panel:focus-within, .solution-form:focus-within, .submission:focus-within,
input[type="text"]:focus, textarea:focus, select:focus, button:focus-visible {
  border-color: #85d4a0;
  border-top-color: #c0f8d2;
  box-shadow: inset 0 1px 0 #b0ffcd12, 0 0 12px #65ff9a12;
}
button:hover, button:focus-visible, input::file-selector-button:hover,
input[type="file"]:focus-visible::file-selector-button {
  color: var(--mint);
  border-color: var(--phosphor);
  text-shadow: var(--glow);
}
.solution-form button { margin-bottom: 0; }
.last-updated { margin-top: 1rem; }
.filter-form { margin: 1rem 0; }
.filter-form select { width: 100%; }
.submission { margin-bottom: 1rem; padding: 12px; }
.submission summary { cursor: pointer; list-style: none; }
.submission summary::-webkit-details-marker { display: none; }
.submission summary::before { content: "[+] "; color: #a0dbb6; }
.submission[open] summary::before { content: "[-] "; }
.submission-day { margin-right: 1ch; }
.submission-time { display: block; }
.submission .code-panel { margin-top: 1rem; max-height: 70vh; }


/* Preference modes keep the hierarchy in solid colors, not light effects. */
@media (prefers-reduced-motion: reduce), (prefers-contrast: more), (forced-colors: active) {
  *, *::before, *::after, input::file-selector-button {
    transition: none !important;
    text-shadow: none !important;
    box-shadow: none !important;
  }
  body { background-image: none; }

}

@media (prefers-contrast: more) {
  :root { color: #e0eee5; --muted: #b7cbbf; --line: #8ab59a; }
  .calendar-art, .calendar-inactive, .progress { color: #c1dec9; }
  .tok-comment { color: #b7cbbf; }
  .code-panel, .solution-form, .submission, input[type="text"], textarea, select, button,
  input::file-selector-button { border-color: var(--line); }
  :focus-visible { outline-width: 3px; }
}

@media (forced-colors: active) {
  :root { color: CanvasText; background: Canvas; }
  body, input, textarea, select, button, .skip-link, input::file-selector-button { background: Canvas; }
  h1, h2, h3, code, .code-panel, .code-panel span, .help, .last-updated,
  .submission-time, .progress, .divider, .notice, .success { color: CanvasText; }
  .calendar-art, .calendar-month { color: CanvasText; }
  .calendar-inactive { color: GrayText; }
  a, a:hover, .calendar-day, .calendar-day.is-saved,
  .submission summary::before { color: LinkText; }
  .calendar-day:hover, .calendar-day:focus-visible {
    background: Highlight; color: HighlightText; outline-color: Highlight;
  }
  button, input::file-selector-button { color: ButtonText; }
  .code-panel, .solution-form, .submission, .notice, input[type="text"], textarea,
  select, button, input::file-selector-button { border-color: CanvasText; }
  :focus-visible { outline: 3px solid Highlight; }
  ::selection { color: HighlightText; background: Highlight; }
}
