:root {
  --bg: #f4f1ec;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --text: #1f1d1a;
  --muted: #6f6a62;
  --line: #e6e0d6;
  --accent: #2f6b4f;
  --accent-soft: #e3efe8;
  --closed: #a8452f;
  --closed-soft: #f6e5e0;
  --soon: #a86d12;
  --soon-soft: #f8eedb;
  --star: #e0a100;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 14px rgba(40, 30, 10, .06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #22201d;
    --surface-2: #2a2824;
    --text: #efebe4;
    --muted: #a39d93;
    --line: #36332e;
    --accent: #6cc39a;
    --accent-soft: #1f3a2d;
    --closed: #e58a72;
    --closed-soft: #3e2620;
    --soon: #e5b45c;
    --soon-soft: #3d3120;
    --star: #f2c14e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; touch-action: manipulation; }

/* ---------- Kopfbereich (bleibt beim Scrollen stehen) ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: var(--safe-top);
}
.top-inner, main, footer {
  max-width: 720px; margin: 0 auto;
  padding-left: max(16px, var(--safe-left));
  padding-right: max(16px, var(--safe-right));
}
.top-inner { padding-top: 14px; padding-bottom: 10px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font-size: 1.75rem; letter-spacing: -.02em; line-height: 1.15; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }

.refresh {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; min-width: 44px;
  border: 1px solid var(--line); background: var(--surface);
  padding: 9px 14px; border-radius: 999px; font-size: .9rem; cursor: pointer;
  box-shadow: var(--shadow);
}
.refresh svg { width: 18px; height: 18px; }
.refresh:disabled { opacity: .7; cursor: progress; }
.refresh.busy svg { animation: spin 1s linear infinite; }
@media (hover: hover) { .refresh:hover { border-color: var(--accent); color: var(--accent); } }
@keyframes spin { to { transform: rotate(360deg); } }

.search { position: relative; margin-top: 12px; }
.search svg { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; min-height: 46px; padding: 12px 14px 12px 44px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; /* ≥16px verhindert das Auto-Zoomen auf dem iPhone */
  box-shadow: var(--shadow); outline: none;
  -webkit-appearance: none; appearance: none;
}
.search input:focus { border-color: var(--accent); }

.filters {
  display: flex; gap: 8px; margin-top: 10px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  margin-left: -16px; margin-right: -16px; padding: 0 16px 2px;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 6px 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: .88rem; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .chip[aria-pressed="true"] { color: #10251b; } }
.chip-star { color: var(--star); }
.chip[aria-pressed="true"] .chip-star { color: inherit; }
.meta { margin-top: 8px; font-size: .78rem; color: var(--muted); }

main { padding-top: 4px; padding-bottom: 24px; }
.list { list-style: none; margin: 0; padding: 0; }
.letter {
  font-weight: 700; color: var(--accent); font-size: .85rem;
  padding: 14px 4px 6px; letter-spacing: .06em;
}

/* ---------- Flip-Kachel ---------- */
.card { perspective: 1200px; margin-bottom: 10px; }
.card-inner {
  position: relative;
  transform-style: preserve-3d; -webkit-transform-style: preserve-3d;
  transition: transform .6s cubic-bezier(.3, .7, .3, 1), height .4s ease;
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.card.flipped .card-inner { transform: rotateX(180deg); }
.face {
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 12px 8px 12px 14px;
}
/* Vorderseite im normalen Fluss → bestimmt die Kachelhöhe ohne JavaScript; Rückseite liegt darüber. */
.front { position: relative; }
.back {
  position: absolute; inset: 0 0 auto 0;
  transform: rotateX(180deg); background: var(--surface-2); padding: 14px 10px 14px 16px;
}
.card-inner:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 18px; }
.card-inner:active .front { transform: scale(.985); }
.front { display: flex; align-items: center; gap: 12px; transition: transform .12s; }
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
}
.front-text { flex: 1; min-width: 0; }
.name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  display: inline-block; margin-top: 5px;
  font-size: .72rem; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--line); color: var(--muted); white-space: nowrap;
}
.badge.open { background: var(--accent-soft); color: var(--accent); }
.badge.closed { background: var(--closed-soft); color: var(--closed); }
.badge.soon { background: var(--soon-soft); color: var(--soon); }

/* Stern: 44×44 Touch-Fläche nach Apple-Richtlinie */
.star {
  flex: none; width: 44px; height: 44px; border: 0; background: none; padding: 0;
  font-size: 1.55rem; line-height: 1; color: var(--muted); cursor: pointer; border-radius: 12px;
}
.star.active { color: var(--star); }
.star.pop { animation: pop .3s ease; }
@keyframes pop { 50% { transform: scale(1.35); } }

.back-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.back h3 { margin: 0 0 2px; font-size: 1.02rem; }
.back .status { font-size: .85rem; color: var(--muted); }
.back .status.open { color: var(--accent); }
.back .status.closed { color: var(--closed); }
.hours { width: calc(100% - 6px); border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
.hours td { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.hours tr:last-child td { border-bottom: none; }
.hours td:last-child { text-align: right; }
.hours tr.today td { font-weight: 700; color: var(--accent); }
.hours .closed-day { color: var(--muted); }
.raw { font-size: .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; white-space: pre-wrap; margin-right: 6px; }
.note { font-size: .8rem; color: var(--muted); margin-top: 8px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; margin-right: 6px; }
.action {
  flex: 1 1 0; min-width: 0; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 10px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text); text-decoration: none; font-size: .9rem; font-weight: 600; white-space: nowrap;
}
.action.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .action.primary { color: #10251b; } }
.action:active { opacity: .75; }

.message { text-align: center; color: var(--muted); padding: 48px 16px; }
footer {
  color: var(--muted); font-size: .75rem; text-align: center;
  padding-bottom: calc(24px + var(--safe-bottom));
}
footer a { color: inherit; }

@media (max-width: 480px) {
  .refresh span { display: none; }
  .refresh { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .card-inner, .front { transition: none; }
  .star.pop { animation: none; }
}
