:root {
  --bg: #12151d;
  --card: #1d2333;
  --card2: #262d40;
  --border: #333c52;
  --text: #e8eaf0;
  --dim: #9aa3b8;
  --blue: #5b8def;
  --blue-h: #6f9bf2;
  --green: #34c759;
  --red: #ff453a;
  --orange: #ff9f0a;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
html {
  background: var(--bg) url("bg.jpg") center / cover fixed no-repeat;
}
/* dunkle Überlagerung, damit Text auf dem Foto lesbar bleibt */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(18,21,29,0.86), rgba(18,21,29,0.94));
}
body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  max-width: 640px; margin: 0 auto;
}
.hidden { display: none !important; }
.muted { color: var(--dim); }
.center { text-align: center; }

.view { padding: 16px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px;
}

/* Login */
.login-card { margin-top: 12vh; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .muted { margin: 0 0 16px; font-size: 13px; }
label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 12px; }
input[type=text], input[type=password], input[type=date] {
  width: 100%; margin-top: 6px; padding: 12px; font-size: 16px;
  background: var(--card2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); outline: none;
}
input:focus { border-color: var(--blue); }
button {
  font-family: inherit; font-size: 16px; cursor: pointer; border: none;
  border-radius: 10px; padding: 12px 14px; color: var(--text);
}
button.primary { background: var(--blue); color: #fff; font-weight: 600; width: 100%; }
button.primary:active { background: var(--blue-h); }
.msg { font-size: 13px; min-height: 18px; margin: 10px 0 0; }
.msg.err { color: var(--red); }
.msg.ok { color: var(--green); }

/* App-Kopf */
header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
header h1 { margin: 0; font-size: 24px; }
.head-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--card2); border: 1px solid var(--border);
  width: 42px; height: 42px; padding: 0; font-size: 20px; line-height: 1;
}
.icon-btn:active { background: var(--border); }
.icon-btn.active { background: var(--blue); border-color: var(--blue); }
.icon-btn.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Neu-Zeile */
.new-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 10px; padding: 10px; }
.new-row #new-text { flex: 1; margin: 0; }
button.add { width: 48px; padding: 12px 0; font-size: 22px; }
/* Datepicker als Icon-Button */
.icon-date {
  width: 46px; padding: 0; font-size: 20px; background: var(--card2);
  border: 1px solid var(--border); color: var(--dim);
}
.icon-date.set { color: #fff; background: var(--blue); border-color: var(--blue); }
.hidden-date {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  border: 0; opacity: 0; pointer-events: none;
}

.status { font-size: 12px; color: var(--dim); min-height: 16px; margin: 0 2px 8px; }
.status.err { color: var(--red); }

/* Liste */
.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.item .check {
  width: 24px; height: 24px; flex: 0 0 24px; margin-top: 1px;
  border: 2px solid var(--dim); border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 15px; color: #fff;
}
.item.done .check { background: var(--green); border-color: var(--green); }
.item .body { flex: 1; min-width: 0; }
.item .txt { font-size: 16px; word-break: break-word; }
.item.done .txt { color: var(--dim); text-decoration: line-through; }
.item .desc {
  font-size: 13px; color: var(--dim); margin-top: 3px; white-space: pre-wrap;
  word-break: break-word; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.item.done .desc { text-decoration: line-through; }
.item .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.item .meta span { font-size: 12px; color: var(--dim); }
.item .meta .due.overdue { color: var(--red); }
.item .tag {
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 7px; font-size: 11px;
}
.item .tag.kunde { color: var(--text); }
.item .body { cursor: pointer; }

/* Gruppen-Überschriften (wie am Desktop) */
.section-head {
  font-size: 12px; font-weight: 700; letter-spacing: .3px;
  margin: 14px 2px 6px; text-transform: none;
}

/* Erledigt-Akkordeon */
.accordion { margin-top: 16px; }
.acc-head {
  width: 100%; text-align: left; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; color: var(--text); font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.acc-caret { display: inline-block; transition: transform .15s; color: var(--dim); }
.accordion.open .acc-caret { transform: rotate(90deg); }
.acc-count {
  margin-left: auto; background: var(--card2); border-radius: 10px;
  padding: 1px 9px; font-size: 12px; color: var(--dim);
}
.accordion .list { margin-top: 8px; }

/* Pull-to-refresh */
.ptr {
  position: fixed; top: 0; left: 0; right: 0; height: 0; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
  color: var(--dim); font-size: 22px; transition: height .15s;
  pointer-events: none; z-index: 5;
}
.ptr.pull { height: 46px; }
.ptr.spin #ptr-icon { display: inline-block; animation: spin .8s linear infinite; }

/* Detail-Overlay */
.overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--bg); width: 100%; max-width: 640px;
  border-radius: 18px 18px 0 0; border: 1px solid var(--border);
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; font-weight: 600; margin-bottom: 10px;
}
.sheet-head .danger:active { color: var(--red); }
.sheet label { margin-top: 4px; }
.sheet textarea {
  width: 100%; margin-top: 6px; padding: 12px; font-size: 15px; resize: vertical;
  background: var(--card2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); outline: none; font-family: inherit;
}
.sheet textarea:focus { border-color: var(--blue); }
.dv-info { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.dv-info span { font-size: 12px; color: var(--dim); background: var(--card2);
  border: 1px solid var(--border); border-radius: 8px; padding: 3px 9px; }
.sheet-btns { display: flex; gap: 10px; margin-top: 14px; }
.sheet-btns .primary { flex: 1; }
button.ghost {
  background: var(--card2); border: 1px solid var(--border); color: var(--text); flex: 1;
}
button.ghost.is-done { background: var(--green); border-color: var(--green); color: #fff; }
