/* Angelehnt an die Apple Human Interface Guidelines (iOS):
   Systemschrift, Systemfarben, große Titel, gruppierte Listen, Tab-Bar, 44-pt-Tippflächen. */
:root {
  --bg: #f2f2f7;              /* systemGroupedBackground */
  --cell: #ffffff;            /* secondarySystemGroupedBackground */
  --fill: rgba(118,118,128,.12); /* tertiarySystemFill */
  --label: #000000;
  --label2: #6c6c70;          /* secondaryLabel, erhöhter Kontrast (≥ 4,5:1) */
  --label3: rgba(60,60,67,.3);
  --sep: rgba(60,60,67,.29);
  --tint: #0066d6;            /* systemBlue, erhöhter Kontrast: 5,4:1 auf Weiß */
  --tint-fill: #0066d6;       /* Hintergrund gefüllter Buttons (weiße Schrift 5,4:1) */
  --red: #d70015;             /* systemRed, erhöhter Kontrast */
  --green: #248a3d;
  --tab-off: #6e6e73;
  --bar: rgba(249,249,249,.94);
  --tab-h: 49px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --cell: #1c1c1e;
    --fill: rgba(118,118,128,.24);
    --label: #ffffff;
    --label2: rgba(235,235,245,.6);
    --label3: rgba(235,235,245,.3);
    --sep: rgba(84,84,88,.65);
    --tint: #0a84ff;          /* 5,8:1 auf Schwarz */
    --tint-fill: #0071e3;     /* weiße Schrift 4,7:1 */
    --red: #ff453a;
    --green: #248a3d;
    --tab-off: #8e8e93;
    --bar: rgba(22,22,22,.94);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--label);
  font: 17px/1.29 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  letter-spacing: -0.41px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { -webkit-appearance: none; appearance: none; }
a { color: inherit; }

/* ---------- Navigationsleiste ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
}
.nav.scrolled { background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); box-shadow: 0 .5px 0 var(--sep); }
.nav-bar { height: 44px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 8px; }
.nav-title { font-weight: 600; text-align: center; opacity: 0; transition: opacity .15s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.nav.compact .nav-title, .nav.scrolled .nav-title { opacity: 1; }
.nav-btn { background: none; border: 0; color: var(--tint); padding: 0 8px; min-height: 44px; cursor: pointer; display: inline-flex; align-items: center; gap: 2px; }
.nav-btn.left { justify-self: start; }
.nav-btn.right { justify-self: end; font-weight: 600; }
.nav-btn:disabled { color: var(--label3); }
.nav-btn .chev { font-size: 28px; line-height: 1; margin-top: -3px; font-weight: 400; }
.large-title { margin: 0; padding: 0 16px 8px; font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: .37px; }
.nav.compact .large-title { display: none; }

main { max-width: 720px; margin: 0 auto; }

/* ---------- Tab-Bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -.5px 0 var(--sep);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; text-decoration: none; color: var(--tab-off); font-size: 10px; font-weight: 500; letter-spacing: .1px; }
.tabbar svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--tint); }

/* ---------- Kategorie-Filter ---------- */
.filter { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 12px; scrollbar-width: none; }
.filter::-webkit-scrollbar { display: none; }
.pill { position: relative; flex: none; border: 0; background: var(--fill); color: var(--label); border-radius: 999px; padding: 7px 14px; font-size: 15px; cursor: pointer; white-space: nowrap; }
.pill::after { content: ""; position: absolute; inset: -5px -4px; } /* Tippfläche ≥ 44 pt */
.pill.on { background: var(--tint-fill); color: #fff; }

/* ---------- Foto-Raster ---------- */
.section-h { display: flex; justify-content: space-between; padding: 14px 16px 6px; font-size: 20px; font-weight: 600; letter-spacing: .38px; }
.section-h small { font-size: 15px; font-weight: 400; color: var(--label2); letter-spacing: -.24px; align-self: flex-end; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 0 16px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(5, 1fr); } }
.tile { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--fill); display: block; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--label3); font-size: 13px; }
.tile.out { opacity: .4; }
.tile .worn { position: absolute; right: 5px; top: 5px; width: 20px; height: 20px; border-radius: 50%; background: var(--green); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 1.5px rgba(255,255,255,.9); }

.empty { text-align: center; color: var(--label2); padding: 80px 32px; }
.empty h2 { color: var(--label); font-size: 22px; margin: 0 0 6px; font-weight: 700; }
.empty p { margin: 0 0 24px; font-size: 15px; }

/* ---------- Gruppierte Listen ---------- */
.group-h { padding: 22px 32px 7px; font-size: 13px; color: var(--label2); text-transform: uppercase; letter-spacing: -.08px; }
.group-f { padding: 7px 32px 0; font-size: 13px; color: var(--label2); letter-spacing: -.08px; }
.group { margin: 0 16px; background: var(--cell); border-radius: 10px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 16px; position: relative; width: 100%; background: none; border: 0; text-align: left; text-decoration: none; color: var(--label); cursor: pointer; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: .5px; background: var(--sep); }
.row.with-img + .row.with-img::before { left: 72px; }
.row .t { flex: 1; min-width: 0; padding: 11px 0; }
.row .t small { display: block; color: var(--label2); font-size: 15px; }
.row .v { color: var(--label2); }
.row .chev::after { content: "›"; color: var(--label3); font-size: 22px; line-height: 1; }
.row img, .row .ph { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--fill); flex: none; margin: 6px 0; }
.row.tint { color: var(--tint); }
.row.danger { color: var(--red); }
.row:active { background: var(--fill); }

/* ---------- Buttons ---------- */
.btn-filled, .btn-tinted { display: block; width: calc(100% - 32px); margin: 0 16px; min-height: 50px; border: 0; border-radius: 12px; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center; line-height: 50px; }
.btn-filled { background: var(--tint-fill); color: #fff; }
.btn-tinted { background: color-mix(in srgb, var(--tint) 15%, transparent); color: var(--tint); }
.btn-filled:active, .btn-tinted:active { opacity: .7; }

/* ---------- Detail ---------- */
.hero { margin: 0 16px 16px; border-radius: 12px; overflow: hidden; background: var(--cell); aspect-ratio: 1; }
.hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero .noimg { height: 100%; display: grid; place-items: center; color: var(--label3); }
.subline { padding: 0 16px 16px; color: var(--label2); font-size: 15px; }

/* ---------- Formular ---------- */
.photo-pick { position: relative; display: grid; place-items: center; margin: 8px 16px 0; aspect-ratio: 1; border-radius: 12px; background: var(--cell); color: var(--tint); overflow: hidden; cursor: pointer; }
.photo-pick img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick .hint { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 17px; }
.photo-pick .hint svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 16px; }
.cat { min-height: 44px; border: 0; border-radius: 10px; background: var(--cell); color: var(--label); font-size: 15px; cursor: pointer; padding: 6px; }
.cat.on { background: var(--tint-fill); color: #fff; font-weight: 600; }

/* ---------- Anmeldung ---------- */
.field { display: block; width: 100%; border: 0; background: none; padding: 11px 16px; min-height: 44px; outline: none; }
.err { color: var(--red); font-size: 13px; padding: 8px 32px 0; min-height: 1.4em; }

/* ---------- Outfits ---------- */
.ogrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 4px 16px 0; }
@media (min-width: 600px) { .ogrid { grid-template-columns: repeat(3, 1fr); } }
.ocard { background: var(--cell); border-radius: 12px; overflow: hidden; text-decoration: none; color: var(--label); display: block; }
.collage { aspect-ratio: 1; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 2px; background: var(--cell); }
.collage.n1 { grid-template-columns: 1fr; }
.collage img, .collage .noimg { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--fill); }
.collage.n3 > :first-child { grid-row: span 2; }
.ocard .meta { padding: 8px 12px 10px; }
.ocard .nm { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ocard .sub { font-size: 13px; color: var(--label2); }
.nav-btn.plus { font-size: 30px; font-weight: 400; line-height: 1; min-width: 44px; justify-content: center; }

/* Auswahl im Outfit-Editor (wie in der Fotos-App) */
button.tile { border: 0; padding: 0; cursor: pointer; width: 100%; }
.tile .check { position: absolute; right: 6px; bottom: 6px; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid #fff; background: rgba(0,0,0,.15); box-shadow: 0 0 2px rgba(0,0,0,.3); display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 700; }
.tile.sel .check { background: var(--tint-fill); }
.tile.sel img { opacity: .75; }
.strip { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px; min-height: 64px; align-items: center; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.strip button { flex: none; width: 56px; height: 56px; border: 0; padding: 0; border-radius: 8px; overflow: hidden; background: var(--fill); cursor: pointer; position: relative; }
.strip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip .x { position: absolute; right: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; line-height: 18px; text-align: center; }
.strip .hint { color: var(--label2); font-size: 15px; }

/* ---------- Übergänge (kurz, abschaltbar über „Bewegung reduzieren“) ---------- */
@keyframes push { from { transform: translateX(32px); opacity: 0; } }
@keyframes pop  { from { transform: translateX(-32px); opacity: 0; } }
@keyframes sheet { from { transform: translateY(48px); opacity: 0; } }
main.push  { animation: push .22s ease-out; }
main.pop   { animation: pop .22s ease-out; }
main.sheet { animation: sheet .28s cubic-bezier(.2,.8,.2,1); }
@media (prefers-reduced-motion: reduce) { main.push, main.pop, main.sheet { animation: none; } }

/* ---------- Hinweis ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  transform: translate(-50%, 12px); opacity: 0; transition: .25s; pointer-events: none; z-index: 20;
  background: var(--bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  color: var(--label); padding: 10px 18px; border-radius: 999px; font-size: 15px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
