:root {
  --bg: #fff;
  --fg: #1b1b1b;
  --muted: #666;
  --primary: #5B4F5B;
  --primary-2: #3a343a;
  --card: #ffffff;
  --border: #e6e6e6;
}
@media (prefers-color-scheme: dark){
  :root{ --bg:#0f0f10; --fg:#f2f2f2; --muted:#aaa; --card:#161618; --border:#2a2a2c; }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font: 16px system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--fg); background: var(--bg);
}

.appbar {
  position: sticky; top: 0; z-index: 10;
  display:flex; align-items:center; justify-content:space-between;
  gap:12px; padding: 10px 14px; background: var(--card); border-bottom:1px solid var(--border);
}
.title { margin:0; font-size: 18px; font-weight: 650; }
.icon-btn, .pill-btn {
  border:1px solid var(--border); background:transparent; color:var(--fg);
  padding:8px 10px; border-radius:12px; cursor:pointer;
}
.icon-btn { min-width:40px; }
.pill-btn { font-weight:600; }

.app { min-height: 100dvh; display:flex; flex-direction:column; }
#view { padding: 14px 14px 72px; }

.card {
  background: var(--card); border:1px solid var(--border);
  border-radius: 14px; padding: 14px; margin: 10px 0;
}
.small { font-size: 13px; color: var(--muted); }

.btn, .webview-btn {
  appearance:none; border:1px solid var(--border); border-radius:12px;
  padding:10px 12px; background: var(--primary); color:#fff; cursor:pointer; font-weight:600;
}
.btn.secondary { background: var(--primary-2); color:#fff; }
.btn.ghost { background:transparent; color:var(--fg); }
.btn + .btn, .btn + .ghost, .ghost + .btn { margin-left: 6px; }

.audio { width: 100%; margin-top: 8px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display:flex; justify-content:space-around; gap: 6px;
  background: var(--card); border-top:1px solid var(--border); padding: 6px 8px 10px;
}
.tablink {
  flex:1; text-decoration:none; display:flex; flex-direction:column; align-items:center; gap:4px;
  color: var(--muted); padding:6px 0; border-radius:10px;
}
.tablink.active { color: var(--primary); font-weight:600; }
.tablink .ico { width:24px; height:24px; display:inline-block; }
.tablink .ico svg { width:100%; height:100%; fill: currentColor; }
.tabtext { font-size: 12px; }

.splash {
  position:fixed; inset:0; display:grid; place-items:center; background:var(--bg); z-index:9999;
}
.splash-inner { display:flex; flex-direction:column; align-items:center; gap:12px; }
.splash-logo { width: 240px; height:auto; }
.splash-portrait-wrap { width: 120px; height:120px; border-radius: 60px; overflow:hidden; border:1px solid var(--border); }
.splash-portrait { width:100%; height:100%; object-fit:cover; }
.spinner { width:28px; height:28px; border-radius:50%; border:3px solid var(--border); border-top-color: var(--primary); animation:spin 1s linear infinite; }
.splash-text { color: var(--muted); font-size: 14px; }
.fade-out { animation: fade .35s ease forwards; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { to { opacity: 0; visibility: hidden; } }

/* Små justeringer for “safe area” på iOS */
@supports(padding: max(0px)) {
  .appbar { padding-top: max(10px, env(safe-area-inset-top)); }
  .tabbar { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}
/* --- Install-hint modal --- */
.install-overlay{
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 10000;
  display: grid; place-items: center; padding: 18px;
}
.install-card{
  width: 100%; max-width: 420px; background: var(--card); color: var(--fg);
  border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.install-card h3{ margin: 0 0 8px; font-size: 18px; }
.install-card p{ margin: 6px 0; color: var(--muted); }
.install-actions{ display:flex; gap:8px; justify-content:flex-end; margin-top: 12px; }
.install-actions .btn{ background: var(--primary); color: #fff; }
.install-actions .ghost{ background: transparent; color: var(--fg); border:1px solid var(--border); }

/* === Cover art / Now playing === */
.now-playing-section {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding-bottom: 4px;
}
.cover-art-wrap {
  width: min(220px, 62vw); aspect-ratio: 1;
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 6px 32px rgba(0,0,0,.22);
  background: var(--border); flex-shrink: 0;
}
.cover-art { width: 100%; height: 100%; object-fit: cover; display: block; }
.now-playing-meta { text-align: center; width: 100%; padding: 0 4px; }
.now-playing-title {
  font-size: 16px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.now-playing-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.player-audio { width: 100%; }

/* === Track list === */
.library-card { margin-top: 12px; }
.library-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.library-hdr h2 { margin: 0; font-size: 16px; }
.track-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; min-height: 60px;
  border-bottom: 1px solid var(--border);
}
.track-item:last-child { border-bottom: none; }
.track-item.active { background: transparent; }
.track-item.active .track-play-btn { background: var(--primary-2); }
.track-play-btn {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  border: none; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.track-play-btn svg { width: 18px; height: 18px; fill: #fff; }
.track-info { flex: 1; min-width: 0; }
.track-name {
  font-size: 14px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.track-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.track-del-btn {
  flex-shrink: 0; border: none; background: transparent;
  color: var(--muted); cursor: pointer;
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.empty-state {
  text-align: center; padding: 28px 0;
  color: var(--muted); font-size: 14px; line-height: 1.6;
}

/* === Rapport === */
.rapport-login {
  max-width: 360px; margin: 40px auto 0; text-align: center;
}
.rapport-login h2 { margin: 0 0 6px; }
.rapport-input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 12px; font-size: 16px; background: var(--card); color: var(--fg);
  outline: none; margin-top: 10px;
}
.rapport-input:focus { border-color: var(--primary); }
.rapport-wrap { max-width: 640px; margin: 0 auto; }
.rapport-cards {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px;
}
.rapport-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; text-align: center;
}
.rapport-num { font-size: 28px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.rapport-label { font-size: 12px; font-weight: 600; margin-top: 4px; }
.rapport-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.rapport-bars {
  display: flex; align-items: flex-end; gap: 6px; height: 80px;
}
.rapport-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.rapport-bar-val { font-size: 11px; color: var(--muted); min-height: 16px; }
.rapport-bar-track { flex: 1; width: 100%; background: var(--border); border-radius: 6px; display: flex; align-items: flex-end; }
.rapport-bar-fill { width: 100%; background: var(--primary); border-radius: 6px; min-height: 2px; }
.rapport-bar-lbl { font-size: 10px; color: var(--muted); }
.rapport-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rapport-table th { text-align: left; font-weight: 600; color: var(--muted); padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.rapport-table td { padding: 5px 0; border-bottom: 1px solid var(--border); }
.rapport-table tr:last-child td { border-bottom: none; }
.rapport-activity { display: flex; flex-direction: column; gap: 8px; }
.rapport-activity-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.rapport-activity-type {
  flex-shrink: 0; padding: 2px 8px; border-radius: 8px;
  font-size: 11px; font-weight: 700; background: var(--border); color: var(--fg);
}
.rapport-type-avspilling { background: #f0e7f5; color: var(--primary); }
.rapport-type-podcast { background: #e8f5e9; color: #2e7d32; }
.rapport-type-import { background: #fff8e1; color: #c8a000; }
@media (prefers-color-scheme: dark) {
  .rapport-type-avspilling { background: #3a2a3f; }
  .rapport-type-podcast { background: #1a2f1e; color: #66bb6a; }
  .rapport-type-import { background: #2d2800; color: #ffc107; }
}
.rapport-activity-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.rapport-activity-time { flex-shrink: 0; font-size: 11px; color: var(--muted); }
