/* Design tokens: one neutral surface family, one primary, one accent, two semantic colours. */
:root {
  --ink: #0e1420;
  --ink-2: #5c6675;
  --ink-3: #98a1ae;
  --surface: #f5f6f8;
  --surface-2: #eceef2;
  --card: #ffffff;
  --line: rgba(14, 20, 32, .09);
  --primary: #0b5fd1;
  --primary-ink: #ffffff;
  --primary-soft: rgba(11, 95, 209, .10);
  --accent: #c9323f;
  --success: #1b8a4b;
  --success-soft: #e6f5ec;
  --danger: #c43d3d;
  --danger-soft: #fbeaea;
  --glass: rgba(255, 255, 255, .78);
  --shadow: 0 12px 32px rgba(14, 20, 32, .10), 0 1px 2px rgba(14, 20, 32, .06);
  --shadow-sheet: 0 -16px 48px rgba(14, 20, 32, .16);
  --r-s: 10px;
  --r-m: 16px;
  --r-l: 24px;
  --gutter: 20px;
  --ease: cubic-bezier(.32, .72, 0, 1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--surface); color: var(--ink); font: 400 16px/1.45 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
#camerafeed { position: fixed; inset: 0; width: 100%; height: 100%; display: none; }
body:not([data-screen="welcome"]) #camerafeed { display: block; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
h1, h2, p { margin: 0; }
h1 { font-size: 36px; line-height: 1.08; font-weight: 700; letter-spacing: -.025em; }
h2 { font-size: 21px; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
.overline { display: block; color: var(--ink-3); font-size: 12px; line-height: 1.2; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.eyebrow { color: var(--primary); font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.lead { color: var(--ink-2); font-size: 17px; line-height: 1.5; }
.footnote { color: var(--ink-3); font-size: 13px; text-align: center; }

/* Buttons: one family, three weights, plus round icon buttons. */
.btn { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 54px; padding: 0 22px; border-radius: var(--r-m); font-size: 17px; font-weight: 600; letter-spacing: -.005em; transition: transform .14s var(--ease), background-color .14s, opacity .14s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; }
.btn-primary { color: var(--primary-ink); background: var(--primary); box-shadow: 0 8px 20px rgba(11, 95, 209, .22); }
.btn-primary:active { background: #0a53b6; }
.btn-secondary { color: var(--ink); background: var(--surface-2); }
.btn-secondary:active { background: #e1e4ea; }
.btn-ghost { min-height: 48px; color: var(--primary); font-weight: 500; }
.btn-ghost:active { opacity: .6; }
.icon-btn { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; color: var(--ink); transition: transform .14s var(--ease), opacity .14s; }
.icon-btn:active { transform: scale(.92); opacity: .7; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.small { width: 40px; height: 40px; color: var(--ink-2); }
.icon-btn.small svg { width: 20px; height: 20px; }
.icon-btn.play { width: 58px; height: 58px; color: var(--primary-ink); background: var(--primary); box-shadow: 0 8px 20px rgba(11, 95, 209, .26); }
.icon-btn.play svg { width: 24px; height: 24px; stroke-width: 1.5; fill: currentColor; }

.glass { background: var(--glass); -webkit-backdrop-filter: saturate(160%) blur(24px); backdrop-filter: saturate(160%) blur(24px); box-shadow: var(--shadow), inset 0 0 0 .5px rgba(255, 255, 255, .6); }
.actions { display: grid; gap: 10px; }
.actions.row { grid-template-columns: 1fr 1fr; }

/* Welcome */
.screen { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; overflow: auto; max-width: 520px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 48px) var(--gutter) calc(env(safe-area-inset-bottom) + 24px); background: radial-gradient(120% 70% at 50% -10%, #ffffff 0%, var(--surface) 70%); transition: opacity .32s var(--ease), visibility .32s; }
body:not([data-screen="welcome"]) #welcome { opacity: 0; visibility: hidden; pointer-events: none; }
.welcome-top { display: grid; gap: 14px; }
.mark { display: grid; justify-self: start; place-items: center; width: 64px; height: 64px; margin-bottom: 10px; border-radius: 20px; color: var(--primary); background: var(--card); box-shadow: var(--shadow); }
.mark svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.facts { display: grid; gap: 2px; margin: 32px 0 0; padding: 6px 0; list-style: none; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts li { display: flex; align-items: center; gap: 14px; min-height: 52px; color: var(--ink); font-size: 15px; font-weight: 500; }
.fact-icon { display: grid; flex: none; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--primary); background: var(--primary-soft); }
.fact-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
#welcome .actions { margin-top: auto; padding-top: 28px; }
.welcome-top > *, .facts, #welcome .actions { animation: rise .6s var(--ease) both; }
.welcome-top > :nth-child(2) { animation-delay: .06s; }
.welcome-top > :nth-child(3) { animation-delay: .12s; }
.welcome-top > :nth-child(4) { animation-delay: .18s; }
.facts { animation-delay: .26s; }
#welcome .actions { animation-delay: .34s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Overlay */
#hud { position: fixed; inset: 0; z-index: 30; display: none; flex-direction: column; gap: 10px; max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) var(--gutter) calc(env(safe-area-inset-bottom) + 16px); pointer-events: none; }
body:not([data-screen="welcome"]) #hud { display: flex; }
#hud button { pointer-events: auto; }
.grow { flex: 1; }
#topbar { padding: 8px 8px 8px 18px; border-radius: 20px; }
.topbar-row { display: flex; align-items: center; gap: 2px; min-height: 40px; }
.topbar-text { display: grid; flex: 1; gap: 2px; min-width: 0; }
#title { overflow: hidden; font-size: 16px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; text-overflow: ellipsis; }
#status { position: relative; display: none; overflow: hidden; padding: 12px 18px; border-radius: var(--r-m); color: var(--ink-2); font-size: 15px; font-weight: 500; text-align: center; }
#status.active { display: block; animation: fade .25s var(--ease); }
#statusBar { position: absolute; left: 0; bottom: 0; display: none; width: 0; height: 3px; border-radius: 2px; background: var(--primary); transition: width .3s var(--ease); }
#status.loading #statusBar { display: block; }
#prompt .btn { animation: rise .4s var(--ease); }

/* Selected part */
#card { display: grid; gap: 10px; padding: 12px 12px 12px 16px; border-radius: 20px; pointer-events: auto; animation: rise .3s var(--ease); }
.card-row { display: flex; align-items: center; gap: 12px; }
.card-text { display: grid; flex: 1; gap: 3px; min-width: 0; }
#cardName { font-size: 17px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.swatch { flex: none; width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(14, 20, 32, .12); }
.btn.slim { min-height: 44px; font-size: 15px; }

/* Toolbar */
#toolbar { display: flex; justify-content: space-around; padding: 6px; border-radius: 22px; }
.tool { display: grid; flex: 1; justify-items: center; gap: 3px; padding: 7px 4px; border-radius: 16px; color: var(--ink-2); font-size: 12px; font-weight: 600; transition: transform .14s var(--ease), background-color .14s, color .14s; }
.tool:active { transform: scale(.95); }
.tool svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool.on { color: var(--primary); background: var(--primary-soft); }

/* Organ labels and leader lines */
#lines { position: fixed; inset: 0; z-index: 20; width: 100%; height: 100%; pointer-events: none; }
#lines line { stroke: #fff; stroke-width: 1.5; stroke-linecap: round; filter: drop-shadow(0 0 2px rgba(0, 0, 0, .5)); }
#labels { position: fixed; inset: 0; z-index: 25; pointer-events: none; }
.organ-label { position: absolute; padding: 6px 12px; border-radius: 999px; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; transform: translate(-50%, -100%); background: rgba(28, 28, 30, .78); }
body[data-screen="welcome"] #labels, body[data-screen="welcome"] #lines { display: none; }

/* Sheets */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-width: 560px; max-height: calc(100% - env(safe-area-inset-top) - 24px); margin: 0 auto; padding: 22px var(--gutter) calc(env(safe-area-inset-bottom) + 20px); overflow: auto; border-radius: var(--r-l) var(--r-l) 0 0; background: var(--card); box-shadow: var(--shadow-sheet); animation: sheet .38s var(--ease); }
.sheet::before { content: ""; display: block; width: 36px; height: 4px; margin: -8px auto 14px; border-radius: 2px; background: var(--line); }
@keyframes sheet { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
#systemList { margin: 0 0 14px; padding: 0; list-style: none; }
#systemList li { display: flex; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--line); }
#systemList li:last-child { border-bottom: 0; }
#systemList label { display: flex; flex: 1; align-items: center; gap: 12px; min-height: 52px; font-size: 16px; font-weight: 500; cursor: pointer; }
#systemList li.selected label::after { content: "Selected"; margin-left: 4px; color: var(--primary); font-size: 12px; font-weight: 600; }
.only { min-height: 34px; padding: 0 12px; border-radius: 999px; color: var(--primary); font-size: 14px; font-weight: 600; background: var(--primary-soft); }
.switch { position: relative; flex: none; width: 51px; height: 31px; margin: 0; appearance: none; -webkit-appearance: none; border-radius: 999px; background: var(--surface-2); transition: background-color .2s; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: transform .2s var(--ease); }
.switch:checked { background: var(--success); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .4; }
.credits { margin-bottom: 16px; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
#log { max-height: 34vh; margin: 6px 0 16px; padding: 12px; overflow: auto; border-radius: var(--r-s); background: var(--surface); font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }

@media (max-height: 640px) {
  h1 { font-size: 30px; }
  .screen { padding-top: calc(env(safe-area-inset-top) + 24px); }
  .mark { width: 52px; height: 52px; }
  .facts { margin-top: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 8th Wall loading screen: hide its "Powered by" logo. For a website the licence only asks for the copyright
   notice, which is in index.html (and credited in About). The spinner and camera prompts stay. */
.poweredby-img, .landing8-attribution-logo { display: none !important; }

/* Course code sheet: two steps, then the code learners type in TalentLMS. */
.tasks { margin: 4px 0 14px; padding: 0; list-style: none; }
.tasks li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: 15px; }
.tasks li::before { content: ""; flex: none; width: 20px; height: 20px; border: 2px solid var(--line); border-radius: 50%; }
.tasks li.done { color: var(--ink); }
.tasks li.done::before { border-color: var(--primary); background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12l4 4 8-8' fill='none' stroke='white' stroke-width='3'/%3E%3C/svg%3E") center/14px no-repeat; }
.tasks li b#partsCount { margin-left: auto; color: var(--primary); }
.code { margin-bottom: 14px; padding: 14px 16px; border-radius: var(--r-s); text-align: center; background: var(--primary-soft); }
.code strong { display: block; margin: 4px 0 2px; color: var(--primary); font-size: 30px; font-weight: 700; letter-spacing: .18em; font-variant-numeric: tabular-nums; }
.code strong:empty { display: none; }
.code p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.4; }
#codeSheet .btn { width: 100%; }
