:root {
  --bg: #f7f6f3;
  --card: #ffffff;
  --text: #1c1917;
  --muted: #6b6560;
  --line: #e6e2dc;
  --accent: #0d9488;
  --accent-soft: #ccfbf1;
  --danger: #b91c1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: calc(.75rem + env(safe-area-inset-top)) 1rem .75rem;
  background: rgba(247,246,243,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.25rem; }
.topbar h1 a { color: inherit; text-decoration: none; }
.topbar-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }

.container { max-width: 44rem; margin: 0 auto; padding: 1rem; }

.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .55rem .9rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; text-decoration: none; color: var(--text);
  font-size: .95rem; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { padding: .35rem .7rem; font-size: .85rem; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.active { background: var(--text); color: #fff; border-color: var(--text); }

.filters { display: flex; gap: .4rem; overflow-x: auto; padding: .25rem 0 .75rem; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }

.section-title { font-size: 1.05rem; color: var(--muted); font-weight: 600; margin: 1.25rem 0 .6rem; text-transform: uppercase; letter-spacing: .04em; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 1rem; overflow: hidden; scroll-margin-top: 5rem;
}
.card.past { opacity: .75; }
.card.sortable-ghost { opacity: .3; }
.card.sortable-chosen { box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.card-hero { aspect-ratio: 16 / 9; background: #ece9e3; }
.card-hero img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: .9rem 1rem 1rem; }
.card-head { display: flex; align-items: flex-start; gap: .6rem; }
.card-head h2 { font-size: 1.2rem; flex: 1; }
.drag-handle { color: var(--muted); cursor: grab; padding: .2rem .3rem; font-size: 1.2rem; line-height: 1; touch-action: none; user-select: none; -webkit-user-select: none; }
.date-line { margin: .3rem 0 .6rem; font-size: 1.02rem; display: flex; flex-wrap: wrap; gap: .3rem .6rem; align-items: baseline; }
.countdown { background: var(--accent-soft); color: #115e59; font-size: .8rem; padding: .1rem .5rem; border-radius: 999px; font-weight: 600; }
.countdown.today { background: #fef3c7; color: #92400e; }
.countdown.past { background: #e7e5e4; color: #57534e; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; letter-spacing: .02em; }
.badge.idee { background: #e7e5e4; color: #44403c; }
.badge.geplant { background: #dbeafe; color: #1e40af; }
.badge.fix { background: #dcfce7; color: #166534; }
.badge.abgesagt { background: #fee2e2; color: #991b1b; }

.meta { display: grid; grid-template-columns: auto 1fr; gap: .3rem .75rem; margin: .5rem 0; font-size: .95rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.description { white-space: pre-wrap; margin: .5rem 0; overflow-wrap: anywhere; }
.links { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.links a { font-size: .9rem; padding: .3rem .7rem; background: var(--accent-soft); border-radius: 999px; text-decoration: none; color: #115e59; }

.gallery { display: flex; gap: .4rem; overflow-x: auto; padding: .4rem 0; -webkit-overflow-scrolling: touch; }
.gallery a { flex: 0 0 auto; }
.gallery img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }

.rsvp { border-top: 1px solid var(--line); margin-top: .75rem; padding-top: .75rem; }
.rsvp-buttons { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .5rem; }
.rsvp-list { display: flex; flex-wrap: wrap; gap: .35rem; font-size: .85rem; }
.rsvp-list span { padding: .15rem .55rem; border-radius: 999px; background: #f1efeb; }
.rsvp-list span.ja { background: #dcfce7; color: #166534; }
.rsvp-list span.vielleicht { background: #fef3c7; color: #92400e; }
.rsvp-list span.nein { background: #fee2e2; color: #991b1b; }

.card-actions { display: flex; gap: .4rem; margin-top: .75rem; flex-wrap: wrap; }

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

/* Login */
.login { max-width: 22rem; margin: 3rem auto; background: var(--card); padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.login h2 { margin-bottom: .75rem; }

/* Forms */
.field { display: block; margin-bottom: .8rem; }
.field span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px;
}
.field textarea { min-height: 5rem; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.check { display: flex; align-items: center; gap: .5rem; margin: .6rem 0; }
.check input { width: 1.2rem; height: 1.2rem; }
.error { color: var(--danger); font-size: .9rem; margin: .4rem 0; }
.link-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: .4rem; margin-bottom: .4rem; }
.link-row input { min-width: 0; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; }
.image-admin { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.image-admin figure { margin: 0; position: relative; }
.image-admin img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; }
.image-admin button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: none; background: var(--danger); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--bg); width: 100%; max-width: 40rem; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.modal h2 { margin-bottom: 1rem; font-size: 1.2rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 18px; }
}

.subscriber-list { list-style: none; padding: 0; margin: .5rem 0; }
.subscriber-list li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; background: #f1efeb; padding: .4rem .6rem; border-radius: 8px; overflow-wrap: anywhere; user-select: all; }

.toast { position: fixed; left: 50%; bottom: calc(1.5rem + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: #fff; padding: .6rem 1rem; border-radius: 999px; font-size: .9rem; z-index: 30; box-shadow: var(--shadow); max-width: 90vw; text-align: center; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 40; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
