:root {
  color-scheme: dark;
  --bg: #121212;
  --bg-elevated: #1c1c1f;
  --bg-elevated-2: #262629;
  --border: #333338;
  --text: #f2f2f4;
  --text-muted: #9a9aa2;
  --accent: #7c3aed;
  --accent-contrast: #ffffff;
  --danger: #e5484d;
  --danger-contrast: #ffffff;
  --radius: 12px;
  --header-h: 60px;
  --bottombar-h: 76px;
  --footer-h: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Generic utility; more specific .foo.hidden rules below (e.g. .toast.hidden's
   fade-out) intentionally override this where a component needs different
   hide behavior. */
.hidden { display: none; }

button {
  font: inherit;
  color: inherit;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
  color: inherit;
  text-decoration: none;
}

.logo-mark { font-size: 1.4rem; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:hover { background: #8b46f4; }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.icon-btn-ghost {
  position: relative;
  background: var(--bg-elevated-2);
  font-size: 1.15rem;
}

.icon-btn-ghost:hover { background: #34343a; }
.icon-btn-ghost.hidden { display: none; }

.icon-btn-ghost.has-status-dot::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 2px solid var(--bg-elevated);
}

.icon-btn-ghost.is-authed::after { background: #22c55e; }
.icon-btn-ghost.is-syncing::after { background: #f59e0b; animation: pulse 0.8s ease-in-out infinite; }
.icon-btn-ghost.is-error::after { background: var(--danger); }

.add-menu {
  position: absolute;
  top: calc(var(--header-h) - 4px);
  right: 12px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  overflow: hidden;
  min-width: 210px;
  z-index: 30;
}

.add-menu.hidden { display: none; }

.add-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 0.95rem;
}

.add-menu-item:hover:not(:disabled) { background: var(--bg-elevated); }
.add-menu-item:disabled { color: var(--text-muted); cursor: not-allowed; }
.add-menu-icon { font-size: 1.05rem; }

/* ---------- Main ---------- */
.main-content {
  flex: 1 1 auto;
  padding: 16px 0 24px;
  overflow-y: auto;
}

.empty-state {
  margin: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  line-height: 1.5;
}

.empty-state.hidden { display: none; }

.category-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 0 16px;
}

/* Ad area: #adSlotAdsense is only unhidden once consent is granted and the
   device is online (app.js, driven by RJConsent + navigator.onLine).
   Deliberately no decorative placeholder box (min-height/border/background)
   here — the in-article/fluid <ins> inside sizes itself to its actual ad
   content and collapses to display:none (AdSense's own doing) on a no-fill
   impression, so an empty slot has zero visual footprint instead of a
   leftover empty box. Scrolls with the page — never in the fixed bottom bar
   or the sticky random-button column. */
.ad-area {
  margin: 18px 16px 0;
}

.ad-slot.hidden { display: none; }

/* ---------- Cookie consent banner ---------- */
.consent-banner {
  position: sticky;
  bottom: calc(var(--footer-h) + var(--bottombar-h));
  z-index: 16;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-elevated-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.consent-banner.hidden { display: none; }

.consent-banner p {
  flex: 1 1 240px;
  margin: 0;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.5;
}

.consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 0 0 auto;
  margin-left: auto;
}

@media (min-width: 720px) {
  .consent-banner { padding: 14px 24px; }
}

/* ---------- Admin dashboard ---------- */
.admin-view {
  padding: 0 16px;
}

.admin-view.hidden { display: none; }

.admin-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.admin-view-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.admin-loading,
.admin-denied {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.admin-loading.hidden,
.admin-denied.hidden {
  display: none;
}

.admin-content.hidden { display: none; }

.admin-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.admin-stat {
  flex: 1 1 120px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-stat-value {
  font-size: 1.6rem;
  font-weight: 700;
}

.admin-stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
}

.admin-table thead th {
  background: var(--bg-elevated-2);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.admin-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid var(--border);
}

@media (min-width: 720px) {
  .admin-view { padding: 0 24px; }
}

/* ---------- Category row ---------- */
.category-row {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 10px 12px;
}

.category-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px 2px;
}

.category-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.08);
}

.category-name-btn {
  background: none;
  border: none;
  padding: 4px 6px;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-name-btn:hover { background: var(--bg-elevated-2); }
.category-name-btn .edit-hint { font-size: 0.75rem; opacity: 0.55; }

.category-count {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-left: auto;
  padding-right: 4px;
}

.category-body {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.random-btn {
  flex: 0 0 auto;
  position: sticky;
  left: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 76px;
  min-height: 64px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--btn-text, #fff);
  background: var(--btn-bg, var(--accent));
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.random-btn .random-icon { font-size: 1.2rem; }
.random-btn:hover { filter: brightness(1.08); }
.random-btn:active { transform: scale(0.95); }
.random-btn.playing { animation: pulse 0.6s ease-in-out infinite; }

.jingle-scroll {
  flex: 1 1 auto;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 8px;
  scrollbar-width: thin;
}

.jingle-scroll:empty::after {
  /* Text comes from the data-i18n-empty attribute (set in app.js from the
     current language) since CSS generated content can't use data-i18n. */
  content: attr(data-i18n-empty);
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  align-self: center;
  padding: 0 8px;
}

.jingle-item {
  position: relative;
  flex: 0 0 auto;
}

.jingle-btn {
  position: relative;
  overflow: hidden;
  display: block;
  width: 100%;
  min-width: 120px;
  max-width: 200px;
  min-height: 64px;
  padding: 10px 34px 10px 14px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: left;
  color: var(--btn-text, #fff);
  background: var(--btn-bg, var(--accent));
  white-space: normal;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.jingle-btn:hover { filter: brightness(1.08); }
.jingle-btn:active { transform: scale(0.96); }

.jingle-btn.playing {
  animation: pulse 0.6s ease-in-out infinite;
  box-shadow: 0 0 0 2px #fff, 0 2px 10px rgba(0,0,0,0.4);
}

.jingle-btn-name {
  position: relative;
  z-index: 1;
  display: block;
}

/* Live "0:03 / 0:08" readout (Phase 7) — hidden while not playing, shown
   and updated every animation frame from RJAudio's onProgress callback. */
.jingle-btn-time {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 3px;
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

.jingle-btn-time.hidden { display: none; }

/* Progress bar (Phase 7): width is set directly in app.js on every
   animation frame, not via a CSS transition, so it stays sample-accurate
   instead of visibly lagging or easing behind the actual playback. */
.jingle-btn-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  width: 0%;
  background: #ef4444;
  z-index: 0;
  pointer-events: none;
}

.jingle-edit-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.jingle-edit-btn:hover { background: rgba(0,0,0,0.55); }

.add-jingle-quick {
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 64px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
}

.add-jingle-quick:hover { border-color: var(--accent); color: var(--text); }

@keyframes pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}

/* ---------- Bottom bar ---------- */
.bottom-bar {
  position: sticky;
  bottom: var(--footer-h);
  z-index: 15;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--bottombar-h);
  padding: 0 16px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}

.volume-control {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
}

.volume-control input[type="range"] {
  flex: 1 1 auto;
  accent-color: var(--accent);
}

.stop-all-btn {
  flex: 0 0 auto;
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  background: var(--danger);
  color: var(--danger-contrast);
  font-weight: 700;
  cursor: pointer;
}

.stop-all-btn:hover { filter: brightness(1.1); }
.stop-all-btn:active { transform: scale(0.97); }

/* ---------- Footer ---------- */
.app-footer {
  flex: 0 0 auto;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-link:hover { color: var(--text); text-decoration: underline; }

/* ---------- Dialogs ---------- */
.app-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 20px;
  width: min(420px, 90vw);
}

.app-dialog::backdrop {
  background: rgba(0,0,0,0.6);
}

.app-dialog h2 {
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.field input[type="text"],
.field input[type="number"],
.field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  font-size: 0.95rem;
}

.field input[type="color"] {
  width: 60px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.field input[type="file"] {
  color: var(--text);
  font-size: 0.85rem;
}

.field-hint {
  margin: -8px 0 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.field-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.field-checkbox input { width: 16px; height: 16px; }

#jingleColorField.hidden { display: none; }

/* ---------- Hotkeys (Phase 9) ---------- */
.hotkey-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hotkey-picker-display {
  min-width: 90px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.jingle-btn-hotkey {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 1;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 5px;
  background: rgba(0,0,0,0.4);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- Trash (Phase 8) ---------- */
.trash-list {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.trash-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.trash-item-name {
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trash-item-expiry {
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* ---------- Trim editor (Phase 6) ---------- */
.trim-dialog {
  width: min(480px, 92vw);
}

.trim-waveform-wrap {
  position: relative;
  height: 120px;
  margin-bottom: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
}

.trim-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.trim-selection {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(124, 58, 237, 0.22);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  pointer-events: none;
}

.trim-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18px;
  margin-left: -9px;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trim-handle::before {
  content: "";
  width: 4px;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.trim-handle:focus-visible::before {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

.trim-fields {
  display: flex;
  gap: 12px;
}

.trim-fields .field {
  flex: 1 1 0;
}

.dialog-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.dialog-actions .spacer {
  flex-basis: 100%;
  height: 0;
}

@media (min-width: 420px) {
  .dialog-actions .spacer {
    flex-basis: 0;
    flex: 1 1 auto;
  }
}

.spacer { flex: 1 1 auto; }

.btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #8b46f4; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-elevated-2); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: rgba(229,72,77,0.12); }

/* Accept and Decline in the consent banner share this identical style on
   purpose — see the comment on .consent-actions in index.html. Neither
   uses --accent (that would read as "the recommended choice") or the
   de-emphasized ghost look (that would read as "the discouraged choice").
   Declared after the .btn base rule so its border isn't clobbered by
   .btn's own `border: none`. */
.btn-consent {
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  color: var(--text);
  min-width: 160px;
  text-align: center;
}

.btn-consent:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottombar-h) + var(--footer-h) + 16px);
  transform: translateX(-50%);
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  z-index: 50;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.hidden { opacity: 0; pointer-events: none; }

@media (min-width: 720px) {
  .category-list { padding: 0 24px; }
  .app-header { padding: 0 24px; }
  .bottom-bar { padding: 0 24px; }
  .ad-area { margin-left: 24px; margin-right: 24px; }
}

/* ---------- Standalone legal pages (impressum/datenschutz/agb) ---------- */
.legal-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 60px;
  line-height: 1.6;
}

.legal-content h1 { margin-top: 0; }
.legal-content a { color: var(--accent); }
