/*
 * zeug.herrsack.de: design foundation
 *
 * One file holds every color, type size, spacing step and shared component.
 * Tools never define their own colors or fonts. They only use what is here.
 *
 * Picture behind the look: an olive green school board with faint squared lines,
 * cream paper sheets lying on it, one chalk-yellow accent.
 *
 * Structure
 *   1. Fonts
 *   2. Tokens (colors, type, spacing, radii)
 *   3. Base (page, headings, links, focus)
 *   4. Components, each prefixed with "z-"
 *   5. Helpers
 */

/* ---------- 1. Fonts ---------- */

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/plus-jakarta-sans-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/plus-jakarta-sans-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/plus-jakarta-sans-latin-800-normal.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

/* ---------- 2. Tokens ---------- */

:root {
  /* Board: the olive green page background */
  --color-board: #5b6236;
  --color-board-deep: #3f4525;   /* header bar, solid shadows under paper */
  --color-board-soft: #6b7342;   /* raised areas on the board */
  --color-grid: rgba(255, 253, 248, 0.06); /* squared lines on the board */

  /* Chalk: text and lines directly on the board */
  --color-chalk: #fffdf8;
  --color-chalk-soft: rgba(255, 253, 248, 0.82);
  --color-chalk-line: rgba(255, 253, 248, 0.55);

  /* Paper: cards, panels, fields */
  --color-paper: #fffdf8;
  --color-paper-dim: #f3eee1;    /* insets on paper, e.g. segmented track */
  --color-paper-edge: #d5cdb9;   /* hairlines and solid bottom edges */
  --color-field-edge: #838d85;   /* borders of inputs, needs 3:1 on paper */

  /* Ink: text on paper */
  --color-ink: #18241d;
  --color-ink-soft: #55635a;

  /* Accent: chalk yellow. Main action and active states only.
     On the board it reaches 3.4:1, so use it there for large text and graphics only. */
  --color-accent: #e9b44c;
  --color-accent-deep: #b4832a;

  /* Area colors for pills. Muted, always with ink text and a word. */
  --area-organisation: #d3e4d0;
  --area-bewerten: #d5e1ec;
  --area-arbeitsblatt: #efe2c2;
  --area-deutsch: #f1d9d2;
  --area-geschichte: #e9d7b4;
  --area-informatik: #dcd7ec;
  --area-mathe: #cfe6e3;
  --area-kooperation: #eed6e2;
  --area-foerderung: #e1e6c6;
  --area-sonstige: #e4e1d8;

  /* Type */
  --font-head: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-1: 0.875rem;   /* 14 small labels, pills */
  --text-2: 1rem;       /* 16 secondary text */
  --text-3: 1.125rem;   /* 18 body */
  --text-4: 1.375rem;   /* 22 card titles, tool name */
  --text-5: 1.75rem;    /* 28 section headings */
  --text-6: 2.5rem;     /* 40 page headings */
  --text-7: 3.5rem;     /* 56 big headings */

  /* Spacing, 4px base */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  /* Shape */
  --radius-card: 16px;
  --radius-control: 12px;
  --radius-pill: 999px;
  --edge: 4px;            /* height of the solid bottom edge on controls */

  /* Touch targets */
  --target: 48px;
  --target-main: 64px;

  /* Motion */
  --quick: 120ms;
  --calm: 220ms;

  /* Focus ring color, switched to ink inside paper areas */
  --focus: var(--color-accent);

  color-scheme: light;
}

/* ---------- 3. Base ---------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-3);
  line-height: 1.5;
  color: var(--color-chalk);
  background-color: var(--color-board);
  background-image:
    linear-gradient(var(--color-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  transition: background-color var(--calm) ease;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.015em;
  word-spacing: 0.08em;
  text-wrap: balance;
}
h1 { font-size: clamp(var(--text-6), 5vw, var(--text-7)); }
h2 { font-size: var(--text-5); font-weight: 700; }
h3 { font-size: var(--text-4); font-weight: 700; }
h4 { font-size: var(--text-3); font-weight: 700; letter-spacing: 0; }

/* The heading face has a narrow word space. Open it a little wherever it is used. */
.z-button,
.z-field__label,
.z-segmented span,
.z-pill,
.z-filter,
.z-header__title,
.z-empty p,
.z-toast--plain {
  padding-right: var(--space-5);
}
.z-toast__action {
  word-spacing: 0.08em;
}

p {
  margin: 0;
  max-width: 68ch;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

svg {
  display: block;
}

/* The hidden attribute always wins, also over components that set display. */
[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ---------- 4. Components ---------- */

/* Icon: <svg class="z-icon"><use href="/shared/icons/icons.svg#back"></use></svg> */
.z-icon {
  width: 24px;
  height: 24px;
  flex: none;
}

/* Paper: a cream sheet on the board. Everything inside reads as ink on paper. */
.z-paper {
  --focus: var(--color-ink);
  color: var(--color-ink);
  background: var(--color-paper);
  border-radius: var(--radius-card);
  box-shadow: 0 6px 0 var(--color-board-deep);
  padding: var(--space-5);
}

/* Button
 *   .z-button            paper button, the default
 *   .z-button--main      the one main action on a screen
 *   .z-button--quiet     low-key action directly on the board
 *   .z-button--large     main action size for the board
 * Buttons have a solid bottom edge and sink when pressed.
 */
.z-button {
  --button-bg: var(--color-paper);
  --button-edge: var(--color-paper-edge);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--target);
  padding: 0 var(--space-5);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: var(--text-3);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  color: var(--color-ink);
  background: var(--button-bg);
  border: 0;
  border-radius: var(--radius-control);
  box-shadow: 0 var(--edge) 0 var(--button-edge);
  margin-bottom: var(--edge);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--quick) ease, box-shadow var(--quick) ease;
}
.z-button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--button-edge);
}
.z-button--main {
  --button-bg: var(--color-accent);
  --button-edge: var(--color-accent-deep);
}
.z-button--quiet {
  --button-bg: transparent;
  color: var(--color-chalk);
  box-shadow: inset 0 0 0 2px var(--color-chalk-line);
}
.z-button--quiet:active {
  transform: none;
  box-shadow: inset 0 0 0 2px var(--color-chalk);
}
.z-paper .z-button--quiet,
.z-panel .z-button--quiet {
  color: var(--color-ink);
  box-shadow: inset 0 0 0 2px var(--color-paper-edge);
}
.z-paper .z-button:not(.z-button--main):not(.z-button--quiet),
.z-panel .z-button:not(.z-button--main):not(.z-button--quiet) {
  --button-bg: var(--color-paper-dim);
}
.z-button--large {
  min-height: var(--target-main);
  padding: 0 var(--space-6);
  font-size: var(--text-4);
  border-radius: 14px;
}
.z-button:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Icon button: round, 48px, for header and panel actions. Needs aria-label. */
.z-iconbutton {
  display: inline-grid;
  place-items: center;
  width: var(--target);
  height: var(--target);
  flex: none;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--quick) ease;
}
.z-iconbutton:active {
  background: rgba(255, 253, 248, 0.16);
}
.z-paper .z-iconbutton:active,
.z-panel .z-iconbutton:active {
  background: var(--color-paper-dim);
}
@media (hover: hover) {
  .z-iconbutton:hover {
    background: rgba(255, 253, 248, 0.1);
  }
  .z-paper .z-iconbutton:hover,
  .z-panel .z-iconbutton:hover {
    background: var(--color-paper-dim);
  }
}

/* Field: label plus input, textarea or select */
.z-field {
  display: grid;
  gap: var(--space-2);
}
.z-field__label {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: var(--text-2);
}
.z-input,
.z-textarea,
.z-select {
  width: 100%;
  min-height: var(--target);
  padding: 0 var(--space-4);
  font-size: var(--text-3);
  color: var(--color-ink);
  background: #fff;
  border: 1.5px solid var(--color-field-edge);
  border-bottom-width: var(--edge);
  border-radius: var(--radius-control);
}
.z-input::placeholder,
.z-textarea::placeholder {
  color: #66716a;
  opacity: 1;
}
.z-textarea {
  min-height: 7.5rem;
  padding: var(--space-3) var(--space-4);
  line-height: 1.45;
  resize: vertical;
}
.z-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 3rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2318241d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 24px;
  cursor: pointer;
}

/* Search field: input with a leading icon */
.z-search {
  position: relative;
  color: var(--color-ink);
}
.z-search .z-icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-60%);
  pointer-events: none;
  color: var(--color-ink-soft);
}
.z-search .z-input {
  padding-left: 3.25rem;
}

/* Switch: <label class="z-switch"><input type="checkbox"><span class="z-switch__track"></span>Ton</label> */
.z-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--target);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.z-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.z-switch__track {
  position: relative;
  width: 58px;
  height: 34px;
  flex: none;
  background: var(--color-paper-dim);
  border: 1.5px solid var(--color-field-edge);
  border-radius: var(--radius-pill);
  transition: background-color var(--calm) ease, border-color var(--calm) ease;
}
.z-switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 25px;
  height: 25px;
  background: var(--color-field-edge);
  border-radius: 50%;
  transition: transform var(--calm) ease, background-color var(--calm) ease;
}
.z-switch input:checked + .z-switch__track {
  background: var(--color-accent);
  border-color: var(--color-accent-deep);
}
.z-switch input:checked + .z-switch__track::after {
  transform: translateX(24px);
  background: var(--color-ink);
}
.z-switch input:focus-visible + .z-switch__track {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Slider: <input class="z-slider" type="range">. JS keeps --fill in sync (0% to 100%). */
.z-slider {
  --fill: 50%;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: var(--target);
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.z-slider::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: var(--radius-pill);
  background: linear-gradient(
    to right,
    var(--color-ink) var(--fill),
    var(--color-paper-edge) var(--fill)
  );
}
.z-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  margin-top: -11px;
  background: var(--color-accent);
  border: 3px solid var(--color-ink);
  border-radius: 50%;
}
.z-slider::-moz-range-track {
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--color-paper-edge);
}
.z-slider::-moz-range-progress {
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--color-ink);
}
.z-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  background: var(--color-accent);
  border: 3px solid var(--color-ink);
  border-radius: 50%;
}

/* Segmented choice: radio inputs that look like one control.
 * <div class="z-segmented" role="radiogroup" aria-label="...">
 *   <label><input type="radio" name="x" checked><span>Eins</span></label> ...
 */
.z-segmented {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  background: var(--color-paper-dim);
  border-radius: 14px;
}
.z-segmented label {
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.z-segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.z-segmented span {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 0 var(--space-4);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: var(--text-2);
  color: var(--color-ink);
  border-radius: 10px;
  transition: background-color var(--quick) ease, color var(--quick) ease;
}
.z-segmented input:checked + span {
  background: var(--color-ink);
  color: var(--color-paper);
}
.z-segmented input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
/* On the board the track is dark and the chosen option is paper. */
.z-segmented--board {
  background: var(--color-board-deep);
}
.z-segmented--board span {
  color: var(--color-chalk);
}
.z-segmented--board input:checked + span {
  background: var(--color-paper);
  color: var(--color-ink);
}

/* Stepper: minus, number, plus */
.z-stepper {
  display: inline-flex;
  align-items: center;
  background: var(--color-paper-dim);
  border-radius: 14px;
}
.z-stepper output {
  min-width: 3.5ch;
  text-align: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Pill: small label for area and audience. Never the only carrier of meaning. */
.z-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 var(--space-3);
  font-family: var(--font-head);
  font-weight: 600;
  font-size: var(--text-1);
  line-height: 1;
  white-space: nowrap;
  color: var(--color-ink);
  background: var(--color-paper-dim);
  border-radius: var(--radius-pill);
}
.z-pill[data-area="organisation"] { background: var(--area-organisation); }
.z-pill[data-area="bewerten"] { background: var(--area-bewerten); }
.z-pill[data-area="arbeitsblatt"] { background: var(--area-arbeitsblatt); }
.z-pill[data-area="deutsch"] { background: var(--area-deutsch); }
.z-pill[data-area="geschichte"] { background: var(--area-geschichte); }
.z-pill[data-area="informatik"] { background: var(--area-informatik); }
.z-pill[data-area="mathe"] { background: var(--area-mathe); }
.z-pill[data-area="kooperation"] { background: var(--area-kooperation); }
.z-pill[data-area="foerderung"] { background: var(--area-foerderung); }
.z-pill[data-area="sonstige"] { background: var(--area-sonstige); }
.z-pill--outline {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--color-paper-edge);
}

/* Filter: a pill you can switch on. <button class="z-filter" aria-pressed="false"> */
.z-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: var(--text-2);
  color: var(--color-chalk);
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  box-shadow: inset 0 0 0 2px var(--color-chalk-line);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--quick) ease, color var(--quick) ease;
}
.z-filter[aria-pressed="true"] {
  color: var(--color-ink);
  background: var(--color-paper);
  box-shadow: none;
}
.z-filter .z-icon {
  width: 18px;
  height: 18px;
  display: none;
}
.z-filter[aria-pressed="true"] .z-icon {
  display: block;
}
/* Toggle: a filter that opens a list, e.g. "Fächer". The chevron is always there. */
.z-filter--toggle .z-icon {
  display: block;
  transition: transform var(--calm) ease;
}
.z-filter--toggle[aria-expanded="true"] .z-icon {
  transform: rotate(180deg);
}
/* How many choices inside the list are on */
.z-filter__count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  font-size: var(--text-1);
  color: var(--color-ink);
  background: var(--color-accent);
  border-radius: var(--radius-pill);
}
/* Smaller pills inside an opened list */
.z-filter--small {
  min-height: 44px;
  padding: 0 var(--space-3);
}

/* Card: one tool on the overview. The whole card is a link. */
.z-card {
  --focus: var(--color-accent);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--color-ink);
  text-decoration: none;
  background: var(--color-paper);
  border-radius: var(--radius-card);
  /* The thin ring keeps green screenshots from melting into the board. */
  box-shadow: 0 0 0 1.5px var(--color-chalk-line), 0 6px 0 var(--color-board-deep);
  transition: transform var(--calm) ease, box-shadow var(--calm) ease;
}
.z-card:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 1.5px var(--color-chalk-line), 0 3px 0 var(--color-board-deep);
}
@media (hover: hover) {
  .z-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 0 0 1.5px var(--color-chalk-line), 0 10px 0 var(--color-board-deep);
  }
}
.z-card__image {
  aspect-ratio: 4 / 3;
  width: 100%;
  height: auto; /* the img height attribute must not override the 4:3 box */
  object-fit: cover;
  background: var(--color-board-deep);
  border-bottom: 1px solid var(--color-paper-edge);
}
.z-card__body {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4) var(--space-5);
}
.z-card__title {
  font-size: var(--text-4);
}
.z-card__text {
  font-size: var(--text-2);
  line-height: 1.4;
  color: var(--color-ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.z-card__pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* Card grid: 4 columns on the board, 3 on a laptop, 1 on a phone */
.z-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .z-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1000px) {
  .z-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1500px) {
  .z-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Tool header: back, name, then help, settings, fullscreen. Nothing else. */
.z-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 64px;
  padding: 0 var(--space-3);
  color: var(--color-chalk);
  background: var(--color-board-deep);
}
.z-header__title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: var(--text-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Display: the one big thing on a board tool (time, name, number) */
.z-display {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(4rem, 17vw, 15rem);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--color-chalk);
}

/* Settings panel: slides in from the right. Groups, rows, reset at the bottom. */
.z-panel {
  --focus: var(--color-ink);
  display: flex;
  flex-direction: column;
  width: min(400px, 100%);
  color: var(--color-ink);
  background: var(--color-paper);
}
.z-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-paper-edge);
}
.z-panel__head h2 {
  font-size: var(--text-4);
}
.z-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-5) var(--space-5);
}
.z-panel__group {
  padding-top: var(--space-5);
}
.z-panel__group h3 {
  font-size: var(--text-2);
  color: var(--color-ink-soft);
  margin-bottom: var(--space-1);
}
.z-panel__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 60px;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-paper-edge);
}
.z-panel__row:last-child {
  border-bottom: 0;
}
.z-panel__row--stacked {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-1);
  padding: var(--space-3) 0;
}
.z-panel__label {
  font-weight: 600;
}
.z-panel__foot {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-paper-edge);
}

/* Toast: short confirmation with one way back */
.z-toast {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--target);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-5);
  font-weight: 600;
  color: var(--color-paper);
  background: var(--color-ink);
  border-radius: var(--radius-pill);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
}
.z-toast--plain {
  padding-right: var(--space-5);
}
.z-toast__action {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--color-ink);
  background: var(--color-accent);
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

/* Empty state: one sentence and one action, never a blank area */
.z-empty {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  border: 2px dashed var(--color-chalk-line);
  border-radius: var(--radius-card);
}
.z-empty p {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: var(--text-4);
}

/* Color choice: round swatches, radio inputs underneath.
 * <div class="z-swatches" role="radiogroup" aria-label="Farbe">
 *   <label><input type="radio" name="c" checked><span style="--swatch:#fffdf8"></span><b class="z-visually-hidden">Kreide</b></label>
 */
.z-swatches {
  display: inline-flex;
  gap: var(--space-1);
}
.z-swatches label {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.z-swatches input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.z-swatches span {
  width: 32px;
  height: 32px;
  background: var(--swatch);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--color-field-edge);
}
.z-swatches input:checked + span {
  box-shadow: inset 0 0 0 1.5px var(--color-field-edge), 0 0 0 3px var(--color-paper), 0 0 0 6px var(--color-ink);
}
.z-swatches input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 7px;
}

/* App frame of a tool: header on top, the stage fills the rest.
 * <body class="z-app"> ... <main class="z-stage">
 * shell.js adds the header, the settings drawer, help and toasts.
 */
.z-app {
  display: flex;
  flex-direction: column;
}
.z-app .z-header {
  position: relative;
  z-index: 22; /* above the scrim, so header buttons keep working */
}
.z-stage {
  flex: 1;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: var(--space-6);
  min-width: 0;
  padding: var(--space-5);
  text-align: center;
  transition: margin-right var(--calm) ease;
}
/* With settings open on a wide screen the stage moves aside, so every
   change stays visible while the panel is open. */
@media (min-width: 900px) {
  .z-app.is-settings-open .z-stage {
    margin-right: 400px;
  }
}

/* Drawer: the settings panel as a sheet from the right */
.z-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  border-radius: 20px 0 0 20px;
  box-shadow: -8px 0 0 rgba(0, 0, 0, 0.16);
  transform: translateX(calc(100% + 12px));
  visibility: hidden;
  transition: transform var(--calm) ease, visibility 0s linear var(--calm);
}
.z-drawer.is-open {
  transform: none;
  visibility: visible;
  transition: transform var(--calm) ease, visibility 0s;
}
@media (max-width: 480px) {
  .z-drawer {
    border-radius: 0;
  }
}
/* Scrim: invisible layer that closes the drawer or help on a tap outside */
.z-scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
}

/* Help: at most five short lines, shown under the help button */
.z-popover {
  --focus: var(--color-ink);
  position: absolute;
  top: calc(100% + var(--space-2));
  right: var(--space-3);
  z-index: 25;
  display: grid;
  gap: var(--space-2);
  width: min(360px, calc(100vw - 1.5rem));
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-3);
  color: var(--color-ink);
  background: var(--color-paper);
  border-radius: var(--radius-card);
  box-shadow: 0 6px 0 var(--color-board-deep);
}

/* Toast area: bottom center, above everything */
.z-toast-area {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--space-5);
  z-index: 40;
  display: grid;
  justify-items: center;
  padding: 0 var(--space-4);
  pointer-events: none;
}
.z-toast-area > * {
  pointer-events: auto;
}

/* Fullscreen: the header slides away and comes back when the top edge is touched */
.z-app.is-fullscreen .z-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  transform: translateY(-100%);
  transition: transform var(--calm) ease;
}
.z-app.is-fullscreen.is-peeking .z-header {
  transform: none;
}
.z-reveal {
  display: none;
}
.z-app.is-fullscreen .z-reveal {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 28px;
  z-index: 9;
}

/* Reading page: one paper sheet in the middle, e.g. Impressum */
.z-page {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-8);
}
.z-page .z-paper {
  display: grid;
  gap: var(--space-3);
  padding: clamp(1.25rem, 4vw, 2.5rem);
}
.z-page h2 {
  font-size: var(--text-3);
  margin-top: var(--space-3);
}
.z-page h2:first-of-type {
  margin-top: 0;
}
.z-page a {
  text-decoration-thickness: 1.5px;
}

/* ---------- 5. Helpers ---------- */

.z-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.z-soft {
  color: var(--color-chalk-soft);
}
.z-paper .z-soft,
.z-panel .z-soft {
  color: var(--color-ink-soft);
}

.z-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.z-stack {
  display: grid;
  gap: var(--space-4);
}
