/* ui.pm7.dev — reference page for the pm7-layout-rules skill.
   Distances between elements only use the scale 4, 8, 16, 20, 24.
   Every distance is set in one place: gap on the container or margin-top on
   the next element, never margin-bottom. */

/* ---------- Theme ---------- */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #eff1f4;
  --field-bg: #fafbfc;
  --border: #d9dde3;
  --border-strong: #b4bbc6;
  --text: #16181d;
  --text-2: #5a6270;
  --accent: #2563eb;
  --on-accent: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--panel-2));
  --danger: #dc2626;
  --on-danger: #ffffff;
  --danger-text: #b91c1c;
  --error: #b91c1c;
  --measure: #c026d3;
  --scrollbar-thumb: rgba(60, 66, 78, 0.38);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1014;
  --panel: #171a20;
  --panel-2: #1f232b;
  --field-bg: #111419;
  --border: #2d323c;
  --border-strong: #4a5160;
  --text: #e8eaef;
  --text-2: #9ba3b1;
  --accent: #3b6fe0;
  --on-accent: #ffffff;
  --danger: #dc2626;
  --on-danger: #ffffff;
  --danger-text: #f87171;
  --error: #f87171;
  --measure: #e879f9;
  --scrollbar-thumb: rgba(200, 206, 216, 0.32);
}

/* ---------- Scrollbars (skill: three fixed rules, once, globally) ---------- */

* {
  scrollbar-color: var(--scrollbar-thumb, rgba(128, 128, 128, 0.5)) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb, rgba(128, 128, 128, 0.5));
  border-radius: 4px;
}

html {
  overflow-y: scroll;
}

@supports (scrollbar-gutter: stable) {
  html {
    overflow-y: auto;
    scrollbar-gutter: stable;
  }
}

html,
body {
  background: var(--bg);
}

html.modal-open {
  overflow: hidden;
}

/* ---------- Base ---------- */

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

body {
  margin: 0;
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ul, ol, dl, dd, figure, fieldset, table {
  margin: 0;
  padding: 0;
}

h1, h2, h3, h4 {
  font-style: normal;
  text-wrap: balance;
}

h2 { font-size: 20px; font-weight: 600; line-height: 1.3; }
h3 { font-size: 16px; font-weight: 600; line-height: 1.3; }

p { text-wrap: pretty; }

ul { list-style: none; }

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

button { cursor: pointer; }

a { color: var(--accent); }
[data-theme="dark"] a { color: #8fb1ff; }

kbd {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.one-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.muted { color: var(--text-2); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-danger);
}
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn:disabled:hover { background: var(--panel); }
.btn-primary:disabled:hover { background: var(--accent); }
.btn-danger:disabled:hover { background: var(--danger); }

.btn-icon {
  width: 36px;
  padding: 0;
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
}
.btn-ghost:hover { background: var(--panel-2); }

/* Pill: icon concentric in the 36px cap. Center 18px from the outer edge:
   1px border + 9px padding + half of the 16px icon. The text side gets a
   little more than the 16px of a normal button. Optical correction, not a
   step on the scale. */
.btn-pill {
  border-radius: 999px;
  padding: 0 18px 0 9px;
}

/* Compact status pill: no optical correction. */
.status-pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Fields (SKILL.md: invoervelden) ---------- */

.field label,
.label {
  display: block;
  font-weight: 500;
}
.field > .input { margin-top: 8px; }
.field > .help { margin-top: 4px; }

.input {
  display: block;
  width: 100%;
  min-height: 32px;
  padding: 0 8px;
  text-align: start;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--text);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
}
.input[aria-invalid="true"] { border-color: var(--error); }
.input[aria-invalid="true"]:focus { border-color: var(--accent); }
.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.input[readonly] {
  background: var(--panel-2);
}
textarea.input {
  padding: 8px;
  min-height: 80px;
  max-height: 160px;
  line-height: 1.5;
  resize: none;
  field-sizing: content;
}
.input::placeholder { color: var(--text-2); opacity: 0.8; }

.help {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}
.help.is-error { color: var(--error); }
.help:empty { display: none; }

.fields {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
.check input {
  margin: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
.options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.option > .help { margin-top: 4px; padding-left: 24px; }

.form-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.section-head > p { margin-top: 8px; color: var(--text-2); }
.groups {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.divider {
  height: 1px;
  border: 0;
  margin: 0;
  background: var(--border);
}

/* ---------- Page chrome ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1248px;
  margin: 0 auto;
  padding: 16px 24px;
}
.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
}
[data-theme="dark"] .brand { color: var(--text); }

.seg {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}
.seg label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-2);
}
.seg label + label { border-left: 1px solid var(--border-strong); }
.seg label:has(input:checked) {
  background: var(--accent);
  color: var(--on-accent);
}
.seg label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
  box-shadow: inset 0 0 0 3px var(--panel);
}
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }

.page {
  max-width: 1248px;
  margin: 0 auto;
  padding: 0 24px 24px;
}

.hero {
  padding-top: 24px;
}
/* Large title: tighter tracking and line height, an optical correction. */
.hero h1,
.display-title {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.hero > p { margin-top: 8px; max-width: 720px; color: var(--text-2); font-size: 16px; }
.toc { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.toc a {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.toc a:hover { background: var(--panel-2); }
.toc a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.block {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.block-head > p { margin-top: 8px; color: var(--text-2); max-width: 760px; }
.block-body { margin-top: 24px; }

.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}
.demo {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.demo.span-2 { grid-column: span 2; }
.demo .rule { margin-top: 8px; color: var(--text-2); }
.rule b { color: var(--text); font-weight: 600; }
.demo-body { margin-top: 24px; }
.demo-body > * + .readout { margin-top: 24px; }

.readout {
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--panel-2);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-2);
}

.legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px 24px;
}
.after-head { margin-top: 24px; }
.legend dt { font-weight: 600; }
.legend dd { margin-top: 4px; color: var(--text-2); }

/* ---------- Example app ---------- */

.app {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 680px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}

/* Fixed chrome: the sidebar toggle lives here and never moves. */
.app-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: relative;
  z-index: 6;
}
.app-name { font-weight: 600; margin-right: auto; }

.app-body {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: 248px;
  min-height: 0;
  padding: 8px;
  gap: 24px;
  border-right: 1px solid var(--border);
  background: var(--panel-2);
}
.app[data-sidebar="closed"] .sidebar { display: none; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  text-align: start;
}
.nav-item span { min-width: 0; }
.nav-item:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* Active: a clear fill plus an indicator bar that sits inside the row's
   rounding, away from the window edge. */
.nav-item[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.side-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  flex: 1;
}
.side-label {
  padding: 0 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.side-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
}
.side-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 16px;
  color: var(--text-2);
}
.side-list li span { min-width: 0; }

.scrim { display: none; }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* Tab row */
.tabs-wrap {
  position: relative;
  flex: none;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.tabs {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  scroll-padding-inline: 24px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs-empty {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  color: var(--text-2);
}
.tab-item {
  position: relative;
  display: flex;
  align-items: center;
  flex: none;
  height: 40px;
  border-right: 1px solid var(--border);
  color: var(--text-2);
}
.tab-item.is-active {
  background: var(--panel);
  color: var(--text);
}
.tab-item.is-active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}
/* The label beside the close button keeps a min-width: a wide click target. */
.tab {
  display: block;
  min-width: 96px;
  max-width: 200px;
  height: 100%;
  padding: 0 8px 0 16px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: start;
  font-weight: 500;
}
.tab:focus-visible,
.tab-close:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tab-close {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
}
.tab-close:hover { background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); }

.chev {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 24px;
  padding: 0;
  border: 0;
  background: color-mix(in srgb, var(--panel-2) 85%, transparent);
  color: var(--text);
}
.chev[hidden] { display: none; }
.chev-left { left: 0; }
.chev-right { right: 0; }
.chev:hover { background: var(--panel-2); }
.chev.is-disabled {
  color: var(--text-2);
  opacity: 0.4;
  cursor: default;
}
@media (hover: none) {
  .chev { display: none !important; }
}

.main-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  container-type: inline-size;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.page-head p { margin-top: 8px; color: var(--text-2); }

.workspace {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@container (max-width: 720px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}

.plist {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.prow {
  display: flex;
  align-items: center;
  border-radius: 8px;
  color: var(--text);
}
.prow:hover { background: var(--panel-2); }
.prow-main {
  flex: 1;
  min-width: 0;
  padding: 8px 8px 8px 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: start;
}
.prow-main:focus-visible,
.prow-more:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.prow-name { display: block; font-weight: 500; }
.prow-meta { display: block; font-size: 12px; color: var(--text-2); }
.prow-more {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  margin-right: 8px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  opacity: 0;
}
.prow-more:hover { background: color-mix(in srgb, var(--text) 10%, transparent); }
.prow:hover .prow-more,
.prow:focus-within .prow-more,
.prow-more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) {
  .prow-more { opacity: 1; }
}
/* Active: a strong accent fill with contrasting text, no extra bar. */
.prow.is-active,
.prow.is-active:hover {
  background: var(--accent);
  color: var(--on-accent);
}
.prow.is-active .prow-meta,
.prow.is-active .prow-more { color: var(--on-accent); opacity: 1; }
.prow.is-active .prow-meta { opacity: 0.88; }
.prow.is-active .prow-more:hover { background: rgba(255, 255, 255, 0.18); }
.prow.is-active .prow-main:focus-visible,
.prow.is-active .prow-more:focus-visible { outline-color: var(--on-accent); }

.card {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.card-empty { color: var(--text-2); }

.tiles-block { margin-top: 24px; }
.tiles-block > h3 + .tiles { margin-top: 16px; }
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.tile {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.tile-title { font-size: 14px; font-weight: 600; line-height: 1.5; }
.tile-meta { margin-top: 8px; font-size: 12px; color: var(--text-2); }

@media (max-width: 899px) {
  .app-body { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 5;
    width: min(280px, 85%);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  }
  .app[data-sidebar="open"] .scrim {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 4;
    background: rgba(0, 0, 0, 0.3);
  }
}

/* ---------- Scroll-aware edge fade (skill: vervaging aan scrollranden) ---------- */

@property --t { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --b { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --l { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --r { syntax: "<length>"; inherits: false; initial-value: 0px; }

@keyframes edges {
  0% { --t: 0px; --b: 24px; }
  10%, 90% { --t: 24px; --b: 24px; }
  100% { --t: 24px; --b: 0px; }
}
@keyframes edges-narrow {
  0% { --t: 0px; --b: 16px; }
  10%, 90% { --t: 16px; --b: 16px; }
  100% { --t: 16px; --b: 0px; }
}
@keyframes edges-x {
  0% { --l: 0px; --r: 24px; }
  10%, 90% { --l: 24px; --r: 24px; }
  100% { --l: 24px; --r: 0px; }
}

@supports (animation-timeline: scroll()) {
  .fade-y {
    mask-image: linear-gradient(#0000, #000 var(--t) calc(100% - var(--b)), #0000);
    animation: edges linear both;
    animation-timeline: scroll(self);
  }
  .fade-y.narrow { animation-name: edges-narrow; }
  .fade-x {
    mask-image: linear-gradient(to right, #0000, #000 var(--l) calc(100% - var(--r)), #0000);
    animation: edges-x linear both;
    animation-timeline: scroll(self inline);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fade-y,
  .fade-x { mask-image: none; animation: none; }
}

/* ---------- Demo pieces ---------- */

.fade-demos {
  display: grid;
  grid-template-columns: 1fr 160px 1fr;
  gap: 24px;
  align-items: start;
}
.fade-col > p { font-size: 12px; color: var(--text-2); }
.fade-col > .demo-list { margin-top: 8px; }
.demo-list {
  height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}
.demo-list.short { height: auto; }
.demo-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
.demo-list li:last-child { border-bottom: 0; }
.demo-list li span { min-width: 0; }

.scroll-box {
  height: 160px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
}
.scroll-box p + p { margin-top: 8px; }

.edge-demo {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  min-height: 120px;
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
}

.scale {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 24px;
}
.scale-step { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.scale-swatch { background: var(--measure); border-radius: 1px; }
.scale-step b { font-weight: 600; }

.rel-table {
  width: 100%;
  border-collapse: collapse;
}
.rel-table th,
.rel-table td {
  padding: 8px 16px 8px 0;
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: middle;
}
.rel-table th { font-size: 12px; color: var(--text-2); font-weight: 600; }
.rel-table td:nth-child(2) { font-weight: 600; white-space: nowrap; }
.rel-gap {
  display: flex;
  flex-direction: column;
  width: 48px;
}
.rel-gap::before,
.rel-gap::after {
  content: "";
  display: block;
  height: 6px;
  border-radius: 2px;
  background: var(--border-strong);
}
.rel-gap i {
  display: block;
  background: color-mix(in srgb, var(--measure) 35%, transparent);
  border-left: 1px solid var(--measure);
  border-right: 1px solid var(--measure);
}

.measure-wrap {
  position: relative;
  padding-right: 48px;
}
.measure-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.measure-wrap.off .measure-layer { display: none; }
.m-bar {
  position: absolute;
  background: var(--measure);
}
.m-tag {
  position: absolute;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--measure);
  color: #fff;
  font: 600 11px/16px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
}
.m-tag.bad { background: #000; color: #ff5; }
.m-shade {
  position: absolute;
  background: color-mix(in srgb, var(--measure) 22%, transparent);
}
.measure-toggle { margin-top: 24px; }

.balance-demo { max-width: 300px; }
.no-balance { text-wrap: wrap; }
.balance-demo h3 + p,
.balance-demo p + h3 { margin-top: 8px; }

.compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.compare-col > p { font-size: 12px; color: var(--text-2); }
.compare-col > .tile,
.compare-col > .fake-tab { margin-top: 8px; }
.fake-tab {
  display: flex;
  min-width: 0;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  font-weight: 500;
}

.pill-guide { position: relative; }
.pill-guide::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px dashed var(--measure);
  pointer-events: none;
}
.pill-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- Menu (skill: menu's) ---------- */

#menu-layer { position: relative; z-index: 300; }

.menu {
  position: fixed;
  z-index: 300;
  min-width: 180px;
  padding: 8px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  outline: none;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  text-align: start;
  cursor: default;
}
.menu-item .icon {
  stroke-width: 1;
  color: var(--text-2);
}
.menu-label { flex: 1; white-space: nowrap; }
.menu-key {
  margin-left: 16px;
  color: var(--text-2);
  font-size: 12px;
}
.menu-item:focus {
  outline: none;
  background: var(--accent);
  color: var(--on-accent);
}
.menu-item:focus .icon,
.menu-item:focus .menu-key { color: var(--on-accent); }
.menu-item.is-danger,
.menu-item.is-danger .icon { color: var(--danger-text); }
.menu-item.is-danger:focus,
.menu-item.is-danger:focus .icon,
.menu-item.is-danger:focus .menu-key {
  background: var(--danger);
  color: #fff;
}
.menu-item[aria-disabled="true"] { opacity: 0.5; }
.menu-sep {
  height: 1px;
  margin: 8px 0;
  background: var(--border);
}

/* ---------- Dialogs (dialogs.md: vorm) ---------- */

.dlg-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.4);
}
.dlg {
  display: flex;
  flex-direction: column;
  width: 520px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  outline: none;
}
.dlg-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
}
.dlg-title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.dlg-text {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.5;
}
.dlg-text p + p { margin-top: 8px; }
.dlg-desc {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-2);
}
.dlg-fields { margin-top: 16px; }
.dlg .input {
  min-height: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
}
.dlg textarea.input {
  height: auto;
  min-height: 80px;
  padding: 8px 12px;
}
.dlg-foot {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--text) 4%, var(--panel));
}
.dlg-foot-left { margin-right: auto; }

/* ---------- Toasts ---------- */

#toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-weight: 500;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

/* ---------- Narrow screens ---------- */

@media (max-width: 760px) {
  .demo.span-2 { grid-column: auto; }
  .fade-demos { grid-template-columns: 1fr 1fr; }
  .fade-demos .fade-col:first-child { grid-column: 1 / -1; }
}

@media (max-width: 599px) {
  .site-header { padding: 16px; }
  .page { padding: 0 16px 24px; }
  .demo-grid { grid-template-columns: minmax(0, 1fr); }
  .legend { grid-template-columns: minmax(0, 1fr); }
  .main-scroll { padding: 16px; }
  .compare { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 160ms ease-out; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

.fake-tab > span { min-width: 0; }
