/* Mô phỏng thủ thuật 3D — giao diện. Token màu và kiểu chữ dùng chung với newbieneuro.com
   (website/public/styles.css, aspects-scorer/css/aspects.css). */

:root {
  --bg: #E7EAE7; --panel: #F1F3F0; --sunk: #DBE0DC; --rowHover: #EFF2EF;
  --ink: #12191A; --ink2: #3C4745; --meta: #5B6764;
  --hair: #BFC7C1; --strong: #12191A; --dash: #8E9A94;
  --core: #A8114F; --coreH: #78093A; --coreOn: #FFFFFF; --coreBg: #F3DCE6;
  --pen: #1B6655; --penOn: #FFFFFF; --penBg: #D3E6DE;
  --amber: #8A5A00; --amberBg: #F3E5C4;
  --inv: #12191A; --invInk: #E7EAE7; --invInk2: #C3CCC8; --invMeta: #9DA9A4; --invHair: #3A4548;
  --stage: #2A3437;
  --display: 'Archivo', 'Be Vietnam Pro', system-ui, sans-serif;
  --body: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #12191B; --panel: #1B2326; --sunk: #283236; --rowHover: #222B2F;
  --ink: #E3E9E5; --ink2: #B2BDB8; --meta: #8B9793;
  --hair: #2F3A3D; --strong: #5A686D; --dash: #4A585C;
  --core: #FF74A8; --coreH: #FFA3C6; --coreOn: #24050F; --coreBg: #3A1024;
  --pen: #63CCAB; --penOn: #05261D; --penBg: #16352C;
  --amber: #EFC478; --amberBg: #3A2A13;
  --inv: #28343A; --invInk: #EDF2EF; --invInk2: #C0CBC6; --invMeta: #94A09B; --invHair: #435256;
  --stage: #151D20;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--core); text-decoration: none; }
a:hover { color: var(--coreH); text-decoration: underline; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--core); outline-offset: 2px; }
p { margin: 0; }
[hidden] { display: none !important; }

.tt-root { max-width: 1480px; margin: 0 auto; padding: 0 32px 40px; }

/* ---------- đầu trang ---------- */
.tt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 28px 0 18px; }
.tt-head--sim { padding-bottom: 14px; }
.tt-back { display: inline-block; font-size: 14px; margin-bottom: 10px; }
.tt-code { font-family: var(--mono); font-size: 13px; color: var(--core); margin-bottom: 6px; }
.tt-head h1 {
  margin: 0 0 8px; font-family: var(--display); font-variation-settings: 'wdth' 112, 'wght' 730;
  font-size: clamp(24px, 3.4vw, 38px); line-height: 1.08; letter-spacing: -0.024em;
}
.tt-lead { font-size: 15.5px; line-height: 1.6; color: var(--ink2); max-width: 860px; }

.tt-btn {
  min-height: 40px; padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 14px; font-weight: 500; border-radius: 2px; white-space: nowrap;
  background: var(--inv); color: var(--invInk); border: 1px solid var(--inv);
}
.tt-btn:hover { background: var(--ink2); border-color: var(--ink2); }
.tt-btn--ghost { background: var(--panel); color: var(--ink); border-color: var(--hair); }
.tt-btn--ghost:hover { background: var(--sunk); border-color: var(--dash); }
.tt-btn--icon { width: 40px; padding: 0; flex-shrink: 0; }
body:has(.nn-header) [data-act="theme"] { display: none; }

/* ---------- danh mục ---------- */
.tt-group { border-top: 2px solid var(--strong); padding-top: 14px; margin-top: 10px; margin-bottom: 26px; }
.tt-group h2 { margin: 0 0 14px; font-family: var(--display); font-variation-settings: 'wdth' 108, 'wght' 680; font-size: 20px; letter-spacing: -0.01em; }
.tt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.tt-card {
  display: flex; flex-direction: column; gap: 8px; padding: 16px 18px 18px; min-height: 150px;
  background: var(--panel); border: 1px solid var(--hair); border-radius: 2px; color: var(--ink);
}
.tt-card:hover { text-decoration: none; border-color: var(--core); background: var(--rowHover); color: var(--ink); }
.tt-card-code { font-family: var(--mono); font-size: 13px; color: var(--core); }
.tt-card-title { font-family: var(--display); font-variation-settings: 'wdth' 104, 'wght' 640; font-size: 17.5px; line-height: 1.28; }
.tt-card-meta { margin-top: auto; font-size: 13px; color: var(--meta); }
.tt-chip { display: inline-block; padding: 2px 8px; border-radius: 2px; font-size: 12px; font-weight: 500; }
.tt-chip--draft { background: var(--amberBg); color: var(--amber); }
.tt-empty { color: var(--meta); }

/* ---------- bố cục trình xem ---------- */
.tt-main { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 22px; align-items: start; border-top: 1px solid var(--hair); padding-top: 18px; }
.tt-left { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.tt-stagewrap { position: relative; background: var(--stage); border-radius: 2px; overflow: hidden; }
.tt-stage { position: relative; height: min(66vh, 680px); min-height: 380px; touch-action: none; }
.tt-stagewrap:fullscreen .tt-stage { height: 100vh; }
.tt-stage canvas { display: block; width: 100%; height: 100%; }
.tt-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tt-tool {
  min-height: 32px; padding: 0 10px; font-size: 12.5px; font-weight: 500; border-radius: 2px;
  background: rgba(10, 16, 18, 0.62); color: #E7EEEA; border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(4px);
}
.tt-tool:hover { background: rgba(10, 16, 18, 0.82); }
.tt-tool[aria-pressed="true"] { background: #A8114F; border-color: #A8114F; color: #fff; }
.tt-tool--flat { background: var(--panel); color: var(--ink); border-color: var(--hair); backdrop-filter: none; }
.tt-tool--flat:hover { background: var(--sunk); }
.tt-tool--flat[aria-pressed="true"] { background: var(--penBg); border-color: var(--pen); color: var(--pen); }
.tt-hint { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: rgba(231, 238, 234, 0.7); pointer-events: none; }

/* nhãn giải phẫu */
.tt-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tt-label { position: absolute; left: 0; top: 0; will-change: transform; }
.tt-label::before { content: ''; position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1.5px rgba(0,0,0,.55); }
.tt-label span {
  position: absolute; left: 8px; top: -11px; white-space: nowrap;
  padding: 2px 7px; font-size: 12px; font-weight: 600; line-height: 18px; border-radius: 2px;
  background: rgba(10, 16, 18, 0.72); color: #F1F5F3;
}
.tt-label.is-focus span { background: #F2C230; color: #1A1400; }
.tt-label.is-focus::before { background: #F2C230; }

/* điều khiển */
.tt-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tt-controls input[type="range"] { flex: 1 1 200px; accent-color: var(--core); }
.tt-time { font-family: var(--mono); font-size: 12.5px; color: var(--meta); min-width: 118px; }
.tt-speed { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--meta); }
.tt-speed select { min-height: 32px; background: var(--panel); border: 1px solid var(--hair); border-radius: 2px; padding: 0 6px; }
.tt-play[data-state] { min-width: 112px; }
#tt-play { min-width: 116px; }

.tt-layerbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 0 0; border-top: 1px solid var(--hair); }
.tt-layers { display: flex; gap: 6px; flex-wrap: wrap; }
.tt-layer {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 10px; font-size: 12.5px;
  background: var(--panel); border: 1px solid var(--hair); border-radius: 2px; color: var(--ink);
}
.tt-layer[aria-pressed="false"] { color: var(--meta); text-decoration: line-through; opacity: .7; }
.tt-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tt-dot--da { background: #e2b49b; } .tt-dot--co { background: #b4554d; } .tt-dot--xuong { background: #ece2c8; box-shadow: inset 0 0 0 1px #b9ad8f; }
.tt-dot--mach { background: linear-gradient(90deg, #c8323c 50%, #3b5fae 50%); } .tt-dot--tk { background: #f0d35a; }
.tt-dot--tang { background: #d9867f; } .tt-dot--dc { background: #c7d0d8; box-shadow: inset 0 0 0 1px #7d8a92; }
.tt-skin { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--meta); }
.tt-skin input { accent-color: var(--core); width: 130px; }

/* cột phải */
.tt-side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 12px; }
.tt-side > * { flex-shrink: 0; }
.tt-inset { background: #000; border-radius: 2px; overflow: hidden; }
.tt-inset-title { padding: 6px 10px; font-size: 12.5px; font-weight: 600; color: #E7EEEA; background: #1a2326; }
.tt-inset-view { position: relative; aspect-ratio: 4 / 3; }
.tt-inset-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.tt-now { background: var(--inv); color: var(--invInk); border-radius: 2px; padding: 14px 16px 16px; border-top: 4px solid #F2C230; }
.tt-now-k { font-family: var(--mono); font-size: 12px; color: var(--invMeta); }
.tt-now h3 { margin: 2px 0 8px; font-family: var(--display); font-variation-settings: 'wdth' 106, 'wght' 680; font-size: 19px; line-height: 1.25; }
.tt-now-d { font-size: 14.5px; line-height: 1.6; color: var(--invInk2); }
.tt-now .tt-warn { margin: 10px 0 0; padding-left: 0; list-style: none; }
.tt-now .tt-warn li { position: relative; padding-left: 20px; font-size: 13.5px; line-height: 1.5; color: #F5CE82; }
.tt-now .tt-warn li + li { margin-top: 4px; }
.tt-now .tt-warn li::before { content: '!'; position: absolute; left: 0; top: 1px; width: 14px; height: 14px; border-radius: 50%; background: #F5CE82; color: #1A1400; font-size: 10px; font-weight: 700; text-align: center; line-height: 14px; }
.tt-neuro { margin-top: 10px; padding: 8px 10px; font-size: 13.5px; line-height: 1.5; background: rgba(127, 220, 190, 0.12); border-left: 3px solid #7FDCBE; color: #D6F2E8; }
.tt-neuro b { color: #7FDCBE; }

.tt-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--hair); }
.tt-tabs button { padding: 8px 0; background: none; border: 0; border-bottom: 3px solid transparent; font-weight: 600; font-size: 14px; color: var(--meta); }
.tt-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--core); }

.tt-steps { list-style: none; margin: 0; padding: 0; border: 1px solid var(--hair); border-radius: 2px; background: var(--panel); max-height: 32vh; overflow: auto; }
.tt-prep, .tt-refs { max-height: 40vh; overflow: auto; }
.tt-steps li + li { border-top: 1px solid var(--hair); }
.tt-steps button { display: flex; gap: 10px; width: 100%; padding: 9px 12px; text-align: left; background: none; border: 0; font-size: 14px; line-height: 1.4; }
.tt-steps button:hover { background: var(--rowHover); }
.tt-steps b { flex: 0 0 24px; height: 24px; display: grid; place-items: center; font-family: var(--mono); font-size: 12px; border-radius: 2px; background: var(--sunk); color: var(--ink2); }
.tt-steps button.is-on { background: var(--coreBg); }
.tt-steps button.is-on b { background: var(--core); color: var(--coreOn); }

.tt-prep, .tt-refs { font-size: 14px; line-height: 1.55; }
.tt-prep h4 { margin: 12px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--meta); }
.tt-prep h4:first-child { margin-top: 4px; }
.tt-prep ul { margin: 0; padding-left: 18px; }
.tt-prep ul.tt-warn li::marker { color: var(--amber); }
.tt-prep ul.tt-neurol { background: var(--penBg); padding: 8px 10px 8px 26px; border-left: 3px solid var(--pen); }
.tt-refs ol { margin: 4px 0 10px; padding-left: 20px; }
.tt-refs li + li { margin-top: 6px; }
.tt-note { font-size: 13px; color: var(--meta); }

.tt-foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--hair); font-size: 13px; color: var(--meta); }

@media (max-width: 1100px) {
  .tt-main { grid-template-columns: 1fr; }
  .tt-side { position: static; }
  .tt-steps, .tt-prep, .tt-refs { max-height: none; }
  .tt-inset-view { aspect-ratio: 16 / 9; }
}
@media (max-width: 640px) {
  .tt-root { padding: 0 16px 32px; }
  .tt-stage { height: 58vh; min-height: 320px; }
  .tt-hint { display: none; }
  .tt-tools { left: 8px; right: 8px; }
  .tt-time { min-width: 0; }
}
