:root {
  --bg: #14121a; --card: #1e1b26; --card2: #262230; --line: #332e3f;
  --text: #ece9f3; --muted: #948ca6; --accent: #c084fc; --accent2: #9333ea;
  --green: #34d399; --yellow: #fbbf24; --red: #f43f5e;
  --r: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { opacity: .4; cursor: default; }
code { font-family: ui-monospace, Consolas, monospace; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.loading { display: grid; place-items: center; height: 100vh; color: var(--muted); }

header {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; background: rgba(20,18,26,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: .02em; color: var(--accent); }
header select { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; }
.me { margin-left: auto; font-size: 13px; color: var(--muted); }

main { max-width: 640px; margin: 0 auto; padding: 12px 14px calc(env(safe-area-inset-bottom) + 96px); }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 4px 8px; }
h3 { margin: 0 0 10px; font-size: 15px; }

nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); background: rgba(20,18,26,.95); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
nav button { flex: 1; padding: 10px; border-radius: 12px; color: var(--muted); font-weight: 600; position: relative; }
nav button.on { color: var(--text); background: var(--card2); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 6px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.card.disabled .grid, .card.disabled .chips, .card.disabled textarea, .card.disabled .check { opacity: .45; pointer-events: none; }
.card.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.big { font-size: 20px; font-weight: 700; }
.sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.status.on { border-color: rgba(52,211,153,.4); background: linear-gradient(160deg, rgba(52,211,153,.12), var(--card) 60%); }
.signal { margin-top: 12px; padding: 10px 12px; border-radius: 12px; font-weight: 700; }
.signal.red { background: rgba(244,63,94,.18); color: #fecdd3; }
.signal.yellow { background: rgba(251,191,36,.16); color: #fde68a; }
.signal.checkin { background: rgba(192,132,252,.16); color: #e9d5ff; }
.card.checkin { border-color: var(--accent); }

/* Schalter */
.switch { position: relative; display: inline-block; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 30px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(20px); }
.big-switch { width: 68px; height: 40px; }
.big-switch span::before { width: 34px; height: 34px; }
.big-switch input:checked + span::before { transform: translateX(28px); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.chip { padding: 7px 12px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); font-size: 14px; }
.chip.on { background: var(--accent2); border-color: var(--accent); color: #fff; }
.lbl { display: block; margin: 16px 0 0; font-size: 13px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: center; margin: 16px 0 10px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent2); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px; border-radius: 14px; background: var(--card2); border: 2px solid transparent; font-size: 14px; text-align: center; }
.item .icon { font-size: 28px; }
.item small { color: var(--green); font-size: 11px; }
.item.on { border-color: var(--accent); background: rgba(147,51,234,.25); }

/* Anweisungen */
.order { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.order.worn { border-left-color: var(--green); }
.oh { display: flex; gap: 12px; align-items: center; }
.oh .icon { font-size: 32px; }
.name { font-weight: 700; font-size: 17px; }
.meta { font-size: 13px; color: var(--muted); }
.note { margin-top: 10px; padding: 8px 12px; background: var(--card2); border-radius: 10px; font-style: italic; }
.timer { margin-top: 10px; font-size: 14px; color: var(--muted); }
.timer b { color: var(--text); font-variant-numeric: tabular-nums; font-size: 18px; }
.timer b.over { color: var(--red); }
.safety { margin-top: 10px; font-size: 13px; color: #fde68a; background: rgba(251,191,36,.1); padding: 8px 10px; border-radius: 10px; }
.proof { display: block; max-width: 100%; max-height: 260px; border-radius: 10px; margin-top: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions:empty { display: none; }

.primary { background: var(--accent2); color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 700; }
.ghost { background: var(--card2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 12px; }
.warn { color: #fda4af; }
.full { width: 100%; margin-top: 10px; display: block; }
.icon-btn { padding: 6px 8px; border-radius: 8px; }

.hold { position: relative; overflow: hidden; flex: 1; user-select: none; -webkit-user-select: none; touch-action: none; }
.hold::before { content: ""; position: absolute; inset: 0; width: 0; background: rgba(255,255,255,.25); }
.hold.holding::before { width: 100%; transition: width 1.2s linear; }
.hold span { position: relative; }

/* Ampel */
.ampel-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.amp { padding: 16px 10px; border-radius: 14px; font-weight: 800; font-size: 17px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.amp small { font-weight: 500; font-size: 12px; opacity: .85; }
.amp.yellow { background: rgba(251,191,36,.18); color: #fde68a; border: 1px solid rgba(251,191,36,.4); }
.amp.red { background: rgba(244,63,94,.22); color: #fecdd3; border: 1px solid rgba(244,63,94,.5); }

textarea, input:not([type=checkbox]) { width: 100%; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; outline: none; resize: vertical; }
textarea:focus, input:focus { border-color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.inline { display: flex; gap: 8px; margin-top: 12px; }
.inline .emoji { width: 60px; text-align: center; flex: none; }
.grow { flex: 1; min-width: 0; }

.inv { list-style: none; margin: 8px 0 0; padding: 0; }
.inv li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.inv li:last-child { border-bottom: 0; }
.inv li.off { opacity: .5; }
.inv .icon { font-size: 22px; width: 30px; text-align: center; }
.big-code { font-size: 20px; letter-spacing: .1em; color: var(--accent); }

.log { list-style: none; padding: 0; margin: 0; }
.log li { display: flex; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.log time { color: var(--muted); white-space: nowrap; min-width: 92px; font-variant-numeric: tabular-nums; }
.stats { display: grid; gap: 8px; }
.stat { display: flex; gap: 10px; align-items: baseline; }
.stat span { flex: 1; }
.stat small { color: var(--muted); width: 32px; text-align: right; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.gallery figcaption { font-size: 11px; color: var(--muted); }

/* Auth */
.auth { max-width: 380px; margin: 0 auto; padding: 12vh 20px 40px; }
.logo { text-align: center; margin-bottom: 24px; }
.logo img { width: 72px; }
.logo h1 { margin: 8px 0 0; color: var(--accent); }
.seg { display: flex; background: var(--card); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; padding: 9px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--card2); color: var(--text); }
#authForm { display: flex; flex-direction: column; gap: 10px; }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%); z-index: 10;
  background: var(--card2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.4); max-width: 90vw; }
#toast.bad { border-color: var(--red); color: #fecdd3; }
details summary { cursor: pointer; margin-top: 8px; }

/* Haltungen, Aufgaben, Planen, Rechte */
.order.kind-pose { border-left-color: #60a5fa; }
.order.kind-task { border-left-color: var(--yellow); }
.order.worn, .order.submitted { border-left-color: var(--green); }
.feedback { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: rgba(244,63,94,.12); color: #fecdd3; font-size: 14px; }
.seg.small { margin-bottom: 12px; }
#fAt { margin-bottom: 4px; }
.inline select { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 0 8px; flex: none; }
.lbl + .inv { margin-top: 0; }
li.dom { display: block; }
.dom-head { display: flex; align-items: center; gap: 10px; text-align: left; padding: 4px 0; }
.dom-head small { margin-left: auto; }
.perms { padding: 4px 0 8px; }
.perms .item small { color: var(--muted); }
.perms .item:not(.on) { opacity: .55; }

/* Nachtruhe */
:root { --night: #818cf8; }
.card.night.on, .status.night-on { border-color: rgba(129,140,248,.45); background: linear-gradient(160deg, rgba(129,140,248,.14), var(--card) 60%); }
.night-switch input:checked + span { background: var(--night); }
.signal.night { background: rgba(129,140,248,.16); color: #c7d2fe; }
.icon-btn.moon { filter: grayscale(1); opacity: .3; }
.icon-btn.moon.on { filter: none; opacity: 1; }
.stat em { font-style: normal; font-size: 12px; color: #c7d2fe; }
