:root {
  --navy: #10233c;
  --blue: #1b3a63;
  --blue-live: #3d7fca;
  --orange: #ff6b35;
  --orange-text: #c9451a;
  --cream: #f7f1e7;
  --paper: #fffdf8;
  --muted: #637285;
  --line: rgba(27, 58, 99, .18);
  --green: #1e7e54;
  --green-bg: #e3f5ec;
  --red: #c0392b;
  --red-bg: #fbe7e4;
  --amber: #b06a00;
  --amber-bg: #fff4e0;
  --shadow: 0 16px 42px rgba(27, 58, 99, .13);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
[hidden] { display: none !important; }
body {
  background: var(--cream);
  color: var(--navy);
  font-family: Calibri, "Segoe UI", system-ui, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
button, a { font: inherit; }
button { cursor: pointer; }
.skip-link { position: fixed; top: -60px; left: 10px; z-index: 99; background: var(--paper); color: var(--blue); padding: 10px 14px; border: 2px solid var(--orange); border-radius: 10px; }
.skip-link:focus { top: 10px; }
:focus-visible { outline: 3px solid rgba(255, 107, 53, .48); outline-offset: 3px; }

.appbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px clamp(10px, 2vw, 24px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--blue); text-decoration: none; min-width: 0; }
.brand-mark { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; background: var(--blue); color: #fff; font-family: "Trebuchet MS", Calibri, Arial, sans-serif; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: .78rem; }
.app-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.draft-badge, .mode-badge { border-radius: 999px; padding: 5px 9px; font-size: .72rem; font-weight: 800; letter-spacing: .04em; }
.draft-badge { border: 2px dashed var(--amber); color: var(--amber); background: var(--amber-bg); }
.mode-badge { border: 1px solid var(--line); color: var(--blue); background: var(--cream); }
.small-button, .back-link { border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--blue); padding: 7px 12px; font-weight: 800; }

main { min-height: calc(100dvh - 64px); }
h1, h2, h3 { font-family: "Trebuchet MS", Calibri, Arial, sans-serif; color: var(--blue); margin-top: 0; }
.eyebrow { margin: 0 0 6px; color: var(--orange-text); font-size: .76rem; font-weight: 900; letter-spacing: .14em; }

.catalogue { min-height: calc(100dvh - 64px); padding: clamp(14px, 2.5vh, 28px) clamp(12px, 3vw, 42px); display: grid; grid-template-rows: auto 1fr auto; gap: clamp(10px, 2vh, 20px); overflow: hidden; }
.catalogue-head { text-align: center; max-width: 780px; margin: 0 auto; }
.catalogue-head h1 { font-size: clamp(1.8rem, 4vw, 3.3rem); line-height: .98; margin-bottom: 10px; }
.catalogue-head h1 span { color: var(--orange-text); }
.catalogue-head > p:last-child { margin: 0; color: var(--muted); font-size: clamp(.94rem, 1.5vw, 1.08rem); }
.fiche-grid { width: min(1120px, 100%); margin: 0 auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: clamp(8px, 1.4vw, 16px); min-height: 0; }
.fiche-card { min-height: 0; text-align: left; border: 1px solid var(--line); border-left: 6px solid var(--blue-live); border-radius: 18px; background: var(--paper); box-shadow: 0 5px 16px rgba(27, 58, 99, .08); padding: clamp(10px, 1.4vw, 17px); color: var(--navy); display: grid; grid-template-columns: auto 1fr; gap: 10px; align-content: center; }
.fiche-card:hover { transform: translateY(-2px); border-color: var(--orange); }
.fiche-number { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--blue); color: #fff; font-weight: 900; }
.fiche-card strong { display: block; color: var(--blue); font-family: "Trebuchet MS", Calibri, Arial, sans-serif; font-size: clamp(.94rem, 1.45vw, 1.16rem); line-height: 1.08; }
.fiche-card small { display: block; margin-top: 5px; color: var(--muted); line-height: 1.2; }
.fiche-card .steps { margin-top: 7px; color: var(--green); font-size: .76rem; font-weight: 800; }
.catalogue-note { margin: 0 auto; max-width: 900px; color: var(--muted); text-align: center; font-size: .82rem; }

.fiche-intro { min-height: calc(100dvh - 64px); display: grid; place-items: center; padding: 18px; overflow: hidden; }
.intro-card { width: min(980px, 100%); max-height: calc(100dvh - 94px); overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: clamp(18px, 3vw, 34px); }
.intro-card h1 { font-size: clamp(1.7rem, 3.5vw, 3rem); line-height: 1; margin: 14px 0 10px; }
.fiche-purpose { color: var(--muted); font-size: 1.08rem; max-width: 760px; }
.source-note { border-left: 5px solid var(--blue-live); padding: 9px 12px; background: #f3f7fb; border-radius: 0 12px 12px 0; }
.source-note strong { color: var(--blue); }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.mode-card { border: 2px solid var(--line); border-radius: 16px; background: var(--paper); color: var(--navy); padding: 14px; text-align: left; }
.mode-card span { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 900; margin-bottom: 8px; }
.mode-card strong, .mode-card small { display: block; }
.mode-card strong { color: var(--blue); font-size: 1.05rem; }
.mode-card small { color: var(--muted); margin-top: 4px; }
.mode-card:hover { border-color: var(--orange); transform: translateY(-2px); }
.open-points { margin-top: 16px; padding: 10px 13px; border: 2px dotted var(--amber); border-radius: 12px; background: var(--amber-bg); color: #714600; }
.open-points strong { display: block; }
.open-points ul { margin: 5px 0 0; padding-left: 20px; }

.trainer { height: calc(100dvh - 64px); overflow: hidden; padding: 8px 10px; display: grid; grid-template-rows: 42px minmax(0, 1fr) 54px; gap: 8px; }
.trainer-progress { display: grid; grid-template-columns: minmax(220px, auto) minmax(180px, 1fr); align-items: center; gap: 16px; padding: 0 8px; }
.trainer-progress strong { color: var(--blue); }
.trainer-progress span { margin-left: 8px; color: var(--muted); font-size: .86rem; }
.progress-track { height: 9px; border-radius: 999px; background: rgba(27, 58, 99, .12); overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; margin: 0; background: var(--orange); transition: width .2s ease; }
.trainer-grid { min-height: 0; display: grid; grid-template-columns: minmax(300px, .78fr) minmax(0, 1.55fr); gap: 9px; }
.instruction, .stage { min-height: 0; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; }
.instruction { padding: clamp(12px, 1.8vw, 22px); display: flex; flex-direction: column; }
.action-source { color: var(--orange-text); font-weight: 900; font-size: .76rem; letter-spacing: .08em; margin: 0 0 5px; }
.instruction h1 { font-size: clamp(1.35rem, 2.2vw, 2.15rem); line-height: 1.04; margin-bottom: 10px; }
.action-block { border-left: 5px solid var(--blue-live); padding: 6px 9px; margin-bottom: 7px; background: #f3f7fb; border-radius: 0 10px 10px 0; }
.action-block.act { border-left-color: var(--orange-text); background: #fff1eb; }
.action-block.check { border-left-style: double; border-left-width: 6px; border-left-color: var(--green); background: var(--green-bg); }
.action-block strong, .why-block strong { color: var(--blue); }
.action-block p, .why-block p { margin: 1px 0 0; line-height: 1.25; }
.why-block { margin-top: auto; border-top: 1px dashed var(--line); padding-top: 8px; }
.help-button { align-self: flex-start; margin-top: 8px; border: 2px solid var(--orange); border-radius: 999px; background: var(--paper); color: var(--orange-text); padding: 7px 13px; font-weight: 900; }
.stage { display: grid; grid-template-rows: 40px minmax(0, 1fr) auto; }
.stage-head { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; border-bottom: 1px solid var(--line); color: var(--blue); }
.stage-head span { color: var(--muted); font-size: .82rem; }
.visual-root { min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 4px; }
.visual-root svg { display: block; width: 100%; height: 100%; max-height: 100%; }
.feedback { margin: 0 8px 7px; border: 2px solid var(--line); border-radius: 10px; padding: 6px 9px; font-size: .9rem; }
.feedback.waiting { color: var(--blue); background: #f3f7fb; }
.feedback.correct { color: var(--green); border-style: double; border-width: 4px; background: var(--green-bg); }
.feedback.error { color: var(--red); border-style: dashed; background: var(--red-bg); }
.bottom-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px; }
.nav-button { border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 900; }
.nav-button.primary { background: var(--blue); color: #fff; }
.nav-button.secondary { background: var(--paper); border: 1px solid var(--line); color: var(--blue); }
.nav-button:disabled { opacity: .42; cursor: not-allowed; }

.svg-bg { fill: #fffdf8; stroke: rgba(27, 58, 99, .12); stroke-width: 2; }
.svg-equipment { fill: #f3f7fb; stroke: #1b3a63; stroke-width: 3; }
.svg-line { fill: none; stroke: #33475b; stroke-width: 8; stroke-linecap: round; }
.svg-blue { stroke: #3d7fca; }
.svg-red { stroke: #c0392b; stroke-dasharray: 18 8; }
.svg-yellow { stroke: #b06a00; stroke-dasharray: 5 10; }
.svg-green { stroke: #1e7e54; }
.svg-text { fill: #10233c; font-family: Calibri, "Segoe UI", Arial, sans-serif; font-weight: 800; text-anchor: middle; }
.svg-title { fill: #1b3a63; font-family: "Trebuchet MS", Calibri, Arial, sans-serif; font-size: 25px; font-weight: 900; text-anchor: middle; }
.svg-label { font-size: 18px; }
.svg-small { font-size: 14px; fill: #637285; }
.svg-control { cursor: pointer; }
.svg-control .hit { fill: rgba(61, 127, 202, .08); stroke: #1b3a63; stroke-width: 2; }
.svg-control:hover .hit, .svg-control:focus .hit { stroke: var(--orange); stroke-width: 5; }
.svg-control.expected .hit { stroke: var(--orange); stroke-width: 7; stroke-dasharray: 12 7; animation: expected-pulse 1.1s ease-in-out infinite alternate; }
.svg-control.done .hit { stroke: var(--green); stroke-width: 5; stroke-dasharray: 3 5; }
.svg-control[aria-disabled="true"] { opacity: .62; }
.state-open { transform-box: fill-box; transform-origin: center; transform: rotate(90deg); }
.state-off { opacity: .42; }
.flow { stroke-dasharray: 8 14; animation: flow 1.1s linear infinite; }
@keyframes expected-pulse { to { stroke-width: 10; } }
@keyframes flow { to { stroke-dashoffset: -44; } }

.result { min-height: calc(100dvh - 64px); display: grid; place-items: center; padding: 16px; }
.result-card { width: min(660px, 100%); background: var(--paper); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: clamp(22px, 4vw, 42px); text-align: center; }
.result-card h1 { font-size: clamp(2rem, 4vw, 3.4rem); margin-bottom: 10px; }
.score { margin: 10px auto; width: 145px; height: 145px; border: 8px double var(--green); border-radius: 50%; display: grid; place-items: center; background: var(--green-bg); color: var(--green); font-size: 2rem; font-weight: 900; }
.result-actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }

@media (max-width: 780px) {
  .fiche-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
  .trainer-grid { grid-template-columns: minmax(250px, .9fr) minmax(0, 1.4fr); }
  .instruction h1 { font-size: 1.35rem; }
  .action-block, .why-block { font-size: .9rem; }
}

@media (max-width: 650px) {
  .appbar { height: 50px; padding: 4px 6px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand small, .draft-badge { display: none; }
  .mode-badge { font-size: .66rem; }
  .small-button { padding: 5px 8px; font-size: .72rem; }
  main { min-height: calc(100dvh - 50px); }
  .catalogue { min-height: calc(100dvh - 50px); padding: 8px; gap: 7px; }
  .catalogue-head h1 { font-size: clamp(1.45rem, 8vw, 2.05rem); margin-bottom: 5px; }
  .catalogue-head > p:last-child { font-size: .82rem; }
  .eyebrow { font-size: .62rem; margin-bottom: 3px; }
  .fiche-grid { gap: 6px; }
  .fiche-card { border-left-width: 4px; border-radius: 12px; padding: 7px; gap: 6px; }
  .fiche-number { width: 30px; height: 30px; font-size: .78rem; }
  .fiche-card strong { font-size: .82rem; }
  .fiche-card small { font-size: .68rem; margin-top: 2px; }
  .fiche-card .steps { font-size: .62rem; margin-top: 3px; }
  .catalogue-note { font-size: .66rem; }
  .fiche-intro { min-height: calc(100dvh - 50px); padding: 6px; }
  .intro-card { max-height: calc(100dvh - 58px); border-radius: 15px; padding: 11px; }
  .intro-card h1 { font-size: 1.45rem; margin: 8px 0 5px; }
  .fiche-purpose, .source-note { font-size: .8rem; }
  .mode-grid { gap: 6px; margin-top: 9px; }
  .mode-card { padding: 8px; border-radius: 11px; }
  .mode-card span { width: 25px; height: 25px; margin-bottom: 3px; }
  .mode-card strong { font-size: .78rem; }
  .mode-card small { font-size: .65rem; }
  .open-points { font-size: .7rem; padding: 6px 8px; margin-top: 8px; }
  .trainer { height: calc(100dvh - 50px); padding: 3px; grid-template-rows: 28px minmax(0, 1fr) 42px; gap: 3px; }
  .trainer-progress { grid-template-columns: 1fr; gap: 2px; padding: 0 4px; font-size: .72rem; }
  .trainer-progress .progress-track { height: 5px; }
  .trainer-grid { grid-template-columns: 42% minmax(0, 1fr); gap: 3px; }
  .instruction, .stage { border-radius: 9px; }
  .instruction { padding: 6px; }
  .action-source { font-size: .55rem; }
  .instruction h1 { font-size: .9rem; margin-bottom: 4px; }
  .action-block { border-left-width: 3px; padding: 3px 4px; margin-bottom: 3px; font-size: .65rem; }
  .action-block p, .why-block p { line-height: 1.08; }
  .why-block { font-size: .62rem; padding-top: 3px; }
  .help-button { margin-top: 4px; padding: 4px 7px; font-size: .62rem; }
  .stage { grid-template-rows: 27px minmax(0, 1fr) auto; }
  .stage-head { padding: 3px 6px; font-size: .67rem; }
  .visual-root { padding: 1px; }
  .feedback { margin: 0 3px 3px; padding: 3px 5px; font-size: .62rem; line-height: 1.08; }
  .nav-button { padding: 7px 11px; font-size: .72rem; }
  .svg-title { font-size: 21px; }
  .svg-label { font-size: 16px; }
  .svg-small { font-size: 13px; }
}

@media (max-width: 380px) {
  .catalogue-head > p:last-child { display: none; }
  .fiche-card small { display: none; }
  .instruction { padding: 4px; }
  .action-block { font-size: .59rem; }
  .why-block { font-size: .56rem; }
}

@media print {
  .appbar, .catalogue, .fiche-intro, .trainer, .result { display: none !important; }
}
