@font-face { font-family: "AppSans"; src: url("/fonts/Inter-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "AppSans"; src: url("/fonts/Inter-Medium.otf") format("opentype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "AppSans"; src: url("/fonts/Inter-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "AppSans"; src: url("/fonts/Inter-ExtraBold.otf") format("opentype"); font-weight: 800; font-display: swap; }

:root {
  --brand: #9E1B32; --accent: #E8B53A; --ink: #17171a; --muted: #6b6b75; --line: #e7e5ea;
  --bg: #f6f5f7; --card: #fff; --ok: #1f8a4c; --warn: #c27c00; --info: #2563eb; --danger: #c62828;
  --radius: 14px; --nav-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 "AppSans", system-ui, -apple-system, sans-serif; }
body { overscroll-behavior-y: contain; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; font-weight: 800; } h2 { font-size: 1.2rem; font-weight: 700; } h3 { font-size: 1rem; font-weight: 700; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.hidden { display: none !important; }

.splash { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Layout */
.shell { min-height: 100vh; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px); }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); padding: calc(var(--safe-t) + 10px) 16px 10px; display: flex; align-items: center; gap: 10px; }
.topbar .title { flex: 1; font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar .title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar img.logo { height: 30px; max-width: 90px; object-fit: contain; }
.page { padding: 16px; max-width: 980px; margin: 0 auto; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); height: calc(var(--nav-h) + var(--safe-b)); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; position: relative; }
.nav a svg { width: 24px; height: 24px; }
.nav a.active { color: var(--brand); }
.badge { position: absolute; top: 8px; left: calc(50% + 6px); background: var(--danger); color: #fff; border-radius: 10px; font-size: .68rem; padding: 0 6px; min-width: 18px; text-align: center; }

/* Elemente */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700;
  background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; min-height: 46px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--brand); padding: 8px 10px; min-height: 0; }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #f1c9c9; }
.btn.ok { background: var(--ok); }
.btn.small { padding: 7px 12px; min-height: 34px; font-size: .88rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); padding: 16px; }
.card + .card { margin-top: 12px; }
label.field { display: block; }
label.field > span { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
input[type=text], input[type=email], input[type=number], input[type=tel], select, textarea {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; min-height: 46px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.check input { width: 22px; height: 22px; margin-top: 1px; accent-color: var(--brand); flex: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 14px; font-size: .88rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
a.chip { text-decoration: none; color: var(--ink); }
a.chip.active { color: #fff; }
.seg { display: inline-flex; background: #ecebef; border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.seg button:disabled { opacity: .4; }
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 20px; padding: 2px 9px; font-size: .75rem; font-weight: 700; }
.pill.free { background: #e5f5ec; color: var(--ok); } .pill.reserved { background: #fff3d6; color: var(--warn); }
.pill.posted { background: #e3ecff; color: var(--info); } .pill.private { background: #f1f1f3; color: var(--muted); }
.pill.pending { background: #fff3d6; color: var(--warn); } .pill.blocked { background: #fde8e8; color: var(--danger); }
.pill.error { background: #fde8e8; color: var(--danger); } .pill.ready { background: #e5f5ec; color: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty svg { width: 54px; height: 54px; opacity: .35; }

/* Galerie */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin: 12px -16px 0; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(5, 1fr); margin: 12px 0 0; gap: 6px; } .grid .tile { border-radius: 8px; } }
.tile { position: relative; aspect-ratio: 1; background: #ddd center/cover no-repeat; cursor: pointer; overflow: hidden; border: 0; padding: 0; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .tag { position: absolute; left: 5px; bottom: 5px; background: rgba(0,0,0,.6); color: #fff; font-size: .7rem; font-weight: 700; border-radius: 6px; padding: 1px 6px; display: flex; gap: 3px; align-items: center; }
.tile .tag svg { width: 12px; height: 12px; }
.tile .st { position: absolute; right: 5px; top: 5px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.tile .st.reserved { background: var(--warn); } .tile .st.posted { background: var(--info); } .tile .st.private { background: #555; }
.tile .st svg { width: 13px; height: 13px; }
.tile.proc::after { content: "wird verarbeitet …"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,.75); font-size: .7rem; font-weight: 700; color: var(--muted); }
.tile.err::after { content: "Fehler"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,230,230,.85); font-size: .75rem; font-weight: 700; color: var(--danger); }
.tile.sel { outline: 4px solid var(--brand); outline-offset: -4px; }
.tile.sel::before { content: attr(data-n); position: absolute; left: 6px; top: 6px; z-index: 2; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; font-size: .8rem; display: grid; place-items: center; border: 2px solid #fff; }
.tile.dim { opacity: .35; }
.fab { position: fixed; right: 18px; bottom: calc(var(--nav-h) + var(--safe-b) + 18px); z-index: 25; width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.25); display: grid; place-items: center; cursor: pointer; }
.fab svg { width: 30px; height: 30px; }
.selbar { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 26; background: var(--ink); color: #fff; padding: 12px 16px; display: flex; gap: 10px; align-items: center; }
.selbar .grow { flex: 1; font-weight: 700; }
.selbar .btn.secondary { background: #fff; border: 0; }

/* Sheets / Dialoge */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + var(--safe-b)); }
@media (min-width: 640px) { .sheet-bg { align-items: center; } .sheet { border-radius: 20px; } }
.uplist { list-style: none; padding: 0; margin: 12px 0; }
.uplist li { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.uplist .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; width: 90px; flex: none; }
.bar > i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }

/* Detail */
.viewer { background: #111; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; }
.viewer img, .viewer video { max-width: 100%; max-height: 70vh; display: block; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .92rem; }
.meta dt { color: var(--muted); } .meta dd { margin: 0; }

/* Studio */
.post-item { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.post-item .thumbs { display: flex; flex: none; }
.post-item .thumbs img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; border: 2px solid #fff; margin-left: -18px; background: #ddd; }
.post-item .thumbs img:first-child { margin-left: 0; }
.editor { display: grid; gap: 16px; }
@media (min-width: 860px) { .editor { grid-template-columns: 380px 1fr; align-items: start; } .editor .preview-col { position: sticky; top: 80px; } }
.preview-wrap { background: repeating-conic-gradient(#e9e8ec 0% 25%, #f6f5f7 0% 50%) 50% / 20px 20px; border-radius: var(--radius); padding: 12px; display: grid; place-items: center; }
.preview-wrap canvas { width: 100%; max-width: 340px; height: auto; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.18); touch-action: none; cursor: grab; display: block; }
.slides { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.slides button { flex: none; width: 58px; height: 58px; padding: 0; border: 3px solid transparent; border-radius: 10px; overflow: hidden; cursor: pointer; background: #ddd; position: relative; }
.slides button.active { border-color: var(--brand); }
.slides button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tpl-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tpl-pick button { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 6px; cursor: pointer; font-size: .8rem; font-weight: 700; }
.tpl-pick button.active { border-color: var(--brand); color: var(--brand); }
.tpl-pick canvas { width: 100%; height: auto; border-radius: 6px; display: block; margin-bottom: 4px; }
input[type=range] { width: 100%; accent-color: var(--brand); }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.results figure { margin: 0; background: #111; border-radius: 10px; overflow: hidden; position: relative; min-height: 120px; display: grid; place-items: center; color: #fff; font-size: .8rem; }
.results img, .results video { width: 100%; display: block; }
.countdown { font-weight: 700; color: var(--warn); }
.notice { background: #fff8e6; border: 1px solid #f3dfa8; border-radius: 12px; padding: 12px 14px; font-size: .92rem; }
.notice.info { background: #eef4ff; border-color: #cfe0ff; }
.notice.ok { background: #e9f7ef; border-color: #bfe6cf; }

/* Admin */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; }
.user-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.user-row:last-child { border-bottom: 0; }
.user-row .who { flex: 1; min-width: 180px; }
.user-row select { width: auto; min-height: 36px; padding: 6px 10px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.qr-box { background: #fff; border-radius: var(--radius); padding: 18px; text-align: center; }
.qr-box img { width: 100%; max-width: 300px; }
.color-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.color-row label { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; font-size: .88rem; font-weight: 600; }
.color-row input[type=color] { width: 38px; height: 38px; border: 0; padding: 0; background: none; border-radius: 8px; }
.stat { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.stat div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 1.5rem; }
.code-big { font-size: 2.2rem; font-weight: 800; letter-spacing: .18em; text-align: center; padding: 10px; background: var(--bg); border-radius: 12px; font-variant-numeric: tabular-nums; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 18px calc(24px + var(--safe-b)); }
.auth .card { width: 100%; max-width: 420px; padding: 24px; }
.auth .brand-head { text-align: center; margin-bottom: 18px; }
.auth .brand-head img { max-height: 80px; max-width: 200px; }
.auth .brand-head .mark { width: 64px; height: 64px; border-radius: 18px; background: var(--brand); color: #fff; display: inline-grid; place-items: center; font-weight: 800; font-size: 1.6rem; }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 90px); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: .92rem; opacity: 0; pointer-events: none; transition: .25s; z-index: 100; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; text-align: center; }
}
