:root {
  --bg: #faf6f1;
  --card: #ffffff;
  --text: #3a2e2a;
  --muted: #8a7a72;
  --line: #eadfd5;
  --accent: #b5446e;
  --accent-dark: #8e3255;
  --accent-soft: #f6e3ea;
  --green: #4f8a5b;
  --green-soft: #e3f1e5;
  --amber: #b7791f;
  --amber-soft: #fdf1dc;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(58, 46, 42, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.4;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overscroll-behavior-y: none;
}

#app { max-width: 560px; margin: 0 auto; padding: 12px 16px 32px; }

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

button {
  cursor: pointer;
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.4; }

.btn-primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:active { background: var(--accent-dark); }
.btn-ghost { background: transparent; box-shadow: none; color: var(--accent); font-weight: 600; padding: 8px 4px; }
.btn-danger { background: #fff; color: #b3261e; border: 1px solid #f0c9c6; box-shadow: none; }

/* Kopfzeile */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; margin-bottom: 8px; }
.topbar h1 { font-size: 1.5rem; margin: 0; }
.topbar .title { font-size: 1.1rem; font-weight: 700; text-align: center; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; font-size: 1.3rem; }

/* Projektliste */
.project-list { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.project-card {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  padding: 16px; border-radius: var(--radius);
}
.project-card .emoji { font-size: 2rem; width: 48px; height: 48px; display: grid; place-items: center; background: var(--accent-soft); border-radius: 14px; flex-shrink: 0; }
.project-card .info { flex: 1; min-width: 0; }
.project-card .name { font-weight: 700; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card .meta { color: var(--muted); font-size: 0.9rem; }
.project-card .chev { color: var(--muted); font-size: 1.4rem; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .big { font-size: 3rem; }
.new-btn { width: 100%; padding: 16px; font-size: 1.1rem; margin-top: 8px; }

/* Zählbildschirm */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.label { color: var(--muted); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.banner { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; font-weight: 600; display: flex; gap: 10px; align-items: flex-start; }
.banner.now { background: var(--amber-soft); color: #7a4f0e; border: 2px solid var(--amber); }
.banner.next { background: var(--card); color: var(--muted); font-weight: 500; box-shadow: var(--shadow); }
.banner .ico { font-size: 1.3rem; line-height: 1.2; }

.repeat-card { text-align: center; }
.repeat-card.done { background: var(--green-soft); }
.repeat-pass { font-size: 1.6rem; font-weight: 800; margin: 2px 0; }
.repeat-pos { color: var(--muted); font-weight: 600; }
.repeat-card.done .repeat-pos { color: var(--green); }
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin: 12px 0 4px; }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--accent); background: transparent; }
.dot.on { background: var(--accent); }
.repeat-card.done .dot { border-color: var(--green); background: var(--green); }
.dots.many .dot { width: 14px; height: 14px; }

.row-card { text-align: center; padding-top: 18px; }
.row-number { font-size: 5.5rem; font-weight: 800; line-height: 1; margin: 6px 0; font-variant-numeric: tabular-nums; }
.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0 4px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.2s; }
.progress-text { color: var(--muted); font-size: 0.9rem; }

/* Fester Zähl-Bereich unten: bleibt immer an derselben Stelle */
.counter-view { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
.count-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: 72px 1fr 72px; gap: 10px;
  max-width: 560px; margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 80%, rgba(250, 246, 241, 0));
}
.plus-btn {
  min-height: 116px; font-size: 2.4rem; font-weight: 800; line-height: 1.1;
  background: var(--accent); color: #fff; border-radius: 24px; padding: 8px;
}
.plus-btn:active { background: var(--accent-dark); }
.plus-btn small { display: block; font-size: 1rem; font-weight: 600; opacity: 0.9; }
.row-now { font-weight: 600; color: var(--accent-dark); }
.repeat-card.done .repeat-pass { font-size: 1.35rem; }
.side-btn { font-size: 1.4rem; font-weight: 700; padding: 6px; }
.side-btn small { display: block; font-size: 0.75rem; font-weight: 500; color: var(--muted); }

.stitch-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stitch-card .num { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: center; }
.stitch-card .ctrl { display: flex; gap: 8px; align-items: center; }
.stitch-card .ctrl button { width: 56px; height: 56px; font-size: 1.6rem; font-weight: 700; padding: 0; }
.stitch-card .ctrl .plus { background: var(--accent-soft); color: var(--accent-dark); }
.stitch-reset { font-size: 0.85rem; padding: 4px 0 0; }

.note-text { white-space: pre-wrap; margin-top: 6px; }

/* Formular */
.form .field { margin-bottom: 16px; }
.form label.lbl { display: block; font-weight: 600; margin-bottom: 6px; }
.form .hint { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.form input[type=text], .form input[type=number], .form textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 1rem;
}
.form input:focus, .form textarea:focus { outline: none; border-color: var(--accent); }
.form textarea { min-height: 90px; resize: vertical; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented button { padding: 14px; font-weight: 600; border: 2px solid transparent; }
.segmented button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); }
.sub { padding: 12px 0 0 34px; }
.inline { display: flex; gap: 10px; align-items: center; }
.inline input[type=number] { width: 110px; }
.reminder-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.reminder-row input[type=number] { width: 84px; flex-shrink: 0; }
.reminder-row input[type=text] { flex: 1; min-width: 0; }
.reminder-row button { width: 44px; height: 44px; padding: 0; flex-shrink: 0; box-shadow: none; border: 1.5px solid var(--line); }
.form-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.form-actions button { padding: 16px; font-size: 1.05rem; }
.section-title { font-size: 1rem; font-weight: 700; margin: 24px 0 10px; padding-top: 16px; border-top: 1px solid var(--line); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: calc(100% - 32px); text-align: center; z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
