/* ==========================================================================
   Design-Grundlagen – angelehnt an Apple Music / Photos
   ========================================================================== */

:root {
  --accent: #0a84ff;
  --accent-rgb: 10, 132, 255;
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --bg-sidebar: rgba(246, 246, 248, 0.8);
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --danger: #ff3b30;
  --success: #34c759;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --star: #ff9f0a;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --bg-sidebar: rgba(28, 28, 30, 0.7);
    --text: #f5f5f7;
    --text-secondary: #98989d;
    --border: rgba(255, 255, 255, 0.09);
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  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);
}

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

.btn {
  appearance: none;
  border: none;
  border-radius: 980px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 590;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-secondary {
  background: rgba(120, 120, 128, 0.16);
  color: var(--text);
}

.btn-secondary:hover {
  background: rgba(120, 120, 128, 0.24);
}

.btn-danger {
  background: rgba(255, 59, 48, 0.12);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(255, 59, 48, 0.2);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(120, 120, 128, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--text);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-block {
  width: 100%;
}

/* ---------- Forms ---------- */

label {
  display: block;
  font-size: 13px;
  font-weight: 590;
  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: var(--bg-elevated);
  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 0 4px rgba(var(--accent-rgb), 0.15);
}

textarea {
  resize: vertical;
  min-height: 70px;
}

.field {
  margin-bottom: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- Auth-Seiten (Login / Setup) ---------- */

.auth-shell {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  text-align: center;
}

.auth-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 18px;
  background: linear-gradient(145deg, #0a84ff, #5e5ce6);
  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;
  display: none;
}

.auth-error.visible {
  display: block;
}

.auth-step {
  display: none;
}

.auth-step.active {
  display: block;
}

.totp-code-input {
  letter-spacing: 8px;
  font-size: 22px;
  text-align: center;
  font-weight: 600;
}

.qr-wrap {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 16px;
  display: inline-block;
  margin-bottom: 16px;
}

.qr-wrap img {
  display: block;
  width: 180px;
  height: 180px;
}

.secret-fallback {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  word-break: break-all;
  margin-bottom: 20px;
}

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

.app-shell {
  display: flex;
  height: 100vh;
  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;
}

.sidebar-brand .icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(145deg, #0a84ff, #5e5ce6);
  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.04em;
  color: var(--text-secondary);
  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);
  user-select: none;
}

.nav-item:hover {
  background: rgba(120, 120, 128, 0.12);
}

.nav-item.active {
  background: var(--accent);
  color: #fff;
}

.nav-item .count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-secondary);
}

.nav-item.active .count {
  color: rgba(255, 255, 255, 0.8);
}

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

.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(var(--bg-rgb, 245, 245, 247), 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

@media (prefers-color-scheme: dark) {
  .topbar {
    background: rgba(0, 0, 0, 0.72);
  }
}

.topbar h2 {
  margin: 0;
  font-size: 20px;
  white-space: nowrap;
}

.search-wrap {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.search-wrap input {
  padding-left: 34px;
  border-radius: 980px;
  background: rgba(120, 120, 128, 0.12);
  border: 1px solid transparent;
}

.search-wrap::before {
  content: '⌕';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 16px;
  pointer-events: none;
}

.topbar-spacer {
  flex: 1;
}

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

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

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

.card {
  cursor: pointer;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
}

.card-cover {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  background: var(--bg-elevated) linear-gradient(145deg, #d8d8dc, #eaeaee);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

@media (prefers-color-scheme: dark) {
  .card-cover {
    background: var(--bg-elevated) linear-gradient(145deg, #2c2c2e, #1c1c1e);
  }
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-cover .placeholder {
  font-size: 30px;
  color: var(--text-secondary);
  opacity: 0.5;
}

.card-rating {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--star);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 8px;
}

.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;
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 26px 28px 28px;
}

.modal-small {
  max-width: 420px;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 19px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.modal-footer.split {
  justify-content: space-between;
}

.tabs {
  display: flex;
  gap: 6px;
  background: rgba(120, 120, 128, 0.12);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 590;
  cursor: pointer;
  color: var(--text-secondary);
}

.tab.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

#scanner-view {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  min-height: 260px;
}

.scanner-hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 10px;
}

.lookup-preview {
  display: flex;
  gap: 16px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(120, 120, 128, 0.1);
  margin-bottom: 18px;
}

.lookup-preview img {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
}

.lookup-preview .meta {
  min-width: 0;
}

.lookup-preview .meta h4 {
  margin: 0 0 2px;
  font-size: 15px;
}

.lookup-preview .meta p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.detail-cover {
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--bg);
  margin-bottom: 16px;
}

.rating-input {
  display: flex;
  gap: 4px;
  font-size: 24px;
}

.rating-input .star {
  cursor: pointer;
  color: var(--border);
}

.rating-input .star.filled {
  color: var(--star);
}

.tracklist {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13.5px;
}

.tracklist li {
  display: flex;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.tracklist li .pos {
  width: 28px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.tracklist li .name {
  flex: 1;
  color: var(--text);
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: 22px 0 10px;
}

.section-title:first-child {
  margin-top: 0;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(28, 28, 30, 0.92);
  color: #fff;
  padding: 12px 20px;
  border-radius: 980px;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.progress-bar {
  height: 6px;
  border-radius: 4px;
  background: rgba(120, 120, 128, 0.2);
  overflow: hidden;
  margin: 12px 0;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s ease;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(120, 120, 128, 0.3);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

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

.hidden {
  display: none !important;
}

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

.hamburger {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  background: rgba(120, 120, 128, 0.16);
  font-size: 17px;
  cursor: pointer;
  flex-shrink: 0;
}

@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 {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 39;
  }

  .sidebar-backdrop.visible {
    display: block;
  }

  .hamburger {
    display: inline-flex;
  }

  .topbar {
    padding: 14px 16px;
  }

  .content {
    padding: 16px 16px 90px;
  }

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

  .modal {
    padding: 20px;
    max-height: 92vh;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .topbar h2 {
    display: none;
  }
}
