:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1d1c1a;
  --muted: #6d6a64;
  --line: #e2dfd8;
  --accent: #d0532f;
  --accent-text: #ffffff;
  --accent-soft: #fbe9e3;
  --ok: #2f8a4f;
  --danger: #b4322a;
  --track: #ebe8e1;
  --buffer: #d7d3ca;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --card: #1e1d1b;
    --text: #efede8;
    --muted: #9c9890;
    --line: #34322e;
    --accent: #ef7a55;
    --accent-text: #1a0f0b;
    --accent-soft: #3a241c;
    --ok: #5cc07f;
    --danger: #ef6b62;
    --track: #2c2b28;
    --buffer: #45423d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 860px; margin: 0 auto; padding: 16px 16px 64px; }
main.narrow { max-width: 420px; padding-top: 12vh; }
h1 { font-size: 1.6rem; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 1.2rem; margin: 24px 0 8px; }
h3 { font-size: 1rem; margin: 20px 0 8px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; padding: 40px 0; }
.error { color: var(--danger); min-height: 1em; }
.help { margin-top: 32px; text-align: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.row-form input { flex: 1 1 180px; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }

input, textarea, select, button, .button {
  font: inherit; color: inherit; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); padding: 9px 12px; min-height: 42px;
}
textarea { width: 100%; resize: vertical; }
input:focus, textarea:focus, button:focus-visible, .button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button { cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:hover, .button:hover { border-color: var(--muted); }
button:disabled { opacity: .4; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--danger); }
button.small, .button.small, input.small { min-height: 34px; padding: 5px 10px; font-size: .88rem; }
button.linkish { border: none; background: none; padding: 2px 4px; min-height: 0; color: var(--accent); text-align: left; }
label.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; font-size: .9rem; }
label.check input { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; }
label.check { flex-direction: row; }
input.code { font-size: 1.4rem; letter-spacing: .12em; text-align: center; text-transform: uppercase; }

.badge { background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 0 7px; font-size: .75rem; font-weight: 700; line-height: 1.6; }
.tag { background: var(--track); border-radius: 6px; padding: 1px 6px; font-size: .78rem; margin-left: 6px; }
.notice { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }

/* Låtar */
.song { padding: 0; overflow: hidden; }
.song-head { width: 100%; border: none; border-radius: 0; background: none; padding: 14px 16px; justify-content: flex-start; gap: 12px; text-align: left; }
.song-head .title { font-weight: 600; flex: 1; }
.song-head::after { content: "▾"; color: var(--muted); transition: transform .15s; }
.song.open .song-head::after { transform: rotate(180deg); }
.song-body { padding: 0 16px; }
.song.open .song-body { padding-bottom: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.song:not(.open) .song-body { display: none; }

/* Spelaren */
.version-head { display: flex; flex-direction: column; gap: 6px; }
.versions { display: flex; flex-wrap: wrap; gap: 6px; }
.version { min-height: 44px; padding: 8px 14px; }
.version.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.version.active .badge { background: var(--accent-text); color: var(--accent); }
.transport { display: flex; align-items: center; gap: 12px; margin: 14px 0 8px; flex-wrap: wrap; }
.play { width: 56px; height: 56px; border-radius: 50%; font-size: 1.1rem; background: var(--accent); color: var(--accent-text); border: none; }
.time { font-variant-numeric: tabular-nums; font-weight: 600; }
.timeline { position: relative; height: 44px; background: var(--track); border-radius: 8px; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.timeline .buffered, .timeline .progress { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 8px; pointer-events: none; }
.timeline .buffered { background: var(--buffer); }
.timeline .progress { background: var(--accent); opacity: .85; }
.timeline .marker { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1px; background: var(--text); cursor: grab; touch-action: none; z-index: 2; }
.timeline .marker.dragging { cursor: grabbing; }
.timeline .marker::after { content: ""; position: absolute; top: -12px; bottom: 0; left: -8px; right: -8px; } /* större yta att ta tag i */
.timeline .marker::before { content: ""; position: absolute; top: -6px; left: -5px; border: 6px solid transparent; border-top-color: var(--text); }
.timeline .pins { position: absolute; inset: 0; }
.pin { position: absolute; bottom: -8px; width: 16px; height: 16px; min-height: 0; padding: 0; margin-left: -8px; border-radius: 50%; background: #f2b134; border: 2px solid var(--card); }
.pin.done { background: var(--ok); }
.pin.mine { background: #5b8def; }
.hover-time { position: absolute; top: -26px; transform: translateX(-50%); font-size: .75rem; background: var(--text); color: var(--bg); padding: 1px 6px; border-radius: 4px; display: none; pointer-events: none; }
@media (hover: hover) { .timeline:hover .hover-time { display: block; } }
.switch-mode { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 18px 0 8px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { border: none; border-radius: 0; min-height: 36px; padding: 5px 12px; font-size: .9rem; }
.segmented button.active { background: var(--text); color: var(--bg); }
.status { min-height: 1.2em; }
.download { margin: 12px 0; }

/* Kommentarer */
.comment-form { display: flex; flex-direction: column; gap: 8px; }
.comment-form .row input { flex: 1 1 160px; }
.comments, .todo, .file-list, .version-list, .browser, .uploads { list-style: none; padding: 0; margin: 8px 0; }
.comments li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.comments li.flash { background: var(--accent-soft); }
.comments li.done .text { color: var(--muted); text-decoration: line-through; }
.comments .time { font-variant-numeric: tabular-nums; min-height: 32px; padding: 3px 8px; font-size: .85rem; }
.comments .body { flex: 1; min-width: 0; }
.comments .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.comments .actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.todo li { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.todo li .text { flex: 1 1 200px; white-space: pre-wrap; overflow-wrap: anywhere; }
.todo li.done .text { text-decoration: line-through; color: var(--muted); }
.todo .time { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Filer och uppladdning */
.file-list li, .uploads li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.file-list .name, .uploads .name { flex: 1 1 200px; overflow-wrap: anywhere; }
.uploads progress { flex: 1 1 120px; accent-color: var(--accent); }
.uploads li.done { color: var(--ok); }
.uploads li.failed { color: var(--danger); }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 20px; text-align: center; cursor: pointer; align-items: center; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

/* Admin */
.admin-nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.admin-nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.admin-nav a.active { background: var(--text); color: var(--bg); }
.admin-nav button { margin-left: auto; }
.project-list { display: flex; flex-direction: column; gap: 8px; }
.project-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.project-row.inactive { opacity: .6; }
.code-box { background: var(--track); border-radius: 8px; padding: 12px; margin: 12px 0; overflow-wrap: anywhere; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 1.2rem; letter-spacing: .08em; }
.version-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.version-row input.small { width: 160px; }
.version-row .file { flex: 1 1 160px; overflow-wrap: anywhere; }
.add-version { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.modal { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); width: min(560px, calc(100vw - 32px)); max-height: 80vh; }
.modal::backdrop { background: rgba(0,0,0,.45); }
.browser { max-height: 50vh; overflow: auto; }
.browser li { padding: 4px 0; border-bottom: 1px solid var(--line); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; transition: .25s; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 100; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

[hidden] { display: none !important; }

details { margin: 12px 0; }
summary { cursor: pointer; color: var(--accent); }
.artist .top { margin-bottom: 0; }
.artist h2 { margin: 0; }
.artist h2 a { color: var(--text); text-decoration: none; }
.artist.inactive { opacity: .6; }

/* Vågform */
.timeline { --wave: var(--muted); --wave-played: var(--accent); height: 64px; }
.timeline .progress { overflow: hidden; }
.timeline .wave { position: absolute; left: 0; top: 0; pointer-events: none; display: none; }
.timeline.has-wave .wave { display: block; }
.timeline.has-wave { background: var(--track); }
.timeline.has-wave .progress { background: transparent; opacity: 1; }
.timeline.has-wave .buffered { background: transparent; border-bottom: 3px solid var(--buffer); border-radius: 0; }
.timeline.has-wave .progress { border-right: 2px solid var(--text); border-radius: 0; }
.code-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.song-uploads { margin-top: 16px; }
.admin-nav .brand { margin-right: 12px; }
p.brand { margin: 0 0 2px; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
.code.small { font-size: .95rem; }
.artist .code-row { margin: 6px 0; }
.version-row .master { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* Handen när man hovrar över allt som går att klicka på */
a, button, summary, select, label.check, label.dropzone, .pin, .version, .song-head, .project-row,
input[type=checkbox], input[type=radio], input[type=file], [role=button], [role=tab] { cursor: pointer; }
button:disabled { cursor: default; }
