:root {
  --bg: #f3efe6;
  --bg-soft: #ebe4d6;
  --card: #ffffff;
  --ink: #171513;
  --muted: #7b7468;
  --line: #e7dfd0;
  --green: #2f9e62;
  --green-dark: #247a4c;
  --green-soft: #e7f6ee;
  --orange: #e86a2a;
  --orange-soft: #fff1e6;
  --blue: #3d7ecf;
  --blue-soft: #eaf2fb;
  --yellow: #e6b23a;
  --yellow-soft: #fff6de;
  --purple: #8b6bc9;
  --shadow: 0 10px 28px rgba(48, 36, 16, 0.08);
  --shadow-soft: 0 4px 16px rgba(48, 36, 16, 0.05);
  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html[data-theme="dark"] {
  --bg: #161410;
  --bg-soft: #211d17;
  --card: #221e19;
  --ink: #f4efe6;
  --muted: #b0a89b;
  --line: #3a342b;
  --green-soft: #1d3a2b;
  --orange-soft: #3a2418;
  --blue-soft: #1c2b3d;
  --yellow-soft: #3a3016;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", "Avenir Next", Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { max-width: 100%; display: block; }

.app {
  width: min(430px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  padding: calc(12px + var(--safe-top)) 16px calc(28px + var(--safe-bottom));
}

.topbar, .row, .tabs, .stat-line, .actions, .status-row, .photo-grid, .area-grid {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-soft);
  display: grid;
  place-items: center;
  color: var(--ink);
}

.icon-btn svg { width: 20px; height: 20px; }

.topbar-right { display: flex; gap: 8px; align-items: center; }

.fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 18px rgba(47, 158, 98, 0.35);
  display: grid;
  place-items: center;
  font-size: 30px;
  line-height: 1;
  font-weight: 500;
}

.kicker {
  margin: 10px 0 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 6px;
  font-size: 34px;
  line-height: 1.05;
}

.page-title .bulb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f3b23a;
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.08);
}

.stat-line {
  gap: 6px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 18px;
}

.stat-hot { color: var(--orange); font-weight: 800; }

.progress {
  height: 8px;
  background: #e4ecdf;
  border-radius: 99px;
  overflow: hidden;
  margin: 8px 0 16px;
}
html[data-theme="dark"] .progress { background: #2a3326; }
.progress > span {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}
.progress-label {
  float: right;
  margin-top: -22px;
  font-size: 12px;
  color: var(--green-dark);
  font-weight: 700;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 800;
  margin: 18px 0 10px;
}

.section-title .hint { color: var(--muted); font-weight: 600; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.area-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.area-card, .card, .idea-row, .list-card, .dashed {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.area-card {
  min-height: 132px;
  padding: 14px;
  text-align: left;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.area-card .mini-plus {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
}

.area-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  margin-bottom: 18px;
}
.area-icon svg { width: 20px; height: 20px; }

.area-card h3, .area-item h3, .idea-main h3 {
  margin: 0;
  font-size: 16px;
}
.meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

.dashed {
  width: 100%;
  margin-top: 12px;
  border: 1.5px dashed #cfc6b4;
  background: transparent;
  box-shadow: none;
  padding: 16px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}
html[data-theme="dark"] .dashed { border-color: #5a5144; }
.dashed strong { display: block; }
.plus-box {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--green-soft);
  color: var(--green-dark);
  display: grid;
  place-items: center;
  font-size: 22px;
  flex: none;
}

.recent-list, .group-list { display: grid; gap: 10px; }

.idea-row {
  width: 100%;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  flex: none;
}
.badge.wichtig { background: var(--orange-soft); color: var(--orange); }
.badge.info { background: var(--blue-soft); color: var(--blue); }
.badge.idee { background: var(--yellow-soft); color: #b88614; }
.badge.spaeter { background: #eef0f2; color: #6b7280; }
html[data-theme="dark"] .badge.spaeter { background: #2c2f33; color: #c5cad1; }

.idea-main { flex: 1; min-width: 0; }
.idea-main h3, .idea-copy h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--bg-soft);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: none;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.chev { color: var(--muted); }

.link-row {
  display: block;
  width: 100%;
  text-align: left;
  margin-top: 8px;
  padding: 8px 2px;
  color: var(--muted);
  font-weight: 600;
}

.tabs {
  background: var(--bg-soft);
  border-radius: 18px;
  padding: 5px;
  gap: 4px;
  margin: 4px 0 18px;
}
.tab {
  flex: 1;
  border-radius: 14px;
  padding: 10px 8px;
  color: var(--muted);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tab.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-soft); }
.tab .count {
  background: #f3b23a;
  color: #3b2a00;
  border-radius: 999px;
  min-width: 22px;
  padding: 1px 6px;
  font-size: 11px;
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  margin: 16px 2px 8px;
}
.group-head .count { color: var(--muted); font-weight: 700; }

.idea-card { padding: 12px 12px 10px; }
.idea-card .top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.check {
  width: 22px;
  height: 22px;
  border: 2px solid #c9c3b6;
  border-radius: 6px;
  margin-top: 2px;
  flex: none;
  background: #fff;
}
.idea-card.done .check {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  display: grid;
  place-items: center;
}
.idea-card.done { opacity: 0.72; }
.idea-card.done h3 { text-decoration: line-through; color: var(--muted); }
.idea-copy { flex: 1; min-width: 0; }
.title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.idea-copy p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.idea-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.actions { gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn {
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 800;
  font-size: 13px;
}
.btn.dark { background: #2f4053; color: #fff; }
.btn.ghost { background: #eef0f2; color: #4b5563; }
.btn.good { background: var(--green-soft); color: var(--green-dark); }
.btn.primary { background: var(--green); color: #fff; }
.btn.wide { flex: 1; }
html[data-theme="dark"] .btn.ghost { background: #2c2a26; color: #d5d0c6; }
html[data-theme="dark"] .btn.dark { background: #3d5368; }

.list-card { padding: 6px 8px; }
.area-item, .suggest-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  text-align: left;
  border-radius: 16px;
}
.area-item + .area-item, .suggest-item + .suggest-item { border-top: 1px solid var(--line); }
.drag {
  color: #c0b8aa;
  letter-spacing: -1px;
  font-size: 16px;
  padding: 4px;
  cursor: grab;
}
.area-item.expanded { align-items: flex-start; }
.area-item .grow { flex: 1; }
.area-tools { display: flex; gap: 8px; margin-top: 10px; }

.search {
  width: 100%;
  border: 0;
  background: var(--card);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 12px;
  outline: none;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 22, 14, 0.42);
  display: none;
  z-index: 20;
}
.overlay.open { display: block; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(110%);
  width: min(430px, 100%);
  max-height: min(92vh, 820px);
  overflow: auto;
  background: var(--card);
  border-radius: 28px 28px 0 0;
  padding: 18px 16px calc(20px + var(--safe-bottom));
  z-index: 21;
  transition: transform .22s ease;
}
.sheet.open { transform: translateX(-50%) translateY(0); }

@media (min-width: 720px) {
  .sheet {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, 20%) scale(0.98);
    border-radius: 28px;
    max-height: 88vh;
  }
  .sheet.open { transform: translate(-50%, -50%) scale(1); }
}
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet h2 { margin: 4px 0 14px; font-size: 28px; }

.field { margin-bottom: 14px; }
.field-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 800; margin-bottom: 6px; }
.req { color: var(--orange); }
label.tiny {
  display: block;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px;
}
input[type="text"], textarea, select.plain {
  width: 100%;
  border: 1.5px solid var(--line);
  background: #fbfaf7;
  border-radius: 16px;
  padding: 12px 14px;
  outline: none;
}
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] textarea,
html[data-theme="dark"] select.plain { background: #2a261f; }
textarea { min-height: 88px; resize: vertical; }
input[type="text"]:focus, textarea:focus { border-color: #c8c0b0; }

.photo-grid { gap: 10px; }
.photo-box {
  flex: 1;
  min-height: 92px;
  border: 1.5px dashed #d2cbbd;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 10px;
  position: relative;
  overflow: hidden;
}
.photo-box input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-box.cam { flex: 0.7; }

.status-row { gap: 8px; flex-wrap: wrap; }
.status-chip {
  border-radius: 999px;
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  font-weight: 800;
  font-size: 13px;
  background: transparent;
}
.status-chip.active.wichtig { background: var(--orange); color: #fff; border-color: var(--orange); }
.status-chip.active.info { background: var(--blue); color: #fff; border-color: var(--blue); }
.status-chip.active.idee { background: #f0c14b; color: #3b2a00; border-color: #f0c14b; }
.status-chip.active.spaeter { background: #6b7280; color: #fff; border-color: #6b7280; }

.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { padding: 14px 12px; font-size: 15px; }
.fineprint { text-align: center; color: var(--muted); font-size: 12px; margin: 12px 0 0; }

.picker { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch, .icon-pick {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 2px solid transparent;
}
.swatch.active, .icon-pick.active { border-color: var(--ink); }
.icon-pick { background: var(--bg-soft); color: var(--ink); display: grid; place-items: center; }
.icon-pick svg { width: 18px; height: 18px; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #1c1a17;
  color: #fff;
  padding: 10px 14px;
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.help-card, .confirm-card {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(380px, calc(100% - 32px));
  background: var(--card);
  border-radius: 24px;
  padding: 22px;
  z-index: 30;
  box-shadow: var(--shadow);
  display: none;
}
.help-card.open, .confirm-card.open { display: block; }
.help-card h3 { margin-top: 0; }
.help-card ol { padding-left: 18px; color: var(--muted); }

.setup-banner {
  background: #fff1e6;
  color: #9a3412;
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 700;
}
.setup-banner a { color: inherit; }

[hidden] { display: none !important; }

.login-page { padding-top: 36px; }
.login-card { padding: 22px; margin-top: 12px; }
.login-error {
  background: var(--orange-soft);
  color: var(--orange);
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 700;
}
.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 14px;
}
.login-card .btn { width: 100%; }
