:root {
  --ink: #0e1013;
  --ink-2: #15181c;
  --ink-3: #1c2026;
  --line: #2a2f37;
  --line-soft: #22262d;
  --text: #ecebe6;
  --muted: #9a9ea6;
  --faint: #6b7079;
  --amber: #e4a861;
  --amber-deep: #c98a3d;
  --teal: #7cc6bd;
  --good: #8fcf8a;
  --bad: #e88b7d;
  --serif: "Newsreader", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(228, 168, 97, 0.07), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(124, 198, 189, 0.05), transparent 60%),
    var(--ink);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

kbd {
  font: 500 11px var(--mono);
  padding: 1px 6px;
  border: 1px solid currentColor;
  border-radius: 5px;
  opacity: 0.6;
  margin-left: 4px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(14, 16, 19, 0.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-mark { width: 28px; height: 28px; color: var(--amber); stroke: var(--amber); }
.brand-mark circle[fill="currentColor"] { fill: var(--amber); stroke: none; }
.brand-name { font: 600 20px/1 var(--serif); letter-spacing: 0.01em; }
.brand-name em { font-weight: 400; color: var(--amber); }
.session { display: flex; gap: 22px; margin-left: auto; }
.stat { display: flex; align-items: baseline; gap: 8px; font-size: 14px; }
.stat-label { color: var(--faint); text-transform: uppercase; letter-spacing: 0.12em; font-size: 11px; }
.actions { display: flex; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--ink-3);
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: background .15s, border-color .15s, transform .1s, color .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #3a404a; background: #222730; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--amber); color: #1a1208; border-color: var(--amber); }
.btn.primary:hover { background: #ecb675; }
.btn.secondary { color: var(--teal); border-color: rgba(124, 198, 189, .35); background: rgba(124, 198, 189, .07); }
.btn.secondary:hover { background: rgba(124, 198, 189, .14); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--ink-3); }
.btn.ghost[aria-pressed="true"] { color: var(--amber); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--text); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- Trainer layout ---------- */
.trainer {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr);
  gap: 28px;
  padding: 28px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}
.stage { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.stage .explanation { margin-top: 18px; }
.panel { position: sticky; top: 90px; }
.viewer {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #050607;
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  overflow: hidden;
  display: grid;
  place-items: center;
  box-shadow: 0 30px 80px -40px rgba(0,0,0,.8), inset 0 0 0 1px rgba(255,255,255,.02);
}
.viewer img {
  width: 100%; height: 100%;
  object-fit: contain;
  transition: transform .25s ease, opacity .3s ease;
  cursor: zoom-in;
  user-select: none;
}
.viewer.zoomed img { transform: scale(2.4); cursor: zoom-out; transition: transform .2s ease; }
.viewer img.fading { opacity: 0; }
.reticle {
  pointer-events: none;
  position: absolute; inset: 14px;
  border-radius: 14px;
  background:
    linear-gradient(var(--amber), var(--amber)) top left / 18px 1px no-repeat,
    linear-gradient(var(--amber), var(--amber)) top left / 1px 18px no-repeat,
    linear-gradient(var(--amber), var(--amber)) top right / 18px 1px no-repeat,
    linear-gradient(var(--amber), var(--amber)) top right / 1px 18px no-repeat,
    linear-gradient(var(--amber), var(--amber)) bottom left / 18px 1px no-repeat,
    linear-gradient(var(--amber), var(--amber)) bottom left / 1px 18px no-repeat,
    linear-gradient(var(--amber), var(--amber)) bottom right / 18px 1px no-repeat,
    linear-gradient(var(--amber), var(--amber)) bottom right / 1px 18px no-repeat;
  opacity: .5;
}
.zoom-hint {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  margin: 0; font-size: 12px; color: var(--muted);
  background: rgba(0,0,0,.55); padding: 4px 10px; border-radius: 999px;
  pointer-events: none;
}
.viewer-empty { text-align: center; padding: 40px; color: var(--muted); }
.viewer-empty h2 { font: 400 28px var(--serif); color: var(--text); margin: 0 0 8px; }
.loading-dot::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.stage-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 12px; }
.keys { color: var(--faint); font-size: 12.5px; text-align: center; }
.keys kbd { margin: 0 2px; }

/* ---------- Panel ---------- */
.panel { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.card {
  background: linear-gradient(180deg, var(--ink-2), #121519);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 26px;
}
.eyebrow { margin: 0 0 6px; text-transform: uppercase; letter-spacing: .16em; font-size: 11px; color: var(--amber); font-weight: 600; }
.prompt { font: 400 34px/1.15 var(--serif); margin: 0 0 10px; }
.hidden-state .muted { margin: 0 0 20px; }
.guess input {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
  margin-bottom: 14px;
}
.guess input:focus { outline: none; border-color: var(--amber-deep); }
.btn.reveal {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  background: transparent;
  border: 1px dashed rgba(228, 168, 97, .55);
  color: var(--amber);
}
.btn.reveal:hover { background: rgba(228, 168, 97, .08); border-style: solid; }

.revealed-state { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.diagnosis { font: 600 38px/1.1 var(--serif); margin: 0 0 6px; color: var(--text); }
.details { font: italic 400 19px/1.35 var(--serif); color: #d7cdbd; margin: 0 0 12px; }
.details:empty { display: none; }
.your-guess { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.your-guess strong { color: var(--text); font-weight: 500; }
.filename { font-size: 12px; color: var(--faint); margin: 0 0 18px; word-break: break-word; }
.filename:has(+ .image-source:not([hidden])) { margin-bottom: 6px; }
.image-source { font-size: 12px; color: var(--muted); margin: 0 0 18px; }
.image-source a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.selfmark { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); margin-bottom: 18px; font-size: 13.5px; }
.selfmark .muted { margin-right: auto; }
.chip { border: 1px solid var(--line); background: transparent; padding: 5px 11px; border-radius: 999px; cursor: pointer; font-size: 13px; }
.chip.good[aria-pressed="true"] { background: rgba(143, 207, 138, .15); border-color: var(--good); color: var(--good); }
.chip.bad[aria-pressed="true"] { background: rgba(232, 139, 125, .15); border-color: var(--bad); color: var(--bad); }
.answer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Explanation ---------- */
.explanation { animation: rise .35s ease both; }
.explanation h3 { font: 600 13px var(--sans); text-transform: uppercase; letter-spacing: .14em; color: var(--teal); margin: 22px 0 10px; }
.explanation h3:first-child { margin-top: 0; }
.ai-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ai-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--teal); background: rgba(124, 198, 189, .08); border: 1px solid rgba(124, 198, 189, .25); padding: 3px 10px; border-radius: 999px; }
.ai-badge svg { width: 14px; height: 14px; }
.summary { font: 400 18px/1.5 var(--serif); margin: 0 0 4px; color: #e6e2d8; }
.features { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: f; }
.features li { counter-increment: f; position: relative; padding: 12px 14px 12px 44px; background: rgba(255,255,255,.02); border: 1px solid var(--line-soft); border-radius: 10px; }
.features li::before { content: counter(f); position: absolute; left: 14px; top: 12px; font: 500 12px var(--mono); color: var(--amber); border: 1px solid rgba(228,168,97,.4); border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; }
.features strong { display: block; font-weight: 600; margin-bottom: 2px; }
.features p { margin: 2px 0 0; font-size: 14px; color: #c9ccd2; }
.features .why { color: var(--muted); }
.diffs { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: 14px; color: #c9ccd2; }
.diffs strong { color: var(--text); font-weight: 600; }
.teaching { margin: 0; padding: 14px 16px; border-left: 3px solid var(--amber); background: rgba(228,168,97,.06); border-radius: 0 10px 10px 0; font: italic 400 17px/1.45 var(--serif); }
.caveats { font-size: 13.5px; color: var(--muted); margin: 0; }
sup.cite { font: 500 10.5px var(--mono); margin-left: 2px; }
sup.cite a { color: var(--teal); text-decoration: none; }
sup.cite a:hover { text-decoration: underline; }
.refs { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 8px; font-size: 12.5px; color: var(--muted); }
.refs li { display: grid; grid-template-columns: 28px 1fr; }
.refs li span { font-family: var(--mono); color: var(--teal); }
.refs a { color: inherit; text-decoration-color: rgba(154,158,166,.4); }
.refs a:hover { color: var(--text); }
.refs li:target { color: var(--text); }
.ai-meta { font-size: 11.5px; color: var(--faint); margin: 18px 0 0; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.thinking { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.scan { height: 3px; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--teal), transparent); background-size: 200% 100%; animation: scan 1.3s linear infinite; margin-top: 14px; }
@keyframes scan { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.error { color: var(--bad); }

/* ---------- Drawers / modals ---------- */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(5,6,8,.65); backdrop-filter: blur(3px); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(760px, 100%);
  background: var(--ink-2);
  border-left: 1px solid var(--line);
  padding: 24px;
  overflow-y: auto;
  animation: slide .25s ease;
}
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.drawer-head > div { flex: 1; }
.drawer-head h2 { font: 400 28px var(--serif); margin: 0 0 4px; }
.drawer-head p { margin: 0; font-size: 13.5px; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; padding-top: 8px; }
.toggle input { accent-color: var(--amber); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.tile { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line-soft); background: #050607; cursor: pointer; text-align: left; padding: 0; }
.tile img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; transition: transform .3s; }
.tile:hover img { transform: scale(1.04); }
.tile.current { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.tile-cap { padding: 8px 10px; font-size: 12.5px; background: var(--ink-3); min-height: 36px; }
.tile-cap .dx { font-weight: 600; display: block; }
.tile-cap .dt { color: var(--muted); font-size: 11.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-num { position: absolute; top: 8px; left: 8px; font: 500 11px var(--mono); background: rgba(0,0,0,.6); padding: 2px 7px; border-radius: 6px; }
.tile-del { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 7px; border: none; background: rgba(0,0,0,.6); color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-del, .tile-del:focus-visible { opacity: 1; }
.tile-del:hover { color: var(--bad); }

.modal .modal-panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(640px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  animation: fade .2s ease;
}
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 34px 20px;
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone svg { width: 28px; height: 28px; color: var(--amber); margin-bottom: 6px; }
.dropzone input { display: none; }
.dropzone.over, .dropzone:hover { border-color: var(--amber); background: rgba(228,168,97,.04); }
.queue { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.queue li { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line-soft); border-radius: 10px; font-size: 13.5px; }
.queue img { width: 48px; height: 48px; object-fit: cover; border-radius: 7px; }
.queue .q-dx { font-weight: 600; }
.queue .q-dt { color: var(--muted); font-size: 12.5px; }
.queue .q-file { color: var(--faint); font: 11.5px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.queue .q-state { font-size: 12px; color: var(--muted); }
.queue .q-state.ok { color: var(--good); }
.queue .q-state.err { color: var(--bad); }
.range-all { padding: 0 0 12px; }
.range-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.range-opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 10px; cursor: pointer; font-size: 14px; transition: border-color .15s, background .15s; }
.range-opt input { accent-color: var(--amber); width: 16px; height: 16px; margin: 0; }
.range-opt small { display: block; color: var(--faint); font-size: 11.5px; }
.range-opt:has(input:checked) { border-color: var(--amber); background: rgba(228,168,97,.06); }
.modal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; gap: 12px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink-3); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 80;
  animation: rise .25s ease;
}

.site-foot { text-align: center; color: var(--faint); font-size: 12px; padding: 18px 28px 26px; max-width: 900px; margin: 0 auto; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .trainer { grid-template-columns: 1fr; padding: 18px; gap: 18px; }
  .stage { display: contents; }
  .viewer { order: 1; }
  .stage-nav { order: 2; margin-top: -6px; }
  .panel { position: static; order: 3; }
  .stage .explanation { order: 4; margin-top: 0; }
  .keys { display: none; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px 16px; padding: 12px 16px; }
  .session { order: 3; width: 100%; margin-left: 0; justify-content: space-between; }
  .actions { margin-left: auto; }
  .actions .btn span { display: none; }
  .prompt { font-size: 28px; }
  .diagnosis { font-size: 30px; }
  .card { padding: 20px; }
  .answer-actions { grid-template-columns: 1fr; }
}

/* ---------- Sign-in gate ---------- */
body.locked > :not(.auth-gate):not(.toast):not(script) { display: none !important; }
body:not(.locked) .auth-gate { display: none; }
.auth-gate {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px;
  padding: 40px 20px;
}
.auth-card {
  width: min(400px, 100%);
  background: var(--ink-2);
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  padding: 32px 30px 24px;
  box-shadow: 0 30px 80px -40px rgba(0,0,0,.8);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.auth-card h1 { font: 600 28px/1.15 var(--serif); margin: 0 0 6px; }
.auth-card > .muted { margin: 0 0 22px; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.field input {
  font: 15px var(--sans); color: var(--text);
  background: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px;
}
.field input:focus { outline: none; border-color: var(--amber); }
.auth-submit { width: 100%; padding: 11px 16px; margin-top: 4px; }
.auth-msg { font-size: 14px; margin: 0 0 12px; color: var(--bad); }
.auth-msg.ok { color: var(--good); }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; margin-top: 16px; padding: 0; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }
.auth-foot { max-width: 400px; text-align: center; font-size: 12px; margin: 0; }
.tile-ai { position: absolute; top: 8px; right: 36px; font: 500 10px var(--mono); padding: 2px 6px; border-radius: 6px; background: rgba(14,16,19,.75); color: var(--faint); }
.tile-ai.ready { color: var(--teal); }

/* ---------- Dermoscopic algorithm pages ---------- */
.actions { flex-wrap: wrap; justify-content: flex-end; }
a.btn { text-decoration: none; }
.btn.ghost[aria-current="page"] { color: var(--amber); background: var(--ink-3); }
@media (max-width: 1240px) { .session { display: none; } .actions { margin-left: auto; } }

a.algo-link { color: var(--amber); text-decoration: underline; text-decoration-color: rgba(228,168,97,.45); text-underline-offset: 3px; }
a.algo-link:hover { text-decoration-color: var(--amber); }
.algos { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.algos li { padding: 12px 14px; border: 1px solid rgba(228,168,97,.22); background: rgba(228,168,97,.04); border-radius: 10px; }
.algos p { margin: 6px 0 0; font-size: 14px; color: #c9ccd2; }
.algo-chip { display: inline-flex; gap: 6px; font-weight: 600; color: var(--amber); text-decoration: none; }
.algo-chip:hover { text-decoration: underline; text-underline-offset: 3px; }
.ai-meta a { color: var(--muted); }

.algo-view {
  flex: 1;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 40px;
  padding: 28px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}
.algo-side { position: sticky; top: 90px; display: flex; flex-direction: column; gap: 14px; }
.algo-back { align-self: flex-start; padding-left: 0; }
.algo-nav { display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.algo-nav a { color: var(--muted); text-decoration: none; padding: 7px 14px; margin-left: -1px; border-left: 2px solid transparent; font-size: 14px; }
.algo-nav a:hover { color: var(--text); }
.algo-nav a.active { color: var(--amber); border-left-color: var(--amber); }
.algo-content { min-width: 0; max-width: 820px; animation: rise .3s ease both; }
.algo-content .eyebrow a { color: inherit; text-decoration: none; }
.algo-content .eyebrow a:hover { text-decoration: underline; }
.algo-title { font: 400 44px/1.1 var(--serif); margin: 0 0 8px; }
.algo-meta { color: var(--faint); font-size: 13.5px; margin: 0 0 18px; }
.algo-lead { font: 400 19px/1.55 var(--serif); color: #e6e2d8; margin: 0 0 8px; }
.algo-h2 { font: 600 13px var(--sans); text-transform: uppercase; letter-spacing: .14em; color: var(--teal); margin: 34px 0 12px; }
.algo-steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; color: #d6d8dc; }
.algo-steps li::marker { color: var(--amber); font-family: var(--mono); font-size: 13px; }
.algo-table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: 12px; }
.algo-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.algo-table th { text-align: left; font: 600 11px var(--sans); text-transform: uppercase; letter-spacing: .12em; color: var(--faint); padding: 10px 14px; background: var(--ink-2); border-bottom: 1px solid var(--line-soft); }
.algo-table td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; color: #c9ccd2; }
.algo-table tr:last-child td { border-bottom: 0; }
.algo-table td strong { color: var(--text); font-weight: 600; }
.algo-table a { color: var(--amber); }
.nowrap { white-space: nowrap; }
.algo-interp { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.algo-interp li { display: grid; grid-template-columns: 190px 1fr; gap: 14px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line-soft); border-left-width: 3px; font-size: 14.5px; }
.algo-interp li .mono { color: var(--text); font-size: 13px; }
.algo-interp li.low { border-left-color: var(--good); }
.algo-interp li.mid { border-left-color: var(--amber); }
.algo-interp li.high { border-left-color: var(--bad); }
.algo-pitfalls { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: #c9ccd2; font-size: 14.5px; }
.algo-refs { margin-top: 0; }
.algo-note { margin: 22px 0 0; padding: 14px 16px; border-left: 3px solid var(--amber); background: rgba(228,168,97,.06); border-radius: 0 10px 10px 0; font-size: 14px; color: #d6d8dc; }
.algo-pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.algo-pager a { color: var(--muted); text-decoration: none; font-size: 14px; }
.algo-pager a:hover { color: var(--amber); }

.algo-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 24px; }
.algo-card { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border: 1px solid var(--line-soft); border-radius: 12px; background: linear-gradient(180deg, var(--ink-2), #121519); color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s; }
.algo-card:hover { border-color: rgba(228,168,97,.5); transform: translateY(-1px); }
.algo-card-name { font: 600 20px/1.2 var(--serif); }
.algo-card-short { font-size: 14px; color: #c9ccd2; }
.algo-card-meta { font-size: 12px; color: var(--faint); margin-top: 6px; }

/* Schematic feature diagrams */
svg.dx { display: block; width: 100%; height: auto; fill: none; stroke: none; border-radius: 10px; }
.dx-note { font-size: 13px; margin: -4px 0 6px; }
.algo-card-dx { display: block; width: 72px; margin-bottom: 8px; }
.algo-card-dx svg.dx { border-radius: 50%; box-shadow: 0 0 0 1px var(--line); }
.feat-group { font: 600 12px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.feat { display: flex; flex-direction: column; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--ink-2); overflow: hidden; }
.feat.wide { grid-column: span 2; }
.feat-dx { display: flex; gap: 8px; padding: 10px 10px 0; }
.feat-dx figure { flex: 1; margin: 0; min-width: 0; }
.feat:not(.wide) .feat-dx figure { max-width: 150px; margin: 0 auto; }
.feat-dx figcaption { font-size: 11.5px; line-height: 1.35; color: var(--muted); margin-top: 6px; text-align: center; }
.feat-body { padding: 10px 14px 14px; }
.feat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.feat-head strong { font-weight: 600; font-size: 14.5px; }
.feat-body p { margin: 6px 0 0; font-size: 13.5px; color: #c9ccd2; }
.feat-tag { flex: none; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid currentColor; }
.feat-tag.low { color: var(--good); }
.feat-tag.mid { color: var(--amber); }
.feat-tag.high { color: var(--bad); }

/* Annotated example: labels and arrows appear on hover, keyboard focus or tap */
.annot { margin: 0; outline: none; }
.annot-stage { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line-soft); background: #000; }
.annot-stage img { display: block; width: 100%; height: 100%; object-fit: cover; transition: filter .25s; }
svg.annot-layer { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: none; pointer-events: none; opacity: 0; transition: opacity .25s; }
.annot-ring { fill: none; stroke: #f4c27f; stroke-width: 4; stroke-dasharray: 10 8; }
.annot-arrow { fill: none; stroke: #f4c27f; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.annot-text { fill: #fff; font-family: var(--sans); font-weight: 600; paint-order: stroke; stroke: rgba(10, 12, 15, .88); stroke-width: 10px; stroke-linejoin: round; }
.annot-hint { position: absolute; left: 12px; bottom: 12px; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; background: rgba(14,16,19,.75); color: var(--text); transition: opacity .2s; pointer-events: none; }
.annot-toggle { position: absolute; right: 10px; bottom: 10px; background: rgba(14,16,19,.75); }
.annot:hover svg.annot-layer, .annot:focus-visible svg.annot-layer, .annot.show svg.annot-layer { opacity: 1; }
.annot:hover .annot-arrow, .annot:focus-visible .annot-arrow, .annot.show .annot-arrow { stroke-dashoffset: 0; transition: stroke-dashoffset .45s ease var(--d, 0s); }
.annot:hover img, .annot:focus-visible img, .annot.show img { filter: brightness(.8) saturate(.9); }
.annot:hover .annot-hint, .annot:focus-visible .annot-hint, .annot.show .annot-hint { opacity: 0; }
.annot:focus-visible .annot-stage { box-shadow: 0 0 0 2px var(--amber); }
.annot figcaption { margin-top: 12px; font-size: 14px; color: #c9ccd2; }
.annot figcaption p { margin: 0 0 8px; }
.annot-list { margin: 0; padding-left: 20px; display: grid; gap: 2px; font-size: 13.5px; color: var(--muted); }
.annot-src { font-size: 12px; color: var(--faint); margin-top: 8px !important; }
@media (prefers-reduced-motion: reduce) { .annot-arrow { stroke-dasharray: none; } svg.annot-layer, .annot-stage img { transition: none; } }

.calc { margin-top: 34px; padding: 4px 22px 20px; border: 1px solid rgba(124,198,189,.25); border-radius: 14px; background: rgba(124,198,189,.03); }
.calc-head { display: flex; align-items: center; justify-content: space-between; }
.calc-head .algo-h2 { margin-top: 18px; }
.calc-hint { font-size: 13px; margin: -4px 0 12px; }
.calc-rows { display: grid; gap: 2px; }
.calc-group { margin: 12px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); }
.calc-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 14.5px; }
.calc-row:hover { background: rgba(255,255,255,.03); }
.calc-row input { accent-color: var(--amber); width: 16px; height: 16px; }
.calc-row.select { justify-content: space-between; }
.calc-row select { background: var(--ink); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font: 14px var(--mono); }
.calc-pts { margin-left: auto; font-size: 12px; color: var(--faint); }
.calc-result { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.calc-score { font-size: 15px; color: var(--text); background: var(--ink-3); padding: 4px 10px; border-radius: 8px; }
.calc-verdict { font-weight: 500; }
.calc-verdict.low { color: var(--good); }
.calc-verdict.mid { color: var(--amber); }
.calc-verdict.high { color: var(--bad); }

@media (max-width: 860px) {
  .algo-view { grid-template-columns: 1fr; gap: 18px; padding: 18px; }
  .algo-side { position: static; }
  .algo-nav { flex-direction: row; flex-wrap: wrap; border-left: 0; gap: 6px; }
  .algo-nav a { border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; margin: 0; font-size: 13px; }
  .algo-nav a.active { border-color: var(--amber); }
  .algo-title { font-size: 34px; }
  .algo-interp li { grid-template-columns: 1fr; gap: 4px; }
  .feat.wide { grid-column: auto; }
  .annot-text { font-size: 44px; }
}
