:root {
  --bg: #ffffff;
  --sidebar: #f7f7f5;
  --hover: #ebebea;
  --card: #ffffff;
  --text: #37352f;
  --strong: #191919;
  --muted: #787774;
  --faint: #a5a49f;
  --border: #e9e9e7;
  --accent: #b4532a;
  --accent-soft: #f6e9e2;
  --accent-text: #ffffff;
  --error: #b3261e;
  --radius: 6px;
  --side-w: 248px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919;
    --sidebar: #202020;
    --hover: #2c2c2c;
    --card: #222222;
    --text: #d4d4d2;
    --strong: #f0f0ee;
    --muted: #9b9a97;
    --faint: #6f6e6a;
    --border: #2f2f2f;
    --accent: #e0814f;
    --accent-soft: #3a2a22;
    --accent-text: #191919;
    --error: #f2b8b5;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { color: var(--strong); line-height: 1.25; }
input, select, button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.error { color: var(--error); min-height: 1.5em; margin: 0; }
button { cursor: pointer; }
.link { background: none; border: 0; padding: 0; color: var(--muted); }
.link:hover { color: var(--strong); }
.primary {
  background: var(--accent); color: var(--accent-text); border: 0;
  border-radius: var(--radius); padding: 9px 14px; font-weight: 500;
}
.icon-btn {
  background: none; border: 0; width: 32px; height: 32px; border-radius: var(--radius);
  display: inline-grid; place-items: center; color: var(--muted); font-size: 18px;
}
.icon-btn:hover { background: var(--hover); color: var(--strong); }
.logo {
  width: 22px; height: 22px; border-radius: 5px; background: var(--accent); color: var(--accent-text);
  display: inline-grid; place-items: center; font-size: 13px; font-weight: 700; flex: none;
}
input:not([type="checkbox"]), select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

/* --- Innlogging --- */
.login-screen { min-height: 100%; display: grid; place-items: center; padding: 16px; background: var(--sidebar); }
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px; display: grid; gap: 14px;
}
.login-card h1 { margin: 4px 0 0; font-size: 22px; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input { color: var(--text); font-size: 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--strong); }

/* --- Ramme --- */
.shell { display: flex; height: 100%; }
.sidebar {
  width: var(--side-w); flex: none; background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 8px 6px; gap: 2px; overflow-y: auto;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 8px; }
.workspace { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--strong); min-width: 0; }
.workspace-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.side-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: var(--radius);
  color: var(--muted); font-weight: 500; font-size: 14px; background: none; border: 0; text-align: left; width: 100%;
}
.side-item:hover { background: var(--hover); color: var(--strong); }
.side-item.active { background: var(--hover); color: var(--strong); }
.side-item.disabled { opacity: .55; cursor: default; }
.side-item.disabled:hover { background: none; color: var(--muted); }
.side-icon { width: 18px; text-align: center; flex: none; }
.side-section { font-size: 12px; color: var(--faint); font-weight: 600; padding: 14px 8px 4px; }
.search-trigger kbd { margin-left: auto; font: 11px ui-monospace, monospace; color: var(--faint); }
.sidebar-bottom {
  margin-top: auto; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 8px 4px; border-top: 1px solid var(--border); font-size: 13px;
}
.who { color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 8px; min-height: 45px; padding: 6px 12px;
  position: sticky; top: 0; background: var(--bg); z-index: 2;
}
.crumbs { display: flex; gap: 6px; font-size: 14px; color: var(--muted); min-width: 0; }
.crumbs a:hover { color: var(--strong); }
.crumbs .sep { color: var(--faint); }
.view { flex: 1; overflow-y: auto; padding: 8px 16px 64px; outline: none; }
.page { max-width: 900px; margin: 0 auto; padding-top: 24px; }
.page-icon { font-size: 40px; line-height: 1; }
.page-title { font-size: 34px; font-weight: 700; margin: 12px 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 28px; }
.section-title { font-size: 14px; font-weight: 600; color: var(--muted); margin: 28px 0 10px; }

.only-mobile { display: none; }
.scrim { display: none; }

/* Mobil: sidemenyen glir inn over innholdet */
@media (max-width: 760px) {
  .only-mobile { display: inline-grid; }
  .only-desktop { display: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20; width: min(82vw, 300px);
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: none;
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .shell.menu-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .shell.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 10; }
  .topbar { padding-top: max(6px, env(safe-area-inset-top)); }
  .page { padding-top: 8px; }
  .page-title { font-size: 28px; }
  .view { padding: 4px 16px 48px; }
}

/* --- Startside --- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--card);
  display: flex; flex-direction: column; gap: 6px; transition: background .1s;
}
a.card:hover { background: var(--sidebar); }
.card-head { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--strong); }
.card-icon { font-size: 18px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card .nums { display: flex; gap: 14px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.card .nums b { color: var(--strong); font-variant-numeric: tabular-nums; }
.card.soon { border-style: dashed; background: none; }
.card.soon .card-head { color: var(--muted); }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--hover); color: var(--muted); font-weight: 500; }
.badge.warn { background: var(--accent-soft); color: var(--accent); }

/* --- VINYL DB --- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 18px; }
.stat { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 20px; color: var(--strong); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.filters input[type="search"], .filters select { grid-column: 1 / -1; }
.filters .check { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
@media (min-width: 761px) {
  .filters { grid-template-columns: 2fr 1fr 90px 90px; }
  .filters input[type="search"], .filters select { grid-column: auto; }
}
.tracks { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--border); }
.tracks li {
  border-bottom: 1px solid var(--border); padding: 10px 4px;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
}
.tracks .title { font-weight: 600; color: var(--strong); overflow-wrap: anywhere; }
.tracks .meta { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.tracks .nums { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); grid-row: span 2; }
.tag { display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 4px; background: var(--hover); margin: 2px 4px 0 0; }
.tag.warn { background: var(--accent-soft); color: var(--accent); }
.more { margin: 14px auto; display: block; background: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; color: var(--muted); }
.more:hover { background: var(--hover); color: var(--strong); }
.empty { border: 1px dashed var(--border); border-radius: 10px; padding: 24px; text-align: center; color: var(--muted); }

/* --- Søk --- */
.search-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50;
  display: flex; justify-content: center; align-items: flex-start; padding: max(10vh, env(safe-area-inset-top)) 12px 12px;
}
.search-box {
  width: 100%; max-width: 620px; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.search-box input { width: 100%; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 14px 16px; font-size: 17px; background: none; }
.search-box input:focus-visible { outline: none; }
.search-results { list-style: none; margin: 0; padding: 6px; max-height: 55vh; overflow-y: auto; }
.search-results li a { display: block; padding: 8px 10px; border-radius: var(--radius); }
.search-results li a:hover, .search-results li a.sel { background: var(--hover); }
.search-results .r-title { color: var(--strong); font-weight: 500; }
.search-results .r-meta { color: var(--muted); font-size: 13px; }
.search-hint { margin: 0; padding: 8px 16px 12px; font-size: 12px; }
.search-results .no-hits, .search-results .error { padding: 8px 10px; }
