@font-face { font-family: "Lilita One"; src: url(fonts/lilita-one-latin-400-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: Barlow; font-weight: 400; src: url(fonts/barlow-latin-400-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: Barlow; font-weight: 600; src: url(fonts/barlow-latin-600-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; src: url(fonts/barlow-condensed-latin-700-normal.woff2) format("woff2"); font-display: swap; }

:root {
  color-scheme: light;
  --sky: #BFE3F0;
  --recess: #93C4D6;
  --ink: #12243F;
  --ink-soft: #3C5068;
  --paper: #FFFBEF;
  --red: #C9281F;
  --yellow: #FFC928;
  --blue: #2B6FD6;
  --green: #17855A;
  --line: 2px solid var(--ink);
  --tabs: 68px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--sky); color: var(--ink);
  font: 400 17px/1.45 Barlow, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: "Lilita One", Barlow, sans-serif; font-weight: 400; margin: 0; line-height: 1.1; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 46px;
  padding: 8px 16px; background: var(--paper); border: var(--line); border-radius: 10px;
  font-weight: 600; text-decoration: none; color: var(--ink); cursor: pointer;
}
.btn.primary { background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); }
.btn.primary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.danger { color: var(--red); }
.btn.small { min-height: 42px; padding: 6px 10px; font-size: 15px; line-height: 1.15; text-align: center; }
.btn:disabled { opacity: .5; }

input:not([type=radio], [type=checkbox], [type=file]), textarea {
  width: 100%; min-height: 46px; padding: 8px 12px; background: var(--paper);
  border: var(--line); border-radius: 10px; font-size: 17px;
}
label { display: block; font-weight: 600; }
.form-error { color: var(--red); font-weight: 600; }

.panel { background: var(--paper); border: var(--line); border-radius: 14px; box-shadow: 5px 5px 0 var(--ink); padding: 22px; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(380px, 100%); display: grid; gap: 14px; }
.login h1 { font-size: 36px; }

/* Einrichtung */
body.install { padding: 16px; }
.install-panel { max-width: 460px; margin: 24px auto; display: grid; gap: 14px; }
.install-panel form, #mysql-fields { display: grid; gap: 12px; }
.install-panel fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
.install-panel legend { font-weight: 600; padding: 0; }
.check { font-weight: 400; display: flex; gap: 8px; align-items: center; }

/* Kopfbereich */
.top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px; max-width: 760px; margin: 0 auto;
}
.top h1 { font-size: clamp(34px, 11vw, 46px); }
.top p { font-weight: 600; color: var(--ink-soft); }
.icon-btn { width: 46px; height: 46px; flex: none; background: var(--paper); border: var(--line); border-radius: 10px; display: grid; place-items: center; }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }
.offline { background: var(--yellow); border-block: var(--line); padding: 6px 16px; font-weight: 600; text-align: center; }

main { max-width: 760px; margin: 0 auto; padding: 0 16px calc(var(--tabs) + 28px + env(safe-area-inset-bottom)); }

/* Das Regal: Jedes Brett ist ein Rückenbild, jeder Band ein Streifen davon. */
.board { display: block; width: 100%; padding: 0; margin: 0 0 26px; background: none; border: 0; text-align: left; }
.board-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.board-head h2 { font-size: 20px; }
.board-head span { flex: none; font-weight: 600; color: var(--ink-soft); }
.spines { display: flex; align-items: stretch; aspect-ratio: var(--ratio, 13 / 8); background: var(--recess); box-shadow: inset 0 6px 0 rgba(18, 36, 63, .18); }
.spines.flow { aspect-ratio: auto; flex-wrap: wrap; }
.plank { height: 11px; background: var(--yellow); border: var(--line); border-radius: 2px; margin-inline: -6px; }

.spine { position: relative; flex: 1 1 0; min-width: 0; border: 0; padding: 0; background: none; }
.spines.flow .spine { flex: 0 0 calc(100% / 13); height: 56px; }
.spine i {
  position: absolute; inset: 5px 0 auto; text-align: center; font: 700 clamp(9px, 2.8vw, 14px)/1 "Barlow Condensed", sans-serif;
  font-style: normal; color: rgba(18, 36, 63, .62);
}
.spine.have { background-color: var(--c, var(--blue)); box-shadow: inset -1px 0 0 rgba(18, 36, 63, .55); }
.spine.have i { color: #fff; }
.spine.future { background: repeating-linear-gradient(135deg, transparent 0 5px, rgba(18, 36, 63, .1) 5px 10px); }
.has-img .spine.slice.have {
  background-color: transparent;
  background-image: var(--img);
  background-size: calc(var(--slices) * 100%) 100%;
  background-position: calc(var(--i) / (var(--slices) - 1) * 100%) 0;
  box-shadow: none;
}
.has-img .spine.slice.have i { display: none; }

.tall-shelf { overflow-x: auto; margin-inline: -18px; padding-inline: 18px; }
.tall-shelf .spines { width: max(100%, calc(var(--count) * 24px)); }
.tall-shelf .spines.flow { width: 100%; }
.tall-shelf .spines.flow .spine { flex-basis: calc(100% / 8); height: 96px; }
.tall-shelf .spine i { font-size: 14px; top: 8px; }

/* Liste */
.search { margin-bottom: 12px; }
.search input { font-size: 20px; }
.segments { display: flex; border: var(--line); border-radius: 10px; overflow: hidden; background: var(--paper); margin-bottom: 12px; }
.segments button { flex: 1; min-height: 42px; border: 0; background: none; font-weight: 600; }
.segments button + button { border-left: var(--line); }
.segments button[aria-pressed=true] { background: var(--ink); color: var(--paper); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 5px; margin-bottom: 16px; }
.tile {
  min-height: 46px; padding: 0; border: 2px dashed var(--ink-soft); border-radius: 6px; background: transparent;
  font: 700 19px/1 "Barlow Condensed", sans-serif; color: var(--ink);
}
.tile.have { border: var(--line); background: var(--yellow); }
.result { display: flex; gap: 12px; align-items: center; justify-content: space-between; background: var(--paper); border: var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.result b { font-family: "Lilita One"; font-weight: 400; font-size: 21px; display: block; }

/* Scanner */
.view.scan { position: fixed; inset: 0 0 calc(var(--tabs) + env(safe-area-inset-bottom)); display: flex; flex-direction: column; background: #000; z-index: 2; }
.viewport { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #000; }
.viewport video { width: 100%; height: 100%; object-fit: cover; display: block; }
.guide {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  width: 92%; height: 24%; border: 3px solid var(--yellow); border-radius: 8px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .55);
}
.guide.single { width: 46%; height: 18%; }
.scan-hint, .scan-status { position: absolute; left: 16px; right: 16px; text-align: center; color: #fff; font-weight: 600; }
.scan-hint { top: calc(12px + env(safe-area-inset-top)); }
.scan-status { bottom: 14px; }
.scan-status span { background: var(--yellow); color: var(--ink); border-radius: 8px; padding: 4px 10px; }
.scan-bar { background: var(--sky); padding: 10px 16px; border-top: var(--line); }
.scan-actions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.shutter { width: 68px; height: 68px; border-radius: 50%; background: var(--red); border: var(--line); box-shadow: inset 0 0 0 4px var(--paper); }
.shutter:active { transform: scale(.94); }
.shutter:disabled { background: var(--recess); }
.scan-session { text-align: center; font-weight: 600; min-height: 24px; margin-top: 6px; }

/* Navigation */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; display: grid; grid-template-columns: 1fr 1fr 1fr;
  height: calc(var(--tabs) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--paper); border-top: var(--line);
}
.tabs button { border: 0; background: none; font: 400 19px/1 "Lilita One", sans-serif; }
.tabs button + button { border-left: var(--line); }
.tabs button[aria-current=page] { background: var(--yellow); }

/* Blätter */
.sheet {
  width: min(620px, 100%); max-width: 100%; max-height: 92dvh; margin: auto auto 0; padding: 18px;
  background: var(--paper); color: var(--ink); border: var(--line); border-bottom: 0; border-radius: 16px 16px 0 0;
  overflow: auto; padding-bottom: calc(18px + env(safe-area-inset-bottom));
}
.sheet::backdrop { background: rgba(18, 36, 63, .55); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.sheet-head h2 { font-size: 27px; }
.sheet-head p { color: var(--ink-soft); font-weight: 600; }
.close { flex: none; width: 42px; height: 42px; border: var(--line); border-radius: 10px; background: none; font-size: 22px; line-height: 1; }
.stack { display: grid; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.issue { display: grid; grid-template-columns: 110px 1fr; gap: 14px; align-items: start; }
.issue img { width: 110px; border: var(--line); border-radius: 4px; display: block; }
.issue.no-cover { grid-template-columns: 1fr; }
.more-section { display: grid; gap: 8px; padding-block: 14px; border-top: var(--line); }
.more-section:first-of-type { border-top: 0; padding-top: 0; }
.more-section h3 { font-size: 19px; }
.more-section small { color: var(--ink-soft); font-size: 15px; }

/* Prüfschritt nach dem Scan */
.crop { position: relative; line-height: 0; margin-bottom: 12px; border: var(--line); border-radius: 8px; overflow: hidden; }
.crop canvas { width: 100%; height: auto; display: block; max-height: 34dvh; object-fit: contain; background: #000; }
.crop mark { position: absolute; border: 2px solid var(--yellow); background: none; }
.found { display: grid; gap: 6px; margin-bottom: 12px; }
.found-row { display: grid; grid-template-columns: 30px 92px 1fr 34px; gap: 8px; align-items: center; }
.found-row input[type=checkbox] { width: 24px; height: 24px; margin: 0; accent-color: var(--ink); }
.found-row input[inputmode] { font: 700 22px/1 "Barlow Condensed", sans-serif; padding: 4px 8px; min-height: 42px; text-align: center; }
.found-row small { font-size: 15px; line-height: 1.2; color: var(--ink-soft); }
.found-row small.warn { color: var(--red); font-weight: 600; }
.found-row button { width: 34px; height: 34px; border: 0; background: none; font-size: 20px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs) + 14px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 20; display: flex; gap: 12px; align-items: center; width: max-content; max-width: calc(100% - 32px);
  padding: 10px 14px; background: var(--ink); color: var(--paper); border-radius: 10px; font-weight: 600;
}
.toast button { background: none; border: 0; padding: 0; color: var(--yellow); font-weight: 600; text-decoration: underline; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
