:root {
  --accent: #f97316;
  --bg: #0b1220;
  --panel: #111a2e;
  --line: #22304d;
  --text: #e7ecf5;
  --muted: #9aa8c1;
  --radius: 14px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.6; }
a { color: var(--accent); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

header.site { border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { font-weight: 800; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.logo span { color: var(--accent); }
nav a { color: var(--muted); text-decoration: none; margin-left: 20px; font-size: 0.95rem; }

.hero { padding: 48px 0 24px; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); line-height: 1.1; letter-spacing: -0.03em; margin: 0 0 12px; }
.hero p { color: var(--muted); font-size: 1.15rem; max-width: 720px; margin: 0; }
.tldr { margin-top: 20px; padding: 16px 18px; border-left: 3px solid var(--accent); background: var(--panel); border-radius: 0 var(--radius) var(--radius) 0; max-width: 820px; }

/* Förklaringen */
.explainer { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 20px; margin: 24px 0 48px; }
.viz { position: relative; height: min(76vh, 720px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--bg); position: sticky; top: 16px; }
.viz canvas { display: block; }
.viz-hint { position: absolute; left: 12px; bottom: 10px; font-size: 0.8rem; color: var(--muted); pointer-events: none; }
.viz-fallback { padding: 24px; color: var(--muted); }
.viz-label { background: rgba(11, 18, 32, 0.85); border: 1px solid var(--line); border-left: 3px solid var(--accent); color: var(--text); padding: 3px 9px; border-radius: 6px; font-size: 12px; white-space: nowrap; }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li { counter-increment: step; padding: 14px 16px 14px 52px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; cursor: pointer; position: relative; background: var(--panel); transition: border-color .2s, opacity .2s; opacity: .6; }
.steps li::before { content: counter(step); position: absolute; left: 14px; top: 14px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--line); }
.steps li.active { opacity: 1; border-color: var(--accent); }
.steps li.active::before { background: var(--accent); color: #111; }
.steps h3 { margin: 0 0 4px; font-size: 1.05rem; }
.steps p { margin: 0; color: var(--muted); font-size: .95rem; }
.steps .temp { margin-top: 6px; font-size: .85rem; color: var(--text); }
.controls { display: flex; gap: 8px; margin-bottom: 12px; }
button { font: inherit; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
button.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; }

section.block { margin: 56px 0; }
section.block h2 { font-size: 1.7rem; letter-spacing: -0.02em; }

/* Kalkylator */
.calc { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.calc label { display: block; font-size: .9rem; color: var(--muted); }
.calc input { width: 100%; margin-top: 4px; font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.calc-out { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.calc-out div { background: var(--bg); border-radius: 10px; padding: 12px; }
.calc-out b { display: block; font-size: 1.4rem; }
.calc-out small, .note { color: var(--muted); font-size: .85rem; }

details { border-bottom: 1px solid var(--line); padding: 12px 0; }
summary { cursor: pointer; font-weight: 600; }
.sources li { margin-bottom: 6px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; color: var(--text); text-decoration: none; }
.card.soon { opacity: .55; }
.card .tag { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
pre { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; overflow-x: auto; font-size: .85rem; }
footer { border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); font-size: .9rem; }

/* Inbäddat läge: bara förklaringen */
body.embed header.site, body.embed .hero, body.embed .after, body.embed footer { display: none; }
body.embed .explainer { margin: 0; gap: 12px; padding: 12px; }
body.embed .viz { height: calc(100vh - 24px); top: 0; }
.embed-credit { display: none; position: absolute; right: 10px; top: 8px; font-size: .75rem; color: var(--muted); text-decoration: none; }
body.embed .embed-credit { display: block; }
body.embed .steps { max-height: calc(100vh - 80px); overflow-y: auto; }

@media (max-width: 860px) {
  .explainer { grid-template-columns: 1fr; }
  .viz { height: 58vh; position: relative; }
  body.embed .viz { height: 55vh; }
  .steps li:not(.active) { display: none; }
}

/* --- Användarvänlighet --- */
.hero { padding: 32px 0 8px; }
.hero h1 { margin-bottom: 8px; }
.explainer { margin-top: 16px; }
.steps { position: relative; max-height: calc(min(76vh, 720px) - 58px); overflow-y: auto; padding-right: 4px; scrollbar-width: thin; }
.steps li:focus-visible, button:focus-visible, .card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.steps li:hover { opacity: .85; }
.controls { align-items: center; }
.controls button { min-width: 44px; min-height: 44px; }
.counter { margin-left: auto; color: var(--muted); font-size: .9rem; }

.viz-legend { position: absolute; left: 12px; top: 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; max-width: calc(100% - 80px); font-size: .75rem; color: var(--muted); background: rgba(11,18,32,.7); padding: 6px 10px; border-radius: 8px; pointer-events: none; }
.viz-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.viz-tools { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.viz-tools button { width: 40px; height: 40px; padding: 0; font-size: 1.15rem; background: rgba(17,26,46,.9); }
.viz-hint { right: 60px; }
.viz-loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); background: var(--bg); transition: opacity .5s; z-index: 2; }
.viz-loading span { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
.viz-loading.done { opacity: 0; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.tldr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; margin: 8px 0 0; }
.tldr-row .tldr { margin: 0; flex: 1 1 520px; }
.cta { display: inline-block; background: var(--accent); color: #111; font-weight: 700; text-decoration: none; padding: 12px 18px; border-radius: 10px; }

.presets { grid-column: 1 / -1; border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.presets legend { font-weight: 600; margin-bottom: 8px; }
.presets button { min-height: 44px; }
.presets button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--panel)); }
.presets .note { flex-basis: 100%; margin: 4px 0 0; }
.calc input { min-height: 44px; font-size: 1rem; }
.calc-out .hl { outline: 1px solid var(--accent); }
.calc-out .hl b { color: var(--accent); }

@media (max-width: 860px) {
  .steps { max-height: none; overflow: visible; }
  .viz-legend { font-size: .7rem; }
  .viz-hint { display: none; }
  .controls { position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 3; }
  /* Färgförklaringen tar hela toppen på smal skärm; tipsraden nertill är dold, så krediten flyttas dit */
  .embed-credit { top: auto; right: auto; left: 12px; bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) { .viz-loading span { animation: none; } }


/* Kontakt */
nav { display: flex; align-items: center; }
nav a { white-space: nowrap; }
nav a.nav-cta { color: #111; background: var(--accent); font-weight: 700; padding: 7px 12px; border-radius: 8px; }
.contact { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; margin: 24px 0; padding: 20px 22px; background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); }
.contact > div:first-child { flex: 1 1 320px; }
.contact h3 { margin: 0 0 4px; font-size: 1.25rem; }
.contact p { margin: 0 0 4px; color: var(--muted); }
.contact-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-ghost { display: inline-block; padding: 12px 18px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-weight: 600; text-decoration: none; }
.btn-ghost:hover { border-color: var(--accent); }
footer a { color: var(--muted); }
@media (max-width: 520px) {
  nav a { margin-left: 12px; }
  /* Bara knappen får plats bredvid loggan; företagsavsnittet nås via den */
  nav a:not(.nav-cta) { display: none; }
  .contact-actions, .contact-actions a { width: 100%; text-align: center; }
}
