:root {
  --brand: #d9480f;
  --brand-soft: #fff0e8;
  --ok: #16a34a;
  --ok-soft: #e7f6ec;
  --bg: #f1efea;
  --surface: #ffffff;
  --surface-2: #ebe8e1;
  --text: #1d1b19;
  --muted: #6f6a64;
  --line: #e3dfd6;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(30, 20, 10, .06), 0 4px 14px rgba(30, 20, 10, .06);
  --shadow-lg: 0 -8px 40px rgba(20, 10, 0, .2);
  --r: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #ff8a4c;
    --brand-soft: #3a2418;
    --ok: #34c46a;
    --ok-soft: #173322;
    --bg: #121110;
    --surface: #1c1a19;
    --surface-2: #272422;
    --text: #f1eeea;
    --muted: #a09992;
    --line: #2f2b28;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    --shadow-lg: 0 -8px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
body.noscroll { overflow: hidden; }
#app { max-width: 820px; margin: 0 auto; padding: 0 16px calc(96px + var(--safe-bot)); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
svg.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Kopfzeile ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  margin: 0 -16px; padding: calc(10px + var(--safe-top)) 10px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.top h1 { font-size: 19px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.95); }

.hero { padding: 18px 2px 14px; }
.hero h2 { font-size: 28px; line-height: 1.15; word-break: break-word; }
.hero .desc { margin-top: 8px; white-space: pre-wrap; word-break: break-word; }

/* ---------- Fortschritt ---------- */
.progress { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .3s; }
.progress .count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Karten ---------- */
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); }
.projects, .steps, .items { grid-template-columns: minmax(0, 1fr); }
.projects { display: grid; gap: 12px; }
html, body { overflow-x: hidden; }
.pcard { display: flex; gap: 14px; padding: 12px; text-align: left; width: 100%; align-items: center; }
.pcard .cover {
  width: 76px; height: 76px; border-radius: 12px; flex: none; background: var(--surface-2) center / cover no-repeat;
  display: grid; place-items: center; color: var(--muted);
}
.pcard h3 { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .next { font-size: 13px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .progress { margin-top: 8px; }
.pcard.archived { opacity: .6; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 26px 4px 10px; }

/* ---------- Arbeitsschritte ---------- */
.filters { display: flex; gap: 8px; margin: 6px 0 12px; overflow-x: auto; scrollbar-width: none; }
.chip {
  padding: 7px 14px; border-radius: 99px; background: var(--surface-2); font-size: 14px; white-space: nowrap;
}
.chip.on { background: var(--text); color: var(--bg); }
.steps { display: grid; gap: 10px; }
.step { display: flex; align-items: stretch; overflow: hidden; }
.step .check { padding: 14px 4px 14px 14px; display: flex; align-items: flex-start; }
.step .body { flex: 1; min-width: 0; padding: 14px 14px 14px 8px; text-align: left; }
.step .num { font-size: 12px; color: var(--muted); font-weight: 600; }
.step h3 { font-size: 16px; font-weight: 600; word-break: break-word; }
.step .snippet { font-size: 14px; color: var(--muted); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.step .meta { display: flex; gap: 12px; margin-top: 8px; font-size: 13px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.step .meta span { display: inline-flex; align-items: center; gap: 4px; }
.step .meta svg.i { width: 15px; height: 15px; }
.step .thumbs { display: flex; gap: 6px; margin-top: 10px; }
.step .thumbs img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.step.done h3 { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); color: var(--muted); }
.step .order { display: flex; flex-direction: column; justify-content: center; padding-right: 6px; }

.tick {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--muted) 70%, transparent);
  display: grid; place-items: center; flex: none; transition: background .15s, border-color .15s;
}
.tick svg.i { width: 16px; height: 16px; stroke-width: 3; opacity: 0; color: #fff; }
.tick.on { background: var(--ok); border-color: var(--ok); }
.tick.on svg.i { opacity: 1; }
.tick:active { transform: scale(.9); }

/* ---------- Schritt-Detail ---------- */
.done-toggle {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; margin: 4px 0 16px;
  border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); text-align: left; font-weight: 600;
}
.done-toggle.on { background: var(--ok-soft); color: var(--ok); }
.done-toggle .sub { font-weight: 400; font-size: 13px; color: var(--muted); }
.desc-box { padding: 4px; margin-bottom: 18px; }
.desc-box label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); padding: 10px 12px 0; }
.desc-box textarea {
  width: 100%; border: 0; background: transparent; resize: none; padding: 6px 12px 12px; outline: none; min-height: 90px; line-height: 1.45;
}
.saved-hint { font-size: 12px; color: var(--muted); float: right; font-weight: 400; transition: opacity .3s; }

.items { display: grid; gap: 12px; }
.item { position: relative; overflow: hidden; }
.item .menu-btn { position: absolute; top: 6px; right: 6px; z-index: 2; }
.item .menu-btn.float { background: rgba(0, 0, 0, .45); color: #fff; border-radius: 50%; width: 36px; height: 36px; }
.item .cap { padding: 10px 50px 12px 14px; white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.item .when { font-size: 12px; color: var(--muted); padding: 0 14px 12px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; padding: 6px; }
.photo-grid .ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.photo-grid .ph img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo-grid .ph .menu-btn { top: 4px; right: 4px; width: 32px; height: 32px; }
.photo-grid .ph .phcap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; font-size: 12px; color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .65)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.video .frame { position: relative; aspect-ratio: 16 / 9; background: #000; }
.video .frame img, .video .frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; }
.video .play {
  position: absolute; inset: 0; display: grid; place-items: center; width: 100%;
  background: linear-gradient(rgba(0,0,0,.05), rgba(0,0,0,.35));
}
.video .play span { width: 68px; height: 48px; border-radius: 14px; background: #e00; display: grid; place-items: center; }
.video .play svg.i { color: #fff; fill: #fff; width: 26px; height: 26px; }
.video .vtitle { padding: 10px 50px 0 14px; font-weight: 600; font-size: 15px; }
.video .vlink { padding: 2px 14px 0; font-size: 13px; }
.video .cap { padding-top: 6px; }
.link { display: flex; gap: 12px; padding: 12px 50px 12px 14px; align-items: center; text-decoration: none; color: inherit; }
.link .ic { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.link .lt { font-weight: 600; font-size: 15px; word-break: break-word; }
.link .lu { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note { border-left: 4px solid #f0b429; }
.note .cap { padding-top: 12px; }
.todo { display: flex; align-items: flex-start; gap: 12px; padding: 12px 50px 12px 14px; }
.todo .t { padding-top: 3px; white-space: pre-wrap; word-break: break-word; }
.todo.on .t { text-decoration: line-through; color: var(--muted); }
.todo .tick { width: 24px; height: 24px; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg.i { width: 44px; height: 44px; stroke-width: 1.5; margin-bottom: 8px; }
.empty h3 { color: var(--text); font-size: 18px; margin-bottom: 4px; }

/* ---------- Hinzufügen-Leiste ---------- */
.addbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-bot)); z-index: 30;
  display: flex; gap: 4px; padding: 6px; border-radius: 22px; background: var(--surface); box-shadow: 0 6px 28px rgba(0,0,0,.18);
  max-width: calc(100vw - 20px); overflow-x: auto; scrollbar-width: none;
}
.addbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 12px; border-radius: 16px; font-size: 12px; min-width: 62px; }
.addbar button:hover { background: var(--surface-2); }
.addbar button.primary { background: var(--brand); color: #fff; }
.fab {
  position: fixed; right: max(18px, calc(50% - 392px)); bottom: calc(20px + var(--safe-bot)); z-index: 30;
  display: flex; align-items: center; gap: 8px; padding: 14px 20px 14px 16px; border-radius: 18px;
  background: var(--brand); color: #fff; font-weight: 600; box-shadow: 0 8px 24px color-mix(in srgb, var(--brand) 45%, transparent);
}
.fab:active { transform: scale(.97); }

/* ---------- Bottom-Sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); animation: fade .2s; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + var(--safe-bot));
  box-shadow: var(--shadow-lg); animation: up .25s cubic-bezier(.2, .9, .3, 1);
}
@media (min-width: 640px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 22px; padding-bottom: 18px; }
}
.sheet .grip { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font-size: 20px; margin-bottom: 14px; }
.sheet .menu { display: grid; margin: 0 -8px; }
.sheet .menu button { display: flex; align-items: center; gap: 14px; padding: 13px 10px; border-radius: 12px; text-align: left; }
.sheet .menu button:hover { background: var(--surface-2); }
.sheet .menu button.danger { color: var(--danger); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); outline: none;
}
.input:focus { border-color: var(--brand); }
textarea.input { resize: vertical; min-height: 96px; line-height: 1.45; }
.btns { display: flex; gap: 10px; margin-top: 18px; }
.btn {
  flex: 1; padding: 13px 16px; border-radius: 14px; font-weight: 600; background: var(--surface-2); text-align: center;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.err { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 1em; }
.check-line { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; font-size: 15px; }
.check-line input { width: 20px; height: 20px; accent-color: var(--brand); }

/* ---------- Anmeldung ---------- */
.auth { max-width: 380px; margin: 0 auto; padding: calc(60px + var(--safe-top)) 4px 40px; }
.auth .logo { width: 72px; height: 72px; border-radius: 20px; display: block; margin-bottom: 18px; }
.auth h1 { font-size: 30px; margin-bottom: 6px; }
.auth p { margin: 0 0 24px; color: var(--muted); }
.auth .btn { width: 100%; margin-top: 8px; }

/* ---------- Bildbetrachter ---------- */
.lightbox { position: fixed; inset: 0; z-index: 200; background: #000; display: flex; flex-direction: column; color: #fff; animation: fade .15s; }
.lightbox .lb-top { display: flex; align-items: center; padding: calc(8px + var(--safe-top)) 8px 8px; gap: 6px; }
.lightbox .lb-top .grow { font-size: 14px; opacity: .8; text-align: center; }
.lightbox .lb-img { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; touch-action: pan-y pinch-zoom; }
.lightbox .lb-img img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.lightbox .nav.prev { left: 10px; }
.lightbox .nav.next { right: 10px; }
.lightbox .lb-cap { padding: 12px 18px calc(16px + var(--safe-bot)); white-space: pre-wrap; font-size: 15px; max-height: 30vh; overflow-y: auto; }
.lightbox .icon-btn:hover { background: rgba(255,255,255,.12); }

/* ---------- Meldungen ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-bot)); transform: translate(-50%, 20px); z-index: 300;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
