/* Pianoveien – varmt, rolig og tilgjengelig design. */

:root {
  --paper: #fbf6ee;
  --bg: #f6efe4;
  --surface: #fffdf9;
  --surface-2: #f3eadd;
  --ink: #2b2420;
  --ink-soft: #5c5148;
  --line: #e2d5c3;
  --line-strong: #c9b8a2;
  --accent: #a8441f;
  --accent-ink: #ffffff;
  --accent-soft: #f6e0d3;
  --ok: #2f6b42;
  --ok-soft: #e1efe3;
  --bad: #a52a2a;
  --bad-soft: #f8e1df;
  --warn: #8a5a00;
  --warn-soft: #fbefd2;
  --info: #3d5a80;
  --info-soft: #e4ebf4;
  --target: #e9a23b;
  --target-soft: #fde9c8;
  --held: #6f8fb8;
  --key-white: #fffefb;
  --key-white-edge: #d8ccbb;
  --key-black: #2a2420;
  --focus: #1f5fbf;
  --shadow: 0 1px 2px rgb(60 40 20 / 0.06), 0 6px 18px rgb(60 40 20 / 0.07);
  --radius: 16px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-head: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --music-font: 'Bravura Text', 'Noto Music', 'Apple Symbols', 'Segoe UI Symbol', 'Segoe UI Historic', serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1f1a16;
    --bg: #1a1613;
    --surface: #26201b;
    --surface-2: #302821;
    --ink: #f3ebe1;
    --ink-soft: #c9bcad;
    --line: #3d342c;
    --line-strong: #5a4d41;
    --accent: #f0956b;
    --accent-ink: #1f1a16;
    --accent-soft: #4a2e22;
    --ok: #8fd19e;
    --ok-soft: #22362a;
    --bad: #ff9e94;
    --bad-soft: #42221f;
    --warn: #f3c46b;
    --warn-soft: #3d3020;
    --info: #9fbfe8;
    --info-soft: #23303f;
    --target: #f0b456;
    --target-soft: #4a3618;
    --held: #8fb0db;
    --key-white: #f4ede3;
    --key-white-edge: #b7a894;
    --key-black: #0f0c0a;
    --focus: #8cb8ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 18px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 96px; /* hold fokuserte elementer fri for den faste topplinjen */
}

@media (max-width: 720px) {
  html {
    scroll-padding-top: 16px;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3 {
  font-family: var(--font-head);
  line-height: 1.25;
  margin: 0 0 0.5em;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1.1rem;
}

p {
  margin: 0 0 0.8em;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

h1:focus {
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 100;
}

.skip-link:focus {
  top: 12px;
}

.muted {
  color: var(--ink-soft);
}

.small {
  font-size: 0.9rem;
}

.center {
  text-align: center;
}

[hidden] {
  display: none !important;
}

/* ---------- Topplinje ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  text-decoration: none;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.25rem;
}

.brand-name {
  color: var(--ink);
}

.mainnav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.mainnav a {
  padding: 6px 11px;
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 550;
  white-space: nowrap;
  border: 2px solid transparent;
}

.mainnav a:hover {
  background: var(--surface-2);
}

.mainnav a[aria-current='page'] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
}

.topbar-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.now-playing {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 3.5em;
  opacity: 0;
  transition: opacity 0.4s;
  color: var(--accent);
}

.now-playing.on {
  opacity: 1;
  transition: none;
}

.midi-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 2px solid currentColor;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--surface);
}

.vol-label {
  font-weight: 600;
  margin-bottom: -6px;
}

.view-opts-panel input[type='range'] {
  width: 100%;
}

.view-opts {
  position: relative;
}

.view-opts summary {
  cursor: pointer;
  list-style: none;
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid var(--line-strong);
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--surface);
}

.view-opts summary::-webkit-details-marker {
  display: none;
}

.view-opts summary::after {
  content: ' ▾';
}

.view-opts-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(320px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 10px;
  z-index: 30;
}

.sound-banner {
  background: var(--warn-soft);
  color: var(--ink);
  border-bottom: 2px solid var(--warn);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 8px 16px;
}

/* ---------- Oppsett ---------- */

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  flex: 1;
}

.page-head {
  margin: 8px 0 24px;
  max-width: 760px;
}

.lead {
  font-size: 1.15rem;
  color: var(--ink-soft);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.3em;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.section-title {
  margin-top: 36px;
}

.footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.footer p {
  margin: 0;
}

/* ---------- Knapper og skjema ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--ink-soft);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 85%, var(--ink));
  border-color: color-mix(in srgb, var(--accent) 85%, var(--ink));
}

.btn-secondary {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
}

.btn-lg {
  min-height: 52px;
  padding: 10px 24px;
  font-size: 1.05rem;
}

.btn-icon {
  min-width: 44px;
  padding: 6px;
  font-size: 1.15rem;
}

.btn.is-complete {
  background: var(--ok-soft);
  border-color: var(--ok);
  color: var(--ok);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

select,
.num-input {
  font: inherit;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  max-width: 100%;
}

.num-input {
  width: 5.5em;
}

input[type='range'] {
  accent-color: var(--accent);
  min-height: 32px;
}

progress {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
}

progress::-webkit-progress-bar {
  background: var(--surface-2);
}

progress::-webkit-progress-value {
  background: var(--ok);
  border-radius: 999px;
}

progress::-moz-progress-bar {
  background: var(--ok);
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin: 12px 0;
}

.field-row label {
  font-weight: 600;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-height: 32px;
  position: relative;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 40px;
  height: 24px;
  margin: 0;
  cursor: pointer;
}

.toggle-track {
  flex: none;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  transition: background 0.15s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 0.15s;
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(16px);
}

.toggle input:focus-visible + .toggle-track {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Statusfarger – alltid sammen med ikon og tekst */
.tone-ok {
  color: var(--ok);
}

.tone-bad {
  color: var(--bad);
}

.tone-warn {
  color: var(--warn);
}

.tone-info {
  color: var(--info);
}

.notice {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
}

/* ---------- Forside ---------- */

.home-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 16px;
}

.hero-card {
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.hero-card h2 {
  font-size: 1.6rem;
}

.hero-card .btn {
  margin-top: auto;
}

.big-number {
  font-family: var(--font-head);
  font-size: 2.6rem;
  font-weight: 700;
  margin: 0 0 8px;
  line-height: 1;
}

.progress-card progress {
  margin-bottom: 8px;
}

.status-line {
  font-weight: 600;
}

.levels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.level-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.level-head h2 {
  margin-bottom: 2px;
  font-size: 1.2rem;
}

.level-head p {
  margin: 0;
  font-size: 0.95rem;
}

.level-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.level-count {
  margin-left: auto;
  font-weight: 700;
  white-space: nowrap;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
}

.level-count.is-done {
  background: var(--ok-soft);
  color: var(--ok);
}

.path-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.path-item a {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  background: var(--paper);
}

.path-item a:hover {
  border-color: var(--line-strong);
}

.path-item.is-next a {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.path-item.is-done a {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--line));
}

.path-status {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  border: 2px solid var(--line-strong);
  color: var(--ink-soft);
}

.is-done .path-status {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--surface);
}

.is-next .path-status {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.path-title {
  flex: 1;
  font-weight: 600;
  display: flex;
  flex-direction: column;
}

.path-title small {
  font-weight: 400;
  font-size: 0.88rem;
}

.path-tag {
  font-size: 0.85rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.quick {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 14px;
  text-decoration: none;
  color: var(--ink);
}

.quick-icon {
  grid-row: span 2;
  font-size: 2rem;
}

.quick:hover {
  border-color: var(--accent);
}

/* ---------- Leksjon ---------- */

.breadcrumb {
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
}

.lesson-main {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.lesson-aside {
  position: sticky;
  top: 90px;
}

.lesson-section h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sec-num {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  font-family: var(--font);
  font-weight: 800;
}

.goal {
  font-size: 1.15rem;
  font-weight: 600;
}

.tip {
  background: var(--target-soft);
  border-left: 4px solid var(--target);
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.checklist {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: grid;
  gap: 8px;
}

.checklist li {
  display: grid;
  grid-template-columns: 1.4em 1fr;
  column-gap: 6px;
  align-items: baseline;
}

.check-state {
  grid-column: 2;
}

.check-icon {
  font-weight: 800;
  width: 1.2em;
}

.checklist .is-done .check-icon {
  color: var(--ok);
}

.check-state {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* ---------- Demonstrasjon ---------- */

.demo {
  margin: 0;
  display: grid;
  gap: 14px;
}

.demo figcaption {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-soft);
}

.letter-strip {
  list-style: none;
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.letter-tile {
  flex: 1 1 48px;
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: var(--paper);
}

.letter-tile .letter {
  display: block;
  font-family: var(--font-head);
  font-size: 1.6rem;
  font-weight: 700;
}

.letter-tile.is-current {
  border-color: var(--target);
  background: var(--target-soft);
  transform: translateY(-3px);
}

.hands {
  display: flex;
  justify-content: center;
}

.hands-svg {
  width: 100%;
  max-width: 460px;
}

.hand-palm,
.hand-finger {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 2;
}

.hand-num-bg {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
}

.hand-num {
  fill: var(--ink);
  font-weight: 800;
  font-size: 14px;
  text-anchor: middle;
  font-family: var(--font);
}

.hand-title {
  fill: var(--ink-soft);
  font-size: 13px;
  text-anchor: middle;
  font-family: var(--font);
  font-weight: 600;
}

.rhythm {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.rh-bar {
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--paper);
}

.rh-counts,
.rh-cells {
  display: grid;
  gap: 4px;
}

.rh-count {
  text-align: center;
  font-weight: 700;
  color: var(--ink-soft);
  border-radius: 6px;
}

.rh-count.on {
  background: var(--accent);
  color: var(--accent-ink);
}

.rh-cell {
  margin-top: 6px;
  min-height: 64px;
  border-radius: 8px;
  background: var(--info-soft);
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.2;
  padding: 4px;
}

.rh-sym {
  font-size: 1.2rem;
  font-family: var(--music-font);
}

.rh-rest {
  background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--paper) 6px, var(--paper) 12px);
}

.rh-cell.is-current {
  border-color: var(--target);
  background: var(--target-soft);
}

/* ---------- Piano ---------- */

.piano-wrap {
  min-width: 0;
}

.piano-scroll {
  overflow-x: auto;
  padding: 4px 0 10px;
  scrollbar-width: thin;
}

.piano {
  --black-w: calc(100% / var(--whites) * 0.6);
  position: relative;
  display: flex;
  min-width: calc(var(--whites) * 34px);
  height: clamp(140px, 22vw, 210px);
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-x;
  background: var(--key-black);
  border: 6px solid var(--key-black);
  border-top-width: 10px;
  border-radius: 10px;
}

.key {
  font: inherit;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  transition: background 0.06s, transform 0.06s;
}

.key-white {
  flex: 1 1 0;
  height: 100%;
  background: var(--key-white);
  border: 1px solid var(--key-white-edge);
  border-top: 0;
  border-radius: 0 0 7px 7px;
  color: #3a312a;
  padding: 0 0 8px;
  box-shadow: inset 0 -6px 0 rgb(0 0 0 / 0.06);
  position: relative;
  z-index: 1;
}

.key-black {
  position: absolute;
  top: 0;
  width: var(--black-w);
  height: 60%;
  background: linear-gradient(#3a322c, var(--key-black));
  border: 1px solid #000;
  border-radius: 0 0 5px 5px;
  z-index: 2;
  color: #f4ede3;
  padding: 0 0 6px;
  box-shadow: 0 3px 3px rgb(0 0 0 / 0.35);
}

.key-labels {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  font-size: 0.78rem;
  line-height: 1.1;
}

.key-name {
  font-weight: 700;
  display: none;
}

.key-kbd {
  display: none;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.7rem;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid currentColor;
  opacity: 0.7;
}

.key-kbd:empty {
  display: none !important;
}

.show-names .key-name {
  display: block;
}

.show-kbd .key-kbd {
  display: block;
}

.key-middle-c .key-name {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.key-mark {
  pointer-events: none;
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 800;
  font-size: 0.85rem;
  line-height: 1;
  min-width: 1.4em;
  text-align: center;
}

.key-black .key-mark {
  top: auto;
  bottom: 30px;
}

.key-white.has-badge .key-mark,
.key-black.has-badge .key-mark {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 3px 4px;
}

.key.is-marked {
  box-shadow: inset 0 0 0 3px var(--info);
}

.key-white.is-marked {
  background: var(--info-soft);
}

/* Neste tone: farge + prikk + kraftig ramme (ikke bare farge) */
.key.is-target {
  outline: 3px dashed #7a4a00;
  outline-offset: -5px;
}

.key-white.is-target {
  background: #fde3b5;
}

.key-black.is-target {
  background: linear-gradient(#a8660f, #6b4005);
  outline-color: #ffd58f;
}

.key.is-target:not(.has-badge) .key-mark::before {
  content: '●';
  color: #7a4a00;
  font-size: 1.1rem;
}

.key-black.is-target:not(.has-badge) .key-mark::before {
  color: #ffd58f;
}

/* Holdes nede */
.key-white.is-held {
  background: #c9d8ec;
  transform: translateY(2px);
  box-shadow: inset 0 3px 6px rgb(0 0 0 / 0.18);
}

.key-black.is-held {
  background: linear-gradient(#4b6487, #2c3d55);
  transform: translateY(2px);
  box-shadow: none;
}

.key-white.flash-ok,
.key-black.flash-ok {
  background: #9fd3ac;
}

.key-white.flash-bad,
.key-black.flash-bad {
  background: #f2a49c;
}

.key.flash-ok .key-mark::before {
  content: '✓' !important;
  color: #14462a !important;
  font-size: 1.2rem;
}

.key.flash-bad .key-mark::before {
  content: '✕' !important;
  color: #6e1010 !important;
  font-size: 1.1rem;
}

.key.flash-ok.has-badge .key-mark,
.key.flash-bad.has-badge .key-mark {
  font-size: 0;
}

/* ---------- Notelinjer ---------- */

.staff {
  display: grid;
  gap: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  max-height: 460px;
  overflow-y: auto;
  color: var(--ink);
}

.staff-svg {
  display: block;
  width: 100%;
  max-width: calc(var(--sys-w) * 1.6px);
  height: auto;
  overflow: visible;
}

.st-line,
.st-ledger {
  stroke: var(--ink-soft);
  stroke-width: 1;
}

.st-ledger {
  stroke-width: 1.4;
}

.st-bar {
  stroke: var(--ink-soft);
  stroke-width: 1.3;
}

.st-bar-final {
  stroke-width: 3.5;
}

.st-clef {
  font-family: var(--music-font);
  fill: var(--ink);
}

.st-time {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 22px;
  fill: var(--ink);
  text-anchor: middle;
}

.st-head,
.st-fill {
  fill: var(--ink);
}

.st-head.hollow {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2;
}

.st-stem {
  stroke: var(--ink);
  stroke-width: 1.4;
}

.st-rest-stroke {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.st-rest-stroke.thin {
  stroke-width: 1.6;
}

.st-acc {
  font-size: 15px;
  fill: var(--ink);
  font-family: var(--font);
}

.st-name {
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
  fill: var(--ink-soft);
  font-family: var(--font);
}

.st-finger {
  font-size: 10px;
  text-anchor: middle;
  fill: var(--info);
  font-family: var(--font);
  font-weight: 700;
}

.hide-names .st-name {
  visibility: hidden;
}

.st-mark {
  font-size: 12px;
  text-anchor: middle;
  font-weight: 800;
  font-family: var(--font);
}

.st-item.is-current .st-head,
.st-item.is-current .st-fill {
  fill: var(--accent);
}

.st-item.is-current .st-head.hollow {
  fill: var(--accent-soft);
  stroke: var(--accent);
}

.st-item.is-current .st-stem,
.st-item.is-current .st-rest-stroke {
  stroke: var(--accent);
}

.st-item.is-current .st-mark,
.st-item.is-current .st-name {
  fill: var(--accent);
  visibility: visible;
}

.st-item.is-hit .st-head:not(.hollow),
.st-item.is-hit .st-fill {
  fill: var(--ok);
}

.st-item.is-hit .st-head.hollow {
  stroke: var(--ok);
}

.st-item.is-hit .st-stem {
  stroke: var(--ok);
}

.st-item.is-hit .st-mark {
  fill: var(--ok);
}

.st-item.is-miss .st-mark,
.st-item.is-miss .st-head:not(.hollow) {
  fill: var(--bad);
}

.st-item.is-miss .st-head.hollow {
  stroke: var(--bad);
}

.st-item.is-skipped {
  opacity: 0.55;
}

.st-item.is-demo .st-head:not(.hollow) {
  fill: var(--info);
}

/* ---------- Øvingspanel ---------- */

.exercise {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.ex-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.segmented {
  display: inline-flex;
  border: 2px solid var(--line-strong);
  border-radius: 999px;
  padding: 3px;
  margin: 0;
  background: var(--surface);
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.segmented span {
  display: block;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
}

.segmented input:checked + span {
  background: var(--accent);
  color: var(--accent-ink);
}

.segmented input:checked + span::before {
  content: '✓ ';
}

.segmented input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.tempo-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.tempo-box input {
  width: 130px;
}

.tempo-out {
  font-variant-numeric: tabular-nums;
  min-width: 7.5em;
  font-weight: 500;
}

.exercise[data-mode='wait'] .tempo-box {
  opacity: 0.85;
}

.ex-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.95rem;
}

.ex-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(160px, 240px);
  gap: 12px 16px;
  align-items: center;
}

.next-box {
  display: grid;
  justify-items: center;
  min-width: 120px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 3px dashed var(--target);
  background: var(--target-soft);
  text-align: center;
}

.next-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--ink-soft);
}

.next-name {
  font-family: var(--font-head);
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.1;
}

.next-extra {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.feedback {
  margin: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 650;
  font-size: 1.05rem;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid currentColor;
  min-height: 56px;
}

.feedback.tone-ok {
  background: var(--ok-soft);
}

.feedback.tone-bad {
  background: var(--bad-soft);
  animation: shake 0.3s;
}

.feedback.tone-warn {
  background: var(--warn-soft);
}

.feedback.tone-info {
  background: var(--info-soft);
}

.fb-icon {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid currentColor;
  font-weight: 800;
}

.fb-text {
  color: var(--ink);
}

@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.ex-progress {
  display: grid;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.pulse-dots {
  display: flex;
  gap: 6px;
}

.pulse-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  transition: transform 0.08s;
}

.pulse-dot:first-child {
  border-radius: 3px;
}

.pulse-dot.on {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.3);
}

.pulse-dots.big .pulse-dot {
  width: 24px;
  height: 24px;
}

.chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--paper);
  font-weight: 700;
}

.chip-icon {
  min-width: 1em;
}

.chip.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chip.is-hit {
  border-color: var(--ok);
  color: var(--ok);
}

.chip.is-miss {
  border-color: var(--bad);
  color: var(--bad);
}

.chip.is-skipped {
  opacity: 0.6;
}

.chip-rest {
  font-weight: 400;
  font-style: italic;
}

.result-box {
  border: 2px solid var(--ok);
  background: var(--ok-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.result-head {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--ok);
}

/* ---------- Quiz ---------- */

.quiz {
  display: grid;
  gap: 14px;
}

.quiz-q {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0;
}

.quiz-q legend {
  font-weight: 700;
  padding: 0 6px;
}

.quiz-options {
  display: grid;
  gap: 6px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  cursor: pointer;
  min-height: 44px;
}

.quiz-option:hover {
  border-color: var(--line-strong);
}

.quiz-option input {
  accent-color: var(--accent);
  width: 20px;
  height: 20px;
  margin: 0;
}

.quiz-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.quiz-feedback {
  margin: 8px 0 0;
  font-weight: 650;
}

.quiz-feedback:empty {
  display: none;
}

.quiz-summary {
  font-weight: 700;
}

/* ---------- Sang ---------- */

.song-intro {
  margin-bottom: 16px;
}

.plain-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: grid;
  gap: 6px;
}

.song-status {
  font-weight: 650;
  margin: 0;
}

.song-player {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* ---------- Sangbibliotek ---------- */

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip-btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.chip-btn[aria-checked='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.chip-btn[aria-checked='true']::before {
  content: '✓ ';
}

.song-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.song-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--ink);
  text-decoration: none;
  border: 2px solid var(--line);
}

.song-card:hover {
  border-color: var(--accent);
}

.song-card.is-done {
  border-color: color-mix(in srgb, var(--ok) 50%, var(--line));
}

.song-genre {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--accent);
}

.song-title {
  font-family: var(--font-head);
  font-size: 1.2rem;
  line-height: 1.25;
}

.song-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: auto;
  padding-top: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.level-pill {
  color: var(--ink-soft);
}

.song-license {
  color: var(--ink-soft);
}

.song-new {
  border-style: dashed;
  background: var(--paper);
  justify-content: center;
}

.song-new-icon {
  font-size: 2rem;
  line-height: 1;
  color: var(--accent);
}

/* ---------- Sangredigering ---------- */

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.editor-aside {
  display: grid;
  gap: 16px;
}

.text-input {
  font: inherit;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.melody-input {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
}

.melody-input[aria-invalid='true'] {
  border-color: var(--bad);
}

.block-label {
  display: block;
  font-weight: 600;
  margin: 14px 0 6px;
}

.form-error {
  font-weight: 650;
  margin: 6px 0;
}

.form-error:empty {
  display: none;
}

.editor-preview {
  margin: 10px 0 14px;
}

.format-help code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ---------- Øving ---------- */

.practice-top {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.now-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.now-note {
  font-family: var(--font-head);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  min-width: 2.5em;
}

.metro {
  display: grid;
  gap: 12px;
  align-content: start;
  transition: box-shadow 0.1s;
}

.metro.beat-flash {
  animation: beat 0.18s;
}

@keyframes beat {
  0% { box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
  100% { box-shadow: var(--shadow); }
}

.metro-display {
  display: flex;
  align-items: center;
  gap: 16px;
}

.metro-beat {
  font-family: var(--font-head);
  font-size: 2.6rem;
  font-weight: 800;
  min-width: 1.2em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.metro-controls {
  display: grid;
  gap: 6px;
}

.metro-controls > label {
  font-weight: 600;
}

.bpm-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.bpm-row input[type='range'] {
  flex: 1;
  min-width: 100px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 14px;
}

.tab {
  font: inherit;
  font-weight: 650;
  padding: 10px 16px;
  min-height: 44px;
  border: 2px solid transparent;
  border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  margin-bottom: -2px;
}

.tab[aria-selected='true'] {
  background: var(--surface);
  border-color: var(--line);
  border-bottom: 2px solid var(--surface);
  color: var(--ink);
  box-shadow: inset 0 3px 0 var(--accent);
}

/* ---------- MIDI ---------- */

.midi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.midi-grid + .card {
  margin-bottom: 16px;
}

.midi-status {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid currentColor;
}

.midi-status.tone-ok {
  background: var(--ok-soft);
}

.midi-status.tone-warn {
  background: var(--warn-soft);
}

.midi-status.tone-bad {
  background: var(--bad-soft);
}

.midi-status.tone-info {
  background: var(--info-soft);
}

.midi-status p {
  color: var(--ink);
  margin: 4px 0 8px;
}

.status-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.signal {
  font-weight: 700;
}

.big-note {
  font-family: var(--font-head);
  font-size: clamp(3rem, 10vw, 5rem);
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  margin: 8px 0;
}

.held-line {
  font-weight: 600;
}

.midi-log {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: grid;
  gap: 2px;
  font-size: 0.88rem;
  max-height: 340px;
  overflow: auto;
}

.midi-log li {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--paper);
}

.midi-log code {
  white-space: pre;
}

.midi-log:empty::before {
  content: 'Ingen meldinger ennå.';
  color: var(--ink-soft);
}

.steps {
  padding-left: 1.3em;
  display: grid;
  gap: 6px;
}

/* ---------- Tastelys ---------- */

.light-card {
  margin-bottom: 16px;
  display: grid;
  gap: 10px;
  justify-items: start;
}

.light-card > * {
  max-width: 100%;
}

.form-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
  width: 100%;
  max-width: 640px;
}

.form-grid label {
  font-weight: 600;
}

.inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.num-input.wide {
  width: 12em;
}

.legend,
.scan-results {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: grid;
  gap: 8px;
}

.legend li {
  display: flex;
  gap: 10px;
  align-items: center;
}

.swatch {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--line-strong);
}

.scan-results li {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  margin-top: 4px;
}

.btn-small {
  min-height: 36px;
  padding: 4px 12px;
  font-size: 0.9rem;
}

.wizard-text {
  font-weight: 650;
  margin: 0;
}

.wizard-text:empty {
  display: none;
}

.more summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 32px;
}

/* ---------- Varsler ---------- */

.toasts {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 50;
  width: min(480px, calc(100vw - 32px));
}

.toast {
  background: var(--surface);
  border: 2px solid currentColor;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 650;
  box-shadow: var(--shadow);
  transition: opacity 0.5s;
}

.toast.out {
  opacity: 0;
}

/* ---------- Responsivt ---------- */

@media (max-width: 1100px) {
  .topbar {
    position: static;
  }
}

@media (max-width: 1000px) {
  .home-grid {
    grid-template-columns: 1fr 1fr;
  }

  .hero-card {
    grid-column: 1 / -1;
  }

  .lesson-layout,
  .editor-layout {
    grid-template-columns: 1fr;
  }

  .lesson-aside {
    position: static;
    order: -1;
  }

  .practice-top {
    grid-template-columns: 1fr;
  }

  .ex-status {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .ex-progress {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 1rem;
  }

  .topbar {
    position: static;
  }

  .topbar-inner {
    gap: 8px 12px;
  }

  .mainnav {
    order: 3;
    width: 100%;
  }

  .pill-label,
  .now-playing {
    display: none;
  }

  .midi-pill {
    max-width: 150px;
  }

  .home-grid,
  .levels,
  .quick-links,
  .midi-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 16px;
  }

  .ex-status {
    grid-template-columns: 1fr;
  }

  .next-box {
    grid-template-columns: auto auto 1fr;
    justify-items: start;
    align-items: baseline;
    gap: 10px;
    text-align: left;
  }

  .path-tag {
    display: none;
  }

  .tempo-box input {
    width: 100px;
  }

  .song-player {
    padding: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
