:root {
  --bg: #121417;
  --surface: #1c2127;
  --surface-2: #252b33;
  --border: #2f3640;
  --text: #ffffff;
  --text-muted: #9aa4b0;
  --mint: #4fd1a5;
  --mint-soft: rgba(79, 209, 165, 0.16);
  --mint-dim: #2f8f71;
  --danger: #ff6b6b;
  --warn: #ffb86b;
  --radius: 14px;
  --tabbar-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}

h1, h2, h3 { color: var(--mint); margin: 0; font-weight: 700; }
h2 { font-size: 1.1rem; margin: 24px 0 8px; }

button, input, select, textarea { font: inherit; color: inherit; }

[hidden] { display: none !important; }

.muted { color: var(--text-muted); font-size: 0.9rem; margin: 4px 0; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: rgba(18, 20, 23, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.app-header h1 { font-size: 1.5rem; letter-spacing: 0.02em; }
.sync-status { font-size: 0.8rem; color: var(--text-muted); }
.sync-status.is-error { color: var(--warn); }

.banner {
  margin: 12px 16px 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(255, 184, 107, 0.12);
  color: var(--warn);
  font-size: 0.9rem;
}

main { padding: 0 16px 24px; }

/* ---------- Fortschritt ---------- */
.progress-card {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  display: grid;
  gap: 12px;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.progress-label span:first-child { font-weight: 600; }
.progress-label span:last-child { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.progress-bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--mint); border-radius: 99px; transition: width 0.3s ease; }
.progress-fill--soft { background: var(--mint-dim); }

/* ---------- Toolbar & Chips ---------- */
.toolbar { margin-top: 16px; display: grid; gap: 10px; }

input[type="search"], input[type="text"], input[type="date"], select, textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--mint); }
::placeholder { color: #6b7480; }

.toggle { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; color: var(--text-muted); }
.toggle input { width: 20px; height: 20px; accent-color: var(--mint); }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 12px -16px 0;
  padding: 0 16px 4px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 8px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  white-space: nowrap;
}
.chip.is-active { background: var(--mint); border-color: var(--mint); color: var(--bg); font-weight: 600; }

/* ---------- Inventarliste ---------- */
.section-title {
  margin: 24px 0 4px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mint);
  display: flex;
  justify-content: space-between;
}
.section-title small { color: var(--text-muted); letter-spacing: 0; text-transform: none; font-size: 0.8rem; }
.group-title { margin: 14px 0 6px; font-size: 0.95rem; color: var(--text); font-weight: 600; }

.item-list, .todo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius);
}
.item.is-done .item-name, .todo.is-done .todo-text { color: var(--text-muted); text-decoration: line-through; }

.check {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--mint);
  background: transparent;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
.check svg { width: 16px; height: 16px; opacity: 0; color: var(--bg); }
.is-done > .check { background: var(--mint); }
.is-done > .check svg { opacity: 1; }

.thumb {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
}
.item-body {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.item-text { min-width: 0; }
.item-name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { display: block; font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty {
  margin-top: 40px;
  text-align: center;
  color: var(--text-muted);
}
.empty strong { display: block; color: var(--mint); font-size: 1.1rem; margin-bottom: 6px; }

/* ---------- To-dos ---------- */
.todo-form { margin-top: 16px; display: grid; gap: 10px; }
.todo-form-row { display: flex; gap: 10px; }
.todo-form-row input { flex: 1; }
#todo-summary { margin: 16px 0 8px; }

.todo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius);
}
.todo-body { flex: 1; min-width: 0; }
.todo-text { display: block; word-break: break-word; }
.todo-due { display: inline-block; margin-top: 2px; font-size: 0.8rem; color: var(--text-muted); }
.todo-due.is-overdue { color: var(--danger); }
.todo-due.is-today { color: var(--warn); }

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--mint); border-color: var(--mint); color: var(--bg); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-small { padding: 9px 12px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; }

.settings-actions { display: grid; gap: 10px; margin-top: 12px; }

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 20px);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  background: var(--mint);
  color: var(--bg);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  z-index: 5;
}
#inventory-list { padding-bottom: 80px; }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 10;
}
.tab {
  border: 0;
  background: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.75rem;
  cursor: pointer;
}
.tab svg { width: 24px; height: 24px; }
.tab.is-active { color: var(--mint); font-weight: 600; }

/* ---------- Dialog (Bottom-Sheet) ---------- */
dialog { color: var(--text); }
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--surface);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
.sheet form { padding: 16px 16px calc(16px + var(--safe-bottom)); display: grid; gap: 14px; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; }
.sheet-header h2 { margin: 0; font-size: 1.2rem; }
.sheet input[type="text"], .sheet select, .sheet textarea { background: var(--bg); }

.photo-box {
  height: 200px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px dashed var(--border);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.photo-placeholder { color: var(--text-muted); }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 0.85rem; color: var(--text-muted); }
.field-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.field-check { display: flex; align-items: center; gap: 8px; padding-bottom: 12px; }
.field-check input { width: 22px; height: 22px; accent-color: var(--mint); }
.field-check span { color: var(--text); font-size: 0.95rem; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; background: var(--bg); border-radius: 12px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block;
  padding: 10px 8px;
  text-align: center;
  border-radius: 9px;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
}
.segmented input:checked + span { background: var(--mint); color: var(--bg); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--mint); outline-offset: 2px; }

.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.sheet-actions .btn-primary { flex: 1; }

.photo-viewer {
  max-width: 100vw;
  max-height: 100dvh;
  padding: 0;
  border: 0;
  background: transparent;
}
.photo-viewer::backdrop { background: rgba(0, 0, 0, 0.92); }
.photo-viewer img { display: block; max-width: 100vw; max-height: 100dvh; object-fit: contain; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 90px);
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.toast.is-error { border-color: var(--danger); color: var(--danger); }
.emoji { margin-right: 6px; }

/* ---------- Anmeldung ---------- */
body.is-locked > :not(#login-screen):not(#toast):not(script) { display: none !important; }
body.is-locked { padding-bottom: 0; }
.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  display: grid;
  gap: 14px;
  padding: 28px 20px;
  background: var(--surface);
  border-radius: 20px;
}
.login-logo { justify-self: center; border-radius: 18px; }
.login-card h1 { text-align: center; font-size: 1.6rem; }
.login-card .muted { text-align: center; margin-top: -6px; }
.login-card input { background: var(--bg); }
.login-card .btn-primary { margin-top: 6px; }
.login-error { margin: 0; color: var(--danger); font-size: 0.9rem; }
