/*! Mechanical Workshop | based on HTML5 Boilerplate | MIT License | https://html5boilerplate.com/ */

/* ==========================================================================
   Theme: "Steel, Copper & Magenta" – shared with the Machinist Hands
   WorldSkills site (machinisthands.github.io/worldskills).
   Copper = labels, links, buttons. Magenta = small brand touches only
   (header line, active menu item, active slide dot).
   All colours are set once here. Change them here.
   ========================================================================== */

:root {
  --bg: #0E0D0F;          /* page background – near-black, slightly warm like machined steel */
  --surface: #211E22;     /* cards, panels, inputs */
  --surface-2: #2C282D;   /* hover / selected / table header */
  --code: #111012;        /* code blocks, 3D viewer base */
  --line: #36313A;        /* borders, dividers */
  --line-strong: #6B5A63; /* focus / selected border */
  --heading: #F3F1EE;     /* headings – warm white */
  --text: #D3D0CB;        /* body text – light steel */
  --muted: #A3A097;       /* metadata */
  --copper: #B9805F;      /* labels, accents */
  --copper-light: #D9A383;/* links on dark */
  --brand: #E4007F;       /* magenta */
  --accent-gradient: linear-gradient(90deg, var(--copper) 0%, var(--brand) 100%);
  --header-bg: rgba(21, 20, 22, .94);
  --viewer-glow: #4a4448; /* centre of the 3D area */
  --copper-tint: rgba(185, 128, 95, .12);
  --on-copper: #1A120D;   /* text/icons on a copper background */
    --radius: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  color-scheme: dark;
}

/* Light theme: same layout, daylight colours – used when the device is set to light mode */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #F5F3F0;
    --surface: #FFFFFF;
    --surface-2: #ECE8E3;
    --code: #E7E2DC;
    --line: #DDD6CF;
    --line-strong: #B5A398;
    --heading: #1A191B;
    --text: #35322F;
    --muted: #67625B;
    --copper: #94593B;
    --copper-light: #8A5236;
    --header-bg: rgba(255, 255, 255, .94);
    --viewer-glow: #FFFFFF;
    --copper-tint: rgba(148, 89, 59, .1);
    --on-copper: #FFFFFF;
    color-scheme: light;
  }
}

/* Fonts (self-hosted, SIL Open Font License): Inter for text, Barlow Condensed for headings */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/inter-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/inter-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/inter-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/barlow-condensed-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/barlow-condensed-latin-700-normal.woff2) format("woff2"); }

/* ==========================================================================
   Base styles
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { color: var(--text); font-size: 1em; line-height: 1.55; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); font-family: var(--font); }
main { flex: 1; }
::selection { background: var(--copper); color: var(--on-copper); text-shadow: none; }
canvas, img, svg { vertical-align: middle; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--copper-light); text-decoration: none; }
a:hover { color: var(--heading); }
:focus-visible { outline: 2px solid var(--line-strong); outline-offset: 2px; box-shadow: 0 0 0 4px rgba(228, 0, 127, .35); }
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0 0 .5rem; color: var(--heading); font-family: var(--font-display); font-weight: 700; letter-spacing: .01em; line-height: 1.1; }
h1 { font-size: clamp(2.1rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 1.9rem); }
h3 { font-size: 1.25rem; font-weight: 600; }
p { margin: 0 0 1rem; }

/* Side padding: content max 1120px wide */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* ==========================================================================
   Header + menu
   ========================================================================== */

.site-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 10px max(16px, calc((100% - 1120px) / 2));
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent-gradient); }
.logo img { width: 190px; max-width: 55vw; }
@media (max-width: 720px) { .logo img { width: 150px; } }

.site-nav { position: relative; }
.menu-btn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--heading); cursor: pointer; }
.menu-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.menu-btn svg { width: 24px; height: 24px; }
.menu { position: absolute; right: 0; top: calc(100% + 10px); min-width: 15rem; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .4); }
.menu[hidden] { display: none; }
.menu a { display: block; padding: 10px 14px; border-radius: 6px; color: var(--text); font-weight: 500; font-size: .95rem; }
.menu a:hover, .menu a:focus-visible { background: var(--surface-2); color: var(--heading); }
.menu a[aria-current] { color: var(--heading); background: var(--copper-tint); box-shadow: inset 3px 0 0 var(--brand); }

/* ==========================================================================
   Banner slideshow
   ========================================================================== */

.banner { position: relative; background: var(--bg); }
.banner picture { display: contents; }
.banner img { display: none; width: 100%; aspect-ratio: 1224 / 386; object-fit: cover; }
.banner img.on { display: block; }
.dots { display: flex; justify-content: center; gap: 0; padding: 2px; }
/* 18 px touch target, 6 px visible dot */
.dot { position: relative; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 12px; background: none; cursor: pointer; transition: width .2s; }
.dot::before { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; transform: translate(-50%, -50%);
  border-radius: 3px; background: var(--line-strong); transition: width .2s, background-color .2s; }
.dot:hover::before { background: var(--copper-light); }
.dot[aria-current="true"] { width: 26px; }
.dot[aria-current="true"]::before { width: 16px; background: var(--brand); }

/* ==========================================================================
   Home
   ========================================================================== */

.home-intro { padding-top: 1.5rem; padding-bottom: .25rem; }
.home-intro p { max-width: 60ch; color: var(--muted); font-size: 1.05rem; }
.group { padding-top: 1rem; padding-bottom: 1rem; }
/* Section heading with a copper bar, like the year headings on the WorldSkills site */
.group > h2 { display: flex; align-items: center; gap: 12px; padding-bottom: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--line); font-size: 2rem; }
.group > h2::before { content: ""; width: 4px; height: .8em; background: var(--copper); border-radius: 2px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.card { display: block; height: 100%; overflow: hidden; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--heading); transition: transform .15s, border-color .15s, background-color .15s; }
.card:hover, .card:focus-visible { transform: translateY(-3px); background: var(--surface-2); border-color: var(--line-strong); color: var(--heading); }
.card picture { display: block; overflow: hidden; }
.card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: transform .3s; }
.card:hover img { transform: scale(1.04); }
.card span { position: relative; display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; background: inherit;
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; }
.card span::after { content: "View 3D →"; color: var(--copper-light); font: 600 .85rem/1 var(--font); white-space: nowrap; margin-left: 8px; }

/* ==========================================================================
   Job page
   ========================================================================== */

.job > section, .job > header { padding-top: 1.25rem; padding-bottom: 1.25rem; }
.job > header { padding-top: .5rem; padding-bottom: .25rem; }
.job > header + section { padding-top: .75rem; }
.job .intro p:last-child { margin-bottom: 0; }
.job > .wrap { max-width: 920px; }
.job .intro { margin-top: .6rem; color: var(--text); }
.job p { -webkit-hyphens: manual; hyphens: manual; }
/* Year / semester label: copper, like the eyebrow on the WorldSkills site */
.badge { display: inline-block; margin: 0 0 .25rem; padding: 3px 10px; border-radius: 6px; background: var(--copper-tint); color: var(--copper-light);
  font-size: .8rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.job > header h1 { margin-bottom: .5rem; }

/* 3D viewer (same as the WorldSkills site) */
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.viewer-head h2 { margin: 0; }
.viewer-tools { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.viewer-tools button { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; background: transparent; border: 0; border-left: 1px solid var(--line);
  color: var(--text); font: inherit; font-size: .88rem; font-weight: 500; cursor: pointer; white-space: nowrap; }
.viewer-tools button:first-child { border-left: 0; }
.viewer-tools button:hover { background: var(--surface-2); color: var(--heading); }
.viewer-tools button[aria-pressed="true"] { color: var(--copper-light); background: var(--copper-tint); }
.viewer { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: 72vh; min-height: 300px; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 35%, var(--viewer-glow) 0%, var(--surface) 55%, var(--code) 100%); touch-action: none; }
.viewer canvas { display: block; width: 100% !important; height: 100% !important; cursor: grab; }
.viewer canvas:active { cursor: grabbing; }
.viewer-status { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px;
  color: var(--heading); text-align: center; pointer-events: none; }
.viewer-status p { margin: 0; }
.viewer-status .bar { width: min(240px, 60%); height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.viewer-status .bar span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.viewer-status.error .bar { display: none; }
.viewer-hint { margin: 8px 0 0; text-align: center; font-size: .8rem; color: var(--muted); }

/* Pneumatics lab (3D lab in an iframe) + Task / How to use boxes */
.lab-box { position: relative; height: min(70vh, 560px); min-height: 380px; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 35%, var(--viewer-glow) 0%, var(--surface) 55%, var(--code) 100%); }
.lab-box iframe { display: block; width: 100%; height: 100%; border: 0; }
.c2d { display: block; width: 100%; height: 900px; border: 0; }
.lab-box.max { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; height: 100%; min-height: 0; border: 0; border-radius: 0; }
.lab-box.max iframe { flex: 1; height: auto; }
.lab-box .close-max { display: none; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); background: var(--header-bg); color: var(--heading); font: inherit; font-weight: 600; text-align: right; cursor: pointer; }
.lab-box.max .close-max { display: block; order: -1; }
html.lab-open { overflow: hidden; }
.task, .howto { padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.task { border-left: 4px solid var(--copper); }
.task p:last-child { margin-bottom: 0; }
.task-title { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; color: var(--heading); margin-bottom: .5rem; }
.howto { margin-top: 14px; }
.howto h3 { margin-bottom: 6px; }
.howto ol { margin: 0; padding-left: 1.3em; line-height: 1.7; }
.howto li::marker { color: var(--copper); }
.howto b, .task b { color: var(--copper-light); font-weight: 600; }
.howto .viewer-hint { text-align: left; }
.drawing-narrow { max-width: 560px; margin: 0 auto; }

/* Drawing */
.drawing { display: block; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
.drawing img { width: 100%; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--copper); border-radius: 8px;
  background: var(--surface); color: var(--copper-light); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; transition: background-color .15s; }
.btn:hover, .btn:focus-visible { background: var(--copper-tint); color: var(--heading); }

/* Resources: download-style buttons */
.resources { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 10px 0 0; padding: 0; list-style: none; }
.res { display: flex; align-items: center; gap: 14px; height: 100%; min-height: 64px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); transition: background-color .15s, border-color .15s; }
.res svg { flex: none; width: 44px; height: 44px; padding: 10px; border-radius: 8px; background: var(--copper-tint); border: 1px solid var(--copper); color: var(--copper-light);
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.res span { display: flex; flex-direction: column; line-height: 1.3; color: var(--heading); font-weight: 600; }
.res small { margin-top: 2px; color: var(--muted); font-size: .8rem; font-weight: 400; }
.res:hover, .res:focus-visible { background: var(--surface-2); border-color: var(--copper); color: var(--heading); }

/* Operations and CNC program (Lathe Bishop) */
.ops { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 1rem 0 0; padding: 0; list-style: none; }
.ops li { padding: 16px 18px; border: 1px solid var(--line); border-left: 3px solid var(--copper); border-radius: 0 var(--radius) var(--radius) 0; background: var(--surface); }
.ops h3 { font-size: 1.2rem; }
.ops p { margin: 0; }
.program { margin: 1rem 0 0; padding: 14px 16px; max-height: 32rem; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--code); color: var(--text);
  font: .9rem/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; }

/* About / Contact / Privacy / Disclaimer pages */
.prose { max-width: 760px; padding-top: 1.75rem; padding-bottom: 1.5rem; }
.prose h2 { margin-top: 1.75rem; font-size: 1.5rem; }
.prose p, .prose li { line-height: 1.7; }
.prose ul { padding-left: 1.3em; }
.prose li { margin-bottom: .5rem; }
.prose li::marker { color: var(--copper); }
.prose b { color: var(--heading); font-weight: 600; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose .lead { color: var(--muted); font-size: 1.08rem; }
.prose .updated { color: var(--muted); font-size: .85rem; margin-bottom: .5rem; }
.contact-list { list-style: none; padding: 0 !important; display: grid; gap: 10px; }
.contact-list li { margin: 0; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.contact-list span { display: block; color: var(--copper-light); font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; margin-bottom: 8px; }
.footer-links a { font-weight: 500; }

/* ==========================================================================
   Ads – clearly labelled, separated from buttons/links, space reserved
   ========================================================================== */

.ad { margin-top: 2.5rem; margin-bottom: 2.5rem; padding-top: .75rem; padding-bottom: 1rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; }
.ad-label { margin: 0 0 .5rem; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ad ins.adsbygoogle { min-height: 100px; }
.ad:has(ins[data-ad-status="unfilled"]) { display: none; }   /* no ad came: no empty box */
.ad:has(ins.adsbygoogle[data-ad-status="unfilled"]) { display: none; }
.ad-preview::after { content: "Ad space"; display: grid; place-items: center; height: 120px; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-weight: 600; }

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer { margin-top: 1.5rem; padding: 14px 16px; border-top: 1px solid var(--line); background: var(--bg); text-align: center; color: var(--muted); font-size: .85rem; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--copper-light); font-weight: 600; }
.site-footer a:hover { color: var(--heading); }

/* ==========================================================================
   Media queries
   ========================================================================== */

/* Computers: menu always open, shown as links in the header (phones/tablets keep the ☰ button) */
@media (min-width: 992px) {
  .menu-btn { display: none; }
  .menu, .menu[hidden] { position: static; display: flex !important; flex-wrap: wrap; justify-content: flex-end; gap: 4px;
    min-width: 0; margin: 0; padding: 0; background: none; border: 0; box-shadow: none; }
  .menu a { padding: 8px 12px; font-size: .9rem; white-space: nowrap; }
  .menu a[aria-current] { box-shadow: inset 0 -2px 0 var(--brand); border-radius: 6px 6px 0 0; }
}
@media (max-width: 767px) {
  .ops { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card span { flex-direction: column; align-items: flex-start; gap: 2px; font-size: 1.1rem; }
  .card span::after { margin-left: 0; }
}
@media (max-width: 560px) {
  .viewer { aspect-ratio: 1 / 1; }
  .viewer-head { flex-direction: column; align-items: stretch; }
  .viewer-tools { display: grid; grid-template-columns: repeat(3, 1fr); }
  .viewer-tools button { flex-direction: column; justify-content: center; gap: 0; min-height: 48px; padding: 0 6px; font-size: .78rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   Print styles (HTML5 Boilerplate): black on white, no 3D viewer or ads
   ========================================================================== */

@media print {
  *, *::before, *::after { background: #fff !important; color: #000 !important; box-shadow: none !important; text-shadow: none !important; }
  a, a:visited { text-decoration: underline; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; }
  pre { white-space: pre-wrap !important; }
  pre, blockquote { border: 1px solid #999; page-break-inside: avoid; }
  tr, img { page-break-inside: avoid; }
  h2, h3 { page-break-after: avoid; }
  .site-header, .site-header::after, .banner, .viewer-head, .viewer, .viewer-hint, .lab-box, .menu-btn, .ad { display: none !important; }
}

/* ==== Views, likes, Share and Comments (same as the WorldSkills pages) ==== */
/* ---- Views, like / dislike and Share (under the 3D model; Share also on the home page) ---- */
.share { margin-top: 28px; }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; }
.share-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--copper); border-radius: 8px; background: var(--surface); color: var(--copper-light); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; }
.share-btn:hover { background: var(--copper-tint); }
.share-status { margin-top: 6px; font-size: .85rem; color: var(--muted); }
.share-status:empty { display: none; }
.engage { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.engage .share-status { flex-basis: 100%; margin: 0; }
.eng-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; flex: 1 1 auto; }
.eng-views { margin-right: auto; font-size: .9rem; color: var(--muted); }
.eng-views b { color: var(--heading); font-weight: 600; }
.eng-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--heading); font: inherit; cursor: pointer; }
.eng-btn:hover { border-color: var(--line-strong); color: var(--heading); }
.eng-ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.eng-views .eng-ico { width: 18px; height: 18px; vertical-align: -4px; }
/* After voting: the thumb turns yellow and fills in, so it is clear the vote counted */
.eng-btn[aria-pressed="true"] { --vote: #FACC15; border-color: var(--vote); background: rgba(250, 204, 21, .12); color: var(--vote); }
.eng-btn[aria-pressed="true"] .eng-ico { fill: var(--vote); }
@media (prefers-color-scheme: light) { .eng-btn[aria-pressed="true"] { --vote: #B7791F; background: rgba(183, 121, 31, .1); } }
.eng-btn b:empty { display: none; }

@media print { .share, .engage { display: none !important; } }

/* ---- Comments: a card under the 3D model that opens a panel from the bottom (like YouTube on phones) ---- */
.visually-hidden { border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; white-space: nowrap; width: 1px; }
.cmt-teaser { display: flex; flex-direction: column; gap: 4px; width: 100%; margin-top: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.cmt-teaser:hover { border-color: var(--line-strong); }
.cmt-teaser-head { color: var(--heading); }
.cmt-teaser-head .cmt-count { color: var(--muted); margin-left: 4px; }
.cmt-teaser-text { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: .9rem; color: var(--muted); }
html.sheet-open { overflow: hidden; }
.sheet { position: fixed; inset: auto 0 0 0; z-index: 300; width: 100%; max-width: 720px; height: min(60dvh, 680px); max-height: none; margin: 0 auto; padding: 0; display: none; flex-direction: column; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 32px rgba(0, 0, 0, .35); }
.sheet[open] { display: flex; animation: sheet-up .22s ease-out; }
@keyframes sheet-up { from { transform: translateY(40%); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }
.sheet-grip { width: 40px; height: 5px; margin: 8px auto 2px; border-radius: 3px; background: var(--line-strong); touch-action: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 1.3rem; margin: 0; }
.sheet-head .cmt-count { color: var(--muted); font-size: 1rem; margin-left: 4px; }
.sheet-close { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; color: var(--heading); cursor: pointer; }
.sheet-close:hover { background: var(--surface-2); }
.sheet-close svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sheet-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 12px; }
.cmt-list { list-style: none; margin: 0; padding: 0; }
.cmt { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); border-radius: 8px; transition: background .15s; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.cmt:last-child { border-bottom: 0; }
.cmt-avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--copper-tint); color: var(--copper-light); font-weight: 600; object-fit: cover; }
.cmt-body { min-width: 0; }
.cmt-meta { font-size: .8rem; color: var(--muted); margin-bottom: 2px; }
.cmt-meta b { color: var(--heading); font-weight: 600; margin-right: 6px; }
.cmt-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.cmt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.cmt-act { min-height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--text); font: inherit; font-size: .8rem; cursor: pointer; }
.cmt-empty, .cmt-loading { padding: 24px 0; text-align: center; color: var(--muted); }
.sheet-foot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.cmt-signin { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--bg); color: var(--heading); font: inherit; font-weight: 600; cursor: pointer; }
.cmt-signin svg { width: 20px; height: 20px; }
.cmt-form { display: flex; align-items: flex-end; gap: 10px; }
.cmt-me { width: 32px; height: 32px; border-radius: 50%; flex: none; margin-bottom: 6px; }
.cmt-form textarea { flex: 1; min-height: 44px; max-height: 140px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); color: var(--heading); font: inherit; resize: vertical; }
.cmt-form textarea:focus { outline: 2px solid var(--copper); outline-offset: 0; }
.cmt-post { min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--copper); color: var(--on-copper); font: inherit; font-weight: 600; cursor: pointer; }
.cmt-post:disabled { opacity: .6; }
.cmt-note { margin-top: 8px; font-size: .78rem; color: var(--muted); }
.cmt-signout { margin-left: 6px; border: 0; background: none; padding: 0; color: var(--copper-light); font: inherit; text-decoration: underline; cursor: pointer; }
.cmt-edit { width: 100%; margin-top: 6px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); color: var(--heading); font: inherit; resize: vertical; }
.cmt-save { border-color: var(--copper); color: var(--copper-light); }
.cmt-mine { background: var(--copper-tint); border-left: 3px solid var(--copper); border-radius: 0 8px 8px 0; margin: 4px -8px; padding: 12px 8px 12px 9px; border-bottom-color: transparent; }
.cmt-you { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 4px; background: var(--copper); color: var(--on-copper); font-size: .7rem; font-weight: 600; line-height: 1.6; }
.cmt-picked { background: var(--surface-2); margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
.cmt-mine.cmt-picked { background: rgba(185, 128, 95, .22); }
.cmt:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }
.cmt-ask { font-size: .8rem; color: var(--heading); }
.cmt-danger { border-color: #E5484D; color: #FF8A8E; }
@media (prefers-color-scheme: light) { .cmt-danger { color: #C62828; border-color: #C62828; } }
.cmt-status { font-size: .85rem; color: var(--copper-light); }
.cmt-status:empty { display: none; }
@media print { .cmt-teaser, .sheet { display: none !important; } }

.feedback { margin-top: 32px; }
.feedback h2 { margin-bottom: 4px; }
/* ==== CNC Lathe: operating notes and programming ==== */
.notes h3 { margin: 1.6rem 0 .6rem; font-size: 1.25rem; }
.notes-lead { margin-bottom: .5rem; }
.step-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.step-card { padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--copper); border-radius: var(--radius); }
.step-card h4 { margin: 10px 0 4px; font-size: .95rem; color: var(--copper-light); text-transform: uppercase; letter-spacing: .06em; }
.step-card h4 + ol { margin-bottom: 4px; }
.step-card h3 { margin: 0 0 6px; font-family: var(--font-display); font-size: 1.15rem; color: var(--heading); }
.step-card ol { margin: 0; padding-left: 1.3em; }
.step-card li { margin-bottom: 3px; line-height: 1.5; }
.step-card li::marker { color: var(--copper); font-weight: 600; }
.note-warn { margin: 8px 0 0; padding: 6px 10px; border-radius: 6px; background: rgba(229, 72, 77, .12); color: #FF8A8E; font-size: .9rem; }
@media (prefers-color-scheme: light) { .note-warn { color: #B42318; background: rgba(198, 40, 40, .08); } }
.codes { display: grid; grid-template-columns: max-content 1fr; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.codes dt, .codes dd { margin: 0; padding: 8px 12px; border-top: 1px solid var(--line); }
.codes dt:first-of-type, .codes dt:first-of-type + dd { border-top: 0; }
.codes dt { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; color: var(--copper-light); background: var(--surface-2); }
.codes code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; color: var(--heading); white-space: nowrap; }
.notes .program { margin: 0; max-height: none; }
/* ==== CNC simulation ==== */
.sim { margin-top: 12px; display: grid; gap: 10px; }
.sim-view { position: relative; height: clamp(260px, 56vw, 460px); border: 1px solid var(--line); border-radius: var(--radius);
  background: radial-gradient(ellipse at 50% 35%, var(--viewer-glow, #3a3439) 0%, var(--surface) 55%, var(--code) 100%); overflow: hidden; touch-action: none; }
.sim-view canvas { display: block; width: 100%; height: 100%; }
.sim-msg { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); }
.sim-lost { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; background: var(--surface); }
.sim-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sim-btn { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--heading); font: inherit; font-weight: 600; cursor: pointer; }
.sim-btn:hover { border-color: var(--line-strong); }
.sim-play { background: var(--copper); border-color: var(--copper); color: var(--on-copper); }
.sim-speed { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }
.sim-speed select { min-height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--heading); font: inherit; padding: 0 6px; }
.sim-speed option { background: var(--surface); color: var(--heading); } /* open list readable in dark and light */
.sim-dro { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--code);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; color: var(--muted); }
.sim-dro b { color: var(--heading); font-weight: 700; display: inline-block; min-width: 7ch; }
.sim-dro .d-msg { flex-basis: 100%; color: var(--copper-light); }
.sim-dro .d-msg:empty { display: none; }
.sim-cols { display: grid; gap: 10px; }
@media (min-width: 760px) { .sim-cols { grid-template-columns: 1fr 1fr; } }
.sim-code { margin: 0; padding: 6px 0; max-height: 320px; overflow: auto; list-style: none; counter-reset: ln; border: 1px solid var(--line); border-radius: var(--radius); background: var(--code);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.55; position: relative; }
.sim-code li { counter-increment: ln; padding: 0 10px 0 0; white-space: pre; color: var(--text); border-left: 3px solid transparent; }
.sim-code li::before { content: counter(ln); display: inline-block; width: 3.2ch; margin-right: 1ch; text-align: right; color: var(--muted); opacity: .6; }
.sim-code li.is-note { color: var(--muted); }
.sim-code li.is-seg { cursor: pointer; color: var(--copper-light); }
.sim-code li.picked { background: rgba(127, 179, 255, .16); border-left-color: #7fb3ff; }
.sim-code li.run { background: var(--copper-tint); border-left-color: var(--brand); color: var(--heading); }
.sim-prof { margin: 0; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.sim-svg { display: block; width: 100%; height: auto; max-height: 300px; }
.sim-svg .axis { stroke: var(--muted); stroke-width: calc(var(--sw) * .5); stroke-dasharray: calc(var(--sw) * 8) calc(var(--sw) * 3); }
.sim-svg .mirror { fill: none; stroke: var(--line-strong); stroke-width: calc(var(--sw) * .8); }
.sim-svg .seg { fill: none; stroke: var(--copper-light); stroke-width: var(--sw); stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.sim-svg .seg.on { stroke: #7fb3ff; stroke-width: calc(var(--sw) * 2.4); }
.sim-svg .seg.run { stroke: var(--brand); stroke-width: calc(var(--sw) * 2.4); }
.sim-svg .hit { fill: none; stroke: transparent; stroke-width: calc(var(--sw) * 8); cursor: pointer; }
.sim-prof figcaption { margin-top: 6px; font-size: .8rem; color: var(--muted); }
@media print { .sim { display: none; } .sim + pre, pre.program[hidden] { display: block !important; } }

/* ==== Wire EDM parameters and experiment ==== */
.edm-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: .95rem; }
.edm-table th, .edm-table td { padding: 7px 12px; border-top: 1px solid var(--line); text-align: left; }
.edm-table thead th { border-top: 0; background: var(--surface-2); color: var(--heading); font-weight: 600; }
.edm-params tbody th { font-weight: 600; color: var(--copper-light); }
.edm-params tbody tr:nth-child(-n+3) td:last-child { color: var(--heading); font-weight: 600; }
.edm-steps { padding-left: 1.3em; list-style: decimal; }
.edm-list { padding-left: 1.2em; list-style: disc; }
.edm-list li { margin-bottom: 4px; }
.edm-steps li::marker { color: var(--copper); font-weight: 600; }
.edm-note { margin: 8px 0 0; font-size: .9rem; color: var(--muted); }
.edm-cards .step-card h4 { margin: 0 0 6px; font-family: var(--font-display); font-size: 1.15rem; color: var(--heading); text-transform: none; letter-spacing: normal; }
.step-card p { margin: 0 0 6px; }
.step-card .edm-up { margin: 8px 0 4px; font-size: .9rem; color: var(--copper-light); font-weight: 600; }
.step-card ul { margin: 0; padding-left: 1.2em; list-style: disc; }
.edm-fig { margin: 4px 0 8px; max-width: 640px; }
.edm-fig figcaption { margin-top: 6px; font-size: .85rem; color: var(--muted); }
.edm-3d { border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background: radial-gradient(ellipse at 50% 35%, var(--viewer-glow, #4a4448) 0%, var(--surface) 60%); position: relative; }
.edm-3d-tag { position: absolute; transform: translate(-50%, -150%); padding: 1px 6px; border-radius: 4px; background: var(--brand); color: #fff; font-size: .68rem; font-weight: 600; white-space: nowrap; pointer-events: none; opacity: 0; }
.edm-3d canvas { display: block; width: 100% !important; pointer-events: none; }
.edm-plate rect { fill: var(--surface-2); stroke: var(--line-strong); }
.edm-plate .cut { stroke: #E5484D; stroke-width: 2; }
.edm-plate .dim { stroke: var(--muted); stroke-width: 1; }
.edm-plate text, .edm-chart text { fill: var(--heading); font-size: 12px; font-family: inherit; }
.edm-plate .ax, .edm-chart .ax { fill: var(--muted); font-size: 11px; }
.edm-exp { margin-top: 18px; }
.edm-exp h3 { margin: 0 0 2px; }
.edm-fixed { color: var(--muted); font-size: .9rem; }
.edm-pair { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 14px; align-items: center; }
.edm-pair .edm-table td { font-variant-numeric: tabular-nums; }
.edm-chart { width: 100%; max-width: 420px; height: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.edm-chart .grid { stroke: var(--line); stroke-width: 1; }
.edm-chart polyline { fill: none; stroke: var(--copper-light); stroke-width: 2.5; stroke-linejoin: round; }
.edm-chart circle { fill: var(--brand); }
.edm-chart .val { font-size: 11px; font-weight: 600; }
.edm-take { margin-top: 8px; font-size: .95rem; }
.edm-task { margin-top: 22px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); }
.edm-task h3 { margin: 0 0 6px; }
.edm-task p { margin: 0 0 10px; }
.edm-task .edm-fig { margin: 0; }
@media (max-width: 560px) { .edm-pair { grid-template-columns: 1fr; } }
/* ==== Front page: notes under the group headings ==== */
.group-note { max-width: 760px; margin: -4px 0 14px; color: var(--text); font-size: .95rem; line-height: 1.55; }
/* ==== Coolant ==== */
.cool-list { padding-left: 1.2em; list-style: disc; }
.cool-list li { margin-bottom: 4px; }
/* ==== Viva questions ==== */
.viva { display: grid; gap: 12px; }
.viva-q { margin: 0; padding: 12px 16px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.viva-q legend { float: left; width: 100%; padding: 0; margin-bottom: 8px; color: var(--heading); font-weight: 600; line-height: 1.45; }
.viva-q legend + * { clear: both; }
.viva-n { color: var(--copper-light); }
.viva-q code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.viva-q label { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; line-height: 1.4; }
.viva-q label:hover { border-color: var(--line-strong); }
.viva-q input { accent-color: var(--copper); width: 18px; height: 18px; margin: 1px 0 0; flex: none; }
.viva-q label:has(input:checked) { border-color: var(--copper); background: var(--copper-tint); }
.viva-q.is-right { border-left: 4px solid #3FB950; }
.viva-q.is-wrong { border-left: 4px solid #E5484D; }
.viva-q label.viva-correct, .viva-q label.viva-correct:has(input:checked) { border-color: #3FB950; background: rgba(63, 185, 80, .12); }
.viva-q label.viva-correct::after { content: "✓"; margin-left: auto; color: #3FB950; font-weight: 700; }
.viva-q label.viva-picked-wrong, .viva-q label.viva-picked-wrong:has(input:checked) { border-color: #E5484D; background: rgba(229, 72, 77, .12); }
.viva-q label.viva-picked-wrong::after { content: "✗"; margin-left: auto; color: #E5484D; font-weight: 700; }
.viva-why { margin: 10px 0 0; font-size: .9rem; color: var(--muted); }
.viva-bar { display: flex; gap: 10px; }
.viva-submit, .viva-again { min-height: 44px; padding: 0 22px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; }
.viva-submit { border: 0; background: var(--copper); color: var(--on-copper); }
.viva-again { border: 1px solid var(--copper); background: none; color: var(--copper-light); }
.viva-score { margin: 0; padding: 12px 16px; border-radius: var(--radius); background: var(--copper-tint); border: 1px solid var(--copper); color: var(--heading); font-size: 1.05rem; }
.viva-score b { font-size: 1.25rem; color: var(--copper-light); }
.viva-score.viva-warn { background: rgba(229, 72, 77, .1); border-color: #E5484D; }
@media print { .viva-bar { display: none; } }
