:root {
  --bg: #15161c;
  --panel: #1f2129;
  --panel-2: #2a2d38;
  --text: #f1f2f6;
  --muted: #9a9fb0;
  --accent: #ffcb05;
  --accent-text: #1b1b1b;
  --blue: #3d7dca;
  --good: #3fbf7f;
  --border: #343846;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

header, main, footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

header { padding-top: max(20px, env(safe-area-inset-top)); }
h1 { margin: 0 0 14px; font-size: 26px; letter-spacing: -0.02em; }

.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--panel);
  padding: 5px;
  border-radius: var(--radius);
}
.mode {
  border: 0;
  border-radius: 10px;
  padding: 12px 8px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.mode.active { background: var(--accent); color: var(--accent-text); }
.mode-hint { color: var(--muted); font-size: 14px; margin: 8px 2px 0; }

.scan { margin-top: 20px; }
.scan-btn {
  display: block;
  text-align: center;
  background: var(--blue);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  padding: 22px;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
}
.scan-btn:active { transform: scale(0.99); }
.tip { color: var(--muted); font-size: 13px; text-align: center; margin: 8px 0 16px; }

.search { display: flex; gap: 8px; }
.search input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.search button, .btn {
  padding: 12px 16px;
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.status {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
}
.status.error { color: #ff8a8a; }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  margin-right: 8px;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.preview { margin-top: 14px; text-align: center; }
.preview img { max-height: 180px; border-radius: 8px; }
.preview .ocr { color: var(--muted); font-size: 13px; margin-top: 4px; }

h2 { font-size: 18px; margin: 22px 0 10px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.cand {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  text-align: left;
}
.cand img, .cand .noimg {
  width: 100%;
  aspect-ratio: 63 / 88;
  object-fit: contain;
  border-radius: 6px;
  background: var(--panel-2);
  display: block;
}
.cand .noimg { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.cand .n { font-weight: 600; font-size: 14px; margin-top: 6px; }

.best-cand {
  display: grid;
  grid-template-columns: minmax(0, 220px);
  justify-content: center;
  gap: 10px;
}
.best-cand .cand { border: 2px solid var(--accent); }
.best-cand .buy { font-size: 17px; padding: 14px; }
.cand .s { color: var(--muted); font-size: 12px; }

.card-head {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 16px;
  margin-top: 20px;
  align-items: start;
}
.card-head img { width: 100%; border-radius: 8px; }
.card-head h2 { margin: 0 0 4px; font-size: 22px; }
.card-head .meta { color: var(--muted); font-size: 14px; }

.best {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 12px;
}
.best .label { font-size: 13px; color: var(--muted); }
.best .price { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.best .where { font-size: 14px; }

.shop {
  margin-top: 14px;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.shop h3 { margin: 0 0 8px; font-size: 16px; display: flex; justify-content: space-between; }
.shop .src { font-weight: 400; color: var(--muted); font-size: 12px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.row:first-of-type { border-top: 0; }
.row .info { flex: 1; min-width: 0; }
.row .t { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 12px; color: var(--muted); }
.row .p { font-weight: 700; white-space: nowrap; text-align: right; }
.row .p small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.row img.thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; }

.buy {
  background: var(--good);
  color: #08140e;
  padding: 8px 12px;
  font-size: 14px;
  white-space: nowrap;
}
.links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.note { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.back { margin-top: 20px; width: 100%; }

.cropper { margin-top: 10px; }
.crop-stage {
  position: relative;
  width: fit-content;
  margin: 10px auto 0;
  border-radius: 10px;
  overflow: hidden;
  touch-action: none; /* Ziehen verschiebt den Rahmen statt die Seite */
  user-select: none;
  -webkit-user-select: none;
}
.crop-stage canvas { display: block; max-width: 100%; max-height: 52vh; width: auto; height: auto; }
.crop-frame {
  position: absolute;
  border: 3px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55); /* dunkelt alles außerhalb ab */
  pointer-events: none;
}
.slider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}
.slider input { flex: 1; accent-color: var(--accent); }
.crop-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-top: 14px; }
.crop-actions .buy { font-size: 16px; padding: 14px; }

footer {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding-top: 30px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

@media (max-width: 420px) {
  .card-head { grid-template-columns: 100px 1fr; }
  .best .price { font-size: 26px; }
}
