/* Repàs LMSGI · estil "Rack" (coherent amb ASIXC Hub) */
:root {
  --bg: #12171b;
  --surface: #1a2126;
  --surface-2: #222b31;
  --line: #2f3a41;
  --text: #e4eae7;
  --muted: #9aa8a3;
  --amber: #f2b33d;
  --amber-ink: #1a1200;
  --brown: #b07a4f;          /* cable del mòdul 0373 */
  --ra1: #5b8def;            /* parell blau */
  --ra2: #f08a3c;            /* parell taronja */
  --ra3: #3fb57f;            /* parell verd */
  --ok: #4fd18b;
  --ok-bg: rgba(79, 209, 139, .12);
  --ko: #ff7b72;
  --ko-bg: rgba(255, 123, 114, .12);
  --focus: #f2b33d;
  --radius: 14px;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #eef1f0;
  --surface: #ffffff;
  --surface-2: #f4f6f5;
  --line: #d6dddb;
  --text: #16201d;
  --muted: #4e5b57;
  --amber: #9a5b00;
  --amber-ink: #ffffff;
  --brown: #8a5a33;
  --ra1: #2f63c9;
  --ra2: #b9581a;
  --ra3: #1f7f54;
  --ok: #157a46;
  --ok-bg: #e3f4ea;
  --ko: #b3261e;
  --ko-bg: #fdeceb;
  --focus: #9a5b00;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 .8em; }
a { color: var(--amber); }
code, pre, .mono { font-family: var(--mono); }
code { font-size: .9em; background: var(--surface-2); border: 1px solid var(--line); padding: .05em .35em; border-radius: 6px; }
pre {
  margin: .6em 0 1em; padding: 14px 16px; overflow-x: auto;
  background: #0d1114; color: #e4eae7; border: 1px solid var(--line); border-radius: 10px;
  font-size: .88rem; line-height: 1.6; tab-size: 2;
}
[data-theme="light"] pre { background: #17201d; color: #eef3f1; }
pre code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* ---------- Barra superior ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 980px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; margin-right: auto; }
.brand .port { width: 26px; height: 22px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); position: relative; }
.brand .port::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: 3px; height: 7px; border-radius: 2px; background: var(--brown); }
.brand .port::before { content: ""; position: absolute; right: 3px; top: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.brand small { font-family: var(--mono); color: var(--muted); font-weight: 500; }
.hub-back { font-size: .9rem; text-decoration: none; color: var(--muted); padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
.hub-back:hover { color: var(--text); background: var(--surface-2); }
.icon-btn {
  min-width: 44px; min-height: 44px; display: inline-grid; place-items: center;
  background: none; border: 1px solid var(--line); color: var(--text); border-radius: 10px; cursor: pointer; font: inherit;
}
.icon-btn:hover { background: var(--surface-2); }

.nav { max-width: 980px; margin: 0 auto; padding: 0 12px 8px; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: none; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .95rem;
  padding: 8px 12px; border-radius: 999px; min-height: 40px; display: inline-flex; align-items: center;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--amber-ink); background: var(--amber); }

main { max-width: 980px; margin: 0 auto; padding: 22px 16px 90px; }
.screen-title:focus { outline: none; }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.grid { display: grid; gap: 14px; }
.grid > *, .split > *, .card { min-width: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

.btn {
  font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: 12px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  transition: transform .08s ease, background .15s ease;
}
.btn:hover { background: var(--line); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: none; }
.btn.danger { color: var(--ko); border-color: color-mix(in srgb, var(--ko) 50%, transparent); background: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ra1 { --c: var(--ra1); } .ra2 { --c: var(--ra2); } .ra3 { --c: var(--ra3); }
.chip.ra1, .chip.ra2, .chip.ra3 { color: var(--c); border-color: color-mix(in srgb, var(--c) 45%, transparent); }

/* ---------- Inici ---------- */
.hero {
  position: relative; overflow: hidden;
  background: radial-gradient(1200px 300px at 100% -20%, color-mix(in srgb, var(--brown) 30%, transparent), transparent),
              var(--surface);
  border: 1px solid var(--line); border-radius: 18px; padding: 24px;
}
.hero .kicker { font-family: var(--mono); color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
.count { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0 6px; }
.count .box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; min-width: 170px; }
.count .num { font-size: 2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.count .lbl { color: var(--muted); font-size: .88rem; }
.count .box.amber .num { color: var(--amber); }

.levelbar { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.xpbar { flex: 1; min-width: 160px; height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.xpbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brown), var(--amber)); border-radius: 999px; transition: width .4s ease; }

.actions { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-top: 18px; }
.action {
  font: inherit; text-align: left; cursor: pointer; text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); position: relative;
  transition: border-color .15s ease, transform .1s ease;
}
.action:hover { border-color: var(--amber); }
.action:active { transform: scale(.99); }
.action .ico { font-size: 1.5rem; line-height: 1; }
.action .t { font-weight: 800; font-size: 1.08rem; }
.action .d { color: var(--muted); font-size: .92rem; }
.action.featured { border-color: color-mix(in srgb, var(--amber) 60%, var(--line)); background: color-mix(in srgb, var(--amber) 8%, var(--surface)); }
.action .tag { position: absolute; top: 14px; right: 14px; }

.ra-progress { display: grid; gap: 12px; }
.ra-progress .r { display: grid; grid-template-columns: 70px 1fr 54px; gap: 12px; align-items: center; }
.ra-progress .lab { font-family: var(--mono); font-weight: 700; color: var(--c); }
.bar { height: 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--c, var(--amber)); border-radius: 999px; transition: width .4s ease; }
.ra-progress .pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- Pestanyes ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 18px; }
.tab {
  font: inherit; font-weight: 700; cursor: pointer; min-height: 42px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.tab[aria-selected="true"] { color: var(--amber-ink); background: var(--amber); border-color: var(--amber); }

/* ---------- Fitxes ---------- */
.topic { border-left: 4px solid var(--c); }
.topic ul { margin: .4em 0 0; padding-left: 1.1em; }
.topic li { margin: .35em 0; }
.topic .row { margin-top: 12px; }

/* ---------- Pregunta ---------- */
.qhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 18px; }
.progress > span { display: block; height: 100%; background: var(--amber); transition: width .3s ease; }
.qtext { font-size: 1.18rem; font-weight: 700; margin-bottom: 16px; }
.qtext pre { font-weight: 400; }
.options { display: grid; gap: 10px; }
.opt {
  font: inherit; text-align: left; cursor: pointer; width: 100%;
  display: flex; align-items: flex-start; gap: 12px; min-height: 54px; padding: 12px 14px;
  background: var(--surface); color: var(--text); border: 2px solid var(--line); border-radius: 12px;
  transition: border-color .12s ease, background .12s ease;
}
.opt:hover:not(:disabled) { border-color: var(--amber); }
.opt:disabled { cursor: default; }
.opt .k {
  flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line); font: 700 .85rem var(--mono); color: var(--muted); margin-top: 1px;
}
.opt .v { overflow-wrap: anywhere; }
.opt.sel { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 10%, var(--surface)); }
.opt.correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.wrong { border-color: var(--ko); background: var(--ko-bg); }
.opt.correct .k { background: var(--ok); color: #fff; border-color: var(--ok); }
.opt.wrong .k { background: var(--ko); color: #fff; border-color: var(--ko); }

.feedback { margin-top: 14px; border-radius: 12px; padding: 14px 16px; border: 1px solid var(--line); background: var(--surface-2); }
.feedback.ok { border-color: var(--ok); background: var(--ok-bg); }
.feedback.ko { border-color: var(--ko); background: var(--ko-bg); }
.feedback .ft { font-weight: 800; display: block; margin-bottom: 4px; }
.feedback.ok .ft { color: var(--ok); }
.feedback.ko .ft { color: var(--ko); }
.kbd-help { color: var(--muted); font-size: .85rem; margin-top: 14px; }
kbd { font: 700 .78rem var(--mono); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface-2); }

.score-big { font-size: clamp(3rem, 12vw, 5rem); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.review { display: grid; gap: 10px; margin-top: 16px; }
.review .it { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.review .it.ko { border-color: color-mix(in srgb, var(--ko) 55%, var(--line)); }
.review .it.ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }

/* Simulacre */
.timer { font: 800 1.2rem var(--mono); font-variant-numeric: tabular-nums; padding: 6px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.timer.low { color: var(--ko); border-color: var(--ko); }
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; margin-top: 14px; }
.qgrid button {
  font: 700 .9rem var(--mono); min-height: 42px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.qgrid button.done { background: color-mix(in srgb, var(--amber) 18%, var(--surface)); color: var(--text); border-color: color-mix(in srgb, var(--amber) 50%, var(--line)); }
.qgrid button.cur { outline: 3px solid var(--amber); outline-offset: 1px; }

/* Teoria */
textarea, input[type="text"] {
  font: inherit; width: 100%; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
textarea { min-height: 180px; resize: vertical; line-height: 1.55; font-size: 16px; }
textarea.code, .code-input { font-family: var(--mono); font-size: 14px; line-height: 1.55; white-space: pre; tab-size: 2; }
.checklist { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; }
.checklist label {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
.checklist input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--ok); flex: none; }
.checklist .auto { font-size: .78rem; color: var(--ok); font-weight: 700; margin-left: auto; white-space: nowrap; }
.model { border-left: 4px solid var(--amber); background: var(--surface-2); padding: 14px 16px; border-radius: 0 12px 12px 0; }
.tq { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.tq:hover { border-color: var(--amber); }
.tq .st { margin-left: auto; flex: none; font: 700 .85rem var(--mono); color: var(--muted); }
.tq .st.good { color: var(--ok); }

/* Laboratori */
.codeview { margin: 0; }
.codeview .ln { display: block; padding: 0 6px; margin: 0 -6px; border-radius: 6px; cursor: default; }
.codeview .ln.hit { background: color-mix(in srgb, var(--amber) 28%, transparent); box-shadow: inset 3px 0 0 var(--amber); }
.codeview .ln.click { cursor: pointer; }
.codeview .ln.click:hover { background: rgba(255,255,255,.06); }
.status { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); margin-top: 10px; }
.status.ok { border-color: var(--ok); background: var(--ok-bg); }
.status.ko { border-color: var(--ko); background: var(--ko-bg); }
.status .sym { font-weight: 900; }
.status.ok .sym { color: var(--ok); }
.status.ko .sym { color: var(--ko); }
.verdict { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.errlist { margin: 6px 0 0; padding-left: 1.1em; }
.split { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* Targetes */
.flash { perspective: 1000px; }
.flash-inner {
  position: relative; min-height: 220px; cursor: pointer; transform-style: preserve-3d; transition: transform .45s ease;
}
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: grid; place-items: center; text-align: center; padding: 24px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--line); font-size: 1.3rem; font-weight: 800;
}
.face.back { transform: rotateY(180deg); font-weight: 500; font-size: 1.1rem; background: var(--surface-2); }

/* Toast i confeti */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); font-weight: 700; padding: 10px 16px; border-radius: 12px;
  transition: all .25s ease; z-index: 50; pointer-events: none; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .9; } }

.pop { animation: pop .25s ease; }
@keyframes pop { 0% { transform: scale(.98); } 60% { transform: scale(1.01); } 100% { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .card { padding: 16px; }
  .hero { padding: 18px; }
  .count .box { min-width: 0; flex: 1; }
  .qtext { font-size: 1.06rem; }
  .hub-back .full { display: none; }
  .verdict { grid-template-columns: 1fr; }
}

/* resaltat de la vista de codi */
.codeview .tg{color:var(--ra1,#5b8def);font-weight:600}
.codeview .an{color:var(--ra2,#f08a3c)}
.codeview .av{color:var(--ra3,#3fb57f)}
.codeview .ln.hit .tg,.codeview .ln.hit .an,.codeview .ln.hit .av{color:inherit}
:not(pre) > code { overflow-wrap: anywhere; }
