:root {
  /* Helles, mattes Grundschema für alle Seiten. Farben ändern: nur hier. */
  --bg: #f5f3f0;          /* warmes, sehr helles Grau */
  --surface: #ffffff;     /* Karten */
  --surface-2: #faf8f5;   /* Eingabefelder, Chips - knapp vom Weiß abgesetzt */
  --border: #ddd7cf;
  --hover: #efebe6;
  --text: #27221f;        /* dunkles Graubraun */
  --muted: #6b635c;
  --wine: #7a2e3b;        /* mattes, gedecktes Weinrot */
  --wine-light: #62232f;  /* Hover: etwas dunkler */
  --accent: #7a2e3b;
  --danger: #b4533f;
  --wine-link: #7a2e3b;
  --danger-text: #8f3322;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(40, 30, 25, .06);
}

/* Kopfleiste und Großansicht bleiben dunkel */
.topbar, .lightbox {
  --bg: #12100f; --surface: #1c1917; --surface-2: #262220; --border: #3a3330;
  --hover: #322c29; --text: #f2ece8; --muted: #a49a94;
  --wine: #8f1d34; --wine-light: #c2415c;
  color: var(--text);
}

* { box-sizing: border-box; }

/* hidden muss jede display-Regel schlagen, sonst zeigen sich versteckte Elemente */
[hidden] { display: none !important; }

/* Buttons erben Textfarbe und Schrift nicht - ohne das steht schwarze
   Systemschrift auf dunklem Grund. */
button { color: inherit; font-family: inherit; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
h1 { font-size: 1.7rem; margin: 0 0 .2rem; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 0 0 .8rem; }
h3 { font-size: 1.02rem; margin: 0 0 .15rem; }
p { margin: .35rem 0; }

.muted { color: var(--muted); }
.small { font-size: .84rem; }
.hint { color: var(--muted); font-size: .82rem; margin-top: .4rem; }
.error { color: var(--danger-text); }
.price { color: var(--accent); font-weight: 600; white-space: nowrap; }
.push-right { margin-left: auto; }
.grow { flex: 1 1 180px; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1rem;
  background: rgba(18, 16, 15, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar nav { display: flex; align-items: center; gap: 1rem; flex: none; }
.topbar nav a { color: var(--muted); font-size: .92rem; }
.topbar nav a:hover { color: var(--text); }
.topbar nav a.btn { color: #fff; }

.container { max-width: 1080px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.footer { text-align: center; color: var(--muted); font-size: .78rem; padding: 0 0 2rem; }
.back { display: inline-block; color: var(--muted); font-size: .9rem; margin-bottom: .8rem; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: .92rem; font-weight: 500; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--wine); border-color: var(--wine); color: #fff; }
.btn-primary:hover { background: var(--wine-light); }
.btn-danger { background: transparent; border-color: #e0b8b0; color: var(--danger-text); }
.btn-danger:hover { background: #f8e9e6; }
.btn-sm { padding: .35rem .8rem; font-size: .85rem; }
.btn-round { width: 42px; height: 42px; padding: 0; font-size: 1.35rem; line-height: 1; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .8rem; padding: 0; }
.link:hover { color: var(--text); }
.link-danger { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .85rem; padding: 0; }
.link-danger:hover { color: var(--danger-text); }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}
.login-card { max-width: 360px; margin: 12vh auto; text-align: center; }
.login-card input { width: 100%; margin: .8rem 0; }

/* ---------------------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: 1rem; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .7rem .5rem; text-align: center;
}
.stat b { display: block; font-size: 1.25rem; }
.stat span { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; }

/* ---------------------------------------------------------------- forms */
input, select, textarea {
  width: 100%; padding: .55rem .7rem;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: .95rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--wine-light); outline-offset: 1px; }
textarea { resize: vertical; }
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .6rem; }
label input, label select, label textarea { margin-top: .2rem; }
label.checkbox { display: flex; align-items: center; gap: .5rem; color: var(--text); font-size: .9rem; align-self: center; }
label.checkbox input { width: auto; }
fieldset { border: 0; border-top: 1px solid var(--border); padding: 1rem 0 .2rem; margin: 0 0 .4rem; }
legend { color: var(--accent); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; padding-right: .6rem; }
.row { display: flex; flex-wrap: wrap; gap: .7rem; }
.row > label { flex: 1 1 140px; }
.actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; }
.inline-form { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; }
.inline-form textarea { margin-bottom: .6rem; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.1rem; }
.filters input[type=search] { flex: 2 1 240px; }
.filters select { flex: 1 1 130px; }

/* ---------------------------------------------------------------- list */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: .9rem; }
.wine-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .12s, border-color .12s;
}
.wine-card:hover { transform: translateY(-3px); border-color: var(--wine-light); }
.thumb {
  position: relative; aspect-ratio: 4 / 3; display: grid; place-items: center;
  background: #ece7e1;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-fallback { font-size: 2.4rem; opacity: .55; }
.wine-card-body { padding: .7rem .8rem .8rem; display: flex; flex-direction: column; gap: .1rem; flex: 1; }
.wine-card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: .5rem; }
.badge {
  position: absolute; top: .5rem; right: .5rem;
  background: rgba(20, 16, 14, .72); border: 1px solid rgba(255, 255, 255, .15); color: #fff;
  padding: .12rem .5rem; border-radius: 999px; font-size: .72rem;
}
.badge-wish { background: var(--wine); border-color: var(--wine); }
.badge-empty { color: var(--muted); }
.stars { color: var(--accent); font-size: .85rem; letter-spacing: .04em; }
.stars-off { color: #9a8f85; }
.dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-right: .35rem; background: var(--wine); vertical-align: baseline; }
.empty { text-align: center; padding: 3.5rem 1rem; color: var(--muted); }
.empty .btn { margin-top: .8rem; }

/* Farbcodes: kraeftig fuer Punkte und Chips, gedaempft als Platzhalter-Hintergrund.
   Weine mit Foto bekommen gar keine Farbklasse, damit das Etikett unverfaelscht bleibt. */
.dot.color-rot, .chip.color-rot { background: #8f1d34; }
.dot.color-weiss, .chip.color-weiss { background: #b39a54; }
.dot.color-rose, .chip.color-rose { background: #d8748a; }
.dot.color-schaumwein, .chip.color-schaumwein { background: #a08d5c; }
.dot.color-suesswein, .chip.color-suesswein { background: #a9762f; }
.dot.color-orange, .chip.color-orange { background: #c96c30; }

.thumb.color-rot { background: #ecd9dc; }
.thumb.color-weiss { background: #ede6d1; }
.thumb.color-rose { background: #f2dde2; }
.thumb.color-schaumwein { background: #e9e5d1; }
.thumb.color-suesswein { background: #efe0cb; }
.thumb.color-orange { background: #f1dccb; }

.cover-empty.color-rot { background: #ecd9dc; }
.cover-empty.color-weiss { background: #ede6d1; }
.cover-empty.color-rose { background: #f2dde2; }
.cover-empty.color-schaumwein { background: #e9e5d1; }
.cover-empty.color-suesswein { background: #efe0cb; }
.cover-empty.color-orange { background: #f1dccb; }

/* ---------------------------------------------------------------- detail */
.detail { display: grid; grid-template-columns: 280px 1fr; gap: 1.4rem; margin-bottom: 1.2rem; }
.detail-media { display: flex; flex-direction: column; gap: .8rem; }
.cover {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.cover-empty { display: grid; place-items: center; font-size: 3.5rem; opacity: .5; }
.subtitle { color: var(--muted); margin-bottom: .8rem; }
.chip {
  display: inline-block; padding: .2rem .7rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font-size: .8rem; margin: 0 .35rem .35rem 0;
}
.chip-accent { border-color: var(--accent); color: var(--accent); }
.chip[class*="color-"] { color: #fff; border-color: transparent; }
.chip.color-weiss { background: #7d6a2c; }
.chip.color-rose { background: #a4506a; }
.chip.color-schaumwein { background: #6f6436; }
.chip.color-suesswein { background: #86561d; }
.chip.color-orange { background: #9c5020; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 1rem 0; font-size: .93rem; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; }
.facts a { color: var(--wine-link); }
.description { white-space: pre-wrap; background: var(--surface); border-left: 3px solid var(--wine); border-radius: 0 10px 10px 0; padding: .7rem .9rem; margin: 1rem 0; }
.trend { font-size: .8rem; font-weight: 500; }
.trend.up { color: var(--danger-text); }
.trend.down { color: #2f7a4c; }

.stock {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .55rem .7rem;
}
.stock form { margin: 0; }
.stock-count { text-align: center; line-height: 1.15; }
.stock-count b { font-size: 1.4rem; }
.stock-count span { display: block; color: var(--muted); font-size: .72rem; }

.note { border-bottom: 1px solid var(--border); padding: .6rem 0; }
.note:last-of-type { border-bottom: 0; }
.note-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.note p { white-space: pre-wrap; margin: .3rem 0 0; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; padding-bottom: .4rem; }
.table td { padding: .45rem 0; border-top: 1px solid var(--border); }
.table a { color: var(--wine-link); }

.flash {
  border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: 1rem;
  border: 1px solid var(--border); background: var(--surface); font-size: .92rem;
}
.flash-info { border-color: #9cc4a8; background: #eaf4ec; color: #1f4a2e; }
.flash-error { border-color: #e2b1a8; background: #fbeae7; color: #7a2a1d; }
.fetch-form { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-top: .7rem; }
.fetch-form .hint { margin: 0; flex: 1 1 200px; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; }
.photo { margin: 0; }
.photo img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.photo figcaption { display: flex; justify-content: space-between; gap: .5rem; padding-top: .3rem; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 760px) {
  .detail { grid-template-columns: 1fr; }
  .detail-media { flex-direction: row; align-items: flex-start; }
  .cover { width: 42%; }
  .detail-media .stock { flex: 1; flex-direction: column; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hide-mobile { display: none; }
  .brand { font-size: 1rem; }
  .topbar { gap: .5rem; padding: .6rem .8rem; }
  .topbar nav { gap: .45rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
  h1 { font-size: 1.4rem; }
}

/* ---------------------------------------------------------------- Etikett-Scan */
.scan-card { max-width: 620px; margin-inline: auto; }
.scan-drop {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 2rem 1rem; margin: 1rem 0; cursor: pointer; text-align: center;
  background: var(--surface-2); color: var(--text); font-size: 1rem;
  transition: border-color .15s, background .15s;
}
.scan-drop:hover { border-color: var(--wine); background: var(--hover); }
.scan-drop input[type=file] { display: none; }
.scan-icon { font-size: 2.4rem; }
.scan-busy { display: flex; align-items: center; gap: .6rem; color: var(--accent); margin: .6rem 0; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.scan-tips { margin-top: 1.2rem; border-top: 1px solid var(--border); padding-top: .8rem; }
.scan-tips summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.scan-tips ul { color: var(--muted); font-size: .88rem; margin: .6rem 0 0; padding-left: 1.1rem; }
.scan-tips li { margin-bottom: .3rem; }

.scan-result { border-color: var(--wine); }
.scan-split { display: grid; grid-template-columns: 180px 1fr; gap: 1rem; margin-top: .8rem; }
.scan-photo { width: 100%; border-radius: 10px; border: 1px solid var(--border); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.chip-line {
  cursor: pointer; max-width: 100%; font-size: .88rem; padding: .35rem .8rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip-line:hover, .chip-line:focus-visible {
  border-color: var(--wine); background: var(--hover);
}
.chip-used { opacity: .5; border-style: dashed; }

@media (max-width: 760px) {
  .scan-split { grid-template-columns: 1fr; }
  .scan-photo { max-width: 55%; }
}

@media (max-width: 430px) {
  .hide-narrow { display: none; }
  .brand { font-size: .95rem; }
}

/* ---------------------------------------------------------------- Weingüter */
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.strong-link { color: var(--wine-link); font-weight: 500; }
.strong-link:hover { text-decoration: underline; }
.winery-edit { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .8rem; }
.winery-edit summary { cursor: pointer; color: var(--muted); font-size: .9rem; }

.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem 1rem; margin-bottom: .5rem; }
.footer-nav a { color: var(--muted); }
.footer-nav a:hover { color: var(--text); }
a.stat { display: block; transition: border-color .12s; }
a.stat:hover { border-color: var(--wine-light); }

/* ---------------------------------------------------------------- Trinkreife */
.stats { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stat-alert { border-color: var(--accent); }
.stat-alert b { color: var(--accent); }
.ripe { font-size: .78rem; margin: .3rem 0 0; }
.ripe-over { color: var(--danger-text); }
.ripe-soon { color: var(--accent); }
.chip-ripe-over { border-color: var(--danger); color: var(--danger-text); }
.chip-ripe-soon { border-color: var(--accent); color: var(--accent); }
.chip-ripe-ok { border-color: #9cc4a8; color: #2f6b44; }
.chip-ripe-young { border-color: #a9bcd4; color: #34557a; }

.scan-sides { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin: 1rem 0; }
.scan-sides .scan-drop { margin: 0; padding: 1.5rem .8rem; }
.scan-drop-optional { border-style: dotted; }
.scan-drop-filled { border-color: #9cc4a8; border-style: solid; background: #eaf4ec; }
.scan-photos { display: flex; flex-direction: column; gap: .5rem; }
@media (max-width: 560px) { .scan-sides { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- Statistik */
.bars { display: flex; flex-direction: column; gap: .4rem; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 150px) 1fr auto; gap: .6rem; align-items: center; }
.bar-label { font-size: .87rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-2); border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--wine); }
.bar-value { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2.2em; text-align: right; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; align-items: start; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.plain-list li:last-child { border-bottom: 0; }

/* ---------------------------------------------------------------- Kellerplan */
.shelves { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.shelf { margin: 0; }
.shelf-unsorted { border-style: dashed; }
.shelf-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.shelf-head h2 { margin: 0; }
.shelf-list { list-style: none; margin: 0; padding: 0; }
.shelf-list li { display: flex; align-items: center; gap: .4rem; padding: .4rem 0; border-top: 1px solid var(--border); font-size: .92rem; }
.shelf-wine { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shelf-wine:hover { color: var(--wine-light); }
.bottles { letter-spacing: -.25em; font-size: .85rem; white-space: nowrap; }
.shelf-list .ripe { margin: 0; }

@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- Weingut-Abgleich */
.winery-check {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); padding: .7rem .9rem; margin-bottom: .8rem;
}
.winery-check .hint { margin-top: 0; }
.winery-tools { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }
.htmx-indicator { display: none; align-items: center; gap: .4rem; color: var(--accent); font-size: .85rem; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.site-results:not(:empty) { margin-top: .7rem; }
.site-error { color: var(--danger-text); }
.site-options { display: flex; flex-direction: column; gap: .3rem; }
.site-option {
  display: flex; align-items: flex-start; gap: .5rem; margin: 0;
  padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: .9rem; cursor: pointer;
}
.site-option:hover { border-color: var(--wine-light); }
.site-option input { width: auto; margin-top: .25rem; flex: none; }
.site-option span { display: flex; flex-direction: column; min-width: 0; }
.site-option .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-row { display: flex; align-items: center; gap: .6rem; width: 100%; }
.site-host { font-weight: 600; }
.site-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.known-wine { border-color: var(--accent); }
.known-wine h2 { color: var(--accent); }

/* ---------------------------------------------------------------- Großansicht */
.zoomable { cursor: zoom-in; }
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 7, 6, .94);
  display: flex; flex-direction: column;
}
.lightbox-bar {
  display: flex; align-items: center; gap: .5rem; justify-content: flex-end;
  padding: .6rem .8rem; border-bottom: 1px solid var(--border);
}
.lightbox-hint { color: var(--muted); font-size: .8rem; margin-right: auto; }
.lightbox-stage {
  flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center;
  touch-action: pinch-zoom pan-x pan-y;
}
.lightbox-stage img {
  max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .6);
}
.lightbox-stage.zoomed { display: block; }
.lightbox-stage.zoomed img { max-width: none; max-height: none; cursor: zoom-out; }
@media (max-width: 560px) { .lightbox-hint { display: none; } }

/* ---------------------------------------------------------------- Freigestellt ("Studio") */
.cover-studio, .photo-studio, .thumb-studio {
  background: #efebe5;
}
.cover-studio { display: flex; align-items: center; justify-content: center; padding: 6%; }
.cover-studio img, .photo-studio img, .thumb-studio img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 14px 14px rgba(0, 0, 0, .28));
}
.photo-studio {
  aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--border);
  padding: 8%; display: flex; align-items: center; justify-content: center;
}
.thumb-studio img { padding: 6% 0; }
.cutout-row { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-top: .35rem; }

.shop-images:not(:empty) { margin-top: .8rem; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; margin-top: .5rem; }
.shop-choice {
  display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .5rem;
}
.shop-choice img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: #fff; border-radius: 6px; }
.shop-host { font-size: .78rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* ================================================================ Übersicht: Aufbau wie eine Weinhandlung
   Flasche links, Weingut + Name rechts, Bestand und Details darunter -
   in den Farben der App. Nur die Startseite (body.page-shop). */
.page-shop .container { max-width: 1340px; }

.shop-list {
  display: grid; gap: 2.4rem 1.6rem;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
}
.shop-card {
  display: grid; grid-template-columns: 78px 1fr; grid-template-rows: 1fr auto;
  column-gap: .9rem; row-gap: .8rem; min-width: 0;
}
.shop-bottle {
  display: flex; align-items: flex-end; justify-content: center; height: 200px;
  /* weicher Lichtkegel, damit dunkles Flaschenglas nicht im Hintergrund verschwindet */
  background: radial-gradient(closest-side, rgba(255, 240, 225, .09), transparent);
}
.shop-bottle img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .55));
}
.shop-bottle img.shop-photo { border-radius: 6px; border: 1px solid var(--border); filter: none; }
.shop-silhouette { height: 90%; }
.shop-silhouette path { fill: currentColor; }
.shop-silhouette-label { fill: rgba(242, 236, 232, .8); }
.shop-silhouette.color-rot { color: #7a1a2c; }
.shop-silhouette.color-weiss { color: #9c8a4a; }
.shop-silhouette.color-rose { color: #c77c8c; }
.shop-silhouette.color-schaumwein { color: #8f8450; }
.shop-silhouette.color-suesswein { color: #9a6a2a; }
.shop-silhouette.color-orange { color: #b56a2c; }

.shop-info { display: flex; flex-direction: column; min-width: 0; padding-top: .4rem; }
.shop-winery {
  margin: 0; color: var(--accent); font-size: .74rem; letter-spacing: .08em;
  text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.shop-name {
  margin: .15rem 0 0; font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 600; font-size: 1.12rem; line-height: 1.2; letter-spacing: .03em;
  text-transform: uppercase; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.shop-name a { color: var(--text); }
.shop-name a:hover { color: var(--wine-link); }
.shop-badges { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.shop-badge {
  border: 1px solid var(--accent); color: var(--accent); border-radius: 4px;
  padding: .05rem .45rem; font-size: .66rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.shop-badge-muted { border-color: var(--border); color: var(--muted); }
.shop-badge-alert { border-color: var(--danger); color: var(--danger-text); }
.shop-bottom { margin-top: auto; padding-top: .6rem; }
.shop-price { margin: 0; font-size: 1.3rem; font-weight: 600; color: var(--text); }
.shop-meta { margin: .05rem 0 0; color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-stars { color: var(--accent); }

.shop-actions { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr; gap: .45rem; }
.shop-stepper {
  display: flex; align-items: center; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2);
}
.shop-stepper button {
  width: 38px; height: 40px; border: 0; background: transparent; color: var(--text);
  font-size: 1.25rem; cursor: pointer; border-radius: 10px;
}
.shop-stepper button:disabled { opacity: .3; cursor: not-allowed; }
.shop-stepper button:hover:not(:disabled) { background: var(--hover); }
.shop-stepper span { min-width: 2rem; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

.btn-gold, .btn-outline {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px;
  padding: .45rem 1rem; border-radius: 10px; font-weight: 600; font-size: .85rem; letter-spacing: .04em;
}
.btn-gold { background: var(--wine); color: #fff; border: 1px solid var(--wine); }
.btn-gold:hover { background: var(--wine-light); }
.btn-outline { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

.shop-empty { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.shop-empty .btn-gold, .shop-empty .btn-outline { margin: .8rem .3rem 0; }

@media (max-width: 600px) {
  .shop-list { grid-template-columns: 1fr; gap: 2rem; }
  .shop-bottle { height: 180px; }
}


/* ================================================================ Feinheiten für den hellen Grund */
.filters input::placeholder { color: #756d66; }
.page-shop .filters { border-bottom: 1px solid var(--border); padding-bottom: 1.1rem; margin-bottom: 1.6rem; }
.stat { box-shadow: none; }
.shop-bottle { background: none; }
.shop-bottle img { filter: drop-shadow(0 8px 10px rgba(40, 30, 25, .18)); }
.shop-bottle img.shop-photo { filter: none; box-shadow: 0 4px 12px rgba(40, 30, 25, .12); }
.shop-silhouette-label { fill: #ffffff; }
.shop-badge { background: #f4e9eb; }
.shop-badge-muted { background: #efebe6; }
.shop-badge-alert { background: #f6e3de; }

/* ================================================================ Karte: Name neben dem Bild,
   wichtige Angaben groß. Überschreibt die Grundwerte weiter oben. */
.shop-list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 2.4rem 1.8rem; }
.shop-card { grid-template-columns: 112px 1fr; column-gap: 1rem; align-items: start; }
.shop-bottle { align-items: flex-start; height: 230px; }
.shop-info { padding-top: 0; }
.shop-winery { font-size: .78rem; }
.shop-name { font-size: 1.2rem; margin-top: .1rem; }

.shop-facts { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; }
.shop-fact {
  display: inline-flex; align-items: center; gap: .3rem;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 6px; padding: .15rem .5rem;
  font-size: .95rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.shop-fact .dot { margin-right: 0; }
.shop-grape { margin: .55rem 0 0; font-size: .98rem; color: var(--text); overflow-wrap: anywhere; }
.shop-origin { margin: .1rem 0 0; font-size: .9rem; color: var(--muted); }
.shop-badges { margin-top: .55rem; }
.shop-bottom { margin-top: .7rem; padding-top: 0; }
.shop-price { font-size: 1.35rem; }
.shop-meta { font-size: .85rem; }

@media (max-width: 600px) {
  .shop-card { grid-template-columns: 96px 1fr; }
  .shop-bottle { height: 200px; }
}

/* ================================================================ Feste Navigation unten */
.topbar, .lightbox, .tabbar {
  --bg: #12100f; --surface: #1c1917; --surface-2: #262220; --border: #3a3330;
  --hover: #322c29; --text: #f2ece8; --muted: #a49a94;
  --wine: #8f1d34; --wine-light: #c2415c;
}
.topbar-logout { color: var(--muted); font-size: .88rem; }
.topbar-logout:hover { color: var(--text); }

/* Platz schaffen, damit nichts hinter der festen Leiste verschwindet */
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.footer { padding-bottom: 1.2rem; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: center; gap: .2rem;
  padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom));
  background: rgba(18, 16, 15, .96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 0 1 108px; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: .35rem .2rem; border-radius: 10px;
  color: var(--muted); font-size: .72rem; line-height: 1.1; text-align: center;
}
.tab svg {
  width: 24px; height: 24px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab:hover { color: var(--text); background: var(--hover); }
.tab-active { color: var(--text); }
.tab-active svg { stroke: #e3a0ad; }
.tab-active::after {
  content: ""; width: 18px; height: 2px; border-radius: 2px; background: #e3a0ad; margin-top: .1rem;
}
@media (max-width: 420px) {
  .tabbar { gap: 0; padding-left: .2rem; padding-right: .2rem; }
  .tab { font-size: .64rem; }
  .tab svg { width: 22px; height: 22px; }
}
/* Die Großansicht liegt über allem, auch über der Leiste */
.lightbox { z-index: 100; }

/* ================================================================ Kellerplan */
.cellar-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 640px; margin-top: .8rem; }
.cellar-stats .stat b { font-size: 1.7rem; line-height: 1.15; }
.cellar-filters select { flex: 1 1 170px; }
.cellar-filters .btn { flex: none; }

.shelves { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 1.2rem; align-items: start; }
.shelf { margin: 0; padding: 0; overflow: hidden; }
.shelf-unsorted { border-style: dashed; }
.shelf-head {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--border); margin: 0;
}
.shelf-head h2 { margin: 0; font-size: 1.15rem; }
.shelf-sub { margin: .15rem 0 0; color: var(--muted); font-size: .88rem; }
.shelf-attention { color: var(--danger-text); font-weight: 600; }
.shelf-total { text-align: right; line-height: 1.05; flex: none; }
.shelf-total b { display: block; font-size: 1.9rem; font-variant-numeric: tabular-nums; }
.shelf-total span { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }

.cellar-rows { display: flex; flex-direction: column; }
.cellar-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: .85rem;
  padding: .7rem 1.1rem; border-bottom: 1px solid var(--border); color: var(--text);
}
.cellar-row:last-child { border-bottom: 0; }
.cellar-row:hover { background: var(--hover); }
.cellar-thumb { width: 44px; height: 58px; display: flex; align-items: center; justify-content: center; }
.cellar-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cellar-thumb img.cellar-photo { width: 44px; height: 58px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.cellar-dot { width: 16px; height: 16px; border-radius: 50%; }
.cellar-dot.color-rot { background: #8f1d34; } .cellar-dot.color-weiss { background: #b39a54; }
.cellar-dot.color-rose { background: #d8748a; } .cellar-dot.color-schaumwein { background: #a08d5c; }
.cellar-dot.color-suesswein { background: #a9762f; } .cellar-dot.color-orange { background: #c96c30; }

.cellar-main { display: flex; flex-direction: column; min-width: 0; gap: .1rem; }
.cellar-name { font-size: 1rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cellar-vintage { font-weight: 400; color: var(--muted); }
.cellar-sub { font-size: .86rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cellar-hint {
  align-self: flex-start; margin-top: .2rem; padding: .05rem .5rem; border-radius: 999px;
  font-size: .76rem; font-weight: 600; white-space: nowrap;
}
.cellar-hint-over { color: var(--danger-text); background: #f6e3de; }
.cellar-hint-soon { color: var(--wine); background: #f4e9eb; }

.cellar-count {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 52px; padding: .3rem .5rem; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); line-height: 1;
}
.cellar-count b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.cellar-count span { font-size: .7rem; color: var(--muted); margin-top: .15rem; }
.shelf-help { padding: .8rem 1.1rem 1rem; margin: 0; border-top: 1px solid var(--border); }

@media (max-width: 600px) {
  .shelves { grid-template-columns: 1fr; }
  .cellar-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cellar-stats .stat b { font-size: 1.4rem; }
}

/* ================================================================ Anmeldung */
.page-auth .container { max-width: 420px; padding-top: 3rem; }
.auth-card { padding: 1.6rem 1.5rem 1.8rem; }
.auth-head { text-align: center; margin-bottom: 1.2rem; }
.auth-logo { font-size: 2.4rem; display: block; }
.auth-head h1 { font-size: 1.5rem; margin: .3rem 0 .2rem; }
.auth-form label { font-size: .85rem; margin-bottom: .9rem; }
.auth-form input { font-size: 1rem; padding: .65rem .75rem; }
.auth-submit { width: 100%; margin-top: .4rem; padding: .7rem; font-size: 1rem; }
.auth-error {
  border: 1px solid #e2b1a8; background: #fbeae7; color: #7a2a1d;
  border-radius: 10px; padding: .6rem .8rem; margin-bottom: 1rem; font-size: .92rem;
}

.topbar-user { display: flex; align-items: center; gap: .7rem; flex: none; }
.topbar-user a { color: var(--text); font-size: .9rem; font-weight: 500; }
.topbar-user form { margin: 0; }
.topbar-logout {
  background: none; border: 0; color: var(--muted); font-size: .85rem; cursor: pointer; padding: 0;
}
.topbar-logout:hover { color: var(--text); }

.user-reset { align-items: flex-end; margin-bottom: .8rem; }
.user-reset-name { flex: 0 0 120px; font-weight: 600; padding-bottom: .55rem; }
@media (max-width: 560px) { .user-reset-name { flex-basis: 100%; } }

/* ================================================================ Profil und Zugänge */
.code-input { font-size: 1.5rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.code-form { display: flex; gap: .6rem; align-items: flex-start; margin-top: .6rem; flex-wrap: wrap; }
.code-form .code-input { flex: 1 1 180px; }
.auth-recovery { margin-top: 1.2rem; border-top: 1px solid var(--border); padding-top: .8rem; }
.auth-recovery summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.auth-foot { text-align: center; margin-top: 1rem; }
.auth-foot a { color: var(--muted); font-size: .88rem; }

.setup-steps { margin: 0; padding-left: 1.3rem; }
.setup-steps > li { margin-bottom: 1.1rem; }
.qr-box { background: #fff; display: inline-block; padding: .6rem; border-radius: 10px; border: 1px solid var(--border); margin: .6rem 0; }
.qr-box img { display: block; width: 190px; height: 190px; image-rendering: pixelated; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .95rem; letter-spacing: .08em; background: var(--surface-2); padding: .2rem .45rem; border-radius: 6px; word-break: break-all; }

.mfa-state { font-weight: 600; margin: 0 0 .3rem; }
.mfa-on { color: #2f6b44; }
.mfa-off { color: var(--muted); }
.mfa-more { margin-top: .9rem; border-top: 1px solid var(--border); padding-top: .7rem; }
.mfa-more summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.mfa-more .row { align-items: flex-end; margin-top: .6rem; }

.codes-card { border-color: var(--accent); }
.codes-list {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .5rem; margin: 1rem 0; padding-left: 1.4rem;
}
.codes-list li {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.05rem; letter-spacing: .06em;
}

.users-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1.1rem; align-items: start; }
.user-card { margin: 0; }
.user-inactive { opacity: .65; border-style: dashed; }
.user-head { display: flex; justify-content: space-between; gap: .8rem; align-items: flex-start; }
.user-head h2 { margin: 0; font-size: 1.15rem; }
.user-tags { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.user-facts { margin: .8rem 0 0; font-size: .9rem; }
.user-warn { color: var(--danger-text); font-weight: 600; }
.user-actions { margin-top: .9rem; border-top: 1px solid var(--border); padding-top: .7rem; }
.user-actions summary { cursor: pointer; color: var(--muted); font-size: .9rem; }

@media print {
  .topbar, .tabbar, .footer, .actions { display: none !important; }
  body { padding-bottom: 0; }
  .codes-card { border: 1px solid #000; }
}

.error-page { max-width: 480px; margin: 3rem auto; text-align: center; padding: 2rem 1.5rem; }
.error-code { display: block; font-size: 3rem; font-weight: 700; color: var(--muted); line-height: 1; }
.error-page h1 { margin: .5rem 0 .4rem; }
.error-page .actions { justify-content: center; }

/* ---------------------------------------------------------------- Papierkorb */
.trash-list { list-style: none; margin: 0; padding: 0; }
.trash-row {
  display: flex; align-items: center; gap: .9rem;
  padding: .7rem 0; border-top: 1px solid var(--border);
}
.trash-row:first-child { border-top: 0; }
.trash-thumb {
  flex: none; width: 52px; height: 52px; border-radius: 10px;
  object-fit: cover; background: var(--surface-2); border: 1px solid var(--border);
}
.trash-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: var(--muted);
}
/* flex-basis 0, sonst drueckt ein langer Weinname das Bild in eine eigene Zeile */
.trash-text { flex: 1 1 0; min-width: 0; }
.trash-text h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-text p { margin: .1rem 0 0; }
.trash-soon { color: var(--danger-text); font-weight: 600; }
.trash-actions { flex: none; display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.trash-actions form { margin: 0; }
.trash-empty { text-align: center; padding: 2.2rem 1.5rem; }
.trash-empty-icon { font-size: 2.4rem; margin: 0 0 .4rem; opacity: .5; }

@media (max-width: 560px) {
  .trash-row { flex-wrap: wrap; }
  .trash-actions { width: 100%; justify-content: flex-start; padding-left: calc(52px + .9rem); }
}

/* Papierkorb-Verknüpfung in der Kopfleiste */
.topbar-trash { display: inline-flex; align-items: center; gap: .3rem; }
.topbar-count {
  min-width: 1.15rem; padding: 0 .3rem; border-radius: 999px;
  background: var(--wine); color: #fff; font-size: .72rem; font-weight: 600;
  line-height: 1.3rem; text-align: center;
}
