:root {
  --outer: #cfcdc7;
  --paper: #f6f5f2;
  --tile: #e8e5df;
  --ink: #141414;
  --muted: #8b8881;
  --line: #dedbd5;
  --accent: #b8432a;
  --gutter: 20px;
  --pad: clamp(16px, 4vw, 56px);
  --fs: 12.5px;
  --fs-s: 10.5px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--outer);
  color: var(--ink);
  font: 400 var(--fs)/1.45 "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-feature-settings: "tnum" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- sheet ---------- */
.sheet {
  max-width: 1480px;
  min-height: calc(100vh - 2 * clamp(0px, 3vw, 48px));
  margin: clamp(0px, 3vw, 48px) auto;
  background: var(--paper);
  padding: var(--pad);
  display: flex;
  flex-direction: column;
}

.top {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: var(--gutter);
  align-items: start;
  margin-bottom: clamp(56px, 10vw, 140px);
}
.mark {
  grid-column: 1 / 3;
  display: grid;
  grid-template-columns: repeat(2, 11px);
  gap: 4px;
  width: max-content;
  text-decoration: none;
}
.mark span { width: 11px; height: 11px; border-radius: 50%; background: var(--ink); }
.site-title {
  grid-column: 7 / 11;
  margin: 0;
  font-size: var(--fs);
  font-weight: 500;
  letter-spacing: 0;
}
.top-meta { grid-column: 11 / 13; text-align: right; color: var(--muted); }

.adminbar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: calc(-1 * clamp(28px, 6vw, 90px)) 0 clamp(36px, 5vw, 64px);
}
.notice {
  margin: calc(-1 * clamp(28px, 6vw, 90px)) 0 clamp(36px, 5vw, 64px);
  color: var(--muted);
}

/* ---------- grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 28px var(--gutter);
}
.item {
  all: unset;
  display: block;
  cursor: pointer;
  min-width: 0;
}
.item:focus-visible .tile { outline: 1px solid var(--ink); outline-offset: 3px; }
.tile {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--tile);
  overflow: hidden;
}
.tile img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 14%;
  mix-blend-mode: multiply;
  transition: transform .8s var(--ease), opacity .4s var(--ease);
}
.item:hover .tile img { transform: scale(1.03); }
.tile .placeholder {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--muted); font-size: var(--fs-s);
  padding: 16%; text-align: center;
}
.tile .heart {
  position: absolute; top: 9px; right: 10px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}
.item.is-reserved .tile img { opacity: .28; }
.item.is-reserved .tile::after {
  content: "Reserviert";
  position: absolute; left: 10px; bottom: 9px;
  font-size: var(--fs-s); color: var(--ink);
}
.item.is-mine .tile::after { content: "Von dir reserviert"; }

.cap {
  display: grid;
  grid-template-columns: 34px 1fr;
  margin-top: 8px;
  font-size: var(--fs-s);
  line-height: 1.35;
}
.cap .n { color: var(--ink); }
.cap .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cap .p { grid-column: 2; color: var(--muted); }

.empty {
  grid-column: 1 / -1;
  color: var(--muted);
  padding: 80px 0;
}

/* ---------- lower ---------- */
.lower {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: var(--gutter);
  margin-top: clamp(80px, 12vw, 180px);
}
.intro {
  grid-column: 1 / 4;
  margin: 0;
  font-size: var(--fs-s);
  line-height: 1.55;
  max-width: 34ch;
  white-space: pre-line;
}
.index {
  grid-column: 5 / 13;
  list-style: none;
  margin: 0; padding: 0;
  columns: 4;
  column-gap: var(--gutter);
  font-size: var(--fs-s);
  line-height: 1.38;
}
.index li {
  break-inside: avoid;
  display: grid;
  grid-template-columns: 34px 1fr;
  margin-bottom: 14px;
}
.index li > span:first-child { grid-row: span 4; }
.index b { font-weight: 500; }
.index .m { color: var(--muted); }
.index .r { color: var(--accent); }
.index button { all: unset; cursor: pointer; }
.index button:hover b { text-decoration: underline; text-underline-offset: 2px; }

.foot {
  margin-top: auto;
  padding-top: clamp(56px, 8vw, 110px);
  display: flex; justify-content: space-between;
  color: var(--muted);
  font-size: var(--fs-s);
}

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; padding: 0 14px;
  border: 1px solid var(--ink);
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  font-size: var(--fs);
  text-decoration: none;
  transition: background .2s, color .2s, opacity .2s;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn-solid { background: var(--ink); color: var(--paper); }
.btn-solid:hover { opacity: .85; }
.btn-quiet { border-color: transparent; color: var(--muted); }
.btn-quiet:hover { background: transparent; color: var(--ink); }
.btn-danger { border-color: transparent; color: var(--accent); padding-left: 0; }
.btn-danger:hover { background: transparent; color: var(--accent); text-decoration: underline; }
.btn[disabled] { opacity: .4; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field > span { font-size: var(--fs-s); color: var(--muted); }
.field small { font-size: var(--fs-s); color: var(--muted); }
.field input, .field textarea, .editor-image input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 6px 0 8px;
  border-radius: 0;
  outline: none;
  transition: border-color .2s;
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .editor-image input:focus { border-bottom-color: var(--ink); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gutter); }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; min-width: 0; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { accent-color: var(--ink); }

/* ---------- dialogs ---------- */
.sheet-dialog {
  border: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  max-width: none; max-height: none;
}
.sheet-dialog::backdrop { background: rgba(40, 38, 34, .45); }
.sheet-dialog[open] { animation: rise .45s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.close {
  all: unset; cursor: pointer;
  font-size: var(--fs); color: var(--muted);
}
.close:hover { color: var(--ink); }

/* detail — split layout */
.detail {
  width: min(1240px, calc(100vw - 2 * clamp(0px, 3vw, 48px)));
  height: min(800px, calc(100dvh - 2 * clamp(0px, 3vw, 48px)));
}
.detail-inner { display: grid; grid-template-columns: 1fr 1fr; height: 100%; }
.detail-text {
  display: flex; flex-direction: column; justify-content: space-between;
  padding: var(--pad);
  min-height: 0; overflow: auto;
}
.detail-head { display: flex; justify-content: space-between; align-items: baseline; }
.detail-num { color: var(--muted); }
.detail-body { max-width: 380px; margin-left: auto; margin-right: 8%; padding-top: 48px; }
.detail-body h2 { font-size: 22px; line-height: 1.2; font-weight: 500; margin: 0 0 20px; letter-spacing: -.01em; }
.specs {
  display: grid; grid-template-columns: 64px 1fr;
  margin: 0 0 20px; font-size: var(--fs-s); row-gap: 2px;
}
.specs dt { color: var(--muted); }
.specs dd { margin: 0; }
.detail-note { font-size: var(--fs-s); line-height: 1.55; margin: 0 0 24px; white-space: pre-line; }
.detail-note:empty { display: none; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-status { font-size: var(--fs-s); color: var(--muted); margin: 14px 0 0; min-height: 1em; }
.detail-img { margin: 0; background: var(--tile); position: relative; overflow: hidden; }
.detail-img img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; padding: 12%;
  mix-blend-mode: multiply;
}

/* editor */
.editor { width: min(900px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
.settings { width: min(560px, calc(100vw - 32px)); }
.editor-inner { padding: clamp(20px, 4vw, 40px); }
.editor-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 32px; font-weight: 500;
}
.editor-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: clamp(20px, 4vw, 48px); }
.editor-image { display: flex; flex-direction: column; gap: 12px; }
.drop {
  position: relative; aspect-ratio: 4 / 5; background: var(--tile);
  display: grid; place-items: center; outline: none;
  transition: box-shadow .2s;
}
.drop.over, .drop:focus-visible { box-shadow: inset 0 0 0 1px var(--ink); }
.drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 12%; mix-blend-mode: multiply; }
.drop-hint { color: var(--muted); font-size: var(--fs-s); text-align: center; line-height: 1.5; }
.drop.busy::after {
  content: "Lädt …"; position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(232, 229, 223, .8); font-size: var(--fs-s);
}
.file-btn { cursor: pointer; }
.editor-foot {
  display: flex; align-items: center; gap: 12px;
  margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line);
}
.spacer { flex: 1; }
.form-error { color: var(--accent); font-size: var(--fs-s); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--ink); color: var(--paper);
  padding: 9px 16px; border-radius: 999px;
  font-size: var(--fs);
  opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .3s var(--ease);
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
  .index { columns: 3; }
}
@media (max-width: 860px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .intro { grid-column: 1 / -1; margin-bottom: 48px; }
  .index { grid-column: 1 / -1; columns: 2; }
  .site-title { grid-column: 4 / 10; }
  .top-meta { grid-column: 10 / 13; }
  .detail-inner { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .detail-img { order: -1; aspect-ratio: 1; }
  .detail-body { margin: 0; padding-top: 24px; max-width: none; }
  .detail { height: auto; max-height: calc(100dvh - 32px); overflow: auto; }
  .detail-text { overflow: visible; }
  .editor-cols { grid-template-columns: 1fr; }
  .editor-image { order: -1; }
  .drop { aspect-ratio: 16 / 10; }
}
@media (max-width: 560px) {
  :root { --gutter: 14px; }
  .sheet { margin: 0; min-height: 100vh; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 22px var(--gutter); }
  .top { grid-template-columns: auto 1fr auto; column-gap: 16px; }
  .mark, .site-title, .top-meta { grid-column: auto; }
  .index { columns: 1; }
  .detail { width: 100vw; max-height: 100dvh; height: 100dvh; }
  .editor, .settings { width: 100vw; max-height: 100dvh; height: 100dvh; }
  .field-pair { grid-template-columns: 1fr; gap: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
