/* ==========================================================================
   Design-Grundlagen – warmes Schwarz mit Gold-Akzenten
   (gleiches Design-System wie vinyl.strauchdaniel.de und hub.strauchdaniel.de)
   ========================================================================== */

/* Schrift liegt lokal: die Content-Security-Policy erlaubt nur 'self'. */
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/public/css/manrope.woff2') format('woff2');
}

:root {
  --accent: #d8ab5c;
  --accent-rgb: 216, 171, 92;
  --accent-2: #f0cf8a;
  --accent-deep: #9c7530;
  --bg: #0b0907;
  --bg-elevated: #141210;
  --bg-sidebar: rgba(19, 17, 16, 0.85);
  --text: #f3ecdf;
  --text-secondary: #a99a83;
  --text-faint: #6c604e;
  --title: #c2a475;
  --border: rgba(255, 255, 255, 0.07);
  --shadow: 0 22px 45px -30px rgba(0, 0, 0, 0.9);
  --shadow-sm: 0 6px 18px -12px rgba(0, 0, 0, 0.8);
  --danger: #ff6b5c;
  --success: #8bd17c;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --star: #f0cf8a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% -5%, rgba(216, 171, 92, 0.07), transparent 42%),
    radial-gradient(circle at 88% 105%, rgba(216, 171, 92, 0.05), transparent 40%);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

a { color: inherit; }
button { font-family: inherit; }
::selection { background: rgba(var(--accent-rgb), 0.25); }
[hidden] { display: none !important; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }
.inline { display: inline; margin: 0; }

/* ---------- Buttons ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent) 65%, var(--accent-deep));
  color: #241a0a;
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 6px 24px -6px rgba(var(--accent-rgb), 0.45); }

.btn-secondary { background: transparent; color: var(--accent); border: 1px solid rgba(var(--accent-rgb), 0.3); }
.btn-secondary:hover { background: rgba(var(--accent-rgb), 0.14); }

.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(255, 107, 92, 0.35); }
.btn-danger:hover { background: rgba(255, 107, 92, 0.12); }

.btn-block { width: 100%; }

/* ---------- Formulare ---------- */

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  margin: 0 0 6px 2px;
}

input[type='text'], input[type='number'], input[type='password'], input[type='date'],
input[type='search'], select, textarea {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #17120c;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.45);
}
textarea { resize: vertical; min-height: 70px; }
input[type='file'] { width: 100%; font: inherit; font-size: 13px; color: var(--text-secondary); }
input[type='file']::file-selector-button {
  font: inherit; font-weight: 700; margin-right: 10px; padding: 8px 14px; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid rgba(var(--accent-rgb), 0.3);
  background: transparent; color: var(--accent);
}

.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); }
.check input { accent-color: var(--accent); }

.hint { color: var(--text-secondary); font-size: 13px; margin: 10px 2px 0; }
.error-text { color: var(--danger); }

.flash, .error {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  margin: 0 0 20px;
}
.flash { background: rgba(var(--accent-rgb), 0.1); border: 1px solid rgba(var(--accent-rgb), 0.3); }
.error { background: rgba(255, 59, 48, 0.1); color: var(--danger); }

/* ---------- Login ---------- */

.auth-shell { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(165deg, var(--bg-elevated), #17140f);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.75), 0 0 40px rgba(var(--accent-rgb), 0.05);
  padding: 36px 32px;
  text-align: center;
}
.auth-logo {
  width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 18px;
  background: linear-gradient(145deg, var(--accent-2), var(--accent) 60%, var(--accent-deep));
  box-shadow: 0 10px 30px -12px rgba(var(--accent-rgb), 0.6);
  display: flex; align-items: center; justify-content: center; font-size: 30px;
}
.auth-card h1 { font-size: 22px; margin: 0 0 4px; }
.auth-card p.subtitle { color: var(--text-secondary); font-size: 14px; margin: 0 0 26px; }
.auth-card form { text-align: left; }
.auth-error {
  background: rgba(255, 59, 48, 0.1); color: var(--danger); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 13px; margin-bottom: 16px; text-align: left;
}
.auth-back { margin: 20px 0 0; font-size: 13px; }
.auth-back a { color: var(--text-secondary); text-decoration: none; }
.auth-back a:hover { color: var(--accent); }

/* ---------- App-Shell ---------- */

.app-shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px;
  font-weight: 700; font-size: 17px; text-decoration: none;
}
.sidebar-brand .icon {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(145deg, var(--accent-2), var(--accent) 60%, var(--accent-deep));
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
}
.sidebar-section { margin-top: 18px; }
.sidebar-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.13em;
  color: var(--title); padding: 0 10px; margin-bottom: 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-sm); font-size: 14px; cursor: pointer;
  color: var(--text); text-decoration: none; user-select: none;
}
.nav-item:hover { background: rgba(var(--accent-rgb), 0.12); color: var(--accent); }
.nav-item.active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent) 65%, var(--accent-deep));
  color: #241a0a; font-weight: 700; box-shadow: 0 6px 20px -8px rgba(var(--accent-rgb), 0.5);
}
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--text-faint); }
.nav-item.active .count { color: rgba(36, 26, 10, 0.72); }
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-button { width: 100%; background: none; border: 0; font: inherit; font-size: 14px; text-align: left; }

.sidebar-footer {
  margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.sidebar-footer form { margin: 0; }

.main { flex: 1; overflow-y: auto; position: relative; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px; padding: 16px 28px;
  background: rgba(11, 9, 7, 0.82);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.topbar h2 { margin: 0; font-size: 20px; font-weight: 700; white-space: nowrap; }
.topbar select { width: auto; min-width: 170px; }
.topbar-spacer { flex: 1; }
.topbar-add { padding: 9px 16px; }

.search-wrap { flex: 1; max-width: 420px; position: relative; }
.search-wrap input { padding-left: 34px; border-radius: 980px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); }
.search-wrap::before {
  content: '⌕'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-secondary); font-size: 16px; pointer-events: none;
}
.search-wide { max-width: none; }

.content { padding: 24px 28px 80px; }

/* ---------- Cover-Grid ---------- */

.result-count { color: var(--text-secondary); font-size: 13px; margin: 0 0 14px; }
.result-count:empty { display: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px; }

.card { display: block; text-decoration: none; border-radius: var(--radius-md); transition: transform 0.15s ease; min-width: 0; }
.card:hover { transform: translateY(-2px); }

.card-cover {
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, #1b160f, #221b13);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover .card-cover { border-color: rgba(var(--accent-rgb), 0.3); box-shadow: 0 18px 40px -22px rgba(var(--accent-rgb), 0.35); }
.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cover-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 14px; text-align: center; font-weight: 700; font-size: 14px; line-height: 1.3;
  color: var(--title); overflow: hidden;
}

.card-rating, .card-status {
  position: absolute; bottom: 6px;
  background: rgba(11, 9, 7, 0.78); border: 1px solid rgba(var(--accent-rgb), 0.28);
  font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
}
.card-rating { right: 6px; color: var(--star); }
.card-status { left: 6px; color: var(--text); }

.card-title { margin-top: 8px; font-size: 13.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-subtitle { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty-state { text-align: center; padding: 80px 20px; color: var(--text-secondary); }
.empty-state .glyph { font-size: 44px; margin-bottom: 12px; opacity: 0.5; }
.empty-state .btn { margin-top: 8px; }

/* ---------- Status-Pillen ---------- */

.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(var(--accent-rgb), 0.14); color: var(--accent); border: 1px solid rgba(var(--accent-rgb), 0.28);
}
.pill.status-gelesen, .card-status.status-gelesen { color: var(--success); border-color: rgba(139, 209, 124, 0.35); }
.pill.status-gelesen { background: rgba(139, 209, 124, 0.1); }
.pill.status-lese-gerade, .card-status.status-lese-gerade { color: var(--accent-2); }
.pill.status-abgebrochen, .card-status.status-abgebrochen { color: var(--text-secondary); border-color: var(--border); }
.pill.status-abgebrochen { background: rgba(255, 255, 255, 0.04); }

.stars { color: var(--star); letter-spacing: 2px; font-size: 16px; }
.stars span { color: rgba(255, 255, 255, 0.12); }

.section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.13em;
  color: var(--title); margin: 26px 0 12px;
}
.section-title:first-child { margin-top: 0; }

/* ---------- Detailseite ---------- */

.detail { display: grid; grid-template-columns: 280px 1fr; gap: 36px; max-width: 980px; }
.detail-cover { position: relative; }
.detail-cover img, .detail-cover .cover-fallback {
  width: 100%; aspect-ratio: 2 / 3; object-fit: cover; display: flex;
  border-radius: var(--radius-md); border: 1px solid var(--border); box-shadow: var(--shadow);
  background: linear-gradient(160deg, #1b160f, #221b13);
}
.detail-cover .cover-fallback { position: relative; font-size: 18px; }
.detail h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; }
.detail-subtitle { margin: 0 0 6px; color: var(--text-secondary); font-size: 16px; }
.detail-author { margin: 0 0 14px; color: var(--accent); font-weight: 700; }
.detail-tags { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0; margin: 0; font-size: 14px; }
.facts dt, .facts dd { padding: 8px 0; border-bottom: 1px solid var(--border); }
.facts dt { color: var(--text-secondary); padding-right: 24px; }
.facts dd { margin: 0; }
.notes {
  white-space: pre-wrap; font-size: 14px; line-height: 1.55;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 16px;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }

/* ---------- Formularseite ---------- */

.form-page { max-width: 680px; }
.panel {
  background: linear-gradient(165deg, var(--bg-elevated), #17140f);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px 26px;
  margin-bottom: 20px;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row .search-wrap { min-width: 200px; }

.cover-edit { display: grid; grid-template-columns: 96px 1fr; gap: 18px; align-items: start; margin-bottom: 18px; }
.cover-edit .card-cover { border-radius: 10px; }

.rating-input { display: flex; align-items: center; gap: 2px; }
.star-option { margin: 0; cursor: pointer; text-transform: none; letter-spacing: 0; }
.star-option input { position: absolute; opacity: 0; pointer-events: none; }
.star-option .star { font-size: 28px; color: rgba(255, 255, 255, 0.12); transition: color 0.1s ease; }
.rating-input .star.filled { color: var(--star); }
.star-option input:focus-visible + span { outline: 2px solid var(--accent); border-radius: 4px; }
.star-clear { margin-left: 12px; font-size: 12px; color: var(--text-secondary); }
.star-clear input:checked + span { color: var(--accent); }

.form-footer {
  display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px;
  margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--border);
}
.form-footer .btn-cancel { order: 1; margin-right: auto; }
.form-footer .btn-again { order: 2; }
.form-footer .btn-save { order: 3; }

/* Trefferliste der Buchsuche */
.results {
  list-style: none; margin: 14px 0 0; padding: 0; max-height: 60vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: rgba(255, 255, 255, 0.02);
}
.results li + li { border-top: 1px solid var(--border); }
.result {
  display: flex; gap: 14px; align-items: flex-start; width: 100%; padding: 12px 14px;
  background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.result:hover, .result:focus-visible { background: rgba(var(--accent-rgb), 0.08); outline: none; }
.result-cover {
  flex: 0 0 46px; height: 69px; border-radius: 6px; overflow: hidden;
  background: linear-gradient(160deg, #1b160f, #221b13); border: 1px solid var(--border);
}
.result-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.result-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.result-text strong {
  font-size: 14.5px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.result-text .muted { color: var(--text-secondary); font-size: 12.5px; }
.result-text .badge {
  align-self: flex-start; margin-top: 3px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  color: var(--accent); background: rgba(var(--accent-rgb), 0.14);
}

#scanner { margin-top: 14px; }
#scanner video { width: 100%; max-height: 50vh; border-radius: var(--radius-md); background: #000; display: block; }
#scanner .btn { margin-top: 10px; }

/* ---------- Mobil ---------- */

.hamburger {
  display: none; width: 36px; height: 36px; border-radius: 50%;
  align-items: center; justify-content: center; flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border);
  color: var(--text); font-size: 17px; cursor: pointer;
}
.sidebar-backdrop { display: none; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    transform: translateX(-100%); transition: transform 0.25s ease;
    width: 78vw; max-width: 300px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.62); z-index: 39; }
  .sidebar-backdrop.visible { display: block; }
  .hamburger { display: inline-flex; }
  .topbar { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  .topbar h2 { font-size: 17px; flex: 1; overflow: hidden; text-overflow: ellipsis; }
  .topbar .search-wrap { order: 5; flex-basis: 100%; max-width: none; }
  .topbar select { order: 6; flex: 1; min-width: 0; }
  .hide-mobile { display: none; }
  .topbar-add { padding: 7px 14px; font-size: 18px; }
  .content { padding: 16px 16px 90px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px; }
  .detail { grid-template-columns: 1fr; gap: 20px; }
  .detail-cover { max-width: 220px; width: 62%; margin: 0 auto; }
  .detail h1 { font-size: 23px; }
  .panel { padding: 18px 16px; border-radius: var(--radius-md); }
  .row .btn { flex: 1; }
}
@media (max-width: 420px) {
  .form-footer .btn { flex: 1; }
  .form-footer .btn-cancel { margin-right: 0; }
}

/* ---------- Import ---------- */
.import-intro { margin: 0 0 16px; line-height: 1.5; }
.import-list { list-style: none; margin: 0 0 8px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-md); }
.import-list li + li { border-top: 1px solid var(--border); }
.import-row {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin: 0; cursor: pointer;
  text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 400; color: var(--text);
}
.import-row:hover { background: rgba(var(--accent-rgb), 0.06); }
.import-row input { margin-top: 26px; accent-color: var(--accent); width: 18px; height: 18px; flex-shrink: 0; }
.import-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.small-stars { font-size: 13px; letter-spacing: 1px; }
.badge-warn { color: var(--danger) !important; background: rgba(255, 107, 92, 0.12) !important; }
