:root {
    --bg: #0f1412;
    --panel: #171e1b;
    --panel-2: #1f2824;
    --line: #2c3833;
    --text: #e9f0ec;
    --muted: #96a59d;
    --accent: #5fd3a0;
    --accent-ink: #072117;
    --danger: #ff7a6b;
    --radius: 18px;
    --ar: 3 / 4;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: clip; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: clip;
    padding-bottom: env(safe-area-inset-bottom);
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

svg { width: 20px; height: 20px; flex-shrink: 0; }

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .4; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }

/* ---------- Kopfzeile ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    max-width: 1200px;
    margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
h1 { font-size: 1.2rem; margin: 0; letter-spacing: -.01em; }
.tagline { margin: 0; color: var(--muted); font-size: .85rem; }

.privacy-badge {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 13px; border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent); font-size: .85rem; font-weight: 600;
    white-space: nowrap;
}
.privacy-badge svg { width: 16px; height: 16px; }

/* ---------- Layout ---------- */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 0 16px 16px;
    max-width: 1200px;
    margin: 0 auto;
}
@media (min-width: 960px) {
    .layout { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
    .camera-panel { position: sticky; top: 16px; }
}

.camera-panel, .gallery-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 6px);
    padding: 12px;
}

/* ---------- Sucher ---------- */
.viewfinder {
    position: relative;
    aspect-ratio: var(--ar);
    width: min(100%, calc(60vh * var(--ar-num, .75)));
    width: min(100%, calc(60dvh * var(--ar-num, .75)));
    margin: 0 auto;
    touch-action: pan-y;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}
#video {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    transform-origin: center;
    transition: transform .15s ease-out;
}
#video.mirrored { scale: -1 1; }

.grid-overlay {
    position: absolute; inset: 0; pointer-events: none;
    background:
        linear-gradient(to right, transparent calc(33.33% - .5px), rgba(255,255,255,.35) calc(33.33% - .5px), rgba(255,255,255,.35) calc(33.33% + .5px), transparent calc(33.33% + .5px),
                        transparent calc(66.66% - .5px), rgba(255,255,255,.35) calc(66.66% - .5px), rgba(255,255,255,.35) calc(66.66% + .5px), transparent calc(66.66% + .5px)),
        linear-gradient(to bottom, transparent calc(33.33% - .5px), rgba(255,255,255,.35) calc(33.33% - .5px), rgba(255,255,255,.35) calc(33.33% + .5px), transparent calc(33.33% + .5px),
                        transparent calc(66.66% - .5px), rgba(255,255,255,.35) calc(66.66% - .5px), rgba(255,255,255,.35) calc(66.66% + .5px), transparent calc(66.66% + .5px));
}

.camera-off {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; padding: 24px; text-align: center;
    background: radial-gradient(circle at 50% 35%, #1d2924, #0b0f0d 75%);
}
.camera-off[hidden] { display: none; }
.camera-off-icon {
    display: grid; place-items: center;
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--panel-2); color: var(--accent); margin-bottom: 6px;
}
.camera-off-icon svg { width: 30px; height: 30px; }
.camera-off-title { margin: 0; font-weight: 650; font-size: 1.1rem; }
.camera-off-text { margin: 0 0 12px; color: var(--muted); max-width: 30ch; font-size: .9rem; }

.vf-tools {
    position: absolute; top: 10px; right: 10px;
    display: flex; flex-direction: column; gap: 8px;
}
.vf-tools[hidden] { display: none; }
.vf-btn {
    position: relative;
    display: grid; place-items: center;
    width: 42px; height: 42px; border-radius: 50%;
    border: 0; background: rgba(0,0,0,.45); color: #fff;
    backdrop-filter: blur(6px);
}
.vf-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.vf-btn-label {
    position: absolute; right: -2px; bottom: -2px;
    font-size: .65rem; font-weight: 700;
    background: #fff; color: #000; border-radius: 6px; padding: 0 4px;
}
.vf-btn-label:empty { display: none; }

.zoom-chip {
    position: absolute; bottom: 12px; left: 50%; translate: -50% 0;
    padding: 4px 10px; border-radius: 999px;
    background: rgba(0,0,0,.55); color: #fff; font-size: .8rem; font-weight: 600;
}
.zoom-chip[hidden] { display: none; }

.countdown {
    position: absolute; inset: 0; display: grid; place-items: center;
    font-size: clamp(4rem, 18vw, 8rem); font-weight: 800; color: #fff;
    text-shadow: 0 4px 30px rgba(0,0,0,.6);
    pointer-events: none;
}
.countdown[hidden] { display: none; }

.shutter-flash {
    position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none;
}
.shutter-flash.go { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }

.replace-banner {
    position: absolute; left: 10px; right: 64px; top: 10px;
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: 12px;
    background: rgba(255, 196, 87, .92); color: #2b1d00; font-size: .85rem; font-weight: 600;
}
.replace-banner[hidden] { display: none; }
.replace-banner span { flex: 1; }
.replace-banner button {
    border: 0; border-radius: 8px; padding: 4px 8px;
    background: rgba(0,0,0,.15); font-weight: 600; font-size: .8rem;
}

/* ---------- Bedienelemente ---------- */
.controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 14px 4px 4px; }
.control-row { display: flex; align-items: center; gap: 12px; }
.control-row > :not(.control-label) { min-width: 0; }
.control-label { width: 64px; flex-shrink: 0; color: var(--muted); font-size: .85rem; }

.segmented {
    display: flex; flex: 1;
    background: var(--panel-2); border-radius: 12px; padding: 3px;
}
.segmented button {
    flex: 1; border: 0; background: transparent;
    padding: 7px 4px; border-radius: 9px; font-size: .9rem; font-weight: 600; color: var(--muted);
}
.segmented button[aria-checked="true"] { background: var(--text); color: var(--bg); }

.zoom-wrap { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
#zoom { flex: 1; min-width: 0; accent-color: var(--accent); }
.zoom-presets { display: flex; gap: 4px; flex-shrink: 0; }
.zoom-presets button {
    border: 1px solid var(--line); background: var(--panel-2);
    border-radius: 999px; padding: 3px 9px; font-size: .8rem; font-weight: 600;
}
.zoom-presets button[hidden] { display: none; }

.hint { margin: -4px 0 0 76px; font-size: .78rem; color: var(--muted); }
.hint:empty { display: none; }

select {
    flex: 1; min-width: 0;
    font: inherit; font-size: .9rem; color: var(--text);
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
    padding: 8px 10px;
}

.shutter-row {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    padding: 14px 8px 6px;
}
.shutter {
    width: 74px; height: 74px; border-radius: 50%;
    border: 4px solid var(--text); background: transparent; padding: 4px;
}
.shutter span {
    display: block; width: 100%; height: 100%; border-radius: 50%;
    background: var(--text); transition: transform .1s;
}
.shutter:active:not(:disabled) span { transform: scale(.88); }

.last-thumb {
    justify-self: start;
    width: 52px; height: 52px; border-radius: 12px;
    border: 2px solid var(--line); background: var(--panel-2) center / cover no-repeat;
    padding: 0; overflow: hidden;
}
.last-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.last-thumb.pop { animation: pop .4s ease-out; }
@keyframes pop { 50% { transform: scale(1.15); } }

.round-btn {
    justify-self: end;
    display: grid; place-items: center;
    width: 52px; height: 52px; border-radius: 50%;
    border: 0; background: var(--panel-2);
}
.round-btn svg { width: 24px; height: 24px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border-radius: 12px; padding: 10px 16px; border: 1px solid transparent;
    font-weight: 600; font-size: .92rem;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: var(--panel-2); border-color: var(--line); }
.btn-light { background: rgba(255,255,255,.1); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger-solid { background: var(--danger); color: #2a0602; }
.btn-block { width: 100%; }

.icon-btn {
    display: grid; place-items: center;
    width: 38px; height: 38px; border-radius: 50%;
    border: 0; background: rgba(255,255,255,.08);
}
.link-btn {
    border: 0; background: none; padding: 0;
    color: var(--accent); text-decoration: underline; font-size: inherit;
}

/* ---------- Galerie ---------- */
.gallery-head {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 10px; padding: 4px 4px 12px;
}
h2 { margin: 0; font-size: 1.1rem; }
.gallery-meta { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }
.gallery-actions { display: flex; gap: 6px; }
.gallery-actions .btn { padding: 8px 12px; }

.storage-bar {
    height: 4px; border-radius: 4px; background: var(--panel-2);
    margin: 0 4px 12px; overflow: hidden;
}
.storage-bar[hidden] { display: none; }
.storage-fill { height: 100%; width: 0; background: var(--accent); border-radius: 4px; }

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
}
.gallery-item {
    position: relative; aspect-ratio: 1;
    border: 0; padding: 0; border-radius: 10px; overflow: hidden;
    background: var(--panel-2);
}
.gallery-item img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    transition: transform .2s;
}
.gallery-item:hover img { transform: scale(1.04); }
.gallery-item.is-new { animation: pop .4s ease-out; }

.gallery-empty {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 36px 16px; color: var(--text);
}
.gallery-empty[hidden] { display: none; }
.gallery-empty svg { width: 40px; height: 40px; color: var(--accent); margin-bottom: 8px; }
.gallery-empty p { margin: 2px 0; max-width: 34ch; }

/* ---------- Fußzeile ---------- */
.footer {
    padding: 8px 16px 28px; color: var(--muted); font-size: .82rem; text-align: center;
}
.footer p {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px;
    margin: 0 0 8px;
}
.footer svg { width: 14px; height: 14px; color: var(--accent); }
.footer-privacy { padding-bottom: 10px; border-bottom: 1px solid var(--line); max-width: 760px; margin-inline: auto !important; }
.credits a, .credits .link-btn { color: var(--text); text-decoration: none; }
.credits a:hover, .credits .link-btn:hover { color: var(--accent); text-decoration: underline; }
.credits .sep { opacity: .5; }
.heart { color: #ff6b81; }

/* ---------- Nutzungsbedingungen ---------- */
.sheet-terms { width: min(560px, calc(100vw - 32px)); }
.sheet-terms[open] { display: flex; flex-direction: column; }
.terms-intro { margin: 0 0 12px; font-size: .9rem; }
.terms-text {
    flex: 1; min-height: 0; overflow: auto; max-height: 52vh;
    padding: 4px 14px 4px 4px; margin-bottom: 14px;
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
    font-size: .9rem;
}
.terms-text h3 { font-size: .95rem; margin: 14px 0 4px; }
.terms-text p { margin: 0 0 8px; }
.terms-text a, .sheet-link a { color: var(--accent); }
.sheet-link { margin: -6px 0 14px; font-size: .88rem; }

/* ---------- Dialoge ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }

.sheet {
    width: min(480px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    border: 1px solid var(--line); border-radius: 22px;
    background: var(--panel); padding: 20px;
}
.sheet-small { width: min(380px, calc(100vw - 32px)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.sheet-head h2 { display: flex; align-items: center; gap: 8px; }
.sheet-head h2 svg { color: var(--accent); }
.sheet-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.privacy-list { list-style: none; margin: 8px 0 14px; padding: 0; display: grid; gap: 12px; }
.privacy-list li { display: flex; gap: 12px; font-size: .92rem; }
.privacy-list li > svg {
    width: 34px; height: 34px; padding: 7px; border-radius: 10px;
    background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
}
.note {
    font-size: .88rem; padding: 12px 14px; border-radius: 12px;
    background: rgba(255, 196, 87, .1); border: 1px solid rgba(255, 196, 87, .3);
}
.storage-facts {
    display: grid; grid-template-columns: 1fr auto; gap: 6px 12px;
    margin: 14px 0 16px; font-size: .88rem;
}
.storage-facts dt { color: var(--muted); }
.storage-facts dd { margin: 0; font-weight: 600; text-align: right; }

.viewer {
    width: 100vw; height: 100vh; max-width: none; max-height: none;
    margin: 0; padding: 0; border: 0;
    background: #000;
}
.viewer[open] { display: flex; flex-direction: column; }
.viewer-top {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
}
.viewer-info { font-size: .85rem; color: #c8d2cc; }
.viewer-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-nav {
    position: absolute; top: 50%; translate: 0 -50%;
    display: grid; place-items: center;
    width: 44px; height: 44px; border-radius: 50%; border: 0;
    background: rgba(255,255,255,.12); color: #fff;
}
.viewer-nav.prev { left: 12px; }
.viewer-nav.next { right: 12px; }
.viewer-nav:disabled { opacity: 0; }
.viewer-actions {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
    padding: 14px 16px; padding-bottom: max(14px, env(safe-area-inset-bottom));
}

/* ---------- Toast ---------- */
.toast {
    position: fixed; left: 50%; bottom: 24px; translate: -50% 20px;
    max-width: calc(100vw - 32px);
    padding: 10px 16px; border-radius: 12px;
    background: var(--text); color: var(--bg); font-weight: 600; font-size: .9rem;
    opacity: 0; pointer-events: none; transition: opacity .2s, translate .2s;
    z-index: 10;
}
.toast.show { opacity: 1; translate: -50% 0; }

@media (max-width: 420px) {
    .camera-panel, .gallery-panel { padding: 8px; }
    .controls { padding-inline: 0; }
    .control-row { gap: 8px; }
    .control-label { width: 52px; }
    .hint { margin-left: 60px; }
    .zoom-wrap { gap: 6px; }
    .zoom-presets button { padding: 3px 7px; }
    .tagline { display: none; }
    .privacy-badge span { display: none; }
    .gallery-actions .btn span { display: none; }
}

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

/* ---------- Datenschutzseite ---------- */
.legal { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; }
.legal article {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: calc(var(--radius) + 6px); padding: 20px 22px;
}
.legal h1 { font-size: 1.5rem; margin: 0 0 4px; }
.legal h2 { font-size: 1.1rem; margin: 24px 0 6px; }
.legal p, .legal li { font-size: .95rem; }
.legal ul { padding-left: 20px; }
.legal a { color: var(--accent); }
.legal .highlight {
    padding: 12px 14px; border-radius: 12px; margin: 14px 0;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.back-link { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 14px; color: var(--accent); text-decoration: none; font-weight: 600; }

/* ---------- PWA: Logo, Installieren, Update, Versionen ---------- */
.brand-logo { width: 42px; height: 42px; border-radius: 12px; display: block; flex-shrink: 0; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.install-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 13px; border-radius: 999px; border: 0;
    background: var(--accent); color: var(--accent-ink); font-size: .85rem; font-weight: 700;
}
.install-btn[hidden] { display: none; }
.install-btn svg { width: 16px; height: 16px; }

.update-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    max-width: 1168px; margin: 0 auto 14px; padding: 10px 12px 10px 16px;
    border-radius: 14px; font-size: .92rem; font-weight: 600;
    background: color-mix(in srgb, var(--accent) 14%, var(--panel));
    border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
@media (max-width: 1200px) { .update-banner { margin-inline: 16px; } }
.update-banner[hidden] { display: none; }
.update-banner .btn { padding: 7px 14px; }

.version-status { margin: 0 0 12px; font-size: .9rem; }
.version-list { max-height: 50vh; overflow: auto; margin-bottom: 16px; }
.version-list h3 { font-size: .95rem; margin: 12px 0 4px; }
.version-list h3 .muted { font-weight: 400; font-size: .85rem; }
.version-list ul { margin: 0; padding-left: 20px; font-size: .9rem; }

@media (max-width: 420px) {
    .install-btn span { display: none; }
}
