/* ============================================================
   Teddy Retter – Gestaltung
   Farben, Schrift, Ecken und Kartenstil kommen aus dem
   Design-Center und werden zur Laufzeit als Variablen gesetzt.
   ============================================================ */

:root {
  --primary: #e0567f;
  --accent: #7c5cff;
  --bg: #fff6fa;

  --surface: #ffffff;
  --surface-2: #fdf1f6;
  --text: #2a1f27;
  --muted: #7b6a75;
  --border: rgba(42, 31, 39, 0.12);
  --shadow: 0 10px 30px rgba(180, 80, 120, 0.13);
  --shadow-sm: 0 3px 10px rgba(180, 80, 120, 0.1);
  --radius: 22px;
  --radius-sm: 14px;
  --btn-radius: 999px;
  --font: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", Quicksand, system-ui, sans-serif;
  --maxw: 1080px;
  --ok: #2e9e6b;
  --warn: #d98324;
  --danger: #d64545;
  --header-h: 60px;
}

[data-theme="dark"] {
  --bg: #17131a;
  --surface: #221c26;
  --surface-2: #2b2431;
  --text: #f4eef2;
  --muted: #b3a4b0;
  --border: rgba(255, 255, 255, 0.14);
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 3px 12px rgba(0, 0, 0, 0.35);
}

/* Kartenstile */
[data-cards="flat"] { --shadow: none; --shadow-sm: none; }
[data-cards="outline"] { --shadow: none; --shadow-sm: none; }
[data-cards="elevated"] { --shadow: 0 18px 44px rgba(120, 50, 90, 0.22); }

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  padding-bottom: env(safe-area-inset-bottom);
}

img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--surface); padding: .7rem 1rem; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ------------------------------------------------------------- Kopfbereich */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 1rem;
  padding: .55rem clamp(.8rem, 3vw, 1.6rem);
  padding-top: calc(.55rem + env(safe-area-inset-top));
  min-height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: inherit; min-width: 0; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 12px; object-fit: cover;
  background: var(--primary); display: grid; place-items: center; font-size: 1.3rem; flex: none;
}
.brand-text { min-width: 0; }
.brand-name { font-weight: 800; font-size: 1.05rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-slogan { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topnav { display: flex; gap: .15rem; margin-left: auto; flex-wrap: wrap; }
.topnav a {
  padding: .45rem .7rem; border-radius: var(--btn-radius); text-decoration: none;
  color: var(--muted); font-size: .9rem; font-weight: 600; white-space: nowrap;
}
.topnav a:hover { background: var(--surface-2); color: var(--text); }
.topnav a.active { background: var(--primary); color: #fff; }
.topbar-actions { display: flex; gap: .4rem; align-items: center; margin-left: auto; }
.topnav + .topbar-actions { margin-left: .4rem; }

@media (max-width: 900px) {
  .topnav { display: none; }
}

/* ------------------------------------------------------------------ Inhalt */

.view {
  max-width: var(--maxw); margin: 0 auto; padding: 1.1rem clamp(.8rem, 3vw, 1.6rem) 6.5rem;
  outline: none;
}
@media (min-width: 901px) { .view { padding-bottom: 3rem; } }

.page-head { margin: .3rem 0 1.2rem; }
.page-head h1 { font-size: clamp(1.5rem, 4.2vw, 2.1rem); margin: 0 0 .25rem; letter-spacing: -0.02em; }
.page-head p { margin: 0; color: var(--muted); }

.section { margin: 0 0 2.2rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.section-head h2 { font-size: 1.25rem; margin: 0; letter-spacing: -0.01em; }
.section-head a { font-size: .88rem; font-weight: 600; text-decoration: none; }

/* -------------------------------------------------------------------- Held */

.hero {
  background: linear-gradient(150deg, color-mix(in srgb, var(--primary) 22%, var(--surface)), var(--surface) 70%);
  border-radius: var(--radius); padding: clamp(1.3rem, 4vw, 2.6rem);
  box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 1.8rem;
  position: relative; overflow: hidden;
}
.hero h1 { font-size: clamp(1.7rem, 5.5vw, 2.7rem); margin: 0 0 .5rem; letter-spacing: -0.03em; line-height: 1.1; }
.hero p { color: var(--muted); margin: 0 0 1.2rem; max-width: 56ch; font-size: 1.02rem; }
.hero-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.hero-image { border-radius: var(--radius-sm); margin-top: 1.2rem; width: 100%; max-height: 320px; object-fit: cover; }
[data-layout="hero-center"] .hero { text-align: center; }
[data-layout="hero-center"] .hero p { margin-left: auto; margin-right: auto; }
[data-layout="hero-center"] .hero-actions { justify-content: center; }
[data-layout="hero-split"] .hero-inner { display: grid; gap: 1.4rem; align-items: center; }
@media (min-width: 760px) {
  [data-layout="hero-split"] .hero-inner { grid-template-columns: 1.1fr .9fr; }
  [data-layout="hero-split"] .hero-image { margin-top: 0; max-height: 260px; }
}
[data-layout="compact"] .hero { padding: 1.1rem 1.3rem; }
[data-layout="compact"] .hero h1 { font-size: clamp(1.4rem, 4vw, 1.9rem); }
[data-layout="compact"] .hero-image { display: none; }

/* ------------------------------------------------------------------ Karten */

.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  border: 1px solid var(--border); padding: 1.1rem; position: relative;
}
[data-cards="outline"] .card { border-width: 2px; }
[data-cards="flat"] .card { border-color: transparent; background: var(--surface-2); }

.card-link { text-decoration: none; color: inherit; display: block; transition: transform .16s ease, box-shadow .16s ease; }
.card-link:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-media { aspect-ratio: 4 / 3; width: 100%; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.card-media.placeholder { display: grid; place-items: center; font-size: 2.6rem; }
.card h3 { margin: .7rem 0 .3rem; font-size: 1.06rem; letter-spacing: -0.01em; }
.card p { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.45; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.stack { display: grid; gap: .8rem; }

/* --------------------------------------------------------------- Fortschritt */

.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: .7rem 0 .35rem; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .5s ease; }
.progress-label { display: flex; justify-content: space-between; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-label strong { color: var(--text); }

/* ------------------------------------------------------------------- Chips */

.badge {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 700;
  padding: .25rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.help_needed { background: #ffe5e5; color: #b02a2a; }
.badge.preparing { background: #fff2d6; color: #96601a; }
.badge.rescuing { background: #ffe2ef; color: #b8306d; }
.badge.rescued, .badge.done, .badge.adopted { background: #ddf6e8; color: #1f7a4f; }
.badge.in_care { background: #e6e2ff; color: #4c3ba6; }
.badge.planned { background: #e6efff; color: #2f5ba8; }
.badge.running { background: #ddf6e8; color: #1f7a4f; }
.badge.cancelled { background: #eceaec; color: #6c6470; }
.badge.active { background: #ddf6e8; color: #1f7a4f; }
.badge.paused { background: #eceaec; color: #6c6470; }
.badge.draft { background: #eceaec; color: #6c6470; }
[data-theme="dark"] .badge { filter: brightness(.85) saturate(1.2); }
.badge-featured { background: #fff0c2; color: #8a6300; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  padding: .35rem .75rem; border-radius: 999px; font-size: .84rem; font-weight: 600; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

/* --------------------------------------------------------------- Schaltflaechen */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .62rem 1.1rem; border-radius: var(--btn-radius); border: 1px solid transparent;
  background: var(--surface-2); color: var(--text); font-weight: 700; font-size: .94rem;
  cursor: pointer; text-decoration: none; transition: filter .15s ease, transform .1s ease;
  min-height: 42px;
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: scale(.98); }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn.accent { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: .38rem .75rem; font-size: .85rem; min-height: 34px; }
.btn.icon { padding: .45rem; width: 40px; min-height: 40px; border-radius: 50%; background: var(--surface-2); }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ------------------------------------------------------------------ Statistik */

.stats-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow-sm); text-align: center;
}
.stat-emoji { font-size: 1.6rem; }
.stat-value { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .84rem; font-weight: 600; }

/* -------------------------------------------------------------------- Formulare */

.field { display: grid; gap: .35rem; margin-bottom: .9rem; }
.field > label { font-weight: 700; font-size: .88rem; }
.field .hint { font-size: .8rem; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; padding: .62rem .8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.field-row { display: grid; gap: .9rem; grid-template-columns: 1fr; }
@media (min-width: 620px) { .field-row.two { grid-template-columns: 1fr 1fr; } .field-row.three { grid-template-columns: repeat(3, 1fr); } }
.switch { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--primary); }
.color-field { display: flex; align-items: center; gap: .6rem; }
.color-field input[type="color"] { width: 52px; height: 40px; padding: 2px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }

.image-picker { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.image-preview {
  width: 96px; height: 96px; border-radius: var(--radius-sm); object-fit: cover;
  border: 1px solid var(--border); background: var(--surface-2); display: grid; place-items: center; font-size: 1.8rem;
}

/* ------------------------------------------------------------------- Tabellen */

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .7rem .8rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
td.wrap { white-space: normal; min-width: 200px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------- Admin */

.admin-shell { display: grid; gap: 1.2rem; }
@media (min-width: 900px) { .admin-shell { grid-template-columns: 220px 1fr; align-items: start; } }
.admin-menu { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .4rem; }
@media (min-width: 900px) {
  .admin-menu { flex-direction: column; overflow: visible; position: sticky; top: calc(var(--header-h) + 1rem); }
}
.admin-menu a {
  padding: .55rem .8rem; border-radius: var(--radius-sm); text-decoration: none; color: var(--muted);
  font-weight: 600; font-size: .92rem; white-space: nowrap; border: 1px solid transparent;
}
.admin-menu a.active { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.admin-bar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.admin-bar .spacer { flex: 1; }
.list-item { display: flex; gap: .9rem; align-items: center; }
.list-item .thumb { width: 62px; height: 62px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-2); display: grid; place-items: center; font-size: 1.5rem; flex: none; }
.list-item .body { flex: 1; min-width: 0; }
.list-item .body h3 { margin: 0 0 .2rem; font-size: 1rem; }
.list-item .body p { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.list-item .actions { display: flex; gap: .35rem; flex: none; }

.sortable-list { display: grid; gap: .5rem; }
.sortable-row { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.sortable-row .grip { color: var(--muted); font-size: 1.1rem; }
.sortable-row .name { flex: 1; font-weight: 600; }

/* -------------------------------------------------------------- Rueckmeldungen */

.toasts { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 88px); transform: translateX(-50%); display: grid; gap: .5rem; z-index: 80; width: min(94vw, 460px); }
@media (min-width: 901px) { .toasts { bottom: 1.5rem; } }
.toast {
  padding: .8rem 1rem; border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); border: 1px solid var(--border); font-weight: 600; font-size: .92rem;
  display: flex; gap: .6rem; align-items: center; animation: pop .22s ease;
}
.toast.success { border-left: 5px solid var(--ok); }
.toast.error { border-left: 5px solid var(--danger); }
.toast.info { border-left: 5px solid var(--accent); }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } }

.offline-banner {
  position: sticky; top: 0; z-index: 40; text-align: center; padding: .5rem 1rem;
  background: #ffe8c2; color: #7a4d00; font-weight: 700; font-size: .88rem;
}
[data-theme="dark"] .offline-banner { background: #4a3612; color: #ffd89a; }

.empty { text-align: center; padding: 2.6rem 1rem; color: var(--muted); }
.empty .emoji { font-size: 2.8rem; display: block; margin-bottom: .5rem; }
.empty h3 { margin: 0 0 .3rem; color: var(--text); }

.error-box { padding: 1rem; border-radius: var(--radius-sm); background: #ffe9e9; color: #a12727; font-weight: 600; border: 1px solid #f3c6c6; }
[data-theme="dark"] .error-box { background: #3a1c1c; color: #ffb9b9; border-color: #5c2a2a; }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(255,255,255,.45); border-top-color: #fff; animation: spin .7s linear infinite; }
.spinner.dark { border-color: var(--border); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

.splash { display: grid; place-items: center; gap: .6rem; padding: 5rem 1rem; color: var(--muted); }
.splash-emoji { font-size: 3rem; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* -------------------------------------------------------------------- Dialog */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 10, 18, .5); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 1rem; z-index: 90; animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: var(--radius); padding: 1.3rem; width: min(680px, 100%);
  max-height: 88vh; overflow: auto; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.modal h2 { margin: 0 0 .3rem; font-size: 1.2rem; }
.modal .modal-sub { color: var(--muted); margin: 0 0 1rem; font-size: .9rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.1rem; }

/* ------------------------------------------------------------ Mobile Navigation */

.mobilenav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: space-around; gap: .1rem;
  padding: .4rem .3rem calc(.4rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(180%) blur(14px); border-top: 1px solid var(--border);
}
.mobilenav a {
  flex: 1; display: grid; justify-items: center; gap: .1rem; padding: .3rem .1rem;
  text-decoration: none; color: var(--muted); font-size: .66rem; font-weight: 700; border-radius: 12px;
}
.mobilenav a .ico { font-size: 1.25rem; line-height: 1; }
.mobilenav a.active { color: var(--primary); }
@media (min-width: 901px) { .mobilenav { display: none; } }

.footer {
  max-width: var(--maxw); margin: 0 auto; padding: 1.5rem clamp(.8rem, 3vw, 1.6rem) 6rem;
  color: var(--muted); font-size: .84rem; text-align: center; border-top: 1px solid var(--border);
}
@media (min-width: 901px) { .footer { padding-bottom: 2rem; } }
.footer a { color: var(--muted); }

.install-hint { display: flex; gap: .7rem; align-items: center; background: var(--surface); border: 1px dashed var(--primary); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1.2rem; }
.install-hint .txt { flex: 1; font-size: .9rem; }

.detail-hero { border-radius: var(--radius); width: 100%; max-height: 380px; object-fit: cover; margin-bottom: 1.2rem; background: var(--surface-2); }
.prose { line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.meta-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .86rem; margin-bottom: .8rem; }

.searchbar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.searchbar .input { flex: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
