/* Fotothek – Oberfläche. Mobil zuerst, Systemschrift, iOS-Systemfarben. */

:root {
    --bg: #ffffff;
    --text: #000000;
    --text2: rgba(60, 60, 67, 0.6);
    --text3: rgba(60, 60, 67, 0.4);
    --fill: #f2f2f7;
    --fill2: #e5e5ea;
    --line: rgba(60, 60, 67, 0.2);
    --line-fein: rgba(60, 60, 67, 0.14);
    --akzent: #007aff;
    --gefahr: #ff3b30;
    --leiste: rgba(249, 249, 249, 0.94);
    --kachel: #e9e9ee;
    --flaeche: #ffffff;
    --radius: 12px;
    --oben: env(safe-area-inset-top, 0px);
    --unten: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --text: #ffffff;
        --text2: rgba(235, 235, 245, 0.6);
        --text3: rgba(235, 235, 245, 0.35);
        --fill: #1c1c1e;
        --fill2: #2c2c2e;
        --line: rgba(235, 235, 245, 0.18);
        --line-fein: rgba(235, 235, 245, 0.12);
        --akzent: #0a84ff;
        --gefahr: #ff453a;
        --leiste: rgba(22, 22, 24, 0.94);
        --kachel: #1c1c1e;
        --flaeche: #1c1c1e;
    }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    height: 100%;
    overscroll-behavior-y: none;
}

body {
    background: var(--bg);
    color: var(--text);
    font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--akzent); text-decoration: none; }

/* ---------------------------------------------------------- Grundgerüst */

#app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

.blatt {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-top: var(--oben);
}

.kopf {
    padding: 14px 16px 8px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.kopf h1 {
    margin: 0;
    font-size: 34px;
    line-height: 41px;
    font-weight: 700;
    letter-spacing: -0.4px;
}

.kopf-zeile {
    padding: 0 16px 10px;
    font-size: 13px;
    color: var(--text2);
}

.text-knopf {
    border: 0;
    background: transparent;
    color: var(--akzent);
    font-size: 17px;
    padding: 0 0 6px;
    min-height: 44px;
}

/* ------------------------------------------------------------ Reiter */

.reiter {
    display: flex;
    border-top: 0.5px solid var(--line);
    background: var(--leiste);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    padding: 8px 0 calc(8px + var(--unten));
    flex-shrink: 0;
}

.reiter button {
    flex-grow: 1;
    border: 0;
    background: transparent;
    color: var(--text2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-height: 44px;
    padding: 0;
}

.reiter button[aria-current="page"] { color: var(--akzent); }
.reiter span { font-size: 10px; font-weight: 500; }

/* ------------------------------------------------------ Segmentwähler */

.segmente {
    display: flex;
    margin: 0 16px 12px;
    background: var(--fill);
    border-radius: 9px;
    padding: 2px;
    gap: 2px;
}

.segmente button {
    flex-grow: 1;
    border: 0;
    background: transparent;
    color: var(--text);
    border-radius: 7px;
    padding: 7px 8px;
    min-height: 34px;
    font-size: 13px;
    white-space: nowrap;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.segmente button[aria-selected="true"] {
    background: var(--bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
    .segmente button[aria-selected="true"] {
        background: #636366;
        box-shadow: none;
    }
}

.segmente .anzahl { color: var(--text2); font-weight: 400; font-size: 11px; }
.segmente button[aria-selected="true"] .anzahl { color: var(--text2); }

/* ----------------------------------------------------------- Zeitleiste */

.monat {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 16px;
    background: var(--bg);
    border-top: 0.5px solid var(--line-fein);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.monat b { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.monat span { font-size: 13px; color: var(--text2); }

.raster {
    display: grid;
    grid-template-columns: repeat(var(--spalten, 3), minmax(0, 1fr));
    gap: 2px;
}

.kachel {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--kachel);
    border: 0;
    padding: 0;
    overflow: hidden;
    display: block;
}

.kachel img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.kachel img.da { opacity: 1; }

.kachel .dauer {
    position: absolute;
    right: 5px;
    bottom: 5px;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    gap: 3px;
}

.kachel .stern {
    position: absolute;
    right: 5px;
    top: 5px;
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.45));
}

.kachel[aria-selected="true"]::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 3px solid var(--akzent);
    background: rgba(0, 122, 255, 0.18);
}

/* ------------------------------------------------------------ Vollbild */

.vollbild {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}

.vollbild-kopf {
    padding: calc(10px + var(--oben)) 8px 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.vollbild-titel { flex-grow: 1; text-align: center; }
.vollbild-titel b { display: block; font-size: 15px; font-weight: 600; }
.vollbild-titel span { display: block; font-size: 12px; color: var(--text2); margin-top: 1px; }

.vollbild-buehne {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--fill);
    overflow: hidden;
    touch-action: pan-y;
}

@media (prefers-color-scheme: dark) {
    .vollbild-buehne { background: #000; }
}

.vollbild-buehne img,
.vollbild-buehne video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.vollbild-fuss {
    padding: 12px 24px calc(14px + var(--unten));
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 0.5px solid var(--line-fein);
    flex-shrink: 0;
}

.icon-knopf {
    width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
    color: var(--akzent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-knopf.gefahr { color: var(--gefahr); }
.icon-knopf[aria-pressed="true"] svg { fill: currentColor; }

.angaben {
    padding: 8px 16px 0;
    font-size: 12px;
    color: var(--text2);
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

/* ------------------------------------------------------------ Personen */

.kopf.mit-zurueck {
    gap: 4px;
    align-items: center;
    padding-left: 6px;
}

.kopf.mit-zurueck .icon-knopf { flex-shrink: 0; margin-bottom: 2px; }

.person-titel {
    flex-grow: 1;
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hinweis {
    margin: 6px 16px 16px;
    padding: 10px 14px;
    background: var(--fill);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 12px;
}

.hinweis svg { width: 22px; height: 22px; color: var(--akzent); flex-shrink: 0; }
.hinweis p { margin: 0; flex-grow: 1; font-size: 14px; line-height: 19px; color: var(--text2); }
.hinweis .text-knopf { min-height: 44px; font-size: 15px; font-weight: 500; }

.gruppe-titel {
    padding: 8px 16px 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
    letter-spacing: 0.3px;
}

.personen-raster {
    padding: 0 16px 8px;
    display: grid;
    grid-template-columns: repeat(var(--personen-spalten, 3), minmax(0, 1fr));
    gap: 18px 14px;
}

.personen-raster.eng { --personen-spalten: 4; padding: 0; gap: 14px 10px; }

.person { display: flex; flex-direction: column; align-items: center; gap: 6px; }

.person-bild {
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 0;
    padding: 0;
    border-radius: 50%;
    background: var(--kachel);
    overflow: hidden;
}

.person-bild img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.person-bild img.da, .personen-raster.eng .person-bild img { opacity: 1; }

.person-name {
    font-size: 14px;
    font-weight: 500;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.person-anzahl { font-size: 12px; color: var(--text2); margin-top: -4px; }
.klein-knopf { font-size: 14px; min-height: 22px; padding: 0; }

/* -------------------------------------------------------------- Alben */

.alben-raster {
    padding: 0 16px 16px;
    display: grid;
    grid-template-columns: repeat(var(--alben-spalten, 2), minmax(0, 1fr));
    gap: 18px 14px;
}

.album {
    border: 0;
    background: transparent;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
    color: inherit;
}

.album-bild {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--kachel);
}

.album-bild img { width: 100%; height: 100%; object-fit: cover; display: block; }

.album-name {
    font-size: 15px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.album-zahl { font-size: 12px; color: var(--text2); margin-top: -4px; }

/* -------------------------------------------------------------- Suche */

.suchfeld {
    margin: 0 16px 12px;
    padding: 0 12px;
    background: var(--fill);
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
}

.suchfeld svg { width: 18px; height: 18px; color: var(--text2); flex-shrink: 0; }

.suchfeld input {
    flex-grow: 1;
    border: 0;
    background: transparent;
    min-height: 40px;
    font-size: 17px;
    outline: none;
    min-width: 0;
}

.suchfeld input::-webkit-search-cancel-button { display: none; }
.suchfeld .text-knopf { font-size: 15px; padding: 0; flex-shrink: 0; }

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 6px;
}

.chip {
    border: 0;
    background: var(--fill);
    color: var(--text);
    border-radius: 16px;
    padding: 7px 13px;
    min-height: 32px;
    font-size: 14px;
    white-space: nowrap;
}

.chip[aria-pressed="true"] { background: var(--akzent); color: #fff; }

/* -------------------------------------------------------------- Karte */

#karte { position: relative; display: flex; flex-direction: column; }

.karte-buehne {
    position: relative;
    height: 62dvh;
    min-height: 320px;
    overflow: hidden;
    background: var(--fill);
    touch-action: none;
    cursor: grab;
    user-select: none;
}

.karte-buehne:active { cursor: grabbing; }
.karte-kacheln, .karte-marken { position: absolute; inset: 0; }
.karte-marken { pointer-events: none; }

.karte-kachel {
    position: absolute;
    width: 256px;
    height: 256px;
    display: block;
}

@media (prefers-color-scheme: dark) {
    .karte-kachel { filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.92); }
}

.karte-marke {
    position: absolute;
    width: 46px;
    height: 46px;
    margin: -23px 0 0 -23px;
    border: 0;
    padding: 0;
    background: transparent;
    pointer-events: auto;
}

/* Bild und Anzahl getrennt: Der Kreis schneidet ab, die Zahl darf
   überstehen. Beides in einem Element ginge nicht. */
.karte-marke-bild {
    display: block;
    width: 100%;
    height: 100%;
    border: 2px solid #fff;
    border-radius: 50%;
    overflow: hidden;
    background: var(--kachel);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.karte-marke img { width: 100%; height: 100%; object-fit: cover; display: block; }

.karte-anzahl {
    position: absolute;
    right: -3px;
    top: -3px;
    min-width: 19px;
    height: 19px;
    border-radius: 10px;
    background: var(--akzent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 19px;
    text-align: center;
    padding: 0 4px;
    border: 1.5px solid var(--bg);
}

.karte-zoom {
    position: absolute;
    right: 12px;
    top: 12px;
    display: flex;
    flex-direction: column;
    border-radius: 9px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.karte-zoom button {
    width: 40px;
    height: 40px;
    border: 0;
    background: var(--flaeche);
    color: var(--text);
    font-size: 20px;
    line-height: 1;
}

.karte-zoom button + button { border-top: 0.5px solid var(--line); }

.karte-nachweis {
    padding: 6px 16px;
    font-size: 11px;
    color: var(--text2);
}

.karte-nachweis a { color: var(--text2); }

/* ---------------------------------------------------------- Bogen */

.bogen-schicht {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.bogen-schicht.da { opacity: 1; }

.bogen {
    width: 100%;
    max-width: 460px;
    max-height: 86dvh;
    overflow-y: auto;
    background: var(--flaeche);
    box-shadow: 0 -1px 0 var(--line-fein);
    border-radius: 16px 16px 0 0;
    padding: 8px 20px calc(20px + var(--unten));
    transform: translateY(20px);
    transition: transform 0.22s ease;
}

.bogen-schicht.da .bogen { transform: none; }
.bogen h2 { margin: 6px 0 14px; font-size: 20px; font-weight: 600; text-align: center; letter-spacing: -0.2px; }

.bogen-griff {
    width: 36px;
    height: 5px;
    border-radius: 3px;
    background: var(--line);
    margin: 0 auto;
}

.bogen-koerper { display: flex; flex-direction: column; gap: 12px; }
.bogen-koerper .meldung { margin: 0; }

.bogen-gesicht {
    width: 132px;
    height: 132px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--kachel);
    align-self: center;
}

.bogen-fuss { display: flex; gap: 10px; margin-top: 18px; }
.bogen-fuss .knopf { flex-grow: 1; }

/* --------------------------------------------------------- Bausteine */

.karte {
    background: var(--fill);
    border-radius: var(--radius);
    padding: 16px;
    margin: 0 16px 14px;
}

.karte h2 { margin: 0 0 8px; font-size: 17px; font-weight: 600; }
.karte p { margin: 0 0 10px; font-size: 15px; color: var(--text2); }
.karte p:last-child { margin-bottom: 0; }

.knopf {
    display: inline-block;
    border: 0;
    background: var(--akzent);
    color: #fff;
    border-radius: 10px;
    padding: 13px 20px;
    min-height: 48px;
    font-size: 17px;
    font-weight: 500;
    text-align: center;
}

.knopf.leise { background: var(--fill2); color: var(--text); }
.knopf.gefahr { background: transparent; color: var(--gefahr); }
.knopf[disabled] { opacity: 0.4; }

.formular { display: flex; flex-direction: column; gap: 14px; }
.formular label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text2); }

.formular input {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 13px;
    min-height: 48px;
    background: var(--bg);
    font-size: 17px;
}

.liste { list-style: none; margin: 0; padding: 0; }

.liste li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    border-top: 0.5px solid var(--line-fein);
    font-size: 15px;
}

.liste li:first-child { border-top: 0; }
.liste .wert { color: var(--text2); text-align: right; }
.liste li.gut .wert { color: #1a7f4b; }
.liste li.schlecht .wert { color: var(--gefahr); }

.meldung { margin: 0 16px 14px; padding: 12px 14px; border-radius: 10px; font-size: 15px; }
.meldung.fehler { background: rgba(255, 59, 48, 0.12); color: var(--gefahr); }
.meldung.gut { background: rgba(26, 127, 75, 0.12); color: #1a7f4b; }

.klein { font-size: 12px; color: var(--text2); font-weight: 400; }

.code {
    background: var(--fill2);
    border-radius: 10px;
    padding: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0 0 12px;
}

.leer {
    padding: 80px 32px;
    text-align: center;
    color: var(--text2);
    font-size: 15px;
}

.laden {
    padding: 28px;
    text-align: center;
    color: var(--text3);
    font-size: 13px;
}

/* ------------------------------------------------------- Anmeldeseite */

.anmelden {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px;
    gap: 8px;
    max-width: 420px;
    margin: 0 auto;
}

.anmelden h1 { font-size: 28px; margin: 0 0 4px; letter-spacing: -0.3px; }
.anmelden p.klein { margin: 0 0 20px; }

/* ------------------------------------------------- Einrichtungsseite */

body.setup { background: var(--fill); }
.setup-wrap { max-width: 640px; margin: 0 auto; padding: 32px 0 60px; }
.setup-wrap h1 { font-size: 28px; margin: 0 16px 20px; letter-spacing: -0.3px; }
.setup-wrap .karte { background: var(--bg); border: 1px solid var(--line-fein); }
.setup-wrap ol { margin: 0; padding-left: 20px; font-size: 15px; color: var(--text2); }
.setup-wrap ol li { padding: 3px 0; }

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.88em;
    background: var(--fill2);
    padding: 2px 5px;
    border-radius: 5px;
}

@media (min-width: 700px) {
    :root { --spalten: 5; --personen-spalten: 5; --alben-spalten: 4; }
    .blatt { max-width: 900px; margin: 0 auto; width: 100%; }
    .reiter { max-width: 900px; margin: 0 auto; width: 100%; }
}
