/* Einkaufsliste: neutrale Basis (Weiß, Grau, Schwarz),
   bunt sind nur die Gänge, jeder in seiner eigenen Farbe. */

:root {
  --paper: #FAFAFA;
  --panel: #FFFFFF;
  --ink: #000000;
  --muted: #66707A;
  --line: #E2E5E9;
  --sign: #000000;
  --sign-dark: #333333;
  --sign-soft: #ECEEF1;
  --tag: #DDE1E6;
  --tag-soft: #F0F2F4;
  --done: #2E7D32;
  --danger: #C53030;

  --display: "Nunito Sans", "Segoe UI", system-ui, sans-serif;
  --text: "Nunito Sans", "Segoe UI", system-ui, sans-serif;

  --step--1: 0.8125rem;   /* 13 */
  --step-0: 1rem;         /* 16 */
  --step-1: 1.125rem;     /* 18 */
  --step-2: 1.5rem;       /* 24 */
  --step-3: 2.25rem;      /* 36 */

  font-family: var(--text);
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 16px; }
body { margin: 0; min-height: 100vh; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--sign); outline-offset: 2px; border-radius: 6px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Kopf ---------- */

.linklike {
  background: none; border: 0; padding: 0;
  color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px;
}

.topbar {
  max-width: 752px; margin: 0 auto;
  padding: 20px 16px 4px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
h1 {
  font-family: var(--display); font-weight: 800;
  font-size: 2rem; line-height: 1.1; letter-spacing: -0.01em;
  margin: 0;
}
.sub { margin: 6px 0 0; color: var(--muted); font-size: var(--step--1); }

.me-btn {
  display: flex; align-items: center; gap: 10px;
  border: 0; background: none; padding: 4px; border-radius: 999px;
}
.me-name { display: none; font-weight: 700; }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c, #8892a6) center / cover no-repeat;
  color: #fff; font-family: var(--display); font-weight: 700; font-size: 13px;
  overflow: hidden;
}
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.avatar.lg { width: 44px; height: 44px; font-size: 18px; }
.avatar.xl { width: 88px; height: 88px; font-size: 34px; }

/* ---------- Anmelden, Profil anlegen ---------- */

.screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--panel);
  border: 1.5px solid var(--line); border-radius: 16px; padding: 28px 24px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .05);
}
.auth-card h1 { margin-bottom: 6px; }
.auth-card .sub { margin: 0 0 20px; font-size: var(--step-0); }
.auth-card form { display: grid; gap: 14px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--sign-soft); border-radius: 12px; margin-bottom: 18px; }
.auth-tabs button {
  border: 0; background: none; border-radius: 9px; padding: 9px 8px; font-weight: 700; color: var(--muted);
}
.auth-tabs button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.primary-btn.wide { width: 100%; padding: 13px 22px; }
.primary-btn:disabled { opacity: .6; cursor: progress; }
.forgot { justify-self: center; font-weight: 600; color: var(--muted); }
.avatar-upload.center { justify-self: center; }
.form-msg { margin: 0; padding: 10px 12px; border-radius: 10px; font-size: 0.9375rem; background: #FDECEC; color: var(--danger); }
.form-msg[data-kind="ok"] { background: #E8F4EA; color: #1E5E2A; }

.toast {
  position: fixed; z-index: 50; left: 50%; bottom: 96px; transform: translateX(-50%);
  max-width: min(92vw, 480px); padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 0.9375rem; box-shadow: 0 8px 30px rgba(0, 0, 0, .2);
}

/* ---------- Grundlayout (Handy zuerst) ---------- */

.layout { max-width: 1064px; margin: 0 auto; }
.side { display: contents; }
.side-title { display: none; }
.route-block { display: none; }
.main { max-width: 752px; margin: 0 auto; padding: 0 16px 140px; min-width: 0; }

/* Läden: auf dem Handy waagerechte Chips */
.filters {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  max-width: 752px; margin: 0 auto; padding: 12px 16px 4px;
}
.filters::-webkit-scrollbar { display: none; }
.filters:empty { display: none; }
.store-btn {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--line); background: var(--panel);
  border-radius: 999px; padding: 7px 14px; font-size: 0.9375rem; white-space: nowrap;
}
.store-btn .count { color: var(--muted); font-size: var(--step--1); }
.store-btn[aria-pressed="true"] { background: var(--sign); border-color: var(--sign); color: #fff; }
.store-btn[aria-pressed="true"] .count { color: rgba(255, 255, 255, .8); }

/* ---------- Eingabe ---------- */

.addbar {
  position: fixed; z-index: 5; left: 0; right: 0; bottom: 0;
  padding: 18px 12px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 72%, color-mix(in srgb, var(--paper) 0%, transparent));
}
.addbar-inner {
  max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 16px;
  padding: 5px 5px 5px 16px; box-shadow: 0 2px 10px rgba(31, 41, 51, .08);
}
.addbar-inner:focus-within { border-color: var(--sign); }
.addbar input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none;
  font-size: var(--step-1); padding: 9px 0;
}
.details-btn {
  border: 0; background: none; color: var(--muted);
  font-size: var(--step--1); font-weight: 700; padding: 10px 8px; border-radius: 8px;
}
.details-btn:hover { color: var(--ink); background: var(--paper); }
.add-btn {
  display: grid; place-items: center; flex: none;
  width: 46px; height: 46px; border: 0; border-radius: 11px;
  background: var(--sign); color: #fff;
}
.add-btn:hover { background: var(--sign-dark); }
.hint {
  max-width: 720px; margin: 6px auto 0; padding: 0 16px;
  font-size: var(--step--1); color: var(--muted); min-height: 1.2em;
}
.hint b { color: var(--ink); }

/* ---------- Liste ---------- */

.list { max-width: 720px; }
.aisle { margin-top: 22px; }

/* Gang-Überschrift: kleine grüne Gangnummer, Name, Anzahl */
.aisle-sign {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 8px; color: var(--ink);
  font-family: var(--display); font-weight: 800; font-size: var(--step-1);
}
.aisle-no {
  display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px;
  border-radius: 8px; background: var(--aisle, var(--sign)); color: #fff;
  font-size: var(--step-0); font-weight: 800; line-height: 1;
}
.aisle-name { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.aisle-name .icon { font-size: 1.05em; }
.aisle-count { color: var(--muted); font-family: var(--text); font-weight: 600; font-size: var(--step--1); }

.rows {
  list-style: none; margin: 0; padding: 0;
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 10px;
}
.item { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 6px; min-height: 58px; position: relative; }
.item + .item { border-top: 1px solid var(--line); }

.check {
  flex: none; display: grid; place-items: center;
  width: 44px; height: 44px; border: 0; background: none; padding: 0; border-radius: 10px;
}
.check-box {
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 7px;
  border: 2px solid #B8C0C8; background: var(--panel); color: transparent;
  transition: background-color .15s, border-color .15s;
}
.check:hover .check-box { border-color: var(--sign); }
.item.done .check-box, .item.checking .check-box { background: var(--done); border-color: var(--done); color: #fff; }

.item-body {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  border: 0; background: none; padding: 6px 4px; text-align: left; border-radius: 8px;
}
.item:hover { background: #F6F7F8; }
.rows .item:first-child { border-radius: 9px 9px 0 0; }
.rows .item:last-child { border-radius: 0 0 9px 9px; }
.rows .item:only-child { border-radius: 9px; }
.item-by { flex: none; display: grid; place-items: center; width: 32px; }
.item-text { flex: 1; min-width: 0; }
.item-name {
  font-size: var(--step-1); font-weight: 600; overflow-wrap: anywhere;
  background-image: linear-gradient(var(--tag), var(--tag));
  background-repeat: no-repeat; background-size: 0% 100%;
  transition: background-size .25s ease-out;
}
.item.checking .item-name { background-size: 100% 100%; }
.item-qty { color: var(--muted); font-size: 0.9375rem; margin-left: 8px; white-space: nowrap; }
.item-extra { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; font-size: var(--step--1); color: var(--muted); }
.item-store { color: var(--ink); background: var(--sign-soft); border-radius: 6px; padding: 0 7px; font-weight: 600; }
.item-note { overflow-wrap: anywhere; }
.item.done .item-name { text-decoration: line-through; color: var(--muted); background: none; }
.thumb { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; flex: none; background: var(--line); }

.item-link {
  flex: none; display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  color: var(--muted); text-decoration: none;
}
.item-link:hover { background: var(--sign-soft); color: var(--ink); }

.cart-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 8px;
}
.cart-head h2 { font-family: var(--display); font-size: var(--step-1); font-weight: 800; margin: 0; }
.cart-head .ghost-btn { padding: 6px 12px; font-size: var(--step--1); }
.cart .rows { background: transparent; }
.cart .item:hover { background: transparent; }

.empty { text-align: center; color: var(--muted); padding: 56px 16px 24px; }
.empty h2 { font-family: var(--display); color: var(--ink); font-size: var(--step-2); margin: 0 0 6px; }
.empty p { margin: 0; }
.empty .ghost-btn { margin-top: 14px; }

/* ---------- Knöpfe ---------- */

.ghost-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1.5px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 10px; padding: 9px 14px; font-size: 0.9375rem; font-weight: 700;
}
.ghost-btn:hover { border-color: #B8C0C8; background: var(--paper); }
.ghost-btn.danger { color: var(--danger); }
.ghost-btn.danger:hover { border-color: var(--danger); }
.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--sign); outline-offset: 2px; }
.primary-btn {
  border: 0; background: var(--sign); color: #fff; border-radius: 10px;
  padding: 11px 22px; font-weight: 700; font-size: var(--step-0);
}
.primary-btn:hover { background: var(--sign-dark); }

/* ---------- Dialoge ---------- */

.sheet {
  border: 0; padding: 0; color: var(--ink); background: var(--panel);
  width: 100%; max-width: 560px; max-height: 92dvh;
  margin: auto auto 0; border-radius: 18px 18px 0 0;
}
.sheet[open] { display: flex; }
.sheet::backdrop { background: rgba(31, 41, 51, .4); }
.sheet form { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.sheet-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px 16px 8px 20px;
}
.sheet-head h2:focus { outline: none; }
.sheet-head h2 { margin: 0; font-family: var(--display); font-size: var(--step-2); letter-spacing: -0.02em; }
.close-btn {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 10px; background: var(--paper); color: var(--ink);
}
.close-btn:hover { background: var(--line); }
.sheet-body { overflow-y: auto; padding: 8px 20px 12px; display: grid; align-content: start; gap: 14px; flex: 1; min-height: 0; }
.sheet-actions {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.sheet-actions .primary-btn:only-child { margin-left: auto; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .field-label { font-size: 0.9375rem; font-weight: 700; margin: 0; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 12px; background: var(--paper); font-size: var(--step-0);
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--sign); background: var(--panel);
  box-shadow: 0 0 0 3px var(--sign-soft);
}
.field input[aria-invalid="true"] { border-color: var(--danger); }
.error { color: var(--danger); font-size: var(--step--1); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.image-picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.image-picker img { width: 76px; height: 76px; border-radius: 10px; object-fit: cover; border: 1.5px solid var(--line); }
.meta { margin: 0; font-size: var(--step--1); color: var(--muted); }

.profile-switch { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-pick {
  display: inline-flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 4px 16px 4px 4px; font-size: var(--step-0);
}
.profile-pick .avatar { width: 34px; height: 34px; font-size: 14px; }
.profile-pick[aria-current="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 700; }
.profile-edit { display: flex; gap: 18px; align-items: center; }
.family { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.profile-fields { flex: 1; display: grid; gap: 12px; min-width: 0; }
.avatar-upload { display: grid; justify-items: center; gap: 6px; cursor: pointer; border-radius: 12px; padding: 4px; }
.avatar-upload:focus-within { outline: 3px solid var(--sign); outline-offset: 2px; }
.avatar-upload-label { font-size: var(--step--1); color: var(--sign); font-weight: 700; }

@media (max-width: 440px) {
  .row { grid-template-columns: 1fr; }
  .profile-edit { flex-direction: column; align-items: stretch; }
  h1 { font-size: 2rem; }
}

/* ---------- Desktop ---------- */

@media (min-width: 960px) {
  .topbar { max-width: 1064px; padding: 32px 32px 8px; }
  .me-name { display: inline; }
  .me-btn { padding: 4px 4px 4px 14px; border: 1.5px solid var(--line); background: var(--panel); }
  .me-btn:hover { border-color: var(--sign); }
  .avatar.lg { width: 38px; height: 38px; font-size: 16px; box-shadow: none; }

  .layout {
    display: grid; grid-template-columns: 260px minmax(0, 1fr);
    gap: 48px; padding: 16px 32px 64px; align-items: start;
  }
  .side {
    display: grid; gap: 28px;
    position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto;
    padding-bottom: 8px;
  }
  .side-title { display: block; font-family: var(--display); font-size: var(--step-0); font-weight: 700; margin: 0 0 10px; }
  .route-block { display: block; }
  #storeBlock:has(.filters:empty) { display: none; }

  .filters { flex-direction: column; overflow: visible; max-width: none; margin: 0; padding: 0; gap: 2px; }
  .store-btn {
    justify-content: space-between; width: 100%;
    border: 0; background: none; border-radius: 8px; padding: 8px 10px; font-size: var(--step-0);
  }
  .store-btn:hover { background: var(--panel); }
  .store-btn[aria-pressed="true"] { background: var(--sign); }

  .route { list-style: none; margin: 0; padding: 0; position: relative; }
  .route::before {
    content: ""; position: absolute; left: 15px; top: 14px; bottom: 14px;
    border-left: 2px dashed var(--line);
  }
  .route a {
    position: relative; display: flex; align-items: center; gap: 10px;
    padding: 6px 10px 6px 0; border-radius: 8px; color: var(--ink); text-decoration: none;
  }
  .route a:hover .route-name { text-decoration: underline; text-underline-offset: 3px; }
  .route-no {
    display: grid; place-items: center; flex: none;
    width: 32px; height: 28px; border-radius: 8px;
    background: var(--aisle, var(--sign)); color: #fff;
    font-family: var(--display); font-weight: 800; font-size: var(--step--1);
  }
  .route-name { flex: 1; min-width: 0; }
  .route-count { color: var(--muted); font-size: var(--step--1); }
  .route-cart .route-no { background: var(--done); color: #fff; }

  .main { max-width: none; margin: 0; padding: 0; }
  .addbar { position: sticky; top: 0; padding: 0 0 4px; background: var(--paper); z-index: 5; max-width: 720px; }
  .addbar::before { content: ""; position: absolute; inset: -16px 0 auto; height: 16px; background: var(--paper); }
  .addbar::after {
    content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 14px;
    background: linear-gradient(var(--paper), color-mix(in srgb, var(--paper) 0%, transparent));
    pointer-events: none;
  }
  .hint { padding-bottom: 2px; }
  .addbar-inner { max-width: none; }
  .hint { max-width: none; }
  .list { padding-bottom: 40px; }
  .aisle:first-child { margin-top: 12px; }
  .aisle { scroll-margin-top: 110px; }

  /* Details als Seitenleiste rechts */
  .sheet {
    margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; max-width: 440px;
    border-radius: 0; border-left: 1px solid var(--line); box-shadow: -8px 0 30px rgba(31, 41, 51, .12);
  }
  .sheet::backdrop { background: rgba(31, 41, 51, .2); }
  .sheet-head { padding: 24px 24px 8px 28px; }
  .sheet-body { padding: 8px 28px 16px; }
  .sheet-actions { padding: 16px 28px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
