:root {
  --bg: #f7f3ec;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #555;
  --line: #d9d2c5;
  --primary: #1d4e89;
  --primary-dark: #163c6a;
  --green: #1e7b34;
  --green-bg: #e3f4e6;
  --red: #b3261e;
  --red-bg: #fbe5e3;
  --yellow: #8a5a00;
  --yellow-bg: #fff2cc;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { font-size: 20px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
  padding-bottom: env(safe-area-inset-bottom);
}

#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  min-height: 64px;
  padding: env(safe-area-inset-top) 16px 0;
  background: var(--primary); color: #fff;
}
#topbar h1 { margin: 0; font-size: 1.3rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#back {
  background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 10px;
  font: inherit; font-weight: 600; padding: 10px 14px; min-height: 48px;
}

#offline { background: var(--yellow-bg); color: var(--yellow); text-align: center; padding: 8px; font-weight: 600; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }

h2 { font-size: 1.4rem; margin: 8px 0 12px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Knöpfe: groß, volle Breite, Symbol + Wort */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 64px; margin: 12px 0; padding: 12px 18px;
  border: 0; border-radius: var(--radius);
  font: inherit; font-size: 1.1rem; font-weight: 700; text-decoration: none; text-align: center;
  background: var(--primary); color: #fff; cursor: pointer;
}
.btn:active { background: var(--primary-dark); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.light { background: var(--card); color: var(--primary); border: 2px solid var(--primary); }
.btn.small { min-height: 52px; font-size: 1rem; }
.btn[disabled] { opacity: .5; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.link { background: none; border: 0; color: var(--primary); font: inherit; text-decoration: underline; padding: 12px 0; cursor: pointer; display: inline-block; }

/* Startseite */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 130px; padding: 12px; border-radius: var(--radius);
  background: var(--card); border: 2px solid var(--line); color: var(--text);
  font: inherit; font-weight: 700; font-size: 1.05rem; text-decoration: none; text-align: center; cursor: pointer;
}
.tile .icon { font-size: 2.6rem; line-height: 1; }
.tile.big { grid-column: 1 / -1; background: var(--primary); color: #fff; border-color: var(--primary); min-height: 150px; font-size: 1.3rem; }
.tile small { font-weight: 400; color: var(--muted); font-size: .85rem; }
.tile.big small { color: #dbe6f5; }

input[type=file].hidden { display: none; }

/* Formulare */
label.field { display: block; margin: 14px 0; font-weight: 600; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=tel], select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 14px;
  font: inherit; font-size: 1.1rem; color: var(--text);
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid #8fb3e0; border-color: var(--primary); }
textarea { min-height: 100px; }
.search { font-size: 1.2rem !important; padding: 18px !important; border-color: var(--primary) !important; }

.stepper { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.stepper button { width: 64px; height: 56px; font-size: 1.6rem; border-radius: 12px; border: 2px solid var(--primary); background: #fff; color: var(--primary); font-weight: 700; }
.stepper input { text-align: center; margin: 0; }

/* Listen */
.list { list-style: none; padding: 0; margin: 0; }
.item {
  display: flex; align-items: center; gap: 14px;
  padding: 10px; margin: 8px 0; min-height: 80px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  color: inherit; text-decoration: none;
}
.item img, .item .noimg { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; flex: none; background: #e9e3d8; }
.item .noimg { display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.item .txt { flex: 1; min-width: 0; }
.item .artist { font-weight: 700; }
.item .title { color: var(--muted); }
.item .badge { flex: none; background: var(--primary); color: #fff; border-radius: 999px; padding: 4px 10px; font-weight: 700; font-size: .9rem; }

/* Antwort-Kasten */
.answer { border-radius: var(--radius); padding: 22px 16px; margin: 8px 0 16px; text-align: center; border: 3px solid; }
.answer .big { font-size: 1.8rem; font-weight: 800; line-height: 1.2; }
.answer.owned { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.answer.missing { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.answer.maybe, .answer.wish { background: var(--yellow-bg); border-color: var(--yellow); color: var(--yellow); }
.answer p { color: var(--text); margin: 8px 0 0; }

.cover { width: 100%; max-height: 60vh; object-fit: contain; border-radius: var(--radius); background: #e9e3d8; display: block; }
.cover-small { width: 160px; height: 160px; object-fit: cover; border-radius: 10px; display: block; margin: 0 auto 10px; }

.facts { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px; margin: 12px 0; }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eee7da; }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card.warn { border: 2px solid var(--yellow); background: var(--yellow-bg); }
.card.err { border: 2px solid var(--red); background: var(--red-bg); }

.summary { display: flex; justify-content: space-between; font-weight: 600; margin: 8px 0; }

/* Import */
.imp { display: flex; gap: 12px; align-items: flex-start; }
.imp img { width: 110px; height: 110px; object-fit: cover; border-radius: 10px; flex: none; }
.imp .fields { flex: 1; min-width: 0; }
.imp input { padding: 10px; font-size: 1rem; margin-top: 4px; }
.progress { height: 18px; background: #e9e3d8; border-radius: 9px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: var(--green); transition: width .3s; }

/* Laden */
.loading { text-align: center; padding: 40px 0; font-size: 1.2rem; font-weight: 600; }
.spinner { width: 72px; height: 72px; margin: 0 auto 20px; border: 8px solid #d6e2f1; border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Barcode */
.scanbox { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; }
.scanbox video { width: 100%; display: block; }
.scanbox .frame { position: absolute; left: 10%; right: 10%; top: 35%; bottom: 35%; border: 4px solid #4cd964; border-radius: 10px; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: 600px; margin: 0 auto; padding: 18px; border-radius: var(--radius);
  background: #222; color: #fff; text-align: center; font-weight: 700; font-size: 1.1rem;
}
#modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal[hidden] { display: none; }
#modal .box { background: #fff; border-radius: var(--radius); padding: 22px; width: 100%; max-width: 480px; }
#modal .box p { font-size: 1.2rem; font-weight: 600; margin: 0 0 8px; }
