:root {
  /* Back to Lerum-temat: synthwave-solnedgång, neonkanter, Orbitron och LED-siffror */
  --bg: #0c051a;
  --bg2: #160a2e;
  --card: rgba(255, 255, 255, 0.05);
  --card2: rgba(255, 255, 255, 0.09);
  --line: rgba(164, 107, 255, 0.28);
  --text: #f4f0ff;
  --muted: #cdbbe9;
  --accent: #a46bff;
  --accent2: #00e5ff;
  --neon-m: #ff2e88;
  --good: #3dff6e;
  --bad: #ff3b30;
  --gold: #ffd23f;
  --radius: 16px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Orbitron', system-ui, sans-serif;
  --mono: 'Share Tech Mono', ui-monospace, Menlo, monospace;
  --hot: linear-gradient(100deg, #ffd23f, #ff7a2f 55%, #ff2e88);
  --neon-edge: linear-gradient(135deg, #00e5ff, #a46bff 45%, #ff2e88);
}
@font-face { font-family: 'Orbitron'; font-style: normal; font-weight: 400 900; font-display: swap; src: url(../fonts/orbitron-latin.woff2) format('woff2'); }
@font-face { font-family: 'Share Tech Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/share-tech-mono-latin.woff2) format('woff2'); }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html, body, button, a, input, label, .card { touch-action: manipulation; }
body {
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1100px 600px at 50% -15%, rgba(255, 46, 136, .32) 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 20%, rgba(0, 229, 255, .14) 0%, transparent 55%),
    radial-gradient(800px 600px at -10% 70%, rgba(164, 107, 255, .22) 0%, transparent 60%),
    linear-gradient(#0c051a, #12052a 60%, #07020f);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
h1, h2, h3, .tp-k, .pill, .btn { font-family: var(--display); letter-spacing: .03em; }
.led, .tp-big, .stat b, .timer, .blitz-time, .synccode, .calc-out { font-family: var(--mono); font-weight: 400; font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; cursor: pointer; }
sup { font-size: 0.65em; }

/* Flytande former i bakgrunden */
.bg { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.float { position: absolute; font-size: 64px; font-weight: 800; opacity: 0.08; color: #ff7ad1; font-family: var(--display); animation: drift 22s ease-in-out infinite; }
.s1 { left: 6%; top: 18%; } .s2 { left: 80%; top: 12%; animation-delay: -4s; font-size: 90px; }
.s3 { left: 70%; top: 70%; animation-delay: -8s; font-size: 120px; } .s4 { left: 12%; top: 75%; animation-delay: -12s; }
.s5 { left: 45%; top: 8%; animation-delay: -2s; } .s6 { left: 30%; top: 50%; animation-delay: -16s; font-size: 80px; }
.s7 { left: 88%; top: 45%; animation-delay: -6s; } .s8 { left: 55%; top: 85%; animation-delay: -10s; font-size: 70px; }
@keyframes drift { 0%, 100% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(30px, -40px) rotate(20deg); } }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  padding: 5px 16px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  background: rgba(12, 5, 26, 0.72); border-bottom: 1px solid transparent; border-image: var(--neon-edge) 1;
}
.brand { display: flex; align-items: center; background: none; border: 0; padding: 0; font-size: 1.25rem; }

/* Kromtiteln från Back to Lerum */
.chrome { display: inline-flex; flex-direction: column; align-items: center; line-height: .9; margin: 0; font-family: var(--display); font-weight: 900;
  transform: skewX(-10deg); filter: drop-shadow(0 2px 0 #4a1d00) drop-shadow(0 4px 0 #2a0f00) drop-shadow(0 0 22px rgba(255, 120, 30, .55)); }
.chrome .back { font-size: .3em; letter-spacing: .32em; margin-right: -.32em; text-transform: uppercase;
  background: linear-gradient(#fff4b0, #ffb300 45%, #ff4d00 60%, #b31b00); -webkit-background-clip: text; background-clip: text; color: transparent; }
.chrome .title { letter-spacing: .04em; text-transform: uppercase;
  background: linear-gradient(#ffffff 0%, #d9e1ea 40%, #59626f 48%, #1c2027 51%, #c5ced9 56%, #ffffff 72%, #8e98a6 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: .012em rgba(255, 190, 120, .85); }
.chrome.mini { filter: drop-shadow(0 1px 0 #4a1d00) drop-shadow(0 0 10px rgba(255, 120, 30, .5)); }

/* Startsidan */
.hub-hero { position: relative; text-align: center; padding: 26px 10px 40px; margin: -24px -18px 18px; overflow: hidden; }
.hub-hero .chrome { position: relative; font-size: clamp(56px, 13vw, 120px); }
.hub-hero p { position: relative; display: table; margin: 14px auto 0; padding: 4px 14px; border-radius: 99px; background: rgba(12, 5, 26, .78); border: 1px solid rgba(0, 229, 255, .45); font-family: var(--mono); color: #9ef6ff; letter-spacing: .12em; text-transform: uppercase; text-shadow: 0 0 8px rgba(0, 229, 255, .6); }
.sunset { position: absolute; inset: 0; pointer-events: none; }
.sunset .sun { position: absolute; left: 50%; bottom: 26%; width: min(60vw, 380px); aspect-ratio: 1; transform: translate(-50%, 50%); border-radius: 50%;
  background: linear-gradient(#fff3a8 0%, #ffcf3f 30%, #ff7a2f 58%, #ff2e88 85%); opacity: .85; box-shadow: 0 0 80px 10px rgba(255, 90, 140, .45);
  -webkit-mask: linear-gradient(#000 48%, transparent 48% 51%, #000 51% 58%, transparent 58% 62%, #000 62% 68%, transparent 68% 73.5%, #000 73.5% 78%, transparent 78%);
          mask: linear-gradient(#000 48%, transparent 48% 51%, #000 51% 58%, transparent 58% 62%, #000 62% 68%, transparent 68% 73.5%, #000 73.5% 78%, transparent 78%); }
.sunset .grid { position: absolute; left: -50%; right: -50%; bottom: 0; height: 26%; background: #0b0418; transform: perspective(200px) rotateX(55deg); transform-origin: 50% 100%;
  background-image: linear-gradient(rgba(255, 60, 200, .85) 2px, transparent 2px), linear-gradient(90deg, rgba(0, 240, 255, .75) 2px, transparent 2px);
  background-size: 50px 30px; -webkit-mask: linear-gradient(transparent, #000 35%); mask: linear-gradient(transparent, #000 35%); animation: gridrun 1.2s linear infinite; }
@keyframes gridrun { to { background-position: 0 30px; } }
.hubstats { margin-top: 0; }
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; margin-bottom: 18px; }
.subject { padding: 16px; border-radius: var(--radius); border: 1.5px solid transparent;
  background: linear-gradient(rgba(14, 6, 30, .92), rgba(14, 6, 30, .92)) padding-box, linear-gradient(135deg, var(--c), transparent 75%) border-box; }
.subject.soon { opacity: .55; padding: 12px 16px; }
.subject.soon .sj-head { margin: 0; }
.sj-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.sj-head h3 { margin: 0; color: var(--c); text-shadow: 0 0 10px color-mix(in srgb, var(--c) 60%, transparent); }
.sj-head small { color: var(--muted); font-size: .8rem; }
.sj-head .pill { margin-left: auto; }
.sj-ic { font-size: 1.6rem; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; background: color-mix(in srgb, var(--c) 18%, transparent); flex: none; }
.subject p { margin: 0; font-size: .9rem; }
.course { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: start; padding: 4px 2px 0; }
.cc-ic { font-size: 1.8rem; }
.cc-t { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cc-t b { font-family: var(--display); font-size: 1.15rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text); }
.cc-t small { color: var(--muted); font-weight: 600; }
.cc-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-family: var(--mono); font-size: .95rem; color: var(--text); }
.cc-btn { grid-column: 1 / -1; width: 100%; padding: 12px 14px; border: 0; border-radius: 12px; color: #1a0612; background: var(--hot);
  font-family: var(--display); font-size: 1rem; letter-spacing: .06em; text-transform: uppercase;
  box-shadow: 0 0 22px rgba(255, 106, 40, .45), inset 0 1px 0 rgba(255, 255, 255, .5); transition: transform .15s, box-shadow .15s; }
.cc-btn:hover { transform: translateY(-2px); box-shadow: 0 0 32px rgba(255, 106, 40, .75); }
.crumb { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.crumb .linkbtn { font-family: var(--display); font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; color: #9ef6ff; text-decoration: none; }
body.inhub .calc-fab, body.inhub .calc, body.inhub .fsheet, body.inhub .xpchip { display: none !important; }
.xpchip { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); }
.xpchip .rank { color: var(--text); font-weight: 700; }
.xpbar { width: 90px; height: 6px; border-radius: 99px; background: var(--card2); overflow: hidden; }
.xpbar i { display: block; height: 100%; background: var(--hot); border-radius: 99px; transition: width 0.6s; }

main { position: relative; z-index: 1; max-width: 1040px; margin: 0 auto; padding: 24px 18px 120px; }
.view { animation: rise 0.45s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Hero */
.hero { text-align: center; padding: 30px 10px 10px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: 1.05; margin: 0 0 12px; font-weight: 900; letter-spacing: -1px; }
.grad { background: linear-gradient(90deg, #00e5ff, #a46bff, #ff2e88, #ffd23f); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 8s linear infinite; }
@keyframes shimmer { to { background-position: 300% 0; } }
.hero p { color: var(--muted); font-size: 1.1rem; max-width: 620px; margin: 0 auto; }
.quote { margin: 22px auto 0; max-width: 640px; padding: 14px 18px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); font-style: italic; color: #e9e0ff; min-height: 54px; transition: opacity .4s; }

/* Kort */
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 30px 0; }
.mode {
  position: relative; overflow: hidden; text-align: left; padding: 22px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--card); transition: transform 0.2s, border-color 0.2s, background 0.2s; min-height: 160px;
}
.mode:hover { transform: translateY(-4px) scale(1.01); border-color: var(--accent2); background: rgba(0, 229, 255, .08); box-shadow: 0 0 18px rgba(0, 229, 255, .3); }
.mode .ic { font-size: 2.3rem; }
.mode h3 { margin: 8px 0 4px; font-size: 1.02rem; text-transform: uppercase; font-family: var(--display); letter-spacing: .04em; }
.mode p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.mode::after { content: ''; position: absolute; width: 180px; height: 180px; right: -60px; top: -60px; border-radius: 50%; background: var(--glow, #8b5cf6); opacity: 0.25; filter: blur(30px); }
.mode.primary { border: 1.5px solid transparent; background: linear-gradient(135deg, rgba(40, 10, 60, .95), rgba(14, 6, 30, .95)) padding-box, var(--neon-edge) border-box; box-shadow: 0 0 22px rgba(255, 46, 136, .25); }

h2.sec { font-size: 1.35rem; margin: 34px 0 14px; display: flex; align-items: center; gap: 10px; }
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.topic {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line);
  text-align: left; transition: transform .15s, background .15s;
}
.topic:hover { transform: translateY(-2px); background: var(--card2); }
.topic .ti { font-size: 1.6rem; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: color-mix(in srgb, var(--c) 25%, transparent); flex: none; }
.topic .tn { font-weight: 700; line-height: 1.2; }
.topic .tm { font-size: 0.8rem; color: var(--muted); }
.mastery { height: 6px; border-radius: 99px; background: var(--card2); margin-top: 6px; overflow: hidden; }
.mastery i { display: block; height: 100%; background: var(--c); border-radius: 99px; }
.topic.sel { outline: 2px solid var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); }
.topic .check { margin-left: auto; font-size: 1.2rem; opacity: 0.25; }
.topic.sel .check { opacity: 1; }

.badges { display: flex; flex-wrap: wrap; gap: 10px; }
.badge { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-size: 0.9rem; }
.badge.locked { opacity: 0.35; filter: grayscale(1); }
.badge.new { animation: pop .6s; border-color: var(--gold); box-shadow: 0 0 20px rgba(251, 191, 36, .4); }
@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* Formulär */
.panel { background: linear-gradient(rgba(14, 6, 30, .88), rgba(14, 6, 30, .88)) padding-box, var(--neon-edge) border-box; border: 1.5px solid transparent; border-radius: var(--radius); padding: 22px; margin-bottom: 18px; box-shadow: 0 0 18px rgba(255, 46, 136, .18), 0 0 34px rgba(0, 229, 255, .06); }
.panel h3 { margin: 0 0 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; transition: all .15s; }
.seg button.on { background: rgba(0, 229, 255, .16); border-color: var(--accent2); box-shadow: 0 0 14px rgba(0, 229, 255, .45); }
.seg button .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.btn {
  padding: 13px 22px; border-radius: 10px; border: 0; font-weight: 800; font-size: .95rem; text-transform: uppercase; color: #1a0612;
  background: var(--hot); box-shadow: 0 0 22px rgba(255, 106, 40, .5), inset 0 1px 0 rgba(255, 255, 255, .5); transition: transform .15s, filter .15s;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.btn:disabled { opacity: .5; transform: none; cursor: default; }
.btn.ghost { background: rgba(255, 255, 255, .05); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--accent2); box-shadow: 0 0 14px rgba(0, 229, 255, .35); }
.btn.good { background: linear-gradient(100deg, #3dff6e, #00e5ff); box-shadow: 0 0 22px rgba(61, 255, 110, .45); }
.btn.small { padding: 8px 14px; font-size: .9rem; }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 4px; }

/* Quiz */
.qhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.progress { flex: 1; min-width: 160px; height: 10px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--neon-m)); transition: width .4s; }
.pill { padding: 5px 12px; border-radius: 99px; font-size: .82rem; font-weight: 700; background: var(--card2); border: 1px solid var(--line); white-space: nowrap; }
.pill.lv { border-color: transparent; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; }
.timer.warn { color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.dots { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.dots button { width: 30px; height: 30px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: .8rem; font-weight: 700; }
.dots button.done { background: rgba(139, 92, 246, .35); }
.dots button.cur { outline: 2px solid var(--accent2); }

.qcard { background: linear-gradient(160deg, rgba(30, 12, 56, .95), rgba(14, 6, 30, .95)) padding-box, var(--neon-edge) border-box; border: 1.5px solid transparent; border-radius: 26px; padding: 26px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.qmeta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: .9rem; margin-bottom: 10px; flex-wrap: wrap; }
.qtext { font-size: 1.25rem; line-height: 1.55; margin-bottom: 16px; }
.qtext .stmt { display: inline-block; margin-top: 10px; padding: 12px 16px; border-radius: 14px; background: rgba(251, 191, 36, .12); border: 1px solid rgba(251, 191, 36, .35); font-size: 1.3rem; }
.qbody { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: center; }
.qbody.hasfig { grid-template-columns: minmax(0, 1fr) minmax(200px, 300px); }
.fig { overflow: visible; width: 100%; max-width: 300px; height: auto; display: block; margin: 0 auto; filter: drop-shadow(0 10px 25px rgba(0, 0, 0, .35)); }
.fig .shape { stroke: #e0e7ff; stroke-width: 2.2; stroke-linejoin: round; }
.fig .dim { stroke: #fde68a; stroke-width: 2; }
.fig .dimDark { stroke: #7c2d12; stroke-width: 2; }
.fig .dash { stroke: #c7d2fe; stroke-width: 1.6; stroke-dasharray: 5 5; fill: none; }
.fig .thin { stroke: #e0e7ff; stroke-width: 1.4; fill: none; }
.fig .cross { stroke: #fb7185; stroke-width: 2.4; }
.fig .lbl { fill: #fde68a; font: 700 15px var(--font); paint-order: stroke; stroke: rgba(11, 16, 38, .85); stroke-width: 4px; }
.fig .lbl.small { font-size: 13px; }
.fig .lbl.dark { fill: #7c2d12; stroke: none; }
.fig .emoji { font-size: 34px; }

.answer { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.inputwrap { display: flex; align-items: center; flex: 1; min-width: 200px; background: rgba(0,0,0,.25); border: 2px solid var(--line); border-radius: 16px; padding: 0 14px; transition: border-color .2s, box-shadow .2s; }
.inputwrap:focus-within { border-color: var(--accent2); box-shadow: 0 0 0 4px rgba(34, 211, 238, .15); }
.inputwrap input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font-size: 1.4rem; font-weight: 700; padding: 12px 0; font-family: var(--font); }
.inputwrap .unit { color: var(--muted); font-weight: 700; font-size: 1.1rem; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; width: 100%; }
.choice { padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line); background: rgba(0,0,0,.2); font-size: 1.1rem; font-weight: 700; text-align: left; transition: all .15s; }
.choice:hover { border-color: rgba(255,255,255,.4); }
.choice.on { border-color: var(--accent2); background: rgba(34, 211, 238, .14); }
.choice.right { border-color: var(--good); background: rgba(34, 197, 94, .2); }
.choice.wrong { border-color: var(--bad); background: rgba(244, 63, 94, .2); }
.order { width: 100%; }
.order .pool, .order .picked { display: flex; flex-wrap: wrap; gap: 10px; min-height: 54px; padding: 10px; border-radius: 14px; }
.order .picked { border: 2px dashed var(--line); margin-bottom: 10px; }
.order .picked:empty::before { content: 'Klicka på värdena nedan i rätt ordning…'; color: var(--muted); align-self: center; }
.chip { padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: rgba(167, 139, 250, .18); font-weight: 800; font-size: 1.1rem; }
.chip .n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); font-size: .75rem; margin-right: 6px; }

.actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 20px; flex-wrap: wrap; }
.hintbox, .feedback { margin-top: 16px; padding: 14px 18px; border-radius: 16px; animation: rise .3s; }
.hintbox { background: rgba(251, 191, 36, .1); border: 1px solid rgba(251, 191, 36, .35); }
.reviewnote { margin-top: 12px; padding: 12px 16px; border-radius: 14px; background: rgba(45, 212, 191, .1); border: 1px solid rgba(45, 212, 191, .4); animation: rise .3s; }
.misconception { margin-top: 10px; padding: 10px 14px; border-radius: 12px; background: rgba(251, 191, 36, .12); border: 1px solid rgba(251, 191, 36, .45); color: #fff3c4; }
.feedback.ok { background: rgba(34, 197, 94, .14); border: 1px solid rgba(34, 197, 94, .45); }
.feedback.no { background: rgba(244, 63, 94, .12); border: 1px solid rgba(244, 63, 94, .45); }
.feedback .big { font-size: 1.3rem; font-weight: 900; }
.sol { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); color: #dbe2ff; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.streak { font-weight: 800; color: var(--gold); }

/* Resultat */
.result-hero { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center; }
.ring { width: 170px; height: 170px; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .val { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .val b { font-size: 2.3rem; display: block; line-height: 1; }
.grade { font-size: 4rem; font-weight: 900; line-height: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: .85rem; }
.review { display: grid; gap: 12px; }
.ritem { padding: 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--good); }
.ritem.no { border-left-color: var(--bad); }
.ritem .rq { font-weight: 600; }
.ritem .ra { margin-top: 6px; color: var(--muted); }
.ritem details { margin-top: 6px; }
.ritem summary { cursor: pointer; color: var(--accent2); font-weight: 700; }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 200px 1fr 60px; gap: 10px; align-items: center; font-size: .92rem; }
.bar .track { height: 12px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.bar .track i { display: block; height: 100%; border-radius: 99px; }

/* Formelsamling */
.formulas { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.fcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.fcard h3 { margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }
.fcard .f { font-size: 1.15rem; font-weight: 800; padding: 8px 12px; margin: 6px 0; border-radius: 12px; background: rgba(164, 107, 255, .16); border: 1px solid rgba(164, 107, 255, .45); display: inline-block; }
.fcard p { margin: 4px 0; color: #d4daf5; }
.fcard .fig { max-width: 180px; margin: 6px 0; }

/* Blixt */
.blitz-time { font-size: 3rem; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; }

/* Miniräknare */
.calc-fab { position: fixed; right: 18px; bottom: 18px; z-index: 20; width: 58px; height: 58px; border-radius: 50%; border: 1.5px solid var(--accent2); background: rgba(14, 6, 30, .92); font-size: 1.6rem; box-shadow: 0 0 16px rgba(0, 229, 255, .45); }
.form-fab { bottom: 88px; border-color: var(--neon-m); box-shadow: 0 0 16px rgba(255, 46, 136, .5); }
.fsheet { position: fixed; inset: 0; z-index: 30; background: rgba(5, 8, 25, .55); display: flex; justify-content: flex-end; }
.fsheet[hidden] { display: none; }
.fsheet-panel { width: min(460px, 100%); height: 100%; display: flex; flex-direction: column; background: rgba(17, 22, 50, .98); border-left: 1px solid var(--line); box-shadow: -20px 0 60px rgba(0,0,0,.5); animation: slidein .25s; padding-top: env(safe-area-inset-top); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.fsheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 1.15rem; }
.fsheet-head .muted { font-size: .95rem; }
.fsheet-head button { margin-left: auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card2); }
.fsheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); }
.fsheet-body .formulas { grid-template-columns: 1fr; }
.calc { position: fixed; right: 18px; bottom: 158px; z-index: 21; width: 290px; padding: 14px; border-radius: 20px; background: rgba(17, 22, 50, .97); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: rise .25s; }
.calc-head { display: flex; justify-content: space-between; font-weight: 800; margin-bottom: 8px; }
.calc-head button { background: none; border: 0; }
.calc input { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.3); color: var(--text); font-size: 1.1rem; font-family: ui-monospace, monospace; }
.calc-out { text-align: right; font-size: 1.5rem; font-weight: 800; margin: 6px 2px 10px; min-height: 36px; color: var(--accent2); overflow-wrap: anywhere; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc-keys button { padding: 10px 0; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); font-weight: 700; font-size: 1.05rem; }
.calc-keys .k-eq { grid-column: span 2; background: var(--hot); color: #1a0612; }
.calc-keys .k-c { background: rgba(244, 63, 94, .3); }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; width: 100%; height: 100%; }
.muted { color: var(--muted); }
.center { text-align: center; }
.fact { font-size: .95rem; color: var(--muted); }
kbd { background: var(--card2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: .85em; }

@media (max-width: 720px) {
  .qbody.hasfig { grid-template-columns: 1fr; }
  .qbody.hasfig .figwrap { order: -1; }
  .fig { max-width: 240px; }
  .qcard { padding: 18px; }
  .qtext { font-size: 1.1rem; }
  .result-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .bar { grid-template-columns: 120px 1fr 48px; }
  .xpbar { width: 60px; }
  .xpchip .rank { display: none; }
  .brand { font-size: 1.1rem; }
  .hub-hero p { font-size: .78rem; letter-spacing: .06em; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print {
  .topbar, .calc-fab, .fsheet, .bg, .actions, .btn { display: none !important; }
  body { background: #fff; color: #000; }
}

/* Kladdpapper & Apple Pencil */
.padslot { margin-top: 18px; }
.pad { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: rgba(0, 0, 0, .28); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.padbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 10px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .04); }
.padtitle { font-weight: 800; margin-right: auto; font-size: .95rem; }
.padbar button { min-width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 1rem; }
.padbar button.on { border-color: var(--accent2); background: rgba(34, 211, 238, .18); }
.padbar .pc { width: 32px; min-width: 32px; height: 32px; border-radius: 50%; background: var(--pc); border: 3px solid transparent; }
.padbar .pc.on { background: var(--pc); border-color: #fff; box-shadow: 0 0 0 2px var(--accent2); }
.pad canvas { display: block; width: 100%; height: 280px; touch-action: none; cursor: crosshair; }
.pad.tall canvas { height: 560px; }
.pad.grid canvas { background-image: linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px); background-size: 24px 24px; }
.padhint { font-size: .8rem; color: var(--muted); padding: 6px 12px; border-top: 1px solid var(--line); }
.inkimg { display: block; max-width: 100%; max-height: 320px; margin-top: 8px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); }
.circlewrap { position: relative; border-radius: 26px; border: 1px solid var(--line); background: radial-gradient(circle at 50% 50%, rgba(139, 92, 246, .15), rgba(0, 0, 0, .3)); overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.circlewrap canvas { display: block; width: 100%; height: min(70vh, 560px); touch-action: none; cursor: crosshair; }
.ccmsg { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; font-size: 1.6rem; font-weight: 800; color: var(--muted); transition: opacity .3s; }

/* Ritprov */
.boardwrap { max-width: 760px; margin: 6px auto 0; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
.board { display: block; width: 100%; height: auto; border-radius: 18px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); }
.board .gl { stroke: rgba(255, 255, 255, .08); stroke-width: .03; }
.board .gd { fill: rgba(255, 255, 255, .35); }
.board .given { fill: rgba(56, 189, 248, .22); stroke: #38bdf8; stroke-width: .08; }
.board circle.given { fill: rgba(56, 189, 248, .07); }
.board .gdot { fill: #fb7185; }
.board .glbl { font: 700 .6px var(--font); fill: #bae6fd; text-anchor: middle; }
.board .upoly { fill: rgba(167, 139, 250, .35); stroke: #c4b5fd; stroke-width: .1; stroke-linejoin: round; }
.board .uline, .board .ufree { fill: none; stroke: #c4b5fd; stroke-width: .13; stroke-linecap: round; stroke-linejoin: round; }
.board .uv { fill: #fff; stroke: #8b5cf6; stroke-width: .07; }
.board .uv.first { fill: #fbbf24; }
.board .hov { stroke: #c4b5fd; stroke-width: .06; stroke-dasharray: .2 .15; }
.board .ex { fill: rgba(34, 197, 94, .16); stroke: #4ade80; stroke-width: .1; stroke-dasharray: .3 .2; }
.board .exl { fill: none; stroke: #4ade80; stroke-width: .12; stroke-dasharray: .3 .2; }

/* ---------- Dagspanel ---------- */
.todaypanel { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin: 26px 0 14px; }
.tp-cell { background: rgba(14, 6, 30, .75); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.tp-k { color: #9ef6ff; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
.tp-big { font-size: 1.9rem; line-height: 1.1; color: #ffd23f; text-shadow: 0 0 10px rgba(255, 210, 63, .45); }
.tp-big small { font-size: .9rem; color: var(--muted); font-weight: 600; }
.tp-s { color: var(--muted); font-size: .85rem; }
.seg.mini { gap: 4px; margin-top: 6px; flex-wrap: nowrap; }
.seg.mini button { padding: 4px 9px; font-size: .78rem; border-radius: 8px; }
.week { display: flex; gap: 5px; margin: 4px 0 2px; }
.week span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; font-weight: 800; background: rgba(255, 255, 255, .07); color: var(--muted); }
.week span.on { background: var(--hot); color: #1a0612; }
.week span.today { outline: 2px solid rgba(255, 255, 255, .5); outline-offset: 1px; }
.mastery.big { height: 10px; margin-top: 4px; }
.mastery.big i { background: linear-gradient(90deg, #ff2e88, #ffd23f, #3dff6e); }
.daterow { display: flex; gap: 8px; align-items: stretch; }
.dateinp { flex: 1; min-width: 0; min-height: 44px; -webkit-appearance: none; appearance: none; background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 16px; color-scheme: dark; }
.dateinp::-webkit-date-and-time-value { text-align: left; }

/* ---------- Formelkort ---------- */
.flashwrap { perspective: 1200px; display: flex; justify-content: center; margin: 20px 0; }
.flashcard { position: relative; width: min(520px, 100%); height: 300px; border: 0; padding: 0; background: none; color: inherit; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.2, .8, .2, 1); cursor: pointer; }
.flashcard.flip { transform: rotateY(180deg); }
.fside { position: absolute; inset: 0; border-radius: 22px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; border: 1px solid var(--line); }
.fside.front { background: linear-gradient(135deg, rgba(164, 107, 255, .35), rgba(255, 46, 136, .2)); }
.fside.back { background: linear-gradient(135deg, rgba(34, 197, 94, .3), rgba(45, 212, 191, .18)); transform: rotateY(180deg); }
.fic { font-size: 2.6rem; }
.fq { font-size: 1.5rem; font-weight: 800; text-align: center; }
.fa { font-size: 2rem; font-weight: 800; text-align: center; font-family: 'Georgia', serif; }
.fa small { display: block; font-size: 1rem; color: var(--muted); font-family: inherit; font-weight: 600; margin-top: 8px; }
.fhint { font-size: .85rem; }

/* ---------- Synk ---------- */
.syncpanel { position: relative; margin: 6px 0 0; padding-right: 50px; }
.syncx { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--card2); color: var(--muted); font-size: 1rem; cursor: pointer; }
.syncx:hover { color: var(--text); }
.syncjoin { display: flex; gap: 6px; }
.syncjoin input { background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; width: 170px; text-transform: uppercase; letter-spacing: 1px; }
.synccode { font-size: 1.3rem; letter-spacing: 2px; color: #3dff6e; text-shadow: 0 0 8px rgba(61, 255, 110, .6); user-select: all; -webkit-user-select: all; }

/* Bokprovet */
.secbanner { margin: 0 0 12px; padding: 10px 16px; border-radius: 14px; font-weight: 800; letter-spacing: .3px;
  background: linear-gradient(90deg, rgba(232, 121, 249, .22), rgba(34, 211, 238, .12)); border: 1px solid rgba(232, 121, 249, .4); }
.secrow { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.secrow:last-child { border-bottom: 0; }
.secrow .muted { font-size: .85rem; }
.stmt { display: inline-block; margin-top: 8px; padding: 8px 14px; border-radius: 10px; background: var(--card2); font-weight: 700; }

/* Belöningar */
.rewards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 12px; }
.reward { padding: 14px; border-radius: 16px; background: var(--card2); border: 1px solid var(--line); }
.reward.ready { border-color: var(--gold); box-shadow: 0 0 24px rgba(251, 191, 36, .35); animation: pop .6s; }
.reward.done { opacity: .6; }
.rw-t { font-weight: 800; font-size: 1.1rem; margin-bottom: 6px; }
.rw-s { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .9rem; color: var(--muted); margin-top: 8px; }
.rw-s b { color: var(--text); }
.rewardpanel.empty { border-style: dashed; }
.rwinp, .pininp { width: 100%; background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font: inherit; font-size: 1.1rem; }
.rwinp.small { width: 110px; }
.pininp { max-width: 220px; display: block; margin-bottom: 10px; letter-spacing: 6px; font-size: 1.4rem; text-align: center; }
.rw-c { display: block; margin-top: 2px; font-family: var(--mono); font-size: .8rem; font-weight: 400; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chips .chip { font-size: .95rem; padding: 8px 12px; cursor: pointer; color: var(--text); }

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

/* Bekräftelse-modal (nollställ) */
.modal-bg { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(5, 8, 24, .75); }
.modal { width: 100%; max-width: 400px; padding: 22px; border-radius: var(--radius); background: var(--bg2); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.modal h3 { margin: 0 0 10px; }
.modal p { margin: 0 0 14px; color: var(--muted); }
.modal input { width: 100%; box-sizing: border-box; padding: 12px; margin-bottom: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 1rem; text-align: center; }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; }
.btn.danger { background: linear-gradient(135deg, #e11d48, #f43f5e); box-shadow: 0 8px 24px rgba(244, 63, 94, .35); }

/* Tillgänglighet: synlig fokusmarkering för tangentbord, läsbara textstorlekar och skärmläsartext */
:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
.inputwrap input:focus-visible { outline: 0; }
input, select, textarea { font-size: max(16px, 1em); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .float { display: none; } }
