/* ============================================================
   MegaPacklist – Design System
   Mobile-first, kompakt, Light/Dark, große Touch-Ziele.
   ============================================================ */

:root {
  --teal:        #0d9488;
  --teal-600:    #0f766e;
  --teal-700:    #115e59;
  --teal-tint:   #f0fdfa;
  --teal-tint-2: #ccfbf1;
  --amber:       #f59e0b;

  --bg:      #f5f7f8;
  --surface: #ffffff;
  --surface-2:#f1f5f6;
  --ink:     #0f172a;
  --muted:   #64748b;
  --faint:   #94a3b8;
  --line:    #e6ebee;
  --line-2:  #eef2f4;
  --danger:  #e11d48;

  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow:    0 4px 16px rgba(15,23,42,.08);
  --shadow-lg: 0 12px 34px rgba(15,23,42,.14);

  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --maxw: 640px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --teal:        #2dd4bf;
    --teal-600:    #14b8a6;
    --teal-700:    #0d9488;
    --teal-tint:   #12262b;
    --teal-tint-2: #0f3b3a;

    --bg:      #0b1220;
    --surface: #131c2b;
    --surface-2:#1b2740;
    --ink:     #e6edf5;
    --muted:   #93a4b8;
    --faint:   #6b7d92;
    --line:    #233149;
    --line-2:  #1c2941;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow:    0 6px 20px rgba(0,0,0,.35);
    --shadow-lg: 0 14px 40px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

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

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--teal-600); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 6px; }

/* ---- Brand ---- */
.brand { font-weight: 800; letter-spacing: -.03em; }
.brand .mega { color: var(--teal); }
.brand .rest { color: var(--ink); }

/* ============================================================
   Layout
   ============================================================ */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100dvh;
}

/* ---------- Startseite / Erstellen ---------- */
.create {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--safe-t) + 14px) 18px calc(var(--safe-b) + 18px);
}
.create-hero {
  text-align: center;
  padding: 4px 6px 12px;
}
.brandbar {
  display: flex; align-items: center; justify-content: center; gap: 11px;
}
.logo-badge {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--teal), var(--teal-700));
  border-radius: 13px;
  box-shadow: 0 6px 16px rgba(13,148,136,.32);
}
.logo-badge svg { width: 24px; height: 24px; }
.wordmark { font-size: 25px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.wordmark .tld { color: var(--teal); opacity: .8; }
.tagline { margin: 9px auto 0; color: var(--muted); font-size: 13.5px; line-height: 1.4; }

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 18px 16px;
}
.card + .card { margin-top: 14px; }

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--muted); margin: 0 0 6px 2px;
}
.input {
  width: 100%;
  padding: 14px 15px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  font-size: 16px;              /* >=16px: verhindert iOS-Zoom */
  transition: border-color .15s, background .15s;
}
.input::placeholder { color: var(--faint); }
.input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--teal);
}

/* Vorlagen-Chips */
.tpl-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 4px 2px 10px;
}
.tpl-head .label { margin: 0; }
.tpl-head .hint { font-size: 12.5px; color: var(--faint); }
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.tpl-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  min-height: 66px; padding: 8px 4px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: 14px;
  color: var(--ink);
  transition: all .14s ease;
}
.tpl-tile .emoji { font-size: 21px; line-height: 1; }
.tpl-tile .nm { font-size: 11.5px; font-weight: 700; text-align: center; line-height: 1.12; }
.tpl-tile .cnt { font-size: 9.5px; color: var(--faint); font-weight: 600; }
.tpl-tile:active { transform: scale(.95); }
.tpl-tile.sel {
  background: var(--teal-tint);
  border-color: var(--teal);
  color: var(--teal-700);
}
.tpl-tile.sel .cnt { color: var(--teal-600); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%;
  padding: 15px 18px;
  background: var(--teal);
  color: #fff;
  border-radius: var(--r-md);
  font-size: 16.5px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(13,148,136,.28);
  transition: transform .12s, box-shadow .12s, opacity .12s;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn:disabled { opacity: .55; box-shadow: none; }
.btn.secondary {
  background: var(--surface-2); color: var(--ink);
  box-shadow: none;
}
.btn.ghost { background: transparent; color: var(--teal-600); box-shadow: none; width: auto; padding: 10px 14px; }
.btn svg { width: 20px; height: 20px; }

.fineprint {
  margin: 12px 4px 0;
  font-size: 12.5px; color: var(--faint); text-align: center; line-height: 1.45;
}
.create-foot { margin-top: auto; padding-top: 22px; text-align: center; }
.create-foot .brand { font-size: 14px; opacity: .8; }
.create-foot .sub { font-size: 12px; color: var(--faint); margin-top: 4px; }

/* ============================================================
   Listenansicht
   ============================================================ */
.list-view { min-height: 100dvh; display: flex; flex-direction: column; }

.appbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: calc(var(--safe-t) + 8px) 12px 8px;
}
.appbar-row { display: flex; align-items: center; gap: 8px; }
.iconbtn {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px; color: var(--muted);
  transition: background .14s, color .14s;
}
.iconbtn:active { background: var(--surface-2); }
.iconbtn svg { width: 22px; height: 22px; }
.list-title {
  flex: 1; min-width: 0;
  font-size: 19px; font-weight: 800; letter-spacing: -.02em;
  border: none; background: transparent;
  padding: 6px 4px; border-radius: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-title:focus { background: var(--surface-2); outline: none; }

/* Fortschritt */
.progress { padding: 10px 6px 2px; }
.progress-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--muted); margin-bottom: 7px; padding: 0 2px;
}
.progress-meta .done { font-weight: 700; color: var(--ink); }
.progress-meta .done b { color: var(--teal-600); }
.bar { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--teal), var(--teal-600));
  border-radius: 99px;
  transition: width .35s cubic-bezier(.2,.8,.2,1);
}
.bar.complete > span { background: linear-gradient(90deg, var(--amber), #fbbf24); }

/* Einträge */
.items {
  flex: 1;
  padding: 8px 12px calc(var(--safe-b) + 96px);
  list-style: none; margin: 0;
}
.section-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); margin: 16px 6px 6px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 12px;
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px;
  transition: opacity .2s, transform .12s;
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.item:active { transform: scale(.995); }

.check {
  width: 26px; height: 26px; flex: none;
  border-radius: 9px;
  border: 2px solid var(--line);
  background: var(--surface-2);
  display: grid; place-items: center;
  transition: all .16s ease;
}
.check svg { width: 16px; height: 16px; color: #fff; opacity: 0; transform: scale(.5); transition: all .16s; }
.item.done .check { background: var(--teal); border-color: var(--teal); }
.item.done .check svg { opacity: 1; transform: none; }

.item-text {
  flex: 1; min-width: 0;
  font-size: 16px; line-height: 1.35;
  word-break: break-word;
  padding: 2px 0;
  border: none; background: transparent;
}
.item-text:focus { outline: none; }
.item.done .item-text { color: var(--faint); text-decoration: line-through; text-decoration-thickness: 1.5px; }

.item-del {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  color: var(--faint); border-radius: 9px;
  opacity: .0; transition: opacity .15s, color .15s, background .15s;
}
.item:hover .item-del, .item:focus-within .item-del { opacity: 1; }
.item-del:active { background: var(--surface-2); color: var(--danger); }
.item-del svg { width: 18px; height: 18px; }
@media (hover: none) { .item-del { opacity: .5; } }

/* Leerzustand */
.empty {
  text-align: center; padding: 46px 24px 20px; color: var(--muted);
}
.empty .ico { font-size: 40px; }
.empty h3 { margin: 10px 0 4px; color: var(--ink); font-size: 18px; }
.empty p { margin: 0 auto; max-width: 30ch; font-size: 14.5px; }

/* Eingabeleiste unten */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 12px calc(var(--safe-b) + 10px);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.composer-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; gap: 9px; align-items: center;
}
.composer .input { border-radius: 999px; background: var(--surface-2); }
.composer .input:focus { background: var(--surface); }
.add-btn {
  width: 50px; height: 50px; flex: none;
  border-radius: 999px; background: var(--teal); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(13,148,136,.3);
  transition: transform .12s;
}
.add-btn:active { transform: scale(.92); }
.add-btn:disabled { opacity: .5; box-shadow: none; }
.add-btn svg { width: 24px; height: 24px; }

/* ---- Share-Banner (einmalig nach Erstellung) ---- */
.share-banner {
  margin: 10px 12px 0; max-width: var(--maxw);
  display: flex; gap: 12px; align-items: center;
  padding: 13px 14px;
  background: var(--teal-tint); border: 1px solid var(--teal-tint-2);
  border-radius: var(--r-md);
}
.share-banner .txt { flex: 1; font-size: 13.5px; color: var(--teal-700); line-height: 1.4; }
.share-banner .txt b { display: block; font-size: 14px; }
.share-banner button.mini {
  padding: 9px 13px; border-radius: 10px; background: var(--teal); color: #fff;
  font-weight: 700; font-size: 13.5px; white-space: nowrap;
}
.share-banner .x { color: var(--teal-700); width: 28px; height: 28px; display: grid; place-items: center; }

/* ============================================================
   Sheet / Menü
   ============================================================ */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15,23,42,.42);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; animation: fade .18s forwards;
}
@keyframes fade { to { opacity: 1; } }
.sheet {
  width: 100%; max-width: var(--maxw);
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 8px 12px calc(var(--safe-b) + 14px);
  box-shadow: var(--shadow-lg);
  animation: slideup .24s cubic-bezier(.2,.9,.2,1);
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.sheet .grip { width: 40px; height: 4px; background: var(--line); border-radius: 99px; margin: 8px auto 10px; }
.sheet-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 15px 12px; border-radius: 12px;
  font-size: 16px; font-weight: 500; text-align: left;
  transition: background .12s;
}
.sheet-item:active { background: var(--surface-2); }
.sheet-item svg { width: 22px; height: 22px; color: var(--muted); }
.sheet-item.danger { color: var(--danger); }
.sheet-item.danger svg { color: var(--danger); }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 88px);
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; z-index: 80;
  transition: opacity .2s, transform .2s;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Ladezustand ---- */
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn.secondary .spinner { border-color: var(--line); border-top-color: var(--teal); }
@keyframes spin { to { transform: rotate(360deg); } }

.center-load {
  min-height: 100dvh; display: grid; place-items: center; color: var(--muted);
}
.center-load .spinner { border-color: var(--line); border-top-color: var(--teal); width: 30px; height: 30px; }

/* 404 / Fehlerzustand */
.state {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 24px; gap: 6px;
}
.state .ico { font-size: 46px; }
.state h2 { margin: 8px 0 2px; letter-spacing: -.02em; }
.state p { color: var(--muted); max-width: 32ch; margin: 0 0 14px; }
