:root {
  --bg: #0d0d0f;
  --surface: #18181b;
  --surface2: #232327;
  --line: #34343a;
  --text: #eef1f4;
  --muted: #a1a1aa;
  --accent: #e4002b;
  --accent-ink: #ffffff;
  --ok: #3ecf8e;
  --warn-bg: #3a2f14;
  --warn: #ffd27a;
  --p5: #e8463a;
  --p2_5: #f2b33d;
  --p1: #4fa3f7;
  --radius: 14px;
  --bar-bg: rgba(13, 13, 15, .95);
  --danger: #ff7a7a;
  --danger-line: #5a2a2a;
  color-scheme: dark;
}
/* Ljust läge: följer systemet om inget annat valts i Inställningar (data-theme). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f5f7; --surface: #ffffff; --surface2: #ececef; --line: #d4d4d8;
    --text: #18181b; --muted: #5f5f6a; --accent: #d1002a; --ok: #12875a;
    --warn-bg: #fff3cd; --warn: #7a5300; --bar-bg: rgba(245, 245, 247, .95);
    --danger: #c0262d; --danger-line: #f0c2c4;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f5f5f7; --surface: #ffffff; --surface2: #ececef; --line: #d4d4d8;
  --text: #18181b; --muted: #5f5f6a; --accent: #d1002a; --ok: #12875a;
  --warn-bg: #fff3cd; --warn: #7a5300; --bar-bg: rgba(245, 245, 247, .95);
  --danger: #c0262d; --danger-line: #f0c2c4;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  overscroll-behavior-y: none;
}
button, select, .btn { font: inherit; color: inherit; }
button { cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button:disabled { opacity: .4; cursor: default; }
h1 { font-size: 17px; margin: 0; text-align: center; font-weight: 650; }
h1.brand { font-size: 22px; letter-spacing: .5px; }
h1.brand::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 4px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 8px; font-weight: 600; }
.pad { padding: 12px 16px; max-width: 560px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--bar-bg); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top > :last-child { justify-self: end; }
.link { background: none; border: 0; color: var(--accent); padding: 8px 4px; font-weight: 600; }

.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--bar-bg); border-top: 1px solid var(--line);
}
.bottom > * { max-width: 560px; margin: 0 auto; }
.bottom.row2 { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }

.btn {
  display: block; width: 100%; text-align: center;
  background: var(--surface2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; font-weight: 600; min-height: 52px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { min-height: 60px; font-size: 18px; margin: 10px 0; }
.btn.danger { background: none; color: var(--danger); border-color: var(--danger-line); margin-top: 24px; }
.filebtn { cursor: pointer; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

.warn { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

.card {
  display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 8px 0;
}
.card.resume { border-color: var(--accent); }
.kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; }

.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; margin: 6px 0 12px; }
.seg button { flex: 1; background: none; border: 0; border-radius: 9px; padding: 11px 6px; font-weight: 600; color: var(--muted); min-height: 46px; }
.seg button.on { background: var(--surface2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; font-weight: 600; min-height: 44px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.tracks { display: flex; flex-direction: column; gap: 6px; }
.trackrow { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.trackrow.off { opacity: .5; }
.trackrow select { width: 100%; background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-top: 4px; font-size: 15px; }
.tick { width: 34px; height: 34px; flex: none; border-radius: 9px; border: 2px solid var(--line); background: none; font-weight: 800; }
.tick.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Passvy */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; position: sticky; top: calc(53px + env(safe-area-inset-top)); z-index: 4; background: var(--bg); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-weight: 700; }
.tab.done { border-color: var(--ok); color: var(--ok); }
.tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.songhead { margin: 6px 0 12px; }
.songtitle { font-size: 22px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.sug { margin-top: 8px; font-size: 13px; color: var(--ok); }
.rows { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.pill { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px; font-weight: 600; font-size: 15px; min-height: 42px; }
.pill.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pill.add { color: var(--accent); border-style: dashed; }
.pill.del { color: var(--muted); padding: 9px 13px; }

.total { font-size: 44px; font-weight: 800; letter-spacing: -.02em; text-align: center; font-variant-numeric: tabular-nums; }
.barzone {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px 12px; touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.bar { display: flex; align-items: center; height: 110px; margin: 4px 0 8px; }
.side { flex: 1; display: flex; align-items: center; height: 100%; gap: 3px; }
.side.l { justify-content: flex-end; }
.side.l::before, .side.r::after { content: ""; flex: 1; height: 8px; background: #8a939e; border-radius: 3px; min-width: 10px; }
.side.l::before { margin-right: 3px; } .side.r::after { margin-left: 3px; }
.shaft { flex: 0 0 34%; height: 10px; background: linear-gradient(#c3cad2, #7f8994); border-radius: 3px; }
.plate { display: block; flex: none; width: 15px; height: var(--h); border-radius: 4px; box-shadow: inset -2px 0 0 rgba(0,0,0,.25); animation: pop .15s ease-out; }
@keyframes pop { from { transform: scaleY(.6); opacity: .3; } }
.p5 { background: var(--p5); } .p2_5 { background: var(--p2_5); } .p1 { background: var(--p1); }
.plate.p1 { width: 11px; }
.platebtns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.platebtn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--surface2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 6px; min-height: 84px; font-weight: 700; font-size: 17px; touch-action: pan-y;
}
.platebtn small { font-weight: 500; color: var(--muted); font-size: 12px; }
.platebtn:active { transform: scale(.97); }
.platebtn.on { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.dot { width: 18px; height: 18px; border-radius: 50%; }

table.hist { width: 100%; border-collapse: collapse; font-size: 14px; }
table.hist td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.hist td:first-child { color: var(--muted); white-space: nowrap; }

/* Kompakt passvy så att allt syns utan att scrolla */
.session .songhead { margin: 2px 0 8px; }
.session .songtitle { font-size: 19px; }
.session .seg { margin: 4px 0 8px; }
.session .seg button { min-height: 38px; padding: 7px 6px; }
.session .total { font-size: 36px; line-height: 1.1; }
.session .bar { height: 84px; margin: 2px 0 4px; }
.platebtns.four { grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.platebtns.four .platebtn { min-height: 72px; font-size: 15px; padding: 10px 4px; }
.platebtn.minus { color: var(--muted); }
.platebtn .big { font-size: 22px; line-height: 18px; font-weight: 800; }
.link.small { font-size: 13px; padding: 0 2px; }

/* Om-sidan */
.about a { color: var(--accent); }
.about ul { padding-left: 20px; margin: 0; }
.about li { margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.footlinks { display: flex; justify-content: center; gap: 18px; margin-top: 18px; }
.footlinks .link { color: var(--muted); }

/* SMARTBAR-grafik (egen stiliserad ritning): smal aluminiumstång, låsklack och fyrkantiga gummiskivor */
.bar { height: 120px; }
.side { gap: 2px; }
.side.l::before, .side.r::after { content: none; }
.shaft { flex: 1 1 auto; height: 7px; background: linear-gradient(#d9dde2, #8d959e); border-radius: 4px; }
.side { flex: 0 0 auto; }
.sleeve { flex: none; width: 14px; height: 7px; background: linear-gradient(#d9dde2, #8d959e); }
.cap { flex: none; width: 7px; height: 13px; border-radius: 3px; background: #6b7280; }
.gator { flex: none; width: 9px; height: 26px; border-radius: 3px; background: #2d2d33; box-shadow: inset 0 0 0 1px #4a4a52; }
.plate {
  flex: none; width: 13px; height: var(--h); border-radius: 5px;
  background: linear-gradient(90deg, #26262b, #3a3a41 45%, #26262b);
  box-shadow: inset 0 0 0 1px #4a4a52; position: relative;
}
.plate::after { content: ""; position: absolute; left: 3px; right: 3px; top: 18%; bottom: 18%; border-radius: 2px; background: var(--c); opacity: .9; }
.withbar { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.pico {
  display: block; width: var(--s); height: var(--s); border-radius: 22%;
  background: #2f2f35; box-shadow: inset 0 0 0 3px var(--c);
}
.platebtns.four .platebtn { min-height: 76px; }
.pchip { display: inline-flex; align-items: center; gap: 8px; }
.pchip .pico { width: 18px; height: 18px; }
.chipwrap { display: inline-flex; align-items: center; gap: 2px; }
.chipdel { background: none; border: 0; color: var(--muted); padding: 8px; }
.addrow { display: flex; gap: 8px; margin: 8px 0; }
.addrow input { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; color: var(--text); font: inherit; }
.addrow .btn { width: auto; flex: none; }
.fetch { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.fetch .pill { font-size: 14px; min-height: 38px; padding: 7px 12px; color: var(--accent); }
.fetch select.pill { color: var(--text); max-width: 100%; }
.colorpick { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; flex: none; }
.addrow input.colorpick { flex: none; width: 52px; padding: 4px; }

/* Anteckning per spår */
.note { width: 100%; min-height: 64px; margin-top: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font: inherit; font-size: 15px; resize: vertical; }
.notetext { margin-top: 4px; font-size: 14px; color: var(--muted); font-style: italic; white-space: pre-wrap; }
.remind { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.remind .link { color: var(--warn); text-decoration: underline; white-space: nowrap; }

/* Progression */
.chart { width: 100%; height: auto; margin: 14px 0 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.chart text { font-size: 10px; fill: var(--muted); }
.chart .grid { stroke: var(--line); stroke-width: .6; }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .pt { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .pb { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .pbt { fill: var(--text); font-weight: 700; font-size: 11px; }
.seg button { white-space: nowrap; }

/* Dela */
.qr { width: 220px; max-width: 70vw; height: auto; display: block; margin: 16px auto; border-radius: 12px; }
.shareurl { word-break: break-all; }

/* Fria vikter: staplade skivor, en eller två händer */
.freebar { display: flex; justify-content: center; align-items: center; gap: 40px; height: 96px; margin: 6px 0 4px; }
.stack { display: flex; align-items: center; gap: 2px; height: 100%; }
.seg.sides { margin: 0 0 6px; }

/* Installera på hemskärmen */
.card.install { border-color: var(--accent); }
.installbtns { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.installbtns .btn { width: auto; min-height: 44px; padding: 10px 18px; }
.steps { padding-left: 22px; margin: 0 0 8px; }
.steps li { margin-bottom: 8px; }
