:root {
  --paper: #f3efe6;
  --ink: #1b1b1b;
  --muted: #6e675c;
  --line: #e4d9c6;
  --card: #fffcf7;
  --gold: #9a8458;
  --gold-soft: #f4ead6;
  --danger: #8d2f2f;
  --ok: #1d6b45;
  --shadow: 0 10px 30px rgba(40, 32, 16, 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overflow-x: clip;
}

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

button { cursor: pointer; }

img { max-width: 100%; }

.boot { padding: 3rem 1.2rem; text-align: center; color: var(--muted); }

.shell { max-width: 860px; margin: 0 auto; padding: 0 1rem 2rem; }

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding: calc(0.55rem + env(safe-area-inset-top)) 0 0.55rem;
  background: rgba(243, 239, 230, 0.94);
  backdrop-filter: blur(8px);
}

.top.test {
  padding-top: 0;
  gap: 0.25rem;
}

.test-banner {
  margin: 0 -1rem 0;
  padding: 0.28rem 0.75rem;
  padding-top: calc(0.28rem + env(safe-area-inset-top));
  background: #ffe14a;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.86rem;
  line-height: 1.2;
  text-align: center;
}

.top-tools {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
}

.top-icons {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
  flex: 0 0 auto;
}

.logo-home {
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 0;
  flex: 0 0 auto;
}

.top img.mark { width: 58px; height: auto; background: white; border-radius: 6px; display: block; }

.top-title { min-width: 0; }

.top-title h1,
.top-title p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn.on { border-color: var(--ink); background: var(--gold-soft); }

.top h1 { font-size: 1.15rem; margin: 0; font-weight: 650; letter-spacing: 0.01em; }

.top p { margin: 0; color: var(--muted); font-size: 0.85rem; }

.top .grow { flex: 1; min-width: 0; }

.top button.link, button.link {
  background: none;
  border: 0;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0.4rem;
}

.icon-btn {
  position: relative;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.icon-btn svg { width: 22px; height: 22px; display: block; }

.fold {
  border: 1px solid var(--line);
  border-radius: 16px;
  margin: 0 0 1rem;
  background: rgba(255, 252, 247, 0.45);
}

.fold > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 52px;
  padding: 0.75rem 1rem;
  font-weight: 650;
}

.fold > summary::-webkit-details-marker { display: none; }

.fold > summary::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  margin-left: auto;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
}

.fold[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }

.fold-count {
  min-width: 1.4rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #5c4a28;
  font-size: 0.78rem;
  text-align: center;
}

.fold-body { padding: 0 0.75rem 0.85rem; }

.fold .fold {
  margin: 0 0 0.55rem;
  background: var(--card);
}

.pw-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.6rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.pw-line .ghost { margin: 0; white-space: nowrap; }
.pw-line label { margin: 0; }

.icon-btn .count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 0.68rem;
  line-height: 1.15rem;
  text-align: center;
}

.save-state {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
  text-align: right;
}

.lead { margin: 0.2rem 0 1rem; color: var(--muted); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-bottom: 1.2rem; }

.actions button, .primary, .ghost, .danger {
  min-height: 52px;
  border-radius: 14px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--ink);
}

.primary, .actions button.solid {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.ghost { background: var(--card); }

.danger { background: white; color: var(--danger); border-color: #e4c4c4; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.8rem;
}

.card h2, .block h2 { font-size: 1rem; margin: 0 0 0.35rem; }

.row-between, .list-card, .key-row, .check, .person-line {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.list-card {
  justify-content: space-between;
  align-items: stretch;
  text-align: left;
  width: 100%;
}

.list-card button.open {
  flex: 1;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
}

.card-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.75rem;
  background: var(--gold-soft);
  color: #5c4a28;
}

.badge.entwurf { background: #ece7dc; color: var(--muted); }
.badge.bereit { background: var(--ink); color: white; }
.badge.gesendet { background: #e5f2ea; color: var(--ok); }
.sent-stamp { margin: 0.2rem 0 0; font-weight: 650; color: var(--ok); }

.filters { display: flex; gap: 0.4rem; margin: 0.4rem 0 0.8rem; }

.filters button, .chip, .yn button, .choice {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  min-height: 40px;
  padding: 0.35rem 0.8rem;
}

.filters button.on, .chip.on, .yn button.on, .choice.on {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.chip .n {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  min-width: 1.2rem;
  margin: 0;
  font-size: 0.78rem;
  text-align: center;
}

.steps {
  display: flex;
  gap: 0.35rem;
  margin: 0.2rem 0 0.8rem;
  overflow-x: auto;
  max-width: 100%;
}

.steps button {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  padding: 0;
}

.steps button.on { background: var(--gold); color: white; border-color: var(--gold); }
.steps button.done { border-color: var(--ink); }

.step-title { margin: 0 0 0.8rem; font-size: 1.35rem; }

label, .field { display: block; margin: 0 0 0.75rem; font-size: 0.92rem; }

input, select, textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 0.28rem;
  padding: 0.75rem 0.8rem;
  border-radius: 12px;
  border: 1px solid #ddd4c4;
  background: white;
  font-size: 16px;
}

/* iOS sizes a filled date to the written-out date and an empty one to the placeholder. */
.date-field {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.date-field > span {
  position: relative;
  display: flex;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.date-field > span::after {
  content: "";
  position: absolute;
  right: 0.8rem;
  top: 50%;
  width: 1.15rem;
  height: 1.15rem;
  transform: translateY(-50%);
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231b1b1b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='5' width='17' height='15.5' rx='2'/%3E%3Cpath d='M3.5 10h17M8 3.5v3M16 3.5v3'/%3E%3C/svg%3E") center / contain no-repeat;
}

input[type="date"] {
  flex: 1 1 auto;
  display: block;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  -webkit-min-logical-width: 100%;
  min-height: 3rem;
  overflow: hidden;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  padding-right: 2.4rem;
}

input[type="date"]::-webkit-date-and-time-value {
  margin: 0;
  min-width: 100%;
  min-height: 1.45em;
  text-align: left;
}

input[type="date"]::-webkit-datetime-edit,
input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  width: 100%;
  min-width: 100%;
  padding: 0;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0;
  width: 1.6rem;
  height: 1.6rem;
  margin: 0;
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"],
input[type="file"] {
  width: 1.15rem;
  height: 1.15rem;
  min-width: 1.15rem;
  max-width: none;
  margin: 0.2rem 0.55rem 0 0;
  padding: 0;
  vertical-align: top;
}

label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
  display: flex;
  align-items: flex-start;
}

textarea { min-height: 120px; resize: vertical; }

.hv-pick {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  margin: 0 0 0.35rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}
.hv-pick:has(input:checked) {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.hv-pick:has(input:checked) .hint { color: #efe8dc; }
.hv-pick:has(input:disabled) { opacity: 0.45; }
.wide-btn { width: 100%; margin-bottom: 0.7rem; }
.schaden-block { padding: 0.2rem 0 0.75rem; border-bottom: 1px solid var(--line); }
.schaden-block .check { border-bottom: 0; }
.schaden-block textarea { min-height: 76px; }

.choices { display: grid; gap: 0.6rem; }

.choice {
  border-radius: 16px;
  text-align: left;
  min-height: 72px;
  padding: 0.9rem 1rem;
  width: 100%;
}

.choice strong { display: block; font-size: 1.05rem; }
.choice span { color: var(--muted); font-size: 0.9rem; }
.choice.on span { color: #efe8dc; }

.hint { color: var(--muted); font-size: 0.92rem; margin-top: 0; }
.legend { display: grid; gap: 0.35rem; margin: 0.7rem 0 0; }
.legend div { display: grid; grid-template-columns: 6.2rem 1fr; gap: 0.6rem; align-items: baseline; }
.legend dt { margin: 0; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.82rem; color: var(--ink); }
.legend dd { margin: 0; color: var(--muted); font-size: 0.9rem; }

.chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0.4rem 0 0.8rem;
}

.chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 0.55rem 1.6rem;
  text-align: center;
  line-height: 1.2;
  border-radius: 12px;
}

.pick {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}

.pick span { min-width: 0; }

.pick input { margin-top: 0.2rem; }

.check {
  justify-content: space-between;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.check p { margin: 0; flex: 1; }

.yn { display: flex; gap: 0.35rem; }

.yn button { min-width: 64px; }

.key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 5.2rem 44px;
  gap: 0.6rem;
  align-items: end;
}
.key-row .field { min-width: 0; margin: 0; }

.icon-x {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  margin-bottom: 2px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.6rem;
}
.grid-2 > * { min-width: 0; }

.own-thing {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: end;
}
.own-thing .field { margin: 0; min-width: 0; }

.foto-block { margin-top: 0.8rem; }
.thumbs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
.thumb { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 0.4rem; }
.thumb img { width: 100%; height: 140px; object-fit: cover; border-radius: 8px; display: block; }
.thumb input { margin-top: 0.35rem; }

.pad-wrap { margin-bottom: 1rem; }
canvas.pad {
  width: 100%;
  height: 190px;
  background: white;
  border: 1px dashed #c9bfae;
  border-radius: 14px;
  touch-action: none;
  display: block;
}
.sig-state { color: var(--ok); font-size: 0.85rem; min-height: 1.2rem; }

.dock {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 0.6rem;
  padding: 0.7rem 0 calc(0.7rem + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--paper) 20%);
}

.dock button { flex: 1; }

.summary { margin: 0; padding-left: 1.1rem; }
.summary li { margin: 0.2rem 0; }
.missing { background: #f8efe8; border-radius: 12px; padding: 0.7rem 0.9rem; }
.missing strong { color: var(--danger); }

.made {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  margin: 1.4rem 0 0.4rem;
}
.made .heart { color: #c0392b; }
.made img { height: 16px; width: auto; }

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  transform: translateX(-50%);
  top: calc(10px + env(safe-area-inset-top));
  width: min(520px, calc(100% - 1.5rem));
  background: var(--ink);
  color: white;
  border-radius: 14px;
  padding: 0.8rem 1rem;
  box-shadow: var(--shadow);
}

.gate-body { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
body.gate-body.testmodus {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0 1.2rem 2rem;
}
body.gate-body.testmodus .test-banner {
  width: 100vw;
  margin: 0 0 1.2rem;
  padding: 0.28rem 0.75rem;
  padding-top: calc(0.28rem + env(safe-area-inset-top));
}
.gate { width: min(440px, 100%); }
.gate .logo { width: 140px; background: white; border-radius: 10px; }
.gate h1 { margin: 0.8rem 0 0.3rem; }
.warn { color: var(--danger); }

.person-line { justify-content: space-between; margin-bottom: 0.55rem; }
.stack { display: grid; gap: 0.7rem; }

@media (max-width: 640px) {
  .actions { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .key-row { grid-template-columns: minmax(0, 1fr) 5.2rem 44px; }
  .key-row .field:first-child { grid-column: 1 / -1; }
  .check { flex-wrap: wrap; align-items: flex-start; }
  .check p { flex: 1 0 100%; }
  .yn { margin-left: auto; }
  .own-thing { grid-template-columns: minmax(0, 1fr); }
  .pw-line { grid-template-columns: auto minmax(0, 1fr); }
  .own-thing .primary { width: 100%; }
  .list-card { flex-wrap: wrap; }
  .list-card button.open { flex: 1 0 100%; }
}

@media (min-width: 800px) {
  .thumbs { grid-template-columns: repeat(3, 1fr); }
  .choices.two { grid-template-columns: 1fr 1fr; }
  .chips { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
