/*
 * komalang.org: the site's own small design system. These tokens are used only in
 * sites/komalang and are not the KomaDocs app's tokens. No web fonts: the system's
 * sans-serif for text, its monospace for code and the heading.
 */
:root {
  color-scheme: light dark;

  /* Type */
  --k-font-text:
    system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo",
    sans-serif;
  --k-font-mono:
    ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Noto Sans Mono",
    monospace;
  --k-text-s: 0.875rem;
  --k-text-m: 1rem;
  --k-text-l: 1.1875rem;
  --k-text-xl: 1.5rem;
  --k-text-hero: clamp(2.75rem, 8vw, 6rem);
  --k-leading: 1.7;
  --k-leading-tight: 1.3;

  /* Space: a 4px scale */
  --k-space-1: 4px;
  --k-space-2: 8px;
  --k-space-3: 12px;
  --k-space-4: 16px;
  --k-space-5: 24px;
  --k-space-6: 32px;
  --k-space-7: 48px;
  --k-space-8: 72px;
  --k-gutter: 20px;
  --k-wide: 1080px;
  --k-prose: 720px;
  --k-radius: 6px;

  /* Colour (WCAG 2.1 AA against --k-bg and --k-surface; checked by the site build test) */
  --k-bg: #fcfcfb;
  --k-surface: #f5f4f0;
  --k-line: #e5e2dc;
  --k-ink: #1c1b18;
  --k-muted: #64615a;
  --k-link: #1d52b8;
  --k-focus: #1d52b8;
  /* The site's accent: the colon of the logo and where the reader is. */
  --k-accent: #1d52b8;
  /* Elevation and translucent header chrome */
  --k-header-bg: rgba(252, 252, 251, 0.92);
  --k-shadow-sheet: 0 1px 2px rgba(28, 27, 24, 0.06), 0 6px 18px rgba(28, 27, 24, 0.05);
  --k-shadow-sheet-hover: 0 2px 6px rgba(28, 27, 24, 0.09), 0 10px 26px rgba(28, 27, 24, 0.08);
  --k-shadow-card: 0 1px 2px rgba(28, 27, 24, 0.04);
  --k-accent-soft: rgba(29, 82, 184, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --k-bg: #191817;
    --k-surface: #21201e;
    --k-line: #33312d;
    --k-ink: #f4f3ef;
    --k-muted: #a39f98;
    --k-link: #8db4ff;
    --k-focus: #8db4ff;
    --k-accent: #8db4ff;
    --k-header-bg: rgba(25, 24, 23, 0.92);
    --k-shadow-sheet: 0 1px 2px rgba(8, 7, 6, 0.32), 0 6px 20px rgba(8, 7, 6, 0.24);
    --k-shadow-sheet-hover: 0 2px 8px rgba(8, 7, 6, 0.44), 0 12px 28px rgba(8, 7, 6, 0.34);
    --k-shadow-card: 0 1px 3px rgba(8, 7, 6, 0.28);
    --k-accent-soft: rgba(141, 180, 255, 0.12);
  }
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--k-bg);
  color: var(--k-ink);
  font-family: var(--k-font-text);
  font-size: var(--k-text-m);
  line-height: var(--k-leading);
  overflow-wrap: break-word;
}
a {
  color: var(--k-link);
  text-underline-offset: 0.2em;
}
:focus-visible {
  outline: 2px solid var(--k-focus);
  outline-offset: 3px;
  border-radius: 2px;
}
code,
pre {
  font-family: var(--k-font-mono);
  font-size: 0.92em;
}
:not(pre) > code {
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: var(--k-surface);
}
pre {
  margin: 0;
  padding: var(--k-space-4);
  overflow-x: auto;
  background: var(--k-surface);
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  line-height: 1.6;
  tab-size: 2;
}
h1,
h2,
h3 {
  line-height: var(--k-leading-tight);
  letter-spacing: 0;
}
h2 {
  font-size: var(--k-text-xl);
  margin: var(--k-space-7) 0 var(--k-space-4);
}
h3 {
  font-size: var(--k-text-l);
  margin: var(--k-space-6) 0 var(--k-space-3);
}

.wrap {
  width: min(var(--k-wide), calc(100% - 2 * var(--k-gutter)));
  margin-inline: auto;
}
.skip {
  position: absolute;
  left: var(--k-space-4);
  top: -100px;
  padding: var(--k-space-2) var(--k-space-4);
  background: var(--k-ink);
  color: var(--k-bg);
  z-index: 1;
}
.skip:focus {
  top: var(--k-space-2);
}

/* Header and footer */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--k-header-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--k-line);
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--k-space-2) var(--k-space-5);
  padding-block: var(--k-space-3);
}
.brand {
  color: var(--k-ink);
  font-family: var(--k-font-mono);
  font-weight: 600;
  font-size: var(--k-text-l);
  letter-spacing: -0.02em;
  text-decoration: none;
}
/* The public preview's mark beside the logo: quiet, one line, never the focal point. */
.brand-preview {
  display: inline-block;
  margin-inline-start: var(--k-space-2);
  padding: 1px 7px;
  border: 1px solid var(--k-line);
  border-radius: 999px;
  color: var(--k-muted);
  font-family: var(--k-font-sans, system-ui, sans-serif);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 16px;
  vertical-align: 0.25em;
  white-space: nowrap;
}
/* The logo: `[koma` in ink, `:]` (where the colon comes from) in the accent. */
.brand-colon {
  color: var(--k-accent);
}
.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--k-space-1) var(--k-space-5);
  font-size: var(--k-text-s);
}
.site-header nav a,
.lang {
  color: var(--k-muted);
  text-decoration: none;
  padding-block: var(--k-space-1);
  transition: color 120ms ease;
}
.site-header nav a:hover,
.lang:hover {
  color: var(--k-ink);
  text-decoration: underline;
}
.site-header nav a[aria-current="page"] {
  color: var(--k-ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--k-accent);
}
.lang {
  margin-left: auto;
  font-size: var(--k-text-s);
}
@media (max-width: 639px) {
  .site-header nav {
    order: 3;
    width: 100%;
    gap: var(--k-space-1) var(--k-space-4);
  }
}
.site-footer {
  margin-top: var(--k-space-8);
  border-top: 1px solid var(--k-line);
  color: var(--k-muted);
  font-size: var(--k-text-s);
}
.footer-cols {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr));
  gap: var(--k-space-5);
  padding-block: var(--k-space-6) var(--k-space-5);
}
.footer-about b {
  color: var(--k-ink);
}
.site-footer p {
  margin: 0 0 var(--k-space-2);
}
.site-footer h2 {
  margin: 0 0 var(--k-space-2);
  color: var(--k-ink);
  font-size: var(--k-text-s);
}
.site-footer ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-footer li {
  padding-block: 2px;
}
.footer-base {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 var(--k-space-5);
  padding-block: var(--k-space-4) var(--k-space-5);
  border-top: 1px solid var(--k-line);
}
.expanded {
  font-family: var(--k-font-mono);
}
@media (max-width: 639px) {
  .footer-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .footer-about {
    grid-column: 1 / -1;
  }
}

/* Koma source is coloured by the app's own sheet and colours (syntax.css, LANG-018). */

/* Top page: a promise, the example to edit, then why and how, each in its own section */
.hero {
  padding-block: var(--k-space-6) var(--k-space-4);
}
.eyebrow {
  margin: 0 0 var(--k-space-2);
  color: var(--k-muted);
  font-family: var(--k-font-mono);
  font-size: var(--k-text-s);
  letter-spacing: 0.02em;
}
.hero h1 {
  font-size: clamp(1.875rem, 5.4vw, 3rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  text-wrap: balance;
  margin: 0 0 var(--k-space-4);
}
:lang(ja) .hero h1 {
  font-size: clamp(1.5rem, 3.8vw, 2.55rem);
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.intro {
  color: var(--k-muted);
  font-size: var(--k-text-l);
  line-height: 1.58;
  max-width: 42rem;
  margin: 0;
}
.next-link {
  margin-block: var(--k-space-5) 0;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--k-space-3);
  margin: var(--k-space-5) 0 0;
}
.pair-note {
  margin: var(--k-space-3) 0 0;
  color: var(--k-muted);
  font-size: var(--k-text-s);
}

/* A pane: a file's text under a strip with its name. */
.pane {
  overflow: hidden;
  background: var(--k-surface);
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-card);
}
.pane pre {
  border: 0;
  border-radius: 0;
  font-size: 0.8125rem;
  line-height: 1.65;
}
.pane-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--k-space-3);
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: var(--k-space-2) var(--k-space-4);
  border-bottom: 1px solid var(--k-line);
  color: var(--k-muted);
  font-family: var(--k-font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
}
.pane-split {
  border-top: 1px solid var(--k-line);
}
.shot {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  background: #fff;
  box-shadow: var(--k-shadow-sheet);
}

/*
 * The language in four parts. On a wide screen each part is a row: what it is, a few lines,
 * the page they make. Narrower, the parts are cards of one shape, two to a row from 820px and
 * one below it, each its page then its words; the guide has the source.
 */
.parts-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.part {
  display: grid;
  grid-template-columns: minmax(0, 13rem) minmax(0, 1fr) minmax(0, 15rem);
  gap: var(--k-space-5);
  align-items: start;
  padding-block: var(--k-space-5);
  border-top: 1px solid var(--k-line);
}
.part:first-child {
  border-top: 0;
  padding-top: 0;
}
.part h3 {
  margin: 0 0 var(--k-space-1);
  font-size: var(--k-text-m);
}
.part p {
  margin: 0;
  color: var(--k-muted);
  font-size: var(--k-text-s);
}
.part-output {
  position: relative;
}
.part-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.part-sheets {
  position: relative;
}
.part-sheet {
  position: relative;
  display: none;
}
.part-radio:nth-of-type(1):checked ~ .part-sheets > .part-sheet:nth-child(1),
.part-radio:nth-of-type(2):checked ~ .part-sheets > .part-sheet:nth-child(2),
.part-radio:nth-of-type(3):checked ~ .part-sheets > .part-sheet:nth-child(3) {
  display: block;
}
@media (prefers-reduced-motion: no-preference) {
  .part-sheet {
    animation: part-turn 160ms ease-out;
  }
}
@keyframes part-turn {
  from {
    opacity: 0.4;
  }
}
.part-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--k-space-2);
  margin-top: var(--k-space-2);
  color: var(--k-muted);
  font-size: var(--k-text-s);
  line-height: 1.4;
}
.part-count {
  min-width: 3.5em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.part-turn {
  cursor: pointer;
  padding: 0 6px;
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  background: var(--k-bg);
  color: var(--k-ink);
  text-decoration: none;
  user-select: none;
}
.part-turn:hover {
  color: var(--k-accent);
  border-color: var(--k-accent);
}
.part-radio:focus-visible ~ .part-sheets .part-pager {
  outline: 2px solid var(--k-focus);
  outline-offset: 1px;
}
@media (max-width: 1099px) {
  .parts-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--k-space-6);
  }
  .part {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: var(--k-space-3);
    padding: 0;
    border: 0;
  }
  .part > * {
    min-width: 0;
    width: 100%;
  }
}
@media (min-width: 820px) and (max-width: 1099px) {
  .parts-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Themes are plain CSS: lines of a theme file, the slide before and after, marks between them. */
.theme-file {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "excerpt shots" "notes shots";
  gap: var(--k-space-4) var(--k-space-5);
  align-items: start;
}
.theme-excerpt {
  grid-area: excerpt;
  margin: 0;
}
.theme-excerpt pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.excerpt-gap {
  color: var(--k-muted);
}
.theme-shots {
  grid-area: shots;
  display: grid;
  gap: var(--k-space-4);
}
.theme-shots figure {
  margin: 0;
}
.theme-shots img,
.theme-another img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-sheet);
}
.theme-shots figcaption {
  margin-top: var(--k-space-1);
  color: var(--k-muted);
  font-size: var(--k-text-s);
}
.theme-marked {
  position: relative;
}
.theme-mark {
  display: inline-grid;
  place-items: center;
  width: 1.4em;
  height: 1.4em;
  border-radius: 50%;
  background: var(--k-accent);
  color: var(--k-bg);
  font-family: var(--k-font-text);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}
.theme-mark.on-picture {
  position: absolute;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px var(--k-bg);
}
.theme-notes {
  grid-area: notes;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--k-text-s);
}
.theme-notes li + li {
  margin-top: var(--k-space-2);
}
.theme-more {
  display: flex;
  align-items: center;
  gap: var(--k-space-4);
  margin: var(--k-space-5) 0 0;
  color: var(--k-muted);
  font-size: var(--k-text-s);
}
.theme-another {
  flex: 0 0 10rem;
}
@media (max-width: 899px) {
  .theme-file {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "excerpt" "shots" "notes";
  }
  .theme-more {
    align-items: flex-start;
  }
  .theme-another {
    flex-basis: 7rem;
  }
}

/* Tools: the commands, and what they promise. */
.tools {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: var(--k-space-5);
  align-items: start;
}
.facts {
  margin: 0;
  padding: 0;
  list-style: none;
}
.facts li {
  display: flex;
  flex-direction: column;
  padding-block: var(--k-space-3);
  border-top: 1px solid var(--k-line);
}
.facts li:first-child {
  border-top: 0;
  padding-top: 0;
}
.facts span {
  color: var(--k-muted);
  font-size: var(--k-text-s);
}
@media (max-width: 760px) {
  .tools {
    grid-template-columns: minmax(0, 1fr);
  }
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--k-space-2) var(--k-space-4);
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  background: var(--k-bg);
  color: var(--k-ink);
  font-weight: 600;
  text-decoration: none;
  transition:
    border-color 120ms ease,
    background-color 120ms ease,
    transform 120ms ease;
}
.button:hover {
  border-color: var(--k-muted);
  background: var(--k-surface);
}
.button.primary {
  background: var(--k-ink);
  border-color: var(--k-ink);
  color: var(--k-bg);
}
.button.primary:hover {
  opacity: 0.9;
  background: var(--k-ink);
  border-color: var(--k-ink);
}
.home-section {
  margin-top: var(--k-space-8);
  padding-top: var(--k-space-6);
  border-top: 1px solid var(--k-line);
}
.home-section h2 {
  margin: 0 0 var(--k-space-2);
  letter-spacing: -0.015em;
}
.home-section .lead {
  margin-bottom: var(--k-space-5);
}
.more {
  margin: var(--k-space-4) 0 0;
}
.strip + .more {
  margin-top: var(--k-space-5);
}
.themes,
.cards,
.strip {
  display: grid;
  gap: var(--k-space-4);
  margin: 0;
  padding: 0;
}
.themes,
.cards.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.cards.two,
.strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 900px) {
  .strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (max-width: 680px) {
  .themes figcaption code {
    display: none;
  }
}
.theme-name {
  color: var(--k-ink);
  font-weight: 600;
}
@media (max-width: 680px) {
  .cards.two,
  .cards.three {
    grid-template-columns: minmax(0, 1fr);
  }
}
.themes figure {
  margin: 0;
}
.themes img,
.strip img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  background: #fff;
  box-shadow: var(--k-shadow-sheet);
  transition:
    box-shadow 150ms ease,
    transform 150ms ease,
    border-color 150ms ease;
}
.strip a:hover img {
  box-shadow: var(--k-shadow-sheet-hover);
  border-color: var(--k-muted);
  transform: translateY(-2px);
}
.themes figcaption {
  margin-top: var(--k-space-2);
  font-size: var(--k-text-s);
  color: var(--k-muted);
}
.themes figcaption code {
  background: none;
  padding: 0;
}
.card {
  padding: var(--k-space-5);
  background: var(--k-surface);
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow-card);
}
.card h3 {
  margin: 0 0 var(--k-space-2);
  font-size: var(--k-text-m);
}
.card p {
  margin: 0;
  color: var(--k-muted);
}
.card :not(pre) > code {
  background: var(--k-bg);
}
.tag {
  margin-left: var(--k-space-1);
  padding: 0 var(--k-space-2);
  border: 1px solid var(--k-line);
  border-radius: 999px;
  color: var(--k-muted);
  font-size: var(--k-text-s);
  font-weight: 400;
  white-space: nowrap;
}
.strip {
  list-style: none;
}
.strip a {
  display: flex;
  flex-direction: column;
  gap: var(--k-space-1);
  color: var(--k-ink);
  text-decoration: none;
}
.strip a:hover .strip-title {
  text-decoration: underline;
}
.strip .work-kind {
  margin-top: var(--k-space-2);
}
.strip-title {
  font-weight: 600;
  line-height: var(--k-leading-tight);
}
.work-kind {
  margin: var(--k-space-3) 0 0;
  color: var(--k-muted);
  font-size: var(--k-text-s);
}
/* On a phone the promise, the two ways in and the slide fit the first screen. */
@media (max-width: 639px) {
  .hero {
    padding-block: var(--k-space-3) var(--k-space-3);
  }
  .eyebrow {
    margin-bottom: var(--k-space-1);
  }
  .hero h1 {
    margin-bottom: var(--k-space-2);
  }
  .hero .intro {
    font-size: var(--k-text-m);
  }
  .hero .actions {
    margin-top: var(--k-space-3);
  }
  .button {
    padding: var(--k-space-1) var(--k-space-3);
  }
  .home > koma-playground {
    margin-top: var(--k-space-3);
  }
}

/* A source next to its real output */
.sample {
  display: grid;
  gap: var(--k-space-4);
  margin: var(--k-space-5) 0;
  min-width: 0;
}
@media (min-width: 681px) {
  .sample {
    grid-template-columns: minmax(0, 4fr) minmax(0, 3fr);
    align-items: start;
  }
  .sample figcaption {
    grid-column: 1 / -1;
  }
}
/* A try-able sample (EMB-001) keeps the sample's place; its figure is what shows without script. */
koma-playground {
  display: block;
  margin: var(--k-space-5) 0;
}
koma-playground > .sample {
  margin: 0;
}
koma-playground[wrap-source] .sample-source pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.sample > div {
  min-width: 0;
}
.sample-label {
  margin: 0 0 var(--k-space-2);
  font-size: var(--k-text-s);
  color: var(--k-muted);
}
.sample-label code {
  background: none;
  padding: 0;
}
.sample img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  background: #fff;
  box-shadow: var(--k-shadow-sheet);
}
.sample figcaption {
  font-size: var(--k-text-s);
  color: var(--k-muted);
}

/* Documents: start, guide, tools, reference */
.doc {
  max-width: var(--k-prose);
  padding-top: var(--k-space-7);
}
.doc.wide,
.doc:has(.sample) {
  max-width: var(--k-wide);
}
.doc:has(.sample) > :not(.sample, koma-playground) {
  max-width: var(--k-prose);
}
.doc h1 {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  margin: 0 0 var(--k-space-4);
}
.lead {
  font-size: var(--k-text-l);
  color: var(--k-muted);
  margin: 0 0 var(--k-space-6);
}
.meta,
.crumb {
  font-size: var(--k-text-s);
  color: var(--k-muted);
  margin: 0 0 var(--k-space-3);
}
.note {
  font-size: var(--k-text-s);
  color: var(--k-muted);
  border-left: 3px solid var(--k-line);
  padding-left: var(--k-space-4);
}
.doc pre {
  margin: var(--k-space-4) 0;
}
.index {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--k-space-6);
}
.index li {
  padding-block: var(--k-space-4);
  border-bottom: 1px solid var(--k-line);
}
.index li a {
  font-weight: 600;
}
.index li p {
  margin: var(--k-space-1) 0 0;
  color: var(--k-muted);
}
.parts {
  margin: 0;
}
.parts dt {
  margin-top: var(--k-space-5);
  font-weight: 600;
}
.parts dd {
  margin: var(--k-space-1) 0 0;
}
.parts .state {
  color: var(--k-muted);
  font-size: var(--k-text-s);
}
.examples .sample {
  padding-bottom: var(--k-space-6);
  border-bottom: 1px solid var(--k-line);
}

/* The generated reference */
.spec h1 {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
}
.spec h2 {
  padding-top: var(--k-space-4);
  border-top: 1px solid var(--k-line);
}
.spec h4 {
  margin: var(--k-space-5) 0 var(--k-space-2);
}
.table {
  overflow-x: auto;
  margin: var(--k-space-4) 0;
}
table {
  border-collapse: collapse;
  font-size: var(--k-text-s);
  min-width: 100%;
}
th,
td {
  border-bottom: 1px solid var(--k-line);
  padding: var(--k-space-2) var(--k-space-3);
  text-align: left;
  vertical-align: top;
}
th {
  background: var(--k-surface);
}

/* The language specification: one section per rule, named by its subject */
.spec-page h2 {
  padding-top: var(--k-space-5);
  border-top: 1px solid var(--k-line);
}
.chapters {
  counter-reset: chapter;
}
.chapters li {
  counter-increment: chapter;
}
.chapters li a::before {
  content: counter(chapter) ".";
  display: inline-block;
  margin-right: 0.3em;
  color: var(--k-muted);
  font-weight: 400;
}
.rule {
  margin: var(--k-space-5) 0;
  padding-left: var(--k-space-4);
  border-left: 2px solid var(--k-line);
  scroll-margin-top: 4.5rem;
}
.spec-alias,
h2[id],
h3[id] {
  scroll-margin-top: 4.5rem;
}
.rule:target,
.rule:has(> .spec-alias:target) {
  border-left-color: var(--k-link);
}
.rule-body > ul {
  padding-left: var(--k-space-5);
}
.rule-body li + li {
  margin-top: var(--k-space-2);
}
.rule-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--k-space-1) var(--k-space-3);
  margin-bottom: var(--k-space-2);
}
.rule-head h3 {
  margin: 0;
}
.rule-kind {
  font-size: var(--k-text-s);
  color: var(--k-muted);
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  padding: 0 var(--k-space-2);
}
.spec-page .rule p {
  margin: 0 0 var(--k-space-3);
}
/* A rule's parts: how to write it, an example with its drawn result, the detailed rules */
.rule-part {
  margin: var(--k-space-4) 0 var(--k-space-2);
  font-size: var(--k-text-s);
  color: var(--k-muted);
}
.doc:has(.sample) > .rule:has(.sample) {
  max-width: none;
}
.rule-body:has(.sample) > :not(.sample, koma-playground) {
  max-width: var(--k-prose);
}
.sample-page {
  margin: 0 0 var(--k-space-1);
  font-size: var(--k-text-s);
  color: var(--k-muted);
}
.sample-shot + .sample-shot {
  margin-top: var(--k-space-4);
}

.work-gallery {
  max-width: var(--k-wide);
  padding-block: var(--k-space-7);
}
.works {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--k-space-6);
}
.works img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  background: #fff;
  box-shadow: var(--k-shadow-sheet);
  transition:
    box-shadow 150ms ease,
    border-color 150ms ease;
}
.works article:hover img {
  box-shadow: var(--k-shadow-sheet-hover);
  border-color: var(--k-muted);
}
/* A work's card keeps one shape; a portrait page (a document, a poster) sits inside it. */
.works article > img {
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: var(--k-surface);
}
.works h2 {
  margin: var(--k-space-1) 0 0;
  font-size: var(--k-text-l);
}
.works h2 a {
  color: var(--k-ink);
  text-decoration: none;
}
.works h2 a:hover {
  text-decoration: underline;
}
.work-detail .work-kind {
  margin: 0 0 var(--k-space-1);
}
.work-credit {
  margin: var(--k-space-1) 0 var(--k-space-3);
  color: var(--k-muted);
  font-size: var(--k-text-s);
}
.work-edit {
  font-size: var(--k-text-s);
}
.work-gallery .lead {
  margin: 0 0 var(--k-space-6);
}
/* A work's pages, two to a row on a wide screen, then its whole source. */
.work-detail .sample {
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 760px) {
  .work-detail .sample-output {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--k-space-5) var(--k-space-4);
  }
  .work-detail .sample-output > .sample-label {
    grid-column: 1 / -1;
    margin: 0;
  }
  .work-detail .sample-shot + .sample-shot {
    margin-top: 0;
  }
}
@media (max-width: 680px) {
  .works {
    grid-template-columns: minmax(0, 1fr);
  }
}
.diagnostics td:nth-child(-n + 2) {
  white-space: nowrap;
}
.chapters li:last-child {
  border-bottom: 0;
}
@media (max-width: 680px) {
  .spec-page table {
    min-width: 40rem;
  }
}

/* At the narrowest the slide still starts on the first screen: the name is in the logo above. */
@media (max-width: 359px) {
  .eyebrow {
    display: none;
  }
  .site-header nav {
    gap: var(--k-space-1) var(--k-space-3);
  }
  .hero .actions {
    gap: var(--k-space-2);
  }
}

/*
 * The documentation's frame: the tree on the left, the page, its sections on the right. Below
 * 1200px the sections fold under the page's heading; below 860px the tree folds into a menu.
 * No script: both folds are <details>.
 */
.docs {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr) 12.5rem;
  gap: var(--k-space-6);
  width: min(88rem, calc(100% - 2 * var(--k-gutter)));
  margin-inline: auto;
  align-items: start;
}
.docs-main > .wrap {
  width: auto;
  margin: 0;
}
.sidebar,
.outline {
  position: sticky;
  top: 3.75rem;
  max-height: calc(100vh - 3.75rem);
  overflow-y: auto;
  padding-block: var(--k-space-6);
  font-size: var(--k-text-s);
}
.sidebar h2,
.outline h2,
.menu-tree h2 {
  margin: var(--k-space-5) 0 var(--k-space-1);
  color: var(--k-ink);
  font-size: 0.8125rem;
  font-weight: 600;
}
.sidebar h2:first-child,
.outline h2:first-child,
.menu-tree h2:first-child {
  margin-top: 0;
}
.sidebar ul,
.outline ul,
.fold ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.docs .sidebar a,
.docs .outline a,
.docs .fold a {
  display: block;
  padding: 3px var(--k-space-2);
  border-left: 2px solid transparent;
  color: var(--k-muted);
  text-decoration: none;
  line-height: 1.45;
}
.docs .sidebar a:hover,
.docs .outline a:hover,
.docs .fold a:hover {
  color: var(--k-ink);
  text-decoration: underline;
}
.docs .sidebar a[aria-current="page"],
.docs .fold a[aria-current="page"] {
  border-left-color: var(--k-accent);
  background: var(--k-accent-soft);
  border-radius: 0 var(--k-radius) var(--k-radius) 0;
  color: var(--k-ink);
  font-weight: 600;
}
.outline {
  border-left: 1px solid var(--k-line);
  padding-left: var(--k-space-4);
}
.fold {
  display: none;
  margin: var(--k-space-4) 0;
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  background: var(--k-surface);
  font-size: var(--k-text-s);
}
.fold summary {
  padding: var(--k-space-2) var(--k-space-4);
  cursor: pointer;
  font-weight: 600;
}
.fold[open] summary {
  border-bottom: 1px solid var(--k-line);
}
.fold > ul,
.menu-tree {
  padding: var(--k-space-2) var(--k-space-3) var(--k-space-3);
}
.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--k-space-4);
  margin: var(--k-space-7) 0 0;
  padding-top: var(--k-space-5);
  border-top: 1px solid var(--k-line);
}
.docs .pager a {
  display: flex;
  flex-direction: column;
  padding: var(--k-space-3) var(--k-space-4);
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  font-weight: 600;
  text-decoration: none;
}
.docs .pager a:hover {
  border-color: var(--k-accent);
}
.docs .pager a span {
  color: var(--k-muted);
  font-size: var(--k-text-s);
  font-weight: 400;
}
.docs .pager a[rel="next"] {
  grid-column: 2;
  text-align: right;
}
@media (max-width: 1199px) {
  .docs {
    grid-template-columns: 14rem minmax(0, 1fr);
  }
  .outline {
    display: none;
  }
  .fold.on-page {
    display: block;
  }
}
@media (max-width: 859px) {
  .docs {
    display: block;
  }
  .sidebar {
    display: none;
  }
  .fold.menu {
    display: block;
  }
}
@media (max-width: 859px) {
  .fold.menu + .doc {
    padding-top: var(--k-space-3);
  }
}

/* Light/dark manual header toggle via CSS checkbox (:has works even without JS on static docs) */
.theme-flip-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}
.theme-flip-input:focus-visible + .theme-toggle {
  outline: 2px solid var(--k-focus);
  outline-offset: 3px;
}
.header-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--k-space-2);
  position: relative;
}
.header-tools .lang {
  margin-left: 0;
}
@media (max-width: 340px) {
  .theme-toggle-text {
    display: none;
  }
  .theme-toggle {
    padding: 4px 6px;
  }
}
@media (max-width: 639px) {
  .hero h1 {
    font-size: clamp(1.375rem, 6.2vw, 1.75rem);
  }
  .hero .intro {
    font-size: 0.9375rem;
    line-height: 1.5;
  }
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--k-line);
  border-radius: 999px;
  background: var(--k-surface);
  color: var(--k-ink);
  font-size: var(--k-text-s);
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
}
.theme-toggle:hover {
  border-color: var(--k-muted);
}
.theme-toggle-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--k-muted);
  background: linear-gradient(90deg, var(--k-ink) 50%, var(--k-bg) 50%);
  flex-shrink: 0;
}
/* Theme flip override */
@media (prefers-color-scheme: light) {
  :root:has(#koma-theme-flip:checked) {
    color-scheme: dark;
    --k-bg: #191817;
    --k-surface: #21201e;
    --k-line: #33312d;
    --k-ink: #f4f3ef;
    --k-muted: #a39f98;
    --k-link: #8db4ff;
    --k-focus: #8db4ff;
    --k-accent: #8db4ff;
    --k-header-bg: rgba(25, 24, 23, 0.92);
    --k-shadow-sheet: 0 1px 2px rgba(8, 7, 6, 0.32), 0 6px 20px rgba(8, 7, 6, 0.24);
    --k-shadow-sheet-hover: 0 2px 8px rgba(8, 7, 6, 0.44), 0 12px 28px rgba(8, 7, 6, 0.34);
    --k-shadow-card: 0 1px 3px rgba(8, 7, 6, 0.28);
    --k-accent-soft: rgba(141, 180, 255, 0.12);
  }
}
@media (prefers-color-scheme: dark) {
  :root:has(#koma-theme-flip:checked) {
    color-scheme: light;
    --k-bg: #fcfcfb;
    --k-surface: #f5f4f0;
    --k-line: #e5e2dc;
    --k-ink: #1c1b18;
    --k-muted: #64615a;
    --k-link: #1d52b8;
    --k-focus: #1d52b8;
    --k-accent: #1d52b8;
    --k-header-bg: rgba(252, 252, 251, 0.92);
    --k-shadow-sheet: 0 1px 2px rgba(28, 27, 24, 0.06), 0 6px 18px rgba(28, 27, 24, 0.05);
    --k-shadow-sheet-hover: 0 2px 6px rgba(28, 27, 24, 0.09), 0 10px 26px rgba(28, 27, 24, 0.08);
    --k-shadow-card: 0 1px 2px rgba(28, 27, 24, 0.04);
    --k-accent-soft: rgba(29, 82, 184, 0.08);
  }
}

/* Hero theme switcher + compact mobile view tabs */
.hero-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--k-space-2) var(--k-space-4);
  margin: var(--k-space-4) 0 var(--k-space-2);
}
.theme-switcher,
.compact-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--k-space-2);
}
.switcher-label {
  font-size: var(--k-text-s);
  color: var(--k-muted);
  font-family: var(--k-font-mono);
}
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--k-line);
  border-radius: 999px;
  background: var(--k-surface);
  color: var(--k-ink);
  font-family: var(--k-font-text);
  font-size: var(--k-text-s);
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
}
.pill-btn code {
  background: none;
  padding: 0;
  font-size: 0.92em;
}
.pill-btn:hover {
  border-color: var(--k-muted);
}
.pill-btn[aria-pressed="true"] {
  background: var(--k-ink);
  border-color: var(--k-ink);
  color: var(--k-bg);
}
@media (min-width: 681px) {
  .compact-tabs {
    display: none;
  }
}

/* Built-in 3 official themes comparison */
.theme-compare {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--k-space-4);
  margin: 0 0 var(--k-space-6);
}
.theme-compare-card {
  margin: 0;
}
.theme-compare-card img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--k-line);
  border-radius: var(--k-radius);
  background: #fff;
  box-shadow: var(--k-shadow-sheet);
}
.theme-compare-card figcaption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--k-space-2);
  font-size: var(--k-text-s);
  color: var(--k-ink);
}
.theme-compare-card figcaption > :last-child {
  color: var(--k-muted);
}
.theme-compare-card figcaption code {
  font-weight: 600;
  background: none;
  padding: 0;
}
.themes-sub {
  margin: var(--k-space-6) 0 var(--k-space-2);
  font-size: var(--k-text-l);
}
.themes-sublead {
  margin: 0 0 var(--k-space-4);
  color: var(--k-muted);
}
@media (max-width: 680px) {
  .theme-compare {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* AI & Git proof cards */
.ai-git-cards .card h3 {
  margin: 0 0 var(--k-space-2);
  font-size: var(--k-text-m);
}
.ai-git-cards .card p {
  margin: 0;
  color: var(--k-muted);
  font-size: var(--k-text-s);
}
.ai-git-cards .card p + p {
  margin-top: var(--k-space-2);
}

/* One-click copy button in code panes */
.pane-copy-bar {
  justify-content: flex-end;
}
.pane-copy-btn {
  margin-left: auto;
  padding: 1px 8px;
  border: 1px solid var(--k-line);
  border-radius: 4px;
  background: var(--k-bg);
  color: var(--k-ink);
  font-family: var(--k-font-text);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
}
.pane-copy-btn:hover {
  border-color: var(--k-muted);
}

/* The Playground (EMB-002): samples and Copy Share URL above one source-first playground. */
.play .lead {
  max-width: var(--k-prose);
  margin-bottom: var(--k-space-5);
}
.play-presets .switcher-label {
  font-family: var(--k-font-text);
}
.play-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--k-space-3) var(--k-space-4);
  margin: 0 0 var(--k-space-4);
}
.play-bar[hidden] {
  display: none;
}
.play-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--k-space-2);
}
.play-copy {
  background: none;
  font: inherit;
  font-size: var(--k-text-s);
  font-weight: 600;
  cursor: pointer;
}
.play-copy:disabled {
  color: var(--k-muted);
  cursor: default;
}
.play-copy:disabled:hover {
  border-color: var(--k-line);
}
.play-notice {
  margin: 0 0 var(--k-space-4);
  color: var(--k-ink);
  font-size: var(--k-text-s);
}
.play-stage {
  min-height: 12rem;
}
.play-fallback {
  color: var(--k-muted);
}
.play-foot {
  margin-top: var(--k-space-6);
  color: var(--k-muted);
  font-size: var(--k-text-s);
}
