:root {
  --paper: #f6f2ea;
  --paper-2: #fbf9f4;
  --ink: #22201c;
  --ink-soft: #6b655c;
  --line: #ddd5c7;
  --accent: #b5462f;
  --shadow: 0 1px 0 rgba(34,32,28,.04), 0 10px 30px -18px rgba(34,32,28,.35);
  --radius: 14px;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, #fffdf8, transparent 60%),
    var(--paper);
  line-height: 1.5;
  min-height: 100vh;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(2.5rem, 8vw, 6rem) clamp(1.25rem, 5vw, 2rem) 5rem;
}

/* =========================================================
   Startseite: fixer Viewport, Logo oben links, Kacheln zentriert
   ========================================================= */
body.home {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  padding: clamp(1rem, 3vw, 2rem);
  gap: clamp(1rem, 3vw, 2rem);
}

/* Logo als schmale, um 90° gedrehte Spalte oben links (b oben, Punkt unten) */
.topbar {
  flex: none;
  position: relative;
  width: clamp(1.7rem, 3.5vw, 2.3rem);
}
.topbar .logo {
  position: absolute;
  top: 0;
  left: 1em;            /* schiebt das gedrehte Wort in die Spalte; = Schrifthöhe */
  margin: 0;
  white-space: nowrap;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-size: clamp(1.7rem, 3.5vw, 2.3rem);
  transform-origin: 0 0;  /* Drehung um obere linke Ecke → oberer = linker Abstand */
  transform: rotate(90deg);
}
.dot { color: var(--accent); }

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Kopf ---- */
.masthead { margin-bottom: clamp(2rem, 6vw, 3.5rem); }

.masthead h1 {
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(2.6rem, 9vw, 4.2rem);
  letter-spacing: -0.01em;
  margin: 0 0 .4rem;
  line-height: 1;
}
.masthead h1 .dot { color: var(--accent); }

/* Logo (Startseite): schlicht, Helvetica, Kleinbuchstaben */
.masthead h1.logo {
  font-weight: 700;
  letter-spacing: -0.03em;
}

.masthead p {
  margin: 0;
  color: var(--ink-soft);
  font-style: italic;
  font-family: var(--sans);
  font-size: clamp(1rem, 3.5vw, 1.2rem);
}

.rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.6rem 0 0;
  max-width: 3.5rem;
  border-color: var(--accent);
  opacity: .5;
}

/* ---- Kachel-Raster ----
   Kachelbreite (--tile-w) und Zeilenbreite (--row-w) berechnet JS so,
   dass alle Kacheln in den Viewport passen. Innenmasse skalieren mit --tile-w. */
.tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 16px;                 /* muss mit GAP im index.php-Script übereinstimmen */
  width: var(--row-w, auto);
  max-width: 100%;
}

.tile {
  --w: var(--tile-w, 240px);
  width: var(--w);
  aspect-ratio: 1 / 1.18;    /* muss mit R im index.php-Script übereinstimmen */
  display: flex;
  flex-direction: column;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.tile:hover,
.tile:focus-visible {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 1px 0 rgba(34,32,28,.04), 0 22px 44px -24px rgba(34,32,28,.5);
  outline: none;
}

.tile__img {
  flex: 0 0 56%;
  width: 100%;
  object-fit: cover;
  background: #eee7da;
  display: block;
  border-bottom: 1px solid var(--line);
}
.tile__img--empty {
  display: grid;
  place-items: center;
  font-family: var(--sans);
  font-size: calc(var(--w) * 0.28);
  color: var(--line);
}

.tile__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: calc(var(--w) * 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tile__title {
  font-family: var(--sans);
  font-weight: 700;
  font-size: calc(var(--w) * 0.108);
  line-height: 1.15;
  margin: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.tile__title .arrow {
  color: var(--accent);
  font-weight: 400;
  transition: transform .18s ease;
  display: inline-block;
}
.tile:hover .tile__title .arrow { transform: translate(2px, -2px); }

.tile__desc {
  margin: calc(var(--w) * 0.02) 0 0;
  color: var(--ink-soft);
  font-size: calc(var(--w) * 0.072);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.tile__host {
  margin: auto 0 0;
  padding-top: calc(var(--w) * 0.03);
  font-size: calc(var(--w) * 0.058);
  letter-spacing: .04em;
  text-transform: lowercase;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Leerzustand ---- */
.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-style: italic;
}

/* =========================================================
   /add – Formular
   ========================================================= */
.form-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 4vw, 2rem);
  box-shadow: var(--shadow);
  margin-bottom: 2.5rem;
}

.field { margin-bottom: 1.15rem; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: .82rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: .35rem;
}

.field input[type="text"],
.field input[type="url"],
.field textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .6rem .75rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(181,70,47,.14);
}
.field textarea { resize: vertical; min-height: 3.5rem; }

.field input[type="file"] {
  font: inherit;
  font-size: .9rem;
  color: var(--ink-soft);
}

.btn {
  font: inherit;
  font-family: var(--sans);
  font-size: 1.05rem;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: .55rem 1.4rem;
  transition: background .15s ease, transform .1s ease;
}
.btn:hover { background: #9c3a26; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }

.notice {
  border-radius: 10px;
  padding: .7rem 1rem;
  margin-bottom: 1.5rem;
  font-size: .95rem;
  border: 1px solid;
}
.notice--ok  { background: #eef5ec; border-color: #bcd8b4; color: #3c5a34; }
.notice--err { background: #fbecea; border-color: #e6b7ae; color: #8a3322; }

/* Bestehende Links auf /add */
.manage-title {
  font-family: var(--sans);
  font-size: 1.4rem;
  margin: 0 0 1rem;
}
.manage-list { list-style: none; margin: 0; padding: 0; }
.manage-item {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .7rem 0;
  border-bottom: 1px solid var(--line);
}
.manage-item:last-child { border-bottom: 0; }
.manage-thumb {
  width: 48px; height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: #eee7da;
  flex: none;
  border: 1px solid var(--line);
}
.manage-meta { flex: 1 1 auto; min-width: 0; }
.manage-meta strong { font-family: var(--sans); font-weight: 400; font-size: 1.05rem; }
.manage-meta span {
  display: block;
  color: var(--ink-soft);
  font-size: .8rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-del {
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  border-radius: 8px;
  padding: .35rem .7rem;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-del:hover { border-color: var(--accent); color: var(--accent); background: #fbecea; }
.btn-del:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--accent);
  text-decoration: none;
  font-size: .9rem;
}
.back-link:hover, .back-link:focus-visible { text-decoration: underline; }
