/* "Förkortningar i V64-startlistan" – code lexicon. Light grey-beige background, graphite text, six family
   accents (identitet tegelröd, härstamning violett, rekord turkos, resultat orange, bana marinblå, personer olivgrön)
   used only on chips, thin borders, icons, markers and connector lines. Codes in monospace. */
.fk {
  --fk-bg: #efece6; --fk-paper: #f8f6f1; --fk-line: #d9d3c7; --fk-ink: #2b2f36;
  --fk-id: #b5442e; --fk-harst: #7a6b9e; --fk-rek: #0f9aa6; --fk-res: #d9781f; --fk-bana: #1f3a68; --fk-pers: #6b7a2f;
  --fk-mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  background: var(--fk-bg); color: var(--fk-ink);
}
.fk h1, .fk h2, .fk h3 { color: var(--fk-ink); letter-spacing: -.01em; }
.fk .fk-paper h2 { margin-top: 56px; }
.fk .fk-paper h3 { margin-top: 26px; font-size: clamp(18px, 1.8vw, 21px); }
.fk-fam-id { --fk-acc: var(--fk-id); } .fk-fam-harst { --fk-acc: var(--fk-harst); } .fk-fam-rek { --fk-acc: var(--fk-rek); }
.fk-fam-res { --fk-acc: var(--fk-res); } .fk-fam-bana { --fk-acc: var(--fk-bana); } .fk-fam-pers { --fk-acc: var(--fk-pers); }

/* Codes */
.fk-code, .fk code { font-family: var(--fk-mono); font-size: .95em; padding: 2px 7px; border-radius: 5px; background: rgba(43, 47, 54, .07); border: 1px solid transparent; color: var(--fk-ink); white-space: nowrap; }
.fk-code[class*="fk-fam-"] { border-color: var(--fk-acc); background: color-mix(in srgb, var(--fk-acc) 10%, #fff); }
.fk-rawline code { white-space: normal; font-size: clamp(16px, 1.6vw, 20px); padding: 8px 12px; display: inline-block; }
.fk .fk-paper p, .fk .fk-paper li { max-width: 72ch; }
.fk-ingress { font-size: clamp(17px, 1.5vw, 20px); font-weight: 600; }
.fk-k { display: block; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }

/* Hero */
.fk-hero { background: #fff; border-bottom: 1px solid var(--fk-line); padding-block: 8px 28px; }
.fk-hero h1 { font-size: clamp(30px, 4.4vw, 54px); margin: 12px 0 4px; }
.fk-tagline { font-size: clamp(16px, 1.6vw, 21px); font-weight: 600; color: var(--muted); margin: 0 0 20px; }
.fk-hero-row { display: grid; gap: 18px; padding: 18px; border-radius: 12px; background: var(--fk-paper); border: 1px solid var(--fk-line); }
.fk-hero-line { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 6px; }
.fk-sep { font-family: var(--fk-mono); font-size: clamp(22px, 3vw, 40px); line-height: 1.2; color: var(--muted); padding-top: 2px; }
.fk-tok { display: grid; justify-items: center; gap: 0; min-width: 44px; }
.fk-tok-code { font-family: var(--fk-mono); font-size: clamp(22px, 3vw, 40px); line-height: 1.2; font-weight: 700; color: var(--fk-acc); padding: 2px 6px; border-radius: 6px; background: color-mix(in srgb, var(--fk-acc) 9%, #fff); }
.fk-tok-line { width: 2px; height: 22px; background: var(--fk-acc); }
.fk-tok-lbl { font-size: 12px; font-weight: 700; color: var(--fk-acc); text-align: center; max-width: 9ch; line-height: 1.2; }
.fk-hero-note { margin: 14px 0 0; font-weight: 700; }

/* Layout with sticky glossary */
.fk-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; padding-block: 24px 48px; align-items: start; }
.fk-paper { background: var(--fk-paper); border-radius: var(--radius); padding: clamp(20px, 3vw, 40px); max-width: none; border: 1px solid var(--fk-line); min-width: 0; }
.fk-paper ul + p, .fk-paper ol + p, .fk-paper .table-scroll + p, .fk-paper .fk-fig + p { margin-top: 12px; }
.fk-two, .fk-three { display: grid; gap: 14px; margin: 14px 0; }
.fk-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fk-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fk-two > *, .fk-three > * { min-width: 0; }
.fk-card { padding: 14px 16px; border-radius: 8px; background: #fff; border: 1px solid var(--fk-line); }
.fk-card h3 { margin-top: 0 !important; }

/* Family cards (asymmetric grid) */
.fk-fams { list-style: none; padding: 0; margin: 14px 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: minmax(120px, auto); gap: 12px; }
.fk-famcard a { display: grid; align-content: start; gap: 6px; height: 100%; padding: 16px; border-radius: 10px; background: #fff; border: 1px solid var(--fk-line); border-top: 5px solid var(--fk-acc); text-decoration: none; color: var(--fk-ink); transition: transform .2s, box-shadow .2s; }
.fk-famcard a:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(43, 47, 54, .1); }
.fk-famcard:nth-child(1) { grid-column: span 3; } .fk-famcard:nth-child(2) { grid-column: span 3; } .fk-famcard:nth-child(3) { grid-column: span 2; }
.fk-famcard:nth-child(4) { grid-column: span 2; } .fk-famcard:nth-child(5) { grid-column: span 2; } .fk-famcard:nth-child(6) { grid-column: span 6; }
.fk-famcard:nth-child(6) a { grid-template-columns: auto 1fr; align-items: center; column-gap: 14px; }
.fk-famcard:nth-child(6) .fk-ico { grid-row: span 2; }
.fk-ico { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 2px solid var(--fk-acc); color: var(--fk-acc); }
.fk-ico svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fk-ico svg circle[r="1.6"] { fill: currentColor; }
.fk-famname { font-weight: 800; font-size: 18px; }
.fk-famincl { color: var(--muted); font-size: 14px; }
.fk-famhead { display: flex; gap: 14px; align-items: flex-start; margin-top: 56px; padding-top: 18px; border-top: 3px solid var(--fk-acc); }
.fk-famhead h2 { margin-top: 0 !important; }
.fk-famtag { display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--fk-acc); }
.fk-famsub { margin: 2px 0 0; color: var(--muted); font-weight: 600; }

/* Decoder cards */
.fk-decs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.fk-dec { padding: 14px 16px; border-radius: 10px; background: #fff; border: 1px solid var(--fk-line); border-left: 5px solid var(--fk-acc); display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
.fk-dec-code { font-family: var(--fk-mono); font-size: clamp(28px, 3vw, 40px); font-weight: 800; color: var(--fk-acc); line-height: 1; padding-top: 4px; }
.fk-dec dl { margin: 0; display: grid; gap: 6px; }
.fk-dec dt { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.fk-dec dd { margin: 0; }

/* Record builder */
.fk-builds { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 12px; }
.fk-build { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0; }
.fk-piece { position: relative; display: grid; gap: 2px; align-content: center; padding: 10px 22px 10px 18px; background: #fff; border: 2px solid var(--fk-rek); min-width: 120px; }
.fk-piece small { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.fk-piece code { font-size: clamp(20px, 2.4vw, 30px); background: none; border: 0; padding: 0; color: var(--fk-rek); font-weight: 800; }
.fk-piece em { font-style: normal; font-size: 13px; color: var(--muted); }
.fk-piece-time { border-radius: 10px 0 0 10px; }
.fk-piece-start, .fk-piece-dist { margin-left: -2px; }
.fk-piece-start::before, .fk-piece-dist::before { content: ""; position: absolute; left: -12px; top: 50%; width: 20px; height: 20px; margin-top: -10px; border-radius: 50%; background: #fff; border: 2px solid var(--fk-rek); }
.fk-piece-dist { border-radius: 0 10px 10px 0; }
.fk-piece-eq { display: grid; place-items: center; padding: 0 14px; font-size: 28px; font-weight: 800; color: var(--muted); }
.fk-piece-result { border-radius: 10px; background: var(--fk-rek); border-color: var(--fk-rek); color: #fff; }
.fk-piece-result small, .fk-piece-result code { color: #fff; }

/* Km figure */
.fk-fig { width: 100%; height: auto; display: block; margin: 14px 0; border-radius: 10px; }
.fk-km-bg { fill: #fff; stroke: var(--fk-line); }
.fk-km-seg { fill: #e6e1d6; }
.fk-km-seg.is-hot { fill: var(--fk-rek); }
.fk-km-lbl { fill: var(--fk-ink); font: 600 12px/1 var(--font); }
.fk-km-time { fill: var(--fk-rek); font: 800 26px/1 var(--fk-mono); }
.fk-km-arrow { fill: none; stroke: var(--fk-rek); stroke-width: 2; }
.fk-km-note { fill: var(--muted); font: 700 12px/1 var(--font); }
.fk-km-cap { margin-top: 4px; }

/* Timeline */
.fk-timeline { list-style: none; padding: 0; margin: 14px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.fk-node { display: grid; gap: 4px; padding: 8px 10px; border-radius: 8px; background: #fff; border: 1px solid var(--fk-line); border-top: 4px solid var(--fk-acc); min-width: 90px; position: relative; }
.fk-node + .fk-node::before { content: ""; position: absolute; left: -6px; top: 50%; width: 6px; height: 2px; background: var(--fk-line); }
.fk-node code { background: none; border: 0; padding: 0; font-weight: 800; font-size: 17px; color: var(--fk-acc); }
.fk-node span { font-size: 12px; color: var(--muted); font-weight: 600; }

/* Placement tiles */
.fk-tiles { list-style: none; padding: 0; margin: 14px 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.fk-tile { display: grid; justify-items: center; gap: 6px; padding: 12px 6px; border-radius: 10px; background: #fff; border: 1px solid var(--fk-line); font-weight: 700; font-size: 14px; text-align: center; }
.fk-tile-code { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; font: 800 28px/1 var(--fk-mono); color: #fff; background: #6b7280; }
.fk-tile-p1 .fk-tile-code { background: #c9a227; } .fk-tile-p2 .fk-tile-code { background: #8f9aa6; } .fk-tile-p3 .fk-tile-code { background: #a9713d; }
.fk-tile-p0 .fk-tile-code { background: #9aa0a6; } .fk-tile-pg .fk-tile-code { background: var(--fk-res); } .fk-tile-pd .fk-tile-code { background: #8b1e2d; }

/* Same letter */
.fk-sames { list-style: none; padding: 0; margin: 14px 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fk-same { position: relative; padding: 14px 16px 14px 74px; border-radius: 10px; background: #fff; border: 1px solid var(--fk-line); overflow: hidden; }
.fk-same-big { position: absolute; left: 10px; top: 4px; font: 800 64px/1 var(--fk-mono); color: rgba(43, 47, 54, .12); transform: rotate(-8deg); }
.fk-same ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.fk-same li { display: grid; gap: 2px; }
.fk-ctx { font-size: 12px; color: var(--muted); font-weight: 600; }

/* Map + register */
.fk-mapgrid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; margin: 14px 0; align-items: start; }
.fk-fig-map { max-width: 300px; background: #fff; border: 1px solid var(--fk-line); }
.fk-map-land { fill: #e7e2d7; stroke: var(--fk-bana); stroke-width: 2; }
.fk-map-pt circle { fill: var(--fk-bana); }
.fk-map-code { fill: #fff; font: 800 9px/1 var(--fk-mono); }
.fk-map-name { fill: var(--fk-ink); font: 600 12px/1 var(--font); }
.fk-register { list-style: none; padding: 0; margin: 10px 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 12px; }
.fk-register li { padding: 6px 8px; border-radius: 6px; background: #fff; border: 1px solid var(--fk-line); }

/* Fact boxes */
.fk-fact { margin: 14px 0; padding: 12px 14px 12px 16px; border-radius: 8px; background: #fff; border: 1px solid var(--fk-line); border-left: 6px solid; }
.fk-fact-tolk { border-left-color: var(--fk-rek); } .fk-fact-seupp { border-left-color: var(--fk-res); } .fk-fact-jamfor { border-left-color: var(--fk-harst); }
.fk-fact-lbl { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; color: #fff; margin-bottom: 4px; }
.fk-fact-tolk .fk-fact-lbl { background: var(--fk-rek); } .fk-fact-seupp .fk-fact-lbl { background: var(--fk-res); } .fk-fact-jamfor .fk-fact-lbl { background: var(--fk-harst); }
.fk-fact strong { display: block; }
.fk-fact p { margin: 4px 0 0; }

/* Workshop */
.fk-ws { margin: 18px 0; padding: 14px 16px; border-radius: 10px; background: #fff; border: 1px solid var(--fk-line); }
.fk-ws h3 { margin-top: 0 !important; }
.fk-ws-tabs { display: none; gap: 8px; margin-bottom: 10px; }
.fk-ws-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 14px; }
.fk-raw { display: block; white-space: normal; font-size: 18px; padding: 10px 12px; }
.fk-parts { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.fk-part { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 6px; border-left: 4px solid var(--fk-acc); background: var(--fk-paper); }
.fk-part code { color: var(--fk-acc); border-color: var(--fk-acc); background: #fff; }
.fk-btn { min-height: 44px; padding: 8px 14px; border-radius: 8px; border: 2px solid var(--fk-line); background: #fff; font: 700 14px/1.2 var(--font); color: var(--fk-ink); cursor: pointer; transition: background .2s, border-color .2s; }
.fk-btn[aria-pressed="true"] { background: var(--fk-ink); border-color: var(--fk-ink); color: #fff; }
.fk-btn-sm { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.fk-btn-sm[class*="fk-fam-"][aria-pressed="true"] { background: var(--fk-acc); border-color: var(--fk-acc); }
.fk-btn:hover { border-color: var(--fk-ink); }

/* Steps, mistakes */
.fk-steps { list-style: none; padding: 0; margin: 14px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; counter-reset: s; }
.fk-steps li { counter-increment: s; padding: 12px 14px 12px 52px; position: relative; border-radius: 8px; background: #fff; border: 1px solid var(--fk-line); }
.fk-steps li::before { content: counter(s); position: absolute; left: 12px; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--fk-ink); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.fk-steps strong { display: block; margin-bottom: 2px; }
.fk-mistakes > div { background: #fff; border-left-color: var(--fk-res); }

/* Glossary aside */
.fk-key { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; padding: 14px; border-radius: var(--radius); background: #fff; border: 1px solid var(--fk-line); display: grid; gap: 10px; align-content: start; }
.fk-key-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fk-key-head h2 { margin: 0; }
.fk-key-close { display: none; }
.fk-key-search { display: grid; gap: 4px; font-size: 13px; font-weight: 700; }
.fk-key-search input { min-height: 44px; padding: 8px 10px; border-radius: 8px; border: 2px solid var(--fk-line); font: 500 15px/1.2 var(--font); width: 100%; }
.fk-key-fams { display: flex; flex-wrap: wrap; gap: 6px; }
.fk-key-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.fk-key-list a { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; padding: 6px 8px; border-radius: 6px; text-decoration: none; color: var(--fk-ink); min-height: 44px; }
.fk-key-list a:hover { background: var(--fk-paper); }
.fk-key-list small { grid-column: 2; color: var(--muted); font-size: 11px; }
.fk-key-list code { font-size: 14px; }
.fk-key-open { display: none; }

@media (prefers-reduced-motion: reduce) {
  .fk-famcard a, .fk-btn { transition: none; }
  .fk-famcard a:hover { transform: none; }
}
@media (max-width: 1100px) {
  .fk-layout { grid-template-columns: 1fr; }
  .fk-key { position: fixed; inset: 0; z-index: 60; max-height: none; border-radius: 0; display: none; padding: 16px; padding-bottom: 32px; }
  .fk-key.is-open { display: grid; }
  .fk-key-close { display: inline-block; }
  .fk-key-open { display: block; position: sticky; bottom: 16px; margin: 0 16px 16px; width: calc(100% - 32px); z-index: 50; min-height: 48px; border-radius: 999px; border: 0; background: var(--fk-ink); color: #fff; font: 800 15px/1 var(--font); box-shadow: 0 6px 20px rgba(0, 0, 0, .25); cursor: pointer; }
  html.fk-key-lock .fk-key-open { display: none; }
  html.fk-key-lock { overflow: hidden; }
  .fk-fams { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fk-famcard:nth-child(n) { grid-column: span 1; grid-row: span 1; }
  .fk-famcard:nth-child(6) { grid-column: span 2; }
  .fk-mapgrid { grid-template-columns: 1fr; }
  .fk-fig-map { margin-inline: auto; }
  .fk-register { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .fk-hero h1 { font-size: clamp(26px, 8vw, 36px); }
  .fk-hero-row { padding: 12px; gap: 14px; }
  .fk-tok-code, .fk-sep { font-size: 22px; }
  .fk-tok-lbl { font-size: 11px; }
  .fk-two, .fk-three, .fk-decs, .fk-sames, .fk-steps, .fk-register { grid-template-columns: 1fr; }
  .fk-fams { grid-template-columns: 1fr; }
  .fk-famcard:nth-child(6) { grid-column: span 1; }
  .fk-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fk-timeline { flex-direction: column; }
  .fk-node + .fk-node::before { left: 50%; top: -6px; width: 2px; height: 6px; }
  .fk-build { flex-direction: column; }
  .fk-piece { border-radius: 8px; margin: 0; }
  .fk-piece-start::before, .fk-piece-dist::before { left: 50%; top: -12px; margin: 0 0 0 -10px; }
  .fk-piece-eq { padding: 4px 0; }
  .fk-dec { grid-template-columns: 1fr; }
  .fk-ws-tabs { display: flex; }
  .fk-ws-grid { grid-template-columns: 1fr; }
  .fk-ws[data-mode="code"] .fk-ws-expl, .fk-ws[data-mode="explained"] .fk-ws-code { display: none; }
  .fk-ws .fk-k { display: none; }
  .fk-cards table, .fk-cards thead, .fk-cards tbody, .fk-cards tr, .fk-cards td { display: block; }
  .fk-cards thead { position: absolute; left: -9999px; }
  .fk-cards tr { margin-bottom: 8px; border: 1px solid var(--fk-line); border-radius: 8px; background: #fff; padding: 6px 10px; }
  .fk-cards td { border: 0; padding: 4px 0; }
  .fk-cards td::before { content: attr(data-th) ": "; font-weight: 700; color: var(--muted); }
  .sp-mistakes.fk-mistakes { grid-template-columns: 1fr; }
  .fk-code, .fk code { white-space: normal; }
}
