/* ============================================================================
 *  Nestbau – styles.css
 *  Warm & freundlich (Baby-Kontext), aber klar und aufgeräumt. Mobile-first,
 *  große Touch-Targets, Shop-Preise auf einen Blick vergleichbar.
 * ========================================================================== */

:root {
  /* Farben – warme, geschlechtsneutrale Baby-Palette */
  --bg:            #faf5ee;
  --bg-2:         #f3ebdf;
  --surface:       #ffffff;
  --surface-soft:  #fbf7f1;
  --ink:           #35302a;
  --ink-soft:      #6f665b;
  --ink-faint:     #a89e90;
  --line:          #ece2d4;
  --line-strong:   #ddd0bd;

  --sage:          #6f9a7e;
  --sage-dark:     #5a8168;
  --sage-soft:     #e7f0ea;
  --apricot:       #e0996a;
  --apricot-dark:  #c97f4f;
  --apricot-soft:  #fbeee2;

  --status-offen:       #c2913c;
  --status-offen-bg:    #f8efd9;
  --status-entschieden: #3f88a6;
  --status-entschieden-bg:#e2eef3;
  --status-gekauft:     #5a8168;
  --status-gekauft-bg:  #e5f0e9;
  --danger:             #c0574d;
  --danger-soft:        #f7e6e4;

  --radius:   16px;
  --radius-sm: 11px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(60, 48, 30, .06), 0 2px 6px rgba(60, 48, 30, .05);
  --shadow-md: 0 6px 18px rgba(60, 48, 30, .10);
  --shadow-lg: 0 14px 40px rgba(60, 48, 30, .18);

  --tap: 44px; /* Mindest-Touch-Target */
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; }

/* ---------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4em;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .05s, color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--sage); color: #fff; }
.btn--primary:hover { background: var(--sage-dark); }
.btn--ghost { background: rgba(255,255,255,.7); color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover { background: #fff; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.95); }
.btn--danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn--danger-ghost:hover { background: var(--danger-soft); }
.btn--block { width: 100%; }
.btn--sm { min-height: 38px; padding: 0 13px; font-size: .875rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- App-Bar */
.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(160deg, #7ba589 0%, #6f9a7e 55%, #648f73 100%);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  box-shadow: var(--shadow-md);
}
.appbar__inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.appbar__brand { display: flex; align-items: center; gap: 12px; }
.appbar__logo {
  font-size: 1.9rem;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.15));
}
.appbar__title { font-size: 1.4rem; font-weight: 800; letter-spacing: -.01em; }
.appbar__subtitle { font-size: .82rem; opacity: .9; font-weight: 500; }

.appbar__budget { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.budget-card {
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  backdrop-filter: blur(2px);
}
.budget-card__label {
  display: block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  opacity: .88;
  font-weight: 600;
}
.budget-card__value { display: block; font-size: 1.15rem; font-weight: 800; margin-top: 2px; }
.budget-card--spent .budget-card__value { color: #ffe7cf; }

.appbar__actions { display: flex; gap: 9px; }
.appbar__actions .btn { flex: 1; }
.appbar__actions .btn--ghost { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.3); }
.appbar__actions .btn--ghost:hover { background: rgba(255,255,255,.28); }
.appbar__actions .btn--primary { background: #fff; color: var(--sage-dark); }
.appbar__actions .btn--primary:hover { background: #f4f4f4; }

/* Fortschritt */
.progress {
  max-width: 1100px;
  margin: 12px auto 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress__bar {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,.28);
  border-radius: 999px;
  overflow: hidden;
}
.progress__fill {
  display: block;
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 999px;
  transition: width .35s ease;
}
.progress__text { font-size: .8rem; font-weight: 600; opacity: .95; white-space: nowrap; }

/* ---------------------------------------------------------------- Banner */
.banner {
  max-width: 1100px;
  margin: 12px auto 0;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
}
.banner--demo {
  background: var(--status-offen-bg);
  color: #7a5a17;
  border: 1px solid #ecd9a8;
  margin: 12px 16px 0;
}
.banner code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 5px; font-size: .85em; }

/* ---------------------------------------------------------------- Content */
.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 40px);
}

.group { margin-top: 22px; }
.group__head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 4px 11px;
}
.group__title { font-size: 1.02rem; font-weight: 700; color: var(--ink); }
.group__dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.group__count {
  font-size: .78rem;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 2px 9px;
  border-radius: 999px;
}
.group--offen .group__dot { background: var(--status-offen); }
.group--entschieden .group__dot { background: var(--status-entschieden); }
.group--gekauft .group__dot { background: var(--status-gekauft); }

/* Positions-Karte (Liste) */
.pcard {
  display: flex;
  align-items: stretch;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  margin-bottom: 11px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .08s, box-shadow .15s, border-color .15s;
}
.pcard:hover { box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.pcard:active { transform: scale(.995); }
.pcard__prio { width: 5px; border-radius: 999px; flex: none; background: var(--line-strong); }
.pcard--prio-hoch .pcard__prio { background: var(--apricot); }
.pcard--prio-mittel .pcard__prio { background: #d9c48a; }
.pcard--prio-niedrig .pcard__prio { background: #cfd8c9; }
.pcard__main { flex: 1; min-width: 0; }
.pcard__toprow { display: flex; align-items: baseline; gap: 8px; }
.pcard__title { font-size: 1.06rem; font-weight: 700; color: var(--ink); }
.pcard__notes {
  font-size: .85rem;
  color: var(--ink-soft);
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pcard__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 10px;
  margin-top: 9px;
  font-size: .82rem;
  color: var(--ink-soft);
}
.pcard__chosen {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--sage-dark);
}
.pcard__price { font-weight: 800; color: var(--ink); }
.pcard__chevron { align-self: center; color: var(--ink-faint); font-size: 1.4rem; flex: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .74rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.chip--count { background: var(--bg-2); color: var(--ink-soft); border: 1px solid var(--line); }
.chip--offen { background: var(--status-offen-bg); color: #8a6410; }
.chip--entschieden { background: var(--status-entschieden-bg); color: #275f76; }
.chip--gekauft { background: var(--status-gekauft-bg); color: #3f6650; }

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 48px 20px;
  font-size: .95rem;
}

/* ---------------------------------------------------------------- Detail */
.detail {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.detail__bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: rgba(250,245,238,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.detail__bar-actions { display: flex; gap: 6px; }
.detail__body { max-width: 1100px; margin: 0 auto; padding: 16px 16px 60px; }

.dhead__toprow { display: flex; align-items: flex-start; gap: 10px; }
.dhead__title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; flex: 1; }
.dhead__notes {
  margin-top: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-left: 4px solid var(--apricot);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: .9rem;
  color: var(--ink-soft);
  white-space: pre-wrap;
}

/* Status – segmentierte Auswahl */
.segmented {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
  margin-top: 14px;
}
.segmented__opt {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: .84rem;
  font-weight: 700;
  padding: 8px 15px;
  min-height: 38px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.segmented__opt[aria-pressed="true"] { color: #fff; box-shadow: var(--shadow-sm); }
.segmented__opt--offen[aria-pressed="true"] { background: var(--status-offen); }
.segmented__opt--entschieden[aria-pressed="true"] { background: var(--status-entschieden); }
.segmented__opt--gekauft[aria-pressed="true"] { background: var(--status-gekauft); }

.section-label {
  margin: 26px 4px 12px;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 800;
  color: var(--ink-faint);
}

/* Options-Vergleichskarten */
.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.ocard {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.ocard--chosen { border-color: var(--sage); box-shadow: 0 0 0 2px var(--sage-soft), var(--shadow-md); }
.ocard__chosen-flag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  background: var(--sage);
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.ocard__fav {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  background: var(--apricot);
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ocard__imgwrap {
  aspect-ratio: 16 / 10;
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line);
}
.ocard__img { width: 100%; height: 100%; object-fit: contain; }
.ocard__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--ink-faint);
  font-size: .78rem;
  font-weight: 600;
}
.ocard__placeholder span:first-child { font-size: 2.2rem; opacity: .55; }
.ocard__body { padding: 14px 15px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.ocard__name { font-size: 1.08rem; font-weight: 800; line-height: 1.25; padding-right: 4px; }

/* Ranking-Badges (separat vom "Unser Favorit"-Overlay) */
.ocard__badges { display: flex; flex-wrap: wrap; gap: 5px; }
.obadge {
  display: inline-flex;
  align-items: center;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.obadge--rank { background: var(--ink); color: #fff; }
.obadge--testsieger { background: var(--status-entschieden-bg); color: #205a72; border-color: #bcd9e5; }
.obadge--reviews { background: var(--sage-soft); color: #3f6650; border-color: #cfe2d6; }
.obadge--value { background: var(--apricot-soft); color: #9c5f2e; border-color: #f0d9c2; }
.obadge--other { background: var(--bg-2); color: var(--ink-soft); border-color: var(--line); }
.ocard__testnote {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--status-entschieden-bg);
  color: #275f76;
  font-size: .78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
/* Kernfakten: Pflichtkriterien auf einen Blick, direkt unter dem Produktnamen. */
.ocard__facts { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.ofact {
  display: inline-flex;
  align-items: center;
  font-size: .72rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 999px;
}
/* Nicht ausgewiesene Werte bleiben lesbar, treten aber zurueck. */
.ofact--unknown {
  color: var(--ink-soft);
  background: transparent;
  border-style: dashed;
  font-weight: 500;
}
.ocard__summary {
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
}
.ocard__desc { font-size: .89rem; color: var(--ink-soft); }
.ocard__pricerange {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.ocard__price-main { font-size: 1.25rem; font-weight: 800; color: var(--ink); }
.ocard__price-stand { font-size: .76rem; color: var(--ink-faint); font-weight: 600; }

/* Shops */
.shoplist { display: flex; flex-direction: column; gap: 7px; }
.shoprow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--tap);
  padding: 8px 13px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  font-size: .9rem;
  transition: background-color .12s, border-color .12s;
}
a.shoprow:hover { background: #fff; border-color: var(--line-strong); }
.shoprow--cheapest { border-color: var(--sage); background: var(--sage-soft); }
.shoprow__name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; min-width: 0; }
.shoprow__name .cheapest-tag {
  font-size: .68rem;
  font-weight: 800;
  color: var(--sage-dark);
  background: #fff;
  border: 1px solid var(--sage);
  padding: 1px 6px;
  border-radius: 999px;
}
.shoprow__right { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.shoprow__price { font-weight: 800; }
.shoprow__ext { color: var(--ink-faint); font-size: 1rem; }
.shoprow--static { cursor: default; }

.ocard__idealo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  font-size: .84rem;
  font-weight: 700;
  color: var(--apricot-dark);
  text-decoration: none;
}
.ocard__idealo:hover { text-decoration: underline; }

.ocard__actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
  margin-top: 2px;
}
.ocard__actions .btn { flex: 1; }

.add-option-btn {
  border: 2px dashed var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  border-radius: var(--radius);
  min-height: 56px;
  font-weight: 700;
  cursor: pointer;
}
.add-option-btn:hover { border-color: var(--sage); color: var(--sage-dark); background: var(--sage-soft); }

/* ---------------------------------------------------------------- Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(46, 38, 28, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(2px);
}
.modal {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.modal__title { font-size: 1.15rem; font-weight: 800; }
.modal__close {
  border: none;
  background: var(--bg-2);
  color: var(--ink-soft);
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
}
.modal__close:hover { background: var(--line); }
.modal__body { padding: 16px 18px; overflow-y: auto; }
.modal__foot {
  display: flex;
  gap: 10px;
  padding: 12px 18px calc(env(safe-area-inset-bottom) + 16px);
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}
.modal__foot .btn { flex: 1; }

/* Formular */
.field { margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }
.field__label { display: block; font-size: .84rem; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.field__hint { font-size: .76rem; color: var(--ink-faint); margin-top: 5px; }
.input, .textarea, .select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  font-family: inherit;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px var(--sage-soft);
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.textarea--sm { min-height: 56px; }
.textarea--code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85rem; min-height: 220px; }

.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  cursor: pointer;
  font-size: .92rem;
  font-weight: 600;
}
.check input { width: 20px; height: 20px; accent-color: var(--sage); }

/* Shop-Editor-Zeilen */
.shops-editor { display: flex; flex-direction: column; gap: 9px; }
.shop-edit-row { display: flex; gap: 7px; align-items: center; }
.shop-edit-row .input { min-height: 40px; }
.shop-edit-row .shop-name { flex: 2; }
.shop-edit-row .shop-price { flex: 1; min-width: 74px; }
.shop-edit-row .shop-url { flex: 3; }
.shop-del {
  flex: none;
  width: 40px; height: 40px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--danger);
  cursor: pointer;
  font-size: 1rem;
}
.shop-del:hover { background: var(--danger-soft); }
.form-error {
  background: var(--danger-soft);
  color: #8a352c;
  border: 1px solid #e6bdb6;
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: .86rem;
  margin-bottom: 14px;
  white-space: pre-wrap;
}
.confirm-text { font-size: .96rem; color: var(--ink-soft); }
.confirm-text strong { color: var(--ink); }

/* ---------------------------------------------------------------- Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  transform: translateX(-50%);
  z-index: 90;
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  max-width: 90vw;
  text-align: center;
  animation: toastIn .2s ease;
}
.toast--error { background: var(--danger); }
.toast--success { background: var(--sage-dark); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

[hidden] { display: none !important; }

/* ---------------------------------------------------------------- Desktop */
@media (min-width: 720px) {
  .appbar__inner {
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 22px;
  }
  .appbar__budget { grid-template-columns: auto auto; }
  .budget-card { min-width: 128px; }
  .appbar__actions { justify-content: flex-end; }
  .appbar__actions .btn { flex: none; }

  .options-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
  .banner--demo { margin-left: auto; margin-right: auto; }
}

@media (min-width: 1000px) {
  .options-grid { grid-template-columns: repeat(3, 1fr); }
}
