:root {
  --teal: #137a5f;
  --teal-light: #22a686;
  --ink: #14201c;
  --paper: #f4f6f5;
  --card: #ffffff;
  --pasta: #d8532b;
  --getraenke: #2f6fb0;
  --wein: #7a2354;
  --danger: #c8342a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  overflow: hidden;
}

.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */
.topbar {
  flex: 0 0 auto;
  background: var(--teal);
  color: #fff;
  padding: 14px 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

/* ---------- Content / Product grid ---------- */
.content {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 260px;
}

.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 12px;
}

.product {
  position: relative;
  border: none;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  padding: 14px 8px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  border-top: 6px solid var(--accent, var(--teal));
  transition: transform 0.06s ease;
}

.product:active {
  transform: scale(0.96);
}

.product.has-qty {
  background: #eefcf6;
}

.product .emoji {
  font-size: 34px;
  line-height: 1;
}

.product .name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
}

.product .price {
  font-size: 17px;
  font-weight: 800;
  color: var(--accent, var(--teal));
  margin-top: 2px;
}

.product .qty-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: 16px;
  background: var(--teal);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.section-title {
  grid-column: 1 / -1;
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent, var(--teal));
  border-bottom: 3px solid var(--accent, var(--teal));
  padding-bottom: 6px;
  margin: 10px 0 0;
}

.section-title:first-child {
  margin-top: 0;
}

/* ---------- Cart / Bottom sheet ---------- */
.cart {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--card);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.18);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  max-height: 78dvh;
  display: flex;
  flex-direction: column;
  transform: translateY(calc(100% - 84px));
  transition: transform 0.22s ease;
}

.cart.expanded {
  transform: translateY(0);
}

.cart-handle {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  height: 84px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  width: 100%;
}

.cart-handle-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.cart-count {
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  border-radius: 999px;
  min-width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.cart-label {
  font-size: 15px;
  color: #6b7570;
  font-weight: 700;
}

.cart-handle-total {
  margin-left: auto;
  font-size: 22px;
  font-weight: 900;
  color: var(--ink);
}

.cart-chevron {
  color: #9aa39d;
  font-size: 14px;
  transition: transform 0.22s ease;
}

.cart.expanded .cart-chevron {
  transform: rotate(180deg);
}

.cart-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid #eee;
}

.cart-list {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px;
}

.cart-empty {
  color: #9aa39d;
  text-align: center;
  padding: 24px 0;
  font-size: 15px;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f1f0;
}

.cart-item .emoji {
  font-size: 22px;
  white-space: nowrap;
  flex-shrink: 0;
}

.cart-item .info {
  flex: 1 1 auto;
  min-width: 0;
}

.cart-item .info .name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.qty-controls button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: #eef1ef;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-controls button.minus { color: var(--danger); }
.qty-controls button.plus { color: var(--teal); }

.qty-controls .qty {
  min-width: 26px;
  text-align: center;
  font-weight: 800;
  font-size: 16px;
}

.cart-item .line-total {
  min-width: 66px;
  text-align: right;
  font-weight: 800;
  font-size: 15px;
}

.cart-footer {
  flex: 0 0 auto;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cart-total-row {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: #6b7570;
}

.cart-total {
  font-size: 26px;
  font-weight: 900;
  color: var(--ink);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 800;
}

.btn-clear {
  background: #fde9e7;
  color: var(--danger);
}

/* ---------- Zahlungs-QR ---------- */
.pay-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: #eefcf6;
  border: 1px solid #cdeee1;
  border-radius: 14px;
  padding: 16px;
  text-decoration: none;
}

.pay-qr {
  position: relative;
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  padding: 0;
}

.pay-qr svg,
.pay-qr img {
  width: 100%;
  height: 100%;
  display: block;
}

.pay-qr::after {
  content: "⇄";
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.pay-info {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  text-decoration: none;
}

.pay-label {
  font-size: 17px;
  font-weight: 800;
  color: var(--teal);
}

.pay-hint {
  font-size: 13px;
  color: #6b7570;
  font-weight: 600;
}

.fee-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #cdeee1;
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px 8px 10px;
  font-size: 13px;
  font-weight: 700;
  color: #2f6f5c;
}

.fee-toggle-dot {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #b7e4d1;
  background: #fff;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.fee-toggle.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.fee-toggle.active .fee-toggle-dot {
  background: #fff;
  border-color: #fff;
}

.fee-toggle:disabled {
  opacity: 0.4;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 18px;
  padding: 24px 20px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal p {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 18px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn {
  flex: 1 1 0;
}

.btn-secondary {
  background: #eef1ef;
  color: var(--ink);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

/* ---------- Wide screens: iPad / landscape → fixed sidebar ---------- */
@media (min-width: 760px) {
  .layout {
    flex-direction: row;
  }

  .content {
    flex: 1 1 auto;
    min-width: 0;
    padding-bottom: 20px;
  }

  .cart {
    position: relative;
    flex: 0 0 380px;
    max-width: 40vw;
    max-height: none;
    height: 100%;
    border-top-left-radius: 0;
    border-left: 1px solid #e6e8e7;
    box-shadow: none;
    transform: none !important;
  }

  .cart-handle {
    display: none;
  }

  .cart-body {
    border-top: none;
    height: 100%;
  }
}
