/* UTM Linkbau · Viola Beuscher
   Welt: Viola Beuscher Designsystem. Papiergrund, Tiefton-Panel mit harter Kante, Sand als Zweitfläche.
   Signatur: der Link als Werkstück. Er steht oben auf ink-deep und wird Zeile für Zeile zusammengesetzt.
   Keine Radien, keine Schatten, keine Verläufe. Struktur nur über 1px-Linien. */

@font-face { font-family: "Forma DJR Deck"; src: url("/fonts/FormaDJRDeck-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Forma DJR Deck"; src: url("/fonts/FormaDJRDeck-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }

:root {
  --paper: #F7F4EE;
  --ink: #2B2620;
  --ink-2: #5E5A55;        /* Zweittext: 6,1:1 auf paper, 4,9:1 auf sand, 5,3:1 auf hair */
  --ink-deep: #141110;
  --on-deep: #F7F4EE;      /* 17,1:1 */
  --on-deep-2: #8E8A85;    /* muted, 5,5:1 auf ink-deep */
  --deep-rule: #3A3430;
  --sand: #E4D8C4;
  --hair: #E4E1DB;
  --line: #CFC9BF;
  --field: #FFFDF9;
  --clay: #B8654A;
  --terracotta: #A4582F;
  --font: "Forma DJR Deck", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
  accent-color: var(--terracotta);
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); scrollbar-color: var(--line) var(--paper); -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 16px/24px var(--font); caret-color: var(--terracotta); font-feature-settings: "kern"; }
::selection { background: var(--sand); color: var(--ink); }
code { font: inherit; font-variant-numeric: tabular-nums; background: var(--hair); padding: 0 4px; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
h1, h2, h3, p, dl, dd { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 1120px; margin: 0 auto; padding-block: 20px 72px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }

/* ---------- Kopf ---------- */
.top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; padding-bottom: 16px; }
.mark { display: flex; align-items: baseline; gap: 8px; font-size: 15px; color: var(--ink-2); }
.mark b { font-weight: 500; font-size: 20px; line-height: 26px; color: var(--ink); }
.dot { color: var(--line); }
.tabs { display: flex; gap: 4px 18px; flex-wrap: wrap; align-items: baseline; }
.tabs a, .linkish { font: inherit; font-size: 15px; color: var(--ink-2); text-decoration: none; padding: 6px 0; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; }
.tabs a:hover, .linkish:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 500; border-bottom-color: var(--clay); }

/* ---------- Werkstück ---------- */
.piece { position: relative; background: var(--ink-deep); color: var(--on-deep); padding: 28px 32px 22px; caret-color: var(--sand); overflow: hidden; }
.piece ::selection { background: var(--clay); color: var(--on-deep); }
.piece :focus-visible { outline-color: var(--sand); }
.sweep { position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--sand); transform: scaleX(0); transform-origin: left; opacity: 0; pointer-events: none; }
.piece.copied .sweep { animation: sweep 700ms var(--ease-out); }
@keyframes sweep { 0% { transform: scaleX(0); opacity: 1; } 70% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }

.piece input { font: inherit; color: var(--on-deep); background: transparent; border: 0; border-bottom: 1px solid var(--deep-rule); border-radius: 0; width: 100%; min-width: 0; padding: 6px 0; }
.piece input::placeholder { color: var(--on-deep-2); opacity: 1; }
.piece input:hover:not([readonly]) { border-bottom-color: var(--on-deep-2); }
.piece input:focus { outline: none; border-bottom: 1px solid var(--sand); box-shadow: 0 1px 0 var(--sand); }

.target input { font-size: 24px; line-height: 32px; font-weight: 500; letter-spacing: -0.01em; padding: 4px 0 10px; }

.params { display: grid; grid-template-columns: max-content minmax(0, 1fr) minmax(0, 220px); column-gap: 16px; margin-top: 14px; }
.prow { display: contents; }
.prow > * { padding-block: 6px; }
.pkey { font-size: 15px; line-height: 32px; color: var(--on-deep-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pkey b { font-weight: 400; color: var(--on-deep); }
.pkey .req { color: var(--sand); }
.pval input { font-size: 17px; line-height: 24px; }
.pval input[readonly] { border-bottom-color: transparent; cursor: default; }
.pside { font-size: 13px; line-height: 18px; color: var(--on-deep-2); align-self: center; display: flex; gap: 6px; align-items: center; min-width: 0; }
.pside svg { flex: none; color: var(--on-deep-2); }
.pside .changed { color: var(--sand); overflow-wrap: anywhere; }
.prow.missing .pkey b { color: var(--sand); }
.prow.missing .pval input { border-bottom-color: var(--clay); }
.prow.extra { display: none; }
.params.show-extra .prow.extra { display: contents; }

.more-toggle { margin-top: 12px; font: inherit; font-size: 14px; color: var(--sand); background: none; border: 0; padding: 4px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.more-toggle:hover { color: var(--on-deep); }

.assembled { margin-top: 18px; font-size: 14px; line-height: 21px; color: var(--on-deep-2); word-break: break-all; font-variant-numeric: tabular-nums; }
.assembled:empty { display: none; }
.assembled .k { color: var(--sand); }
.assembled .v { color: var(--on-deep); }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 18px 32px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--deep-rule); }
.channel { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: 52ch; }
.channel-label { font-size: 13px; line-height: 18px; color: var(--on-deep-2); }
.channel strong { font-weight: 500; font-size: 28px; line-height: 34px; letter-spacing: -0.01em; }
.channel strong.warn { color: var(--sand); }
.channel-why { font-size: 14px; line-height: 20px; color: var(--on-deep-2); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.status { min-height: 20px; margin-top: 12px; font-size: 14px; line-height: 20px; color: var(--sand); }

/* ---------- Knöpfe ---------- */
.btn { font: inherit; font-size: 15px; font-weight: 500; line-height: 20px; padding: 11px 18px; border: 1px solid transparent; border-radius: 0; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), border-color 150ms var(--ease-out); }
.btn:disabled { cursor: not-allowed; opacity: .4; }
.btn svg { flex: none; }
.btn-primary { background: var(--on-deep); color: var(--ink-deep); }
.btn-primary:hover:not(:disabled) { background: var(--sand); }
.btn-outline { background: transparent; color: var(--on-deep); border-color: var(--on-deep-2); }
.btn-outline:hover:not(:disabled) { border-color: var(--on-deep); }
.btn-text { background: transparent; color: var(--sand); padding-inline: 6px; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; font-weight: 400; }
.btn-text:hover:not(:disabled) { color: var(--on-deep); }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover:not(:disabled) { background: var(--ink-deep); }
.btn-line { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 400; }
.btn-line:hover:not(:disabled) { border-color: var(--ink); }
.btn-danger { background: transparent; color: var(--terracotta); border-color: var(--terracotta); font-weight: 400; }
.btn-danger:hover:not(:disabled) { background: var(--terracotta); color: var(--paper); }
.btn-sm { font-size: 14px; padding: 6px 10px; }

/* ---------- Vorlagen-Band ---------- */
.tray { background: var(--sand); padding: 18px 32px 20px; display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px 16px; }
.tray-h { font-size: 15px; line-height: 32px; font-weight: 500; }
.presets { display: flex; flex-direction: column; gap: 10px; }
.pgroup { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 4px 12px; align-items: baseline; }
.pgroup > span { font-size: 13px; line-height: 32px; color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 14px; line-height: 20px; padding: 5px 11px; background: transparent; color: var(--ink); border: 1px solid rgba(43, 38, 32, .35); border-radius: 0; cursor: pointer; transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), border-color 150ms var(--ease-out); }
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink-deep); color: var(--on-deep); border-color: var(--ink-deep); }
.preset-note { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(43, 38, 32, .2); font-size: 14px; line-height: 21px; max-width: 75ch; }
.quiet { color: var(--ink-2); font-size: 14px; }

/* ---------- Prüfung und Regeln ---------- */
.below { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 48px; margin-top: 40px; }
.below h2 { font-size: 18px; line-height: 24px; font-weight: 500; padding-bottom: 10px; border-bottom: 1px solid var(--ink); }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--hair); font-size: 15px; line-height: 22px; }
.checks li::before { content: ""; width: 8px; height: 8px; margin-top: 7px; background: var(--line); }
.checks li.warn::before { background: var(--clay); }
.checks li.err { font-weight: 500; }
.checks li.err::before { background: var(--terracotta); width: 10px; height: 10px; margin-top: 6px; }
.checks li.ok::before { background: var(--ink); }
.rules > div { display: grid; grid-template-columns: minmax(0, 200px) minmax(0, 1fr); gap: 4px 20px; padding: 10px 0; border-bottom: 1px solid var(--hair); }
.rules dt { font-weight: 500; font-size: 15px; line-height: 22px; }
.rules dd { font-size: 15px; line-height: 22px; color: var(--ink-2); max-width: 62ch; }

/* ---------- Unterseiten ---------- */
.page-head { display: flex; flex-direction: column; gap: 6px; padding: 24px 0 20px; border-top: 1px solid var(--hair); }
.page-head h1 { font-size: 28px; line-height: 34px; font-weight: 500; letter-spacing: -0.01em; }
.lede { color: var(--ink-2); max-width: 65ch; }
.field-label { display: block; font-weight: 500; font-size: 15px; margin-bottom: 6px; }
.field-hint { font-size: 13px; line-height: 18px; color: var(--ink-2); margin-top: 4px; }
.form-msg { min-height: 20px; margin-top: 8px; font-size: 14px; color: var(--terracotta); }
.form-msg.ok { color: var(--ink); }

input.box, textarea.box, select.box, .login input {
  font: inherit; font-size: 15px; color: var(--ink); background: var(--field); width: 100%; min-width: 0;
  border: 1px solid var(--line); border-radius: 0; padding: 9px 11px;
}
input.box:hover, textarea.box:hover, select.box:hover, .login input:hover { border-color: var(--ink-2); }
input.box:focus, textarea.box:focus, select.box:focus, .login input:focus { outline: none; border-color: var(--terracotta); box-shadow: inset 0 0 0 1px var(--terracotta); }
textarea.box { min-height: 140px; line-height: 22px; resize: vertical; }
.login { max-width: 460px; }
.login-row { display: flex; gap: 8px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; }
.toolbar input { max-width: 380px; }
.count { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 20px; }
th { text-align: left; font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--ink); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--hair); vertical-align: top; }
td.url { word-break: break-all; min-width: 280px; }
td.num { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-2); }
td.act { white-space: nowrap; }
tbody tr:hover td { background: rgba(228, 216, 196, .35); }
.empty { padding: 28px 0; color: var(--ink-2); max-width: 60ch; }

.admin { display: grid; grid-template-columns: minmax(0, 250px) minmax(0, 1fr); gap: 40px; align-items: start; }
.plist { display: flex; flex-direction: column; border-top: 1px solid var(--ink); }
.plist button { font: inherit; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--hair); padding: 10px 6px; cursor: pointer; color: var(--ink); display: flex; flex-direction: column; gap: 1px; }
.plist button span { font-size: 13px; color: var(--ink-2); }
.plist button:hover { background: rgba(228, 216, 196, .35); }
.plist button[aria-current="true"] { background: var(--sand); }
.plist-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.form { display: flex; flex-direction: column; gap: 18px; }
.form h2 { font-size: 22px; line-height: 28px; font-weight: 500; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 120px); gap: 14px; }
.frows { border-top: 1px solid var(--ink); }
.frow { display: grid; grid-template-columns: minmax(0, 210px) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--hair); }
.frow .fname { font-size: 15px; }
.frow .fname code { display: block; width: fit-content; margin-top: 2px; font-size: 12px; background: none; padding: 0; color: var(--ink-2); }
.lock { display: flex; gap: 6px; align-items: center; font-size: 14px; white-space: nowrap; cursor: pointer; }
.lock input { width: 16px; height: 16px; }
.lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Schmal ---------- */
@media (max-width: 860px) {
  .below { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .admin { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .rules > div { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .piece { padding: 20px 18px 16px; margin-inline: -16px; }
  .tray { padding: 16px 18px; margin-inline: -16px; grid-template-columns: minmax(0, 1fr); }
  .target input { font-size: 19px; line-height: 26px; }
  .params { grid-template-columns: minmax(0, 1fr); }
  .prow > * { padding-block: 0; }
  .pkey { line-height: 20px; margin-top: 10px; }
  .pside:empty { display: none; }
  .pgroup { grid-template-columns: minmax(0, 1fr); }
  .pgroup > span { line-height: 18px; }
  .row2 { grid-template-columns: minmax(0, 1fr); }
  .frow { grid-template-columns: minmax(0, 1fr) auto; }
  .frow .fname { grid-column: 1 / -1; }
  .login-row { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
