:root {
  color-scheme: light dark;
  --bg: #f6f7f9; --card: #fff; --text: #1d2330; --muted: #6b7280; --accent: #2563eb; --accent-text: #fff;
  --border: #d8dce3; --err: #b91c1c; --chip: #eef1f5;
  --dock-h: 88px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171c; --card: #1d2129; --text: #e7e9ee; --muted: #9aa3b2; --accent: #60a5fa; --accent-text: #0b1220;
          --border: #2f3542; --err: #f87171; --chip: #262b35; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text);
       -webkit-tap-highlight-color: transparent; }
h1, h2 { margin: 0; }
h2 { font-size: 18px; }
.sub, .hint { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
[hidden] { display: none !important; }
body.lock { overflow: hidden; }

/* Kopfzeile */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
       padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px; background: var(--bg); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand img { border-radius: 7px; }

main { max-width: 960px; margin: 0 auto; padding: 16px 16px calc(var(--dock-h) + var(--safe-b) + 24px); }

/* Buttons */
button, .btn { font: inherit; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text);
               cursor: pointer; touch-action: manipulation; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 18px; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.wide { width: 100%; }
button:disabled { opacity: .45; cursor: default; }
.ghost { background: transparent; color: var(--muted); }
.small { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.icon { width: 44px; height: 44px; border-radius: 50%; border: 0; font-size: 22px; line-height: 1; display: grid; place-items: center; }
button:focus-visible, .btn:has(input:focus-visible), .seg input:focus-visible + span, .chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Auswahl */
.drop { background: var(--card); border: 2px dashed var(--border); border-radius: 18px; padding: 24px 16px; text-align: center;
        transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); }
.drop-title { margin: 0; font-weight: 700; font-size: 18px; }
.pick { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-top: 18px; }
.pick .btn { padding: 0 10px; white-space: nowrap; }
@media (max-width: 360px) { .pick .btn svg { display: none; } .drop { padding: 20px 12px; } }
.desktop-only { display: none; }
@media (hover: hover) and (pointer: fine) { .desktop-only { display: block; margin-top: 12px; } }
.drop.compact { padding: 12px; }
.drop.compact .drop-title, .drop.compact .sub { display: none; }
.drop.compact .pick { margin-top: 0; }

.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 10px; }
.thumbs { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.thumb { position: relative; flex: 0 0 88px; height: 88px; scroll-snap-align: start; }
.thumb.noprev::after { content: attr(data-name); position: absolute; inset: 0; display: grid; place-items: center; border-radius: 12px;
                     background: var(--chip); border: 1px solid var(--border); font-size: 13px; font-weight: 700; color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); display: block; }
.thumb button { position: absolute; z-index: 1; top: -6px; right: -6px; width: 30px; height: 30px; border-radius: 50%; padding: 0;
                background: var(--text); color: var(--bg); border: 2px solid var(--bg); font-size: 14px; line-height: 1; }

/* Einstellungen */
.settings { margin-top: 8px; }
fieldset { border: 0; padding: 0; margin: 18px 0 0; min-width: 0; }
legend { font-weight: 600; font-size: 15px; margin-bottom: 8px; padding: 0; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--chip); border-radius: 12px; padding: 4px; gap: 4px; }
.seg label, .chips label { position: relative; }
.seg input, .chips input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 4px 6px; border-radius: 9px;
            font-size: 14px; font-weight: 600; text-align: center; color: var(--muted); cursor: pointer; line-height: 1.2; }
.seg input:checked + span { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.chips span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px; white-space: nowrap;
              background: var(--chip); font-size: 15px; font-weight: 600; cursor: pointer; border: 1px solid transparent; }
.chips input:checked + span { background: var(--accent); color: var(--accent-text); }
input[type=range] { width: 100%; height: 36px; accent-color: var(--accent); margin: 0; }
output { color: var(--accent); }

/* Ergebnisse */
.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .gallery { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; } }
.item { background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.item .shot { display: block; width: 100%; padding: 0; border: 0; border-radius: 0; background: var(--chip); aspect-ratio: 3 / 4; }
.item img { width: 100%; height: 100%; object-fit: contain; display: block; }
.item .actions { display: flex; border-top: 1px solid var(--border); }
.item .actions button { flex: 1; border: 0; border-radius: 0; min-height: 46px; font-size: 14px; font-weight: 600; color: var(--accent); background: var(--card); }
.item .actions button + button { border-left: 1px solid var(--border); }
.errors { display: grid; gap: 8px; margin-bottom: 12px; }
.errors:empty { display: none; }
.error { background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--err); border-radius: 10px;
         padding: 10px 12px; font-size: 14px; color: var(--err); word-break: break-word; }

/* Aktionsleiste */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 12px 16px calc(12px + var(--safe-b));
        background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--border); }
.dock > * { max-width: 560px; margin: 0 auto; }
.dock-row, .viewer-bottom { display: flex; gap: 10px; }
.btn.square { flex: 0 0 52px; padding: 0; }
.viewer .btn.square { background: rgba(255,255,255,.14); color: #fff; border: 0; }
.progress { margin-bottom: 10px; }
.progress-text { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
progress { width: 100%; height: 6px; appearance: none; border: 0; border-radius: 3px; background: var(--chip); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--chip); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

/* Vollbild */
.viewer { position: fixed; inset: 0; z-index: 20; background: #000; color: #fff; display: flex; flex-direction: column;
          padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); }
.viewer-top { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 8px 20px; font-size: 14px; color: #ccc; }
.viewer-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; touch-action: pan-y pinch-zoom; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.viewer .icon { background: rgba(255,255,255,.14); color: #fff; }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 30px; }
#viewer-prev { left: 8px; }
#viewer-next { right: 8px; }
.viewer-bottom { padding: 12px 16px; }
@media (hover: none) { .viewer .nav { display: none; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--dock-h) + var(--safe-b) + 12px); transform: translateX(-50%); z-index: 30;
         background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); }

/* Login / Einrichtung */
body.auth { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 28px 22px; }
.card h1 { margin: 0 0 4px; }
.card label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
.card input { width: 100%; font: inherit; font-size: 16px; min-height: 48px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.card button { width: 100%; margin-top: 22px; min-height: 50px; padding: 10px 12px; background: var(--accent); color: var(--accent-text); border: 0; font-weight: 600; }
.msg-error { color: var(--err); margin: 12px 0 0; }
