/* ═══════════════════════════════════════════════════════════════
   Vorratskammer – Stylesheet  (Bring!-inspiriertes Design)
   Tablet-first, Touch-optimiert, mind. 44 px Touch-Targets
═══════════════════════════════════════════════════════════════ */

/* ─── Design-Tokens ─────────────────────────────────────────── */
:root {
  --clr-primary:       #00b894;
  --clr-primary-dark:  #009d7d;
  --clr-primary-light: #d5f5ec;
  --clr-cam:           #2d3436;
  --clr-cam-dark:      #1a1f20;
  --clr-scan:          #6c5ce7;
  --clr-scan-dark:     #5a4bd1;
  --clr-danger:        #e74c3c;
  --clr-danger-light:  #fde8e6;
  --clr-warning:       #f39c12;
  --clr-warning-light: #fef3cd;
  --clr-success:       #00b894;
  --clr-success-light: #d5f5ec;
  --clr-bg:            #f0f4f8;
  --clr-surface:       #ffffff;
  --clr-border:        #dde3eb;
  --clr-text:          #2d3436;
  --clr-muted:         #636e72;
  --clr-skeleton:      #e8ecf0;

  --shadow-sm: 0 1px 4px rgba(0,0,0,.06);
  --shadow:    0 2px 10px rgba(0,0,0,.08);
  --shadow-md: 0 4px 20px rgba(0,0,0,.12);

  --radius:    14px;
  --radius-sm: 9px;
  --radius-xs: 5px;

  --touch: 44px;          /* minimale Touch-Target-Höhe */
  --hdr:   0px;           /* wird per JS nach Header-Höhe gesetzt */

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;

  --transition: 0.18s ease;
}

/* ─── Basis ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--clr-bg);
  color: var(--clr-text);
  min-height: 100vh;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

img { display: block; max-width: 100%; }

/* ─── Header ─────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--clr-surface);
  box-shadow: var(--shadow);
  padding: 12px 16px 0;
  user-select: none;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.app-icon { font-size: 1.5rem; line-height: 1; }

.app-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--clr-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ─── Kategorie-Filter ──────────────────────────────────────── */
.category-filter {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.category-filter::-webkit-scrollbar { display: none; }

.cat-btn {
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  border: 2px solid var(--clr-border);
  background: transparent;
  color: var(--clr-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  touch-action: manipulation;
}

.cat-btn.active,
.cat-btn:hover {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: #fff;
}

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--touch);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.925rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  touch-action: manipulation;
  user-select: none;
}

.btn-primary       { background: var(--clr-primary); color: #fff; }
.btn-primary:hover { background: var(--clr-primary-dark); }

.btn-scan          { background: var(--clr-scan); color: #fff; }
.btn-scan:hover    { background: var(--clr-scan-dark); }

.btn-secondary       { background: var(--clr-border); color: var(--clr-text); }
.btn-secondary:hover { background: #c8d0da; }

.btn-danger          { background: var(--clr-danger); color: #fff; }
.btn-danger:hover    { filter: brightness(0.9); }

.btn-ghost          { background: transparent; color: var(--clr-muted); }
.btn-ghost:hover    { background: var(--clr-bg); }

.btn-sm  { height: 36px; padding: 0 12px; font-size: 0.85rem; border-radius: var(--radius-xs); }
.btn-lg  { height: 52px; padding: 0 28px; font-size: 1rem; border-radius: var(--radius); }

.btn-icon  { font-size: 1.1rem; line-height: 1; }
.btn-label { }

/* ─── Panels (Accordion) ─────────────────────────────────────── */
.panel {
  background: var(--clr-surface);
  border-bottom: 2px solid var(--clr-border);
  animation: panelSlide 0.2s ease;
}

@keyframes panelSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel[hidden] { display: none !important; }

.panel-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 20px 24px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--clr-text);
}

.panel-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--clr-bg);
  color: var(--clr-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  touch-action: manipulation;
}

.panel-close:hover { background: var(--clr-danger); color: #fff; }

.panel-hint {
  font-size: 0.875rem;
  color: var(--clr-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--clr-border);
  margin-top: 8px;
}

/* ─── Formular-Raster ────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 4px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group--full { grid-column: 1 / -1; }

.form-group label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--clr-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.form-group input,
.form-group select {
  height: var(--touch);
  padding: 0 12px;
  border: 2px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: var(--clr-surface);
  color: var(--clr-text);
  font-size: 1rem;
  transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px var(--clr-primary-light);
}

.required { color: var(--clr-danger); }
.optional { font-weight: 400; text-transform: none; }

.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }

.field-hint {
  font-size: 0.8rem;
  min-height: 18px;
  transition: color var(--transition);
}

.field-hint.ok      { color: var(--clr-primary); }
.field-hint.warn    { color: var(--clr-warning); }
.field-hint.error   { color: var(--clr-danger); }

/* ─── Mengen-Steuerung ─────────────────────────────────────────── */
.qty-control {
  display: flex;
  align-items: center;
  height: var(--touch);
  border: 2px solid var(--clr-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition);
}

.qty-control:focus-within { border-color: var(--clr-primary); }

.qty-btn {
  flex-shrink: 0;
  width: 44px;
  height: 100%;
  border: none;
  background: var(--clr-bg);
  color: var(--clr-text);
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition);
  touch-action: manipulation;
  user-select: none;
}

.qty-btn:hover  { background: var(--clr-border); }
.qty-btn:active { background: var(--clr-primary-light); }

.qty-control input[type="number"] {
  flex: 1;
  border: none !important;
  border-left:  2px solid var(--clr-border) !important;
  border-right: 2px solid var(--clr-border) !important;
  border-radius: 0 !important;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  box-shadow: none !important;
  padding: 0 4px;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { display: none; }
input[type="number"] { -moz-appearance: textfield; }

/* ─── Scan-Panel spezifisch ──────────────────────────────────── */
.panel--scan .panel-inner { max-width: 560px; }

.scan-input {
  font-size: 1.25rem !important;
  text-align: center;
  letter-spacing: 3px;
}

.scan-result {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  transition: all var(--transition);
}

.scan-result:empty { display: none; }

.scan-result.success { background: var(--clr-success-light); color: #0a6649; }
.scan-result.error   { background: var(--clr-danger-light);  color: #8c1b11; }
.scan-result.warning { background: var(--clr-warning-light); color: #7a4e00; }

/* ─── Haupt-Layout ───────────────────────────────────────────── */
.main-content {
  padding: 20px 16px 40px;
}

/* ─── Artikel-Raster ─────────────────────────────────────────── */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

/* ─── Artikel-Karte ──────────────────────────────────────────── */
.item-card {
  background: var(--clr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  display: flex;
  gap: 12px;
  position: relative;
  border-left: 4px solid transparent;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.item-card:hover { box-shadow: var(--shadow); }

.item-card.expired  { border-left-color: var(--clr-danger); }
.item-card.expiring { border-left-color: var(--clr-warning); }

/* Bild / Platzhalter */
.item-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--clr-bg);
}

.item-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  background: var(--clr-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

/* Karten-Body */
.item-body {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 0.975rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
  padding-right: 36px; /* Platz für Aktions-Spalte */
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.badge-cat         { background: #eef2ff; color: #3b4fd8; }
.badge-cat-unknown { background: var(--clr-warning-light); color: #7a4e00; }
.badge-ok          { background: #e8f8f5; color: #1a7a5e; }
.badge-expiring    { background: var(--clr-warning-light); color: #7a4e00; }
.badge-expired     { background: var(--clr-danger-light);  color: #8c1b11; }

/* Inline-Mengensteuerung (in der Karte) */
.item-qty {
  display: flex;
  align-items: center;
  height: 38px;
  border: 2px solid var(--clr-border);
  border-radius: var(--radius-xs);
  overflow: hidden;
  width: fit-content;
  transition: border-color var(--transition);
}

.item-qty:focus-within { border-color: var(--clr-primary); }

.item-qty-btn {
  width: 38px;
  height: 100%;
  border: none;
  background: var(--clr-bg);
  color: var(--clr-text);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--transition);
  user-select: none;
}

.item-qty-btn:hover  { background: var(--clr-border); }
.item-qty-btn:active { background: var(--clr-primary-light); }

.item-qty-input {
  width: 50px;
  height: 100%;
  border: none;
  border-left:  2px solid var(--clr-border);
  border-right: 2px solid var(--clr-border);
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  background: var(--clr-surface);
  color: var(--clr-text);
}

.item-qty-input:focus {
  outline: none;
  background: var(--clr-primary-light);
}

/* Aktions-Spalte (Bearbeiten + Entfernen) */
.card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.item-edit,
.item-remove {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--clr-muted);
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  touch-action: manipulation;
}

.item-edit:hover {
  background: var(--clr-primary);
  color: #fff;
  transform: scale(1.1);
}

.item-remove:hover {
  background: var(--clr-danger);
  color: #fff;
  transform: scale(1.1);
}

/* ─── Leerer Zustand ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--clr-muted);
}

.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 1.05rem; }

/* ─── Skeleton Loading ───────────────────────────────────────── */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.skeleton-card {
  height: 96px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--clr-skeleton) 25%, #f5f7fa 50%, var(--clr-skeleton) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ─── History ────────────────────────────────────────────────── */
.history-section {
  margin-top: 8px;
  border-top: 2px solid var(--clr-border);
  padding-top: 20px;
}

.section-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--clr-muted);
  flex: 1;
}

.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-item {
  background: var(--clr-surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0.82;
  transition: opacity var(--transition);
}

.history-item:hover { opacity: 1; }

.history-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
  background: var(--clr-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.history-info { flex: 1; min-width: 0; }

.history-name {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  font-size: 0.78rem;
  color: var(--clr-muted);
  margin-top: 2px;
}

.history-restore {
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  border: 2px solid var(--clr-primary);
  background: transparent;
  color: var(--clr-primary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  touch-action: manipulation;
}

.history-restore:hover { background: var(--clr-primary); color: #fff; }

.muted-text {
  color: var(--clr-muted);
  font-size: 0.9rem;
  padding: 8px 0;
}

/* ─── Toast-Benachrichtigungen ───────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(480px, 90vw);
}

.toast {
  background: #2d3436;
  color: #fff;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease;
  text-align: center;
  max-width: 100%;
}

.toast.success { background: var(--clr-primary); }
.toast.error   { background: var(--clr-danger); }
.toast.warning { background: var(--clr-warning); }
.toast.info    { background: var(--clr-scan); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ─── Responsive ─────────────────────────────────────────────── */

/* Mobil (bis 599 px) */
@media (max-width: 599px) {
  .app-title  { font-size: 1.1rem; }
  .btn-label  { display: none; }        /* nur Icons in der Header-Bar */
  .btn        { padding: 0 14px; }
  .items-grid { grid-template-columns: 1fr; }
  .form-grid  { grid-template-columns: 1fr; }
  .panel-inner { padding: 16px; }
  .main-content { padding: 14px 12px 32px; }
}

/* Desktop / großes Tablet (ab 1024 px) */
@media (min-width: 1024px) {
  .app-header   { padding: 14px 24px 0; }
  .main-content { padding: 24px 24px 48px; }
}

/* ═══════════════════════════════════════════════════════════════
   Kamera-Button
═══════════════════════════════════════════════════════════════ */
.btn-cam {
  background: var(--clr-cam);
  color: #fff;
  font-size: 1rem;
}
.btn-cam:hover { background: var(--clr-cam-dark); }

/* Großer Kamera-Start-Button im Scan-Panel */
.btn-cam--big {
  width: 100%;
  height: 60px;
  border-radius: var(--radius);
  font-size: 1.1rem;
  gap: 10px;
  margin-bottom: 14px;
}

.cam-icon { font-size: 1.15rem; }

/* ─── Manuelle Eingabe (Fallback im Scan-Panel) ───────────────── */
.manual-input-details {
  margin-bottom: 12px;
}

.manual-input-details summary {
  font-size: 0.875rem;
  color: var(--clr-muted);
  cursor: pointer;
  padding: 6px 0;
  user-select: none;
  list-style: none;
}

.manual-input-details summary::before {
  content: '▸ ';
}

.manual-input-details[open] summary::before {
  content: '▾ ';
}

/* ═══════════════════════════════════════════════════════════════
   Kamera-Scanner Modal
═══════════════════════════════════════════════════════════════ */

/* Overlay */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.modal[hidden] { display: none !important; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* Karte */
.modal-card {
  position: relative;
  z-index: 1;
  background: var(--clr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: modalIn 0.22s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.scanner-card { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--clr-border);
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--clr-bg);
  color: var(--clr-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  touch-action: manipulation;
}

.modal-close:hover { background: var(--clr-danger); color: #fff; }

.modal-hint {
  font-size: 0.82rem;
  color: var(--clr-muted);
  text-align: center;
  padding: 8px 16px 4px;
}

/* Scanner-Body: Inhaltsbereich des Modals */
.scanner-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.scanner-body[hidden] { display: none !important; }

/* Großer Foto-Aufnahme-Button (label als Button) */
.btn-cam--full {
  display: flex !important;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 64px;
  font-size: 1.1rem;
  border-radius: var(--radius);
  gap: 10px;
  cursor: pointer;
}

/* Tipp-Text im Scanner */
.scanner-hint {
  font-size: 0.85rem;
  color: var(--clr-muted);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* Live-Kamera Video-Element */
.scanner-video {
  width: 100%;
  border-radius: var(--radius-sm);
  background: #000;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  margin-bottom: 10px;
}

/* Lade-Spinner (Verarbeitungs-Ansicht) */
.scan-spinner {
  width: 48px;
  height: 48px;
  border: 5px solid var(--clr-border);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 20px auto 14px;
}

/* Status-Zeile unter dem Viewfinder */
.scanner-status {
  min-height: 36px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  color: var(--clr-muted);
}

.scanner-status.error   { color: var(--clr-danger); }
.scanner-status.success { color: var(--clr-primary); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--clr-border);
}

/* ═══════════════════════════════════════════════════════════════
   Foto-Vorschau (im Hinzufügen-Formular)
═══════════════════════════════════════════════════════════════ */

.photo-preview {
  position: relative;
  margin-top: 10px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: 100%;
  max-width: 220px;
  border: 2px solid var(--clr-border);
  background: var(--clr-bg);
}

.photo-preview[hidden] { display: none; }

.photo-preview img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 200px;
  object-fit: cover;
}

/* ✕-Button auf der Vorschau */
.photo-preview-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: background var(--transition);
}

.photo-preview-remove:hover { background: var(--clr-danger); }

/* Upload-Spinner auf der Vorschau */
.photo-preview-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  color: var(--clr-muted);
  font-size: 0.875rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--clr-border);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

/* ─── MHD Inline-Editor ──────────────────────────────────── */
.badge--editable {
  cursor: pointer;
  transition: opacity var(--transition);
}
.badge--editable:hover { opacity: 0.7; }

.badge-no-mhd {
  background: #f0f0f0;
  color: var(--clr-muted);
}

.mhd-inline-edit {
  height: 26px;
  padding: 0 8px;
  border: 2px solid var(--clr-primary);
  border-radius: 13px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--clr-primary-light, #e8f8f5);
  color: var(--clr-text);
  max-width: 150px;
  cursor: pointer;
}

.mhd-inline-edit:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--clr-primary-light, #e8f8f5);
}

/* ─── Modal Body (Edit + Kategorie-Manager) ──────────────────── */
.modal-body {
  padding: 16px 16px 4px;
  overflow-y: auto;
  max-height: calc(80vh - 120px);
}

.modal-hint {
  font-size: 0.82rem;
  color: var(--clr-muted);
  line-height: 1.5;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--clr-bg);
  border-radius: var(--radius-xs);
}

/* ─── Kategorie-Manager ──────────────────────────────────────── */
.cat-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.cat-add-row input {
  flex: 1;
  height: var(--touch);
  padding: 0 12px;
  border: 2px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: var(--clr-surface);
  color: var(--clr-text);
  font-size: 1rem;
  transition: border-color var(--transition);
}

.cat-add-row input:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px var(--clr-primary-light);
}

.cat-manager-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
}

.cat-manager-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  background: var(--clr-bg);
  transition: background var(--transition);
}

.cat-manager-item:hover { background: #e8ecf2; }

.cat-manager-name {
  font-size: 0.95rem;
  font-weight: 600;
}

.cat-delete-btn { color: var(--clr-muted); }
.cat-delete-btn:hover { background: var(--clr-danger) !important; color: #fff !important; }

/* ─── Volltextsuche ──────────────────────────────────────────── */
.search-row {
  padding: 0 0 12px;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--touch);
  padding: 0 12px;
  background: var(--clr-bg);
  border: 2px solid var(--clr-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-wrap:focus-within {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px var(--clr-primary-light);
  background: var(--clr-surface);
}

.search-icon {
  font-size: 1rem;
  flex-shrink: 0;
  user-select: none;
}

#search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  color: var(--clr-text);
  outline: none;
  min-width: 0;
}

#search-input::placeholder { color: var(--clr-muted); }

.search-clear {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--clr-muted);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  touch-action: manipulation;
}

.search-clear:hover { background: var(--clr-danger); }
.search-clear[hidden] { display: none !important; }

/* Treffer-Hervorhebung im Artikelnamen */
mark.search-hl {
  background: #fff176;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
  font-weight: 800;
}

/* ─── Seitennavigation (Pagination) ─────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 16px 0 24px;
}

.page-info {
  font-size: 0.85rem;
  color: var(--clr-muted);
  white-space: nowrap;
  margin-right: 6px;
}

.page-btn {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 2px solid var(--clr-border);
  border-radius: var(--radius-xs);
  background: var(--clr-surface);
  color: var(--clr-text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  touch-action: manipulation;
  white-space: nowrap;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}

.page-btn.active {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.page-ellipsis {
  color: var(--clr-muted);
  font-size: 0.9rem;
  padding: 0 2px;
  user-select: none;
  line-height: 40px;
}
