/* Blåbär och prickmärkning: blåbärsblå text och knappar på svalt papper,
   proverna märks som muggar med gula prisprickar. */
:root {
  --paper: #f3f4f8; --card: #ffffff; --text: #1c1f3a; --muted: #5c6283; --line: #dfe2ec;
  --accent: #34388a; --accent-text: #ffffff; --accent-soft: #e5e6f5; --accent-mid: #c5c8ec;
  --sticker: #f5c518; --sticker-text: #1c1f3a;
  --ok: #1d7a4c; --ok-soft: #e3f3ea; --err: #b4232f; --err-soft: #fbe7e8; --warn: #8a6100;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #13152a; --card: #1b1e38; --text: #eceef8; --muted: #a3a8c8; --line: #2d3156;
    --accent: #aeb3ff; --accent-text: #13152a; --accent-soft: #272b57; --accent-mid: #3d4280;
    --sticker: #f5c518; --sticker-text: #13152a;
    --ok: #6fd69e; --ok-soft: #173a2a; --err: #ff8f97; --err-soft: #3d1b22; --warn: #f2c14e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--text); line-height: 1.5; font-size: 17px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); text-underline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Sidhuvud */
header.top { border-bottom: 1px solid var(--line); background: var(--card); }
header.top .wrap { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 12px; padding-bottom: 12px; }
.brand { font-family: var(--display); font-weight: 750; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand::before { content: ""; display: inline-block; width: .7em; height: .7em; border-radius: 50%; background: var(--sticker); margin-right: .4em; vertical-align: -.02em; }
nav { display: flex; gap: 16px; align-items: center; font-size: .95rem; }
nav .who { color: var(--muted); }

h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: 2rem; font-weight: 800; margin: 1.4rem 0 .4rem; }
h2 { font-size: 1.2rem; font-weight: 700; margin: 0 0 .75rem; }
h3 { font-size: 1.05rem; font-weight: 700; margin: 1.2rem 0 .4rem; }
main { padding-bottom: 80px; }
.foot { color: var(--muted); font-size: .85rem; padding-bottom: 24px; }
.muted { color: var(--muted); }

/* Ytor */
.card {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px; margin: 0 0 16px; color: inherit; text-decoration: none;
}
.card.danger { border-color: var(--err); }
a.test-link { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 16px 18px; }
a.test-link:hover { border-color: var(--accent); }
.t-title { font-family: var(--display); font-weight: 700; font-size: 1.15rem; margin-right: auto; }

/* Formulär */
label { display: block; margin: 0 0 14px; font-weight: 600; }
input[type=text], input[type=password], input[type=number], select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: inherit; font-weight: 400;
  color: var(--text); background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
label.check { font-weight: 400; display: flex; gap: 8px; align-items: center; }
label.check input { width: 22px; height: 22px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 10px 24px;
  font: inherit; font-weight: 700; color: var(--accent-text); background: var(--accent);
  border: 0; border-radius: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--err); color: #fff; }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: .95rem; }
.btn[disabled] { opacity: .45; cursor: default; }
form > .btn { width: 100%; }
form.inline > .btn, form.inline .btn { width: auto; }

.flash, .banner { padding: 12px 16px; border-radius: 14px; margin: 0 0 16px; font-weight: 600; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--err-soft); color: var(--err); }
.banner { background: var(--accent-soft); color: var(--text); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; vertical-align: middle; background: var(--accent-soft); color: var(--muted); }
.badge.open { background: var(--ok-soft); color: var(--ok); }
.badge.locked { background: var(--accent-soft); color: var(--warn); }
.badge.revealed { background: var(--accent); color: var(--accent-text); }
.badge.ok { background: var(--ok); color: var(--card); }
.badge.todo { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }

/* Prisprick: provets märkning */
.tag, .row .lbl {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 48px; height: 48px; border-radius: 50%; background: var(--sticker); color: var(--sticker-text);
  font-family: var(--display); font-weight: 800; font-size: 1.5rem; line-height: 1;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12);
}
.tag.sm { width: 30px; height: 30px; font-size: .95rem; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12); }
.sample-head { display: flex; align-items: center; gap: 12px; font-size: 1.05rem; color: var(--muted); font-weight: 600; margin-bottom: 1rem; }

/* Betygsskala 1–10: en sammanhängande rad som fylls upp till valt betyg */
.crit { margin: 0 0 18px; }
.crit-name { display: block; font-weight: 600; margin-bottom: 6px; }
.pills {
  display: flex; border-radius: 12px; overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--line); background: var(--paper);
}
.pills input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pills label {
  flex: 1 1 0; min-width: 0; height: 46px; margin: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 650; font-size: 1rem; color: var(--muted);
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  border-left: 1px solid var(--line);
  transition: background-color .12s, color .12s;
}
.pills input:first-child + label { border-left: 0; }
.pills label:has(~ input:checked) { background: var(--accent-soft); color: var(--accent); border-left-color: var(--accent-mid); }
.pills input:checked + label { background: var(--accent); color: var(--accent-text); border-left-color: var(--accent); font-weight: 800; }
.pills input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: -3px; }
.ro-score { font-family: var(--display); font-weight: 800; font-size: 1.3rem; }

/* Produktlistan */
.product-list { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.product-list li { margin: 0; padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); font-weight: 600; }
.product-list li .muted { font-weight: 400; }

/* Resultat */
.rank { margin: 0 0 16px; }
.rank:last-child { margin-bottom: 0; }
.rank-head { display: flex; gap: 10px; align-items: center; }
.rank-head .pos { font-family: var(--display); font-weight: 800; font-size: 1.3rem; width: 1.2em; color: var(--muted); }
.rank:first-child .pos { color: var(--accent); }
.rank-head .score { margin-left: auto; font-family: var(--display); font-weight: 800; font-size: 1.35rem; color: var(--accent); }
.bar { height: 8px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; margin: 8px 0 0 calc(1.2em + 10px); }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.tablewrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: center; }
thead th { font-size: .85rem; color: var(--muted); font-weight: 600; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tbody th { text-align: left; font-weight: 600; }
th small { font-weight: 400; }
td.right, span.right { color: var(--ok); }
td.wrong, span.wrong { color: var(--err); }
.mark { font-size: .8rem; font-weight: 700; white-space: nowrap; }
.best { margin: 0; font-size: 1.05rem; }
.comments { padding-left: 18px; margin: 0; }
details.mine summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.mine summary::-webkit-details-marker { display: none; }
details.mine summary::after { content: "Visa"; font-size: .9rem; font-weight: 600; color: var(--accent); }
details.mine[open] summary::after { content: "Dölj"; }
details.mine summary h2 { margin: 0; }
.mine h3:first-of-type { margin-top: 1rem; }

/* Autospar-status */
.save-status {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); padding: 8px 18px;
  border-radius: 999px; background: var(--text); color: var(--card);
  box-shadow: 0 6px 20px rgba(20, 22, 50, .25); font-weight: 600; font-size: .9rem; z-index: 10; white-space: nowrap;
}
.save-status.ok::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 8px; vertical-align: 1px; }
.save-status.err { background: var(--err); color: #fff; white-space: normal; max-width: calc(100% - 32px); text-align: center; }
.save-status.busy { opacity: .85; }

/* Admin */
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.row label { flex: 1 1 160px; margin: 0; }
.row .lbl { width: 40px; height: 40px; font-size: 1.15rem; margin-bottom: 4px; }
.row.member { align-items: center; margin: 0; padding: 10px 0; border-top: 1px solid var(--line); }
.row.member:first-of-type { border-top: 0; padding-top: 0; }
.row.member > form:first-child { flex: 1 1 240px; flex-wrap: nowrap; }
.row.member > form:first-child input[type=text] { min-width: 0; flex: 1 1 auto; }
.row.product {
  display: grid; grid-template-columns: 1fr 7.5rem; gap: 8px 10px; align-items: end;
  margin: 0; padding: 14px 0; border-top: 1px solid var(--line);
}
.row.product:first-of-type { border-top: 0; padding-top: 0; }
.row.product label { margin: 0; }
.row.product label.check { font-size: .9rem; color: var(--muted); }
.row.product .btn { justify-self: end; }
.row.product + .btn { margin-top: 6px; }
.btn.small.danger { background: var(--err-soft); color: var(--err); }
.row.inactive input[type=text] { opacity: .6; }
form.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
form.inline input[type=text] { margin: 0; flex: 1 1 160px; width: auto; }
form.add { margin-top: 12px; }
ul { padding-left: 18px; }
li { margin: 4px 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
