:root{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --control-h: 44px;

  /* ===== Light Theme ===== */
  --bg-dark: hsl(215 35% 94%);
  --bg: hsl(215 35% 97%);
  --bg-light: hsl(0 0% 100%);

  --text: hsl(226 55% 12%);
  --text-muted: hsl(226 20% 40%);

  --highlight: hsl(214 70% 42%);
  --border: hsl(211 30% 78%);
  --border-muted: hsl(216 35% 86%);

  --primary: hsl(214 80% 40%);
  --secondary: hsl(39 79% 52%);
  --danger: hsl(8 79% 52%);
  --warning: hsl(54 100% 31%);
  --success: hsl(156 55% 35%);
  --info: hsl(217 75% 45%);

  /* Semantik */
  --surface: var(--bg-light);
  --surface-2: var(--bg-dark);
  --muted: var(--text-muted);

  --btn-bg: var(--bg-light);
  --btn-border: var(--border-muted);
  --btn-text: var(--text);

  --btn-primary-bg: var(--highlight);
  --btn-primary-border: var(--highlight);
  --btn-primary-text: hsl(215 100% 100%);

  --input-bg: var(--bg-light);
  --input-border: var(--border-muted);
  --input-text: var(--text);

  --focus: var(--primary);

  color-scheme: light;
}

.dark{
  /* ===== Dark Theme ===== */
  --bg-dark: rgb(19, 24, 18);
  --bg: rgb(27, 33, 26);
  --bg-light: rgb(40, 52, 34);

  --text: rgb(235, 213, 171);
  --text-muted: rgba(235, 213, 171, .72);

  --highlight: rgb(139, 174, 102);
  --border: rgba(98, 129, 65, .75);
  --border-muted: rgba(98, 129, 65, .45);

  --primary: rgb(139, 174, 102);
  --secondary: rgb(235, 213, 171);
  --danger: rgb(225, 110, 96);
  --warning: rgb(230, 195, 90);
  --success: rgb(139, 174, 102);
  --info: rgb(170, 200, 130);

  /* Semantik */
  --surface: var(--bg-light);
  --surface-2: var(--bg-dark);
  --muted: var(--text-muted);

  --btn-bg: rgba(98, 129, 65, .16);
  --btn-border: var(--border-muted);
  --btn-text: var(--text);

  --btn-primary-bg: rgba(139, 174, 102, .22);
  --btn-primary-border: rgba(139, 174, 102, .55);
  --btn-primary-text: var(--text);

  --input-bg: rgba(19, 24, 18, .75);
  --input-border: var(--border-muted);
  --input-text: var(--text);

  --focus: var(--primary);

  color-scheme: dark;
}

@supports (color: color-mix(in hsl, white, black)){
  .flash.ok{
    background: color-mix(in hsl, var(--success) 14%, var(--surface));
    border-color: color-mix(in hsl, var(--success) 55%, var(--border));
  }
  .flash.err{
    background: color-mix(in hsl, var(--danger) 12%, var(--surface));
    border-color: color-mix(in hsl, var(--danger) 55%, var(--border));
  }
}

/* Reset-ish */
*, *::before, *::after{ box-sizing: border-box; }
img{ max-width: 100%; height: auto; display: block; }

body{ margin: 0; background: var(--bg); color: var(--text); }
a{ color: inherit; }

input, button, textarea, select{ font: inherit; color: inherit; }
input, textarea, select{ max-width: 100%; }

/* App Layout */
body.app{
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.app > .container{ flex: 1 0 auto; }
.footer-sticky{ margin-top: auto; }

.container{ max-width: 980px; margin: 18px auto; padding: 0 14px; }

/* Header */
.topbar{
  display:flex; gap:12px; align-items:center;
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  flex-wrap: wrap;
  z-index: 900;
}

.brand a{ font-weight: 700; text-decoration: none; }
.brand-link{ display:flex; align-items:center; gap:10px; text-decoration:none; }

.brand-logo{ height:80px; width:auto; display:block; }
.header-logo{ height: 28px; width: auto; display:block; } /* optional später */

.search{ flex: 1; min-width: 220px; }

/* Suche: Input + Button als EIN Rahmen */
.search-inline{
  display: flex;
  width: 100%;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  border-radius: 12px;
  overflow: hidden;
}

.search-inline input{
  flex: 1;
  min-width: 0;
  height: var(--control-h);
  border: 0;
  outline: none;
  background: transparent;
  padding: 0 12px;
  color: var(--input-text);
}

.search-inline button{
  height: var(--control-h);
  width: var(--control-h);
  border: 0;
  border-left: 1px solid var(--border-muted);
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.search-inline:focus-within{
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Mask-Icon (Angel) */
.icon{
  width: 25px;
  height: 25px;
  display: inline-block;
  background: currentColor;
  -webkit-mask: var(--icon) no-repeat center / contain;
  mask: var(--icon) no-repeat center / contain;
}
.icon-fishing{
  --icon: url("https://upload.wikimedia.org/wikipedia/commons/b/ba/Fishing.svg");
}

.nav a{
  text-decoration:none;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.card{
  background: var(--surface);
  border: 1px solid var(--border-muted);
  border-radius: 14px;
  padding: 14px;
  margin: 12px 0;
}

.muted{ color: var(--muted); }

.flash{
  padding: 10px 12px;
  border-radius: 12px;
  margin: 10px 0;
  border: 1px solid var(--border-muted);
  background: var(--surface);
}
.flash.ok{ border-color: var(--success); }
.flash.err{ border-color: var(--danger); }

/* Tables */
.table{ width: 100%; border-collapse: collapse; }
.table th, .table td{
  padding: 10px;
  border-bottom: 1px solid var(--border-muted);
  vertical-align: top;
}
.table th{ text-align:left; color: var(--text-muted); font-weight: 600; }

/* Buttons */
.actions{ display:flex; gap:10px; align-items:center; }

.btn{
  display:inline-block;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-text);
  text-decoration:none;
  cursor:pointer;
}
.btn.primary{
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: var(--btn-primary-border);
}
.btn.disabled{ opacity: .55; pointer-events: none; }

button.btn{
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  background: var(--btn-bg);
  color: var(--btn-text);
}
.btn:disabled{
  opacity: .55;
  cursor: not-allowed;
}

/* Card-head */
.card-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
}
.card-head > .btn{
  flex: 0 0 auto;
  white-space: nowrap;
}

input.qty{
  width: 80px;
  padding: 8px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  color: var(--input-text);
}

/* Footer */
.footer{
  padding: 18px;
  text-align:center;
  color: var(--muted);
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
.footer-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap: wrap;
}
.theme-switch{ display:flex; align-items:center; gap:10px; }

pre{ white-space: pre-wrap; }

/* Grid / Tiles */
.grid{
  display:grid;
  gap:12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
@media (min-width: 1100px){
  .grid{ grid-template-columns: repeat(5, 1fr); }
}

.product-card .product-title{ margin-bottom: 6px; line-height:1.2; }
.grid > .card, .grid > a.card{ margin: 0; }

.tile{
  aspect-ratio: 1 / 1;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:6px;
  text-decoration:none;
}
.tile-title{ font-weight:700; line-height:1.2; }

.tile-add{
  border-style: dashed;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  text-align:center;
}
.tile-plus{
  font-size: 54px;
  line-height: 1;
  font-weight: 700;
  color: var(--muted);
}

/* Checkout */
.checkout-row{ display:flex; justify-content:flex-end; }
.checkout-input{ position: relative; width: 100%; max-width: 350px; }
.checkout-input input{
  width: 100%;
  padding: 10px 120px 10px 10px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  color: var(--input-text);
}
.checkout-input button{
  position:absolute;
  top:4px; right:4px; bottom:4px;
  padding: 0 14px;
  border-radius: 10px;
  white-space: nowrap;
  border: 1px solid var(--btn-primary-border);
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

/* Login-Overlay */
.auth-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 1000;
}
.auth-modal{
  position: fixed;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 14px;
  z-index: 1001;
}
.auth-modal .card{
  width: min(520px, 100%);
  margin: 0;
}

/* Focus */
:focus-visible{
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Helfer */
.pager{ display:flex; gap:8px; flex-wrap:wrap; }

/* Screenreader-only */
.sr-only{
  position:absolute !important;
  width:1px; height:1px;
  padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0);
  white-space:nowrap; border:0;
}

/* Warenkorb */
.cart-link{
  display:inline-flex;
  align-items:center;
  gap:10px;
  flex-wrap:nowrap;
}
.nav a.cart-link{
  height: var(--control-h);
  padding: 0 10px;
  box-sizing: border-box;
}
.icon-cart{ width:22px; height:22px; display:block; }
.cart-badge{
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size: 12px;
  font-weight: 700;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: 1px solid var(--btn-primary-border);
}

/* Icon Buttons */
.icon-btn{
  width: var(--control-h);
  height: var(--control-h);
  padding: 0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
.icon-btn.active{
  border-color: var(--btn-primary-border);
  background: var(--btn-primary-bg);
}
.icon-filter{ width: 20px; height: 20px; display:block; }

/* ===== Link "Liste aller Gegenstände" (zentriert, losgelöst) ===== */
.home-items-link{
  display:flex;
  justify-content:center;
  margin: 6px 0 10px 0;
}
.items-link{
  display:inline-block;
  padding: 6px 10px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  color: var(--highlight);
}
.items-link:hover{
  text-decoration: underline;
  background: color-mix(in hsl, var(--btn-bg) 70%, transparent);
}

/* ===== Boxen Section ===== */
.card.boxes-section{
  padding: 0;
  overflow: hidden;
  width: 100%;
}
.boxes-summary{
  list-style: none;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}
.boxes-summary::-webkit-details-marker{ display:none; }
.boxes-summary::marker{ content:""; }

.boxes-summary-actions{
  display:flex;
  align-items:center;
  gap:10px;
  margin-left: auto;
}

/* Filterbutton nur anzeigen, wenn aufgeklappt */
.boxes-section details:not([open]) .box-filter-toggle{
  display: none;
}

.icon-chevron{
  width: 18px;
  height: 18px;
  display:block;
  opacity: .85;
  transition: transform .18s ease;
}
.boxes-section details[open] .icon-chevron{
  transform: rotate(180deg);
}

.boxes-body{
  padding: 0 14px 10px 14px;
}

.box-filter{
  margin-top: 6px;
}
.box-filter input{
  width: 100%;
  height: var(--control-h);
  padding: 0 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  color: var(--input-text);
}

.boxes-grid{ margin-top: 8px; }
.box-pager{ justify-content: center; }

/* Mobile */
@media (max-width: 720px){
  .container{ padding: 0 12px; }
  .topbar{ gap:10px; align-items: stretch; }
  .brand{ width: 100%; }
  .search{ width: 100%; }

  .tile{
    aspect-ratio: auto;
    padding: 16px;
    min-height: 120px;
  }

  .table{
    display:block;
    width:100%;
    overflow-x:auto;
    -webkit-overflow-scrolling: touch;
  }

  form[style*="max-width"]{ max-width: none !important; }

  .card-head{ flex-wrap: wrap; align-items: flex-start; }
  .actions{ flex-wrap: wrap; justify-content: flex-start; }
  .card-head > b{ flex: 1 1 100%; }
  .card-head > .btn{ width: 100%; text-align: center; }
}

/* ===== Post-Login Hint (Vorhang + Tooltip auf Suche) ===== */
.tour-backdrop{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;

  /* Startet unterhalb vom Header (wird per JS gesetzt) */
  top: var(--tour-top, 0px);

  background: rgba(0,0,0,.55);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
  z-index: 950;
}

/* Tooltip */
.tour-tip{
  position: fixed;
  z-index: 970;
  width: min(340px, calc(100vw - 24px));
  padding: 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border-muted);
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}

/* Pfeil: oben mittig, deutlich */
.tour-tip::before{
  content:"";
  position:absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  border: 14px solid transparent;
  border-bottom-color: var(--surface);
  filter: drop-shadow(0 -2px 0 var(--border-muted)) drop-shadow(0 6px 10px rgba(0,0,0,.18));
}

/* kleiner "Pin" unter dem Pfeil für mehr Fokus */
.tour-tip::after{
  content:"";
  position:absolute;
  top: -42px;
  left: 50%;
  transform: translateX(-50%);
  width: 15px;
  height: 15px;
  border-radius: 999px;
  background: var(--focus);
  box-shadow: 0 0 0 4px color-mix(in hsl, var(--focus) 30%, transparent);
}

.tour-tip-title{
  margin-bottom: 6px;
}

.tour-tip-text{
  color: var(--muted);
  line-height: 1.35;
}

.tour-tip-actions{
  margin-top: 10px;
  display:flex;
  justify-content:flex-end;
}

/* optional: Suchleiste optisch hervorheben */
.tour-highlight{
  position: relative;
  z-index: 980;
  box-shadow:
    0 0 0 2px var(--focus),
    0 0 0 8px rgba(0,0,0,.18);
  border-radius: 12px;
}
