/* PróteseLab 3D — estilos */
:root {
  --bg: #f4f6fa; --bg-2: #ffffff; --bg-3: #eaeef5; --fg: #14213d; --fg-2: #4b5670; --fg-3: #7c869c;
  --line: #d9dfea; --brand: #0f2a4a; --brand-2: #1f5fa8; --accent: #2f7dd1; --accent-2: #e0edfb; --ok: #16a34a; --warn: #d97706; --err: #dc2626;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 6px 20px rgba(16,24,40,.08); --radius: 12px; --topbar-h: 56px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-theme="dark"] {
  --bg: #0d1424; --bg-2: #141d31; --bg-3: #1b2640; --fg: #e8edf6; --fg-2: #b4bdd0; --fg-3: #8a94ab;
  --line: #27334f; --brand: #dbe7ff; --brand-2: #8fb8ff; --accent: #5aa0f0; --accent-2: #1a2f4f; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--fg); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; color: var(--brand); }
h1 { font-size: 1.9rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; } h4 { font-size: 1rem; }
p { margin: 0 0 .8em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--bg-3); padding: .1em .35em; border-radius: 4px; }
#app { min-height: 100%; display: flex; flex-direction: column; }
.only-mobile { display: none !important; }

/* ---------- topbar */
.topbar { position: sticky; top: 0; z-index: 50; height: var(--topbar-h); display: flex; align-items: center; gap: 1.2rem; padding: 0 1rem; background: var(--brand); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
[data-theme="dark"] .topbar { background: #0a1220; }
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; font-size: 1.15rem; letter-spacing: .2px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-flex; width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.14); align-items: center; justify-content: center; }
.brand-text strong { font-weight: 800; }
.mainnav { display: flex; gap: .2rem; }
.mainnav a { color: rgba(255,255,255,.82); padding: .45rem .7rem; border-radius: 8px; font-weight: 500; white-space: nowrap; }
.mainnav a:hover, .mainnav a.active { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.search { position: relative; }
.search input { width: 240px; padding: .45rem .7rem; border-radius: 8px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.12); color: #fff; outline: none; }
.search input::placeholder { color: rgba(255,255,255,.6); }
.search input:focus { background: #fff; color: var(--fg); }
.search-results { position: absolute; top: 110%; right: 0; width: 420px; max-height: 60vh; overflow: auto; background: var(--bg-2); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: .3rem; }
.search-results a { display: block; padding: .45rem .6rem; border-radius: 6px; color: var(--fg); }
.search-results a:hover { background: var(--bg-3); text-decoration: none; }
.search-results .type { font-size: .72rem; text-transform: uppercase; color: var(--fg-3); margin-right: .4rem; }
.icon-btn { background: transparent; border: 1px solid rgba(255,255,255,.25); color: #fff; width: 36px; height: 36px; border-radius: 8px; font-size: 1rem; }
.icon-btn:hover { background: rgba(255,255,255,.15); }

/* ---------- botões e formulários */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid transparent; background: var(--accent); color: #fff; font-weight: 600; transition: background .15s, transform .05s; }
.btn:hover { background: var(--brand-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.35); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.15); }
.btn-secondary { background: var(--bg-3); color: var(--fg); border-color: var(--line); }
.btn-secondary:hover { background: var(--line); }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.btn-lg { padding: .7rem 1.2rem; font-size: 1.05rem; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; }
.field label { font-size: .85rem; font-weight: 600; color: var(--fg-2); }
.field input, .field select, .field textarea { padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); color: var(--fg); font: inherit; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent-2); border-color: var(--accent); }
.hint { font-size: .8rem; color: var(--fg-3); }
.error { color: var(--err); font-size: .9rem; margin: .4rem 0; }

/* ---------- layout de páginas */
.main { flex: 1; }
.page { max-width: 1180px; margin: 0 auto; padding: 1.6rem 1.2rem 3rem; }
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 2rem; align-items: center; padding: 2.5rem 0 2rem; }
.hero h1 { font-size: 2.4rem; }
.hero p.lead { font-size: 1.12rem; color: var(--fg-2); }
.hero-art { border-radius: 16px; overflow: hidden; background: linear-gradient(135deg, #0f2a4a, #1f5fa8); min-height: 280px; display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: var(--shadow); position: relative; }
.hero-art .stat { position: absolute; background: rgba(255,255,255,.12); backdrop-filter: blur(4px); padding: .5rem .8rem; border-radius: 10px; font-size: .85rem; }
.grid { display: grid; gap: 1rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card h3 { margin-top: .2rem; }
.module-card { display: flex; flex-direction: column; gap: .5rem; border-top: 4px solid var(--accent); transition: transform .12s, box-shadow .12s; }
.module-card:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(16,24,40,.14); }
.module-card .icon { font-size: 1.8rem; }
.module-card .meta { font-size: .8rem; color: var(--fg-3); display: flex; gap: .8rem; flex-wrap: wrap; }
.progress { height: 6px; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ok); border-radius: 4px; transition: width .3s; }
.badge { display: inline-block; padding: .1em .5em; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--accent-2); color: var(--brand-2); }
.badge.pos { background: #fde68a; color: #92400e; } .badge.grad { background: #bbf7d0; color: #166534; }
.lesson-list { display: flex; flex-direction: column; gap: .5rem; }
.lesson-row { display: flex; align-items: center; gap: .9rem; padding: .8rem 1rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; color: var(--fg); }
.lesson-row:hover { border-color: var(--accent); text-decoration: none; }
.lesson-row .num { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-2); color: var(--brand-2); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.lesson-row .info { flex: 1; }
.lesson-row .info small { color: var(--fg-3); }
.lesson-row .done { color: var(--ok); font-weight: 700; }
.refs { font-size: .85rem; color: var(--fg-2); }
.refs li { margin-bottom: .3rem; }
.toc { position: sticky; top: calc(var(--topbar-h) + 1rem); }
.two-col { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem .8rem; font-size: .9rem; }
.kv dt { color: var(--fg-3); } .kv dd { margin: 0; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tbl th, table.tbl td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; }
table.tbl th { background: var(--bg-3); }

/* ---------- viewport 3D */
.viewport-host { position: fixed; z-index: 5; inset: var(--topbar-h) 0 0 0; pointer-events: none; }
.viewport-host[hidden] { display: none; }
.viewport { position: absolute; inset: 0; pointer-events: auto; background: radial-gradient(1200px 700px at 50% 30%, #ffffff 0%, #e9eef6 60%, #d7deea 100%); }
[data-theme="dark"] .viewport { background: radial-gradient(1200px 700px at 50% 30%, #1b2740 0%, #0f1727 65%, #0a101c 100%); }
.viewport canvas.gl-canvas { display: block; width: 100% !important; height: 100% !important; outline: none; }
.label-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { font-size: 12px; font-weight: 600; color: #14213d; background: rgba(255,255,255,.92); padding: 2px 7px; border-radius: 6px; border: 1px solid rgba(20,33,61,.25); white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.15); transform: translate(-50%, -50%); }
.lbl-fdi { background: rgba(15,42,74,.9); color: #fff; border-color: transparent; font-size: 11px; padding: 1px 6px; }
.lbl-measure { background: #ff5722; color: #fff; border-color: transparent; }
.viewport-overlay { position: absolute; inset: 0; pointer-events: none; }
.viewport-overlay > * { pointer-events: auto; }

/* player layout */
.player { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 6; display: grid; grid-template-columns: 250px 1fr 380px; pointer-events: none; }
.player > * { pointer-events: auto; }
.player .side { background: var(--bg-2); border-right: 1px solid var(--line); overflow: auto; padding: .8rem; display: flex; flex-direction: column; gap: .6rem; }
.player .center { position: relative; pointer-events: none; }
.player .lesson-panel { background: var(--bg-2); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side .module-title { font-weight: 700; color: var(--brand); font-size: .95rem; }
.side .steps { display: flex; flex-direction: column; gap: 2px; }
.side .step-btn { text-align: left; background: transparent; border: 0; padding: .4rem .5rem; border-radius: 6px; color: var(--fg-2); font-size: .85rem; display: flex; gap: .5rem; align-items: center; }
.side .step-btn:hover { background: var(--bg-3); }
.side .step-btn.active { background: var(--accent-2); color: var(--brand-2); font-weight: 600; }
.side .step-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.side .step-btn.done .dot { background: var(--ok); }
.side .lessons-nav a { display: block; padding: .35rem .5rem; border-radius: 6px; color: var(--fg-2); font-size: .85rem; }
.side .lessons-nav a.active { background: var(--bg-3); color: var(--fg); font-weight: 600; }
.lesson-panel .panel-head { padding: .9rem 1.1rem .5rem; border-bottom: 1px solid var(--line); }
.lesson-panel .panel-head .crumbs { font-size: .78rem; color: var(--fg-3); }
.lesson-panel .panel-head h2 { font-size: 1.15rem; margin: .2rem 0 .3rem; }
.lesson-panel .panel-body { flex: 1; overflow: auto; padding: .8rem 1.1rem 1rem; }
.lesson-panel .panel-body p, .lesson-panel .panel-body li { font-size: .93rem; }
.lesson-panel .panel-body table { width: 100%; border-collapse: collapse; font-size: .85rem; margin: .5rem 0; }
.lesson-panel .panel-body td, .lesson-panel .panel-body th { border: 1px solid var(--line); padding: .3rem .45rem; }
.keyfacts { margin: .8rem 0; padding: .7rem .9rem; background: var(--accent-2); border-left: 4px solid var(--accent); border-radius: 8px; }
.keyfacts h4 { margin: 0 0 .3rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; color: var(--brand-2); }
.keyfacts li { font-size: .88rem; }
.task { margin: .8rem 0; padding: .6rem .9rem; background: #fef3c7; color: #78350f; border-radius: 8px; font-size: .88rem; }
[data-theme="dark"] .task { background: #3a2f0f; color: #fde68a; }
.panel-foot { display: flex; gap: .5rem; align-items: center; padding: .7rem 1rem; border-top: 1px solid var(--line); }
.panel-foot .counter { margin-left: auto; font-size: .85rem; color: var(--fg-3); }
.notes { margin-top: .8rem; }
.notes textarea { width: 100%; min-height: 70px; font-size: .85rem; }
.obj-info { position: absolute; left: 12px; top: 12px; max-width: 320px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: .6rem .8rem; font-size: .85rem; pointer-events: auto; }
.obj-info h4 { margin: 0 0 .2rem; font-size: .95rem; }
.obj-info .mat { color: var(--fg-3); font-size: .78rem; }
.obj-info .close { float: right; border: 0; background: transparent; color: var(--fg-3); font-size: 1rem; }
.tooltip { position: absolute; background: rgba(15,42,74,.92); color: #fff; padding: 3px 8px; border-radius: 6px; font-size: .78rem; pointer-events: none; transform: translate(12px, 12px); white-space: nowrap; z-index: 9; }
.scene-name { position: absolute; left: 50%; transform: translateX(-50%); top: 10px; max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .78rem; color: var(--fg-3); background: rgba(255,255,255,.7); padding: 2px 8px; border-radius: 6px; pointer-events: none; }
[data-theme="dark"] .scene-name { background: rgba(0,0,0,.4); }
.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.55); backdrop-filter: blur(2px); font-weight: 600; color: var(--brand); z-index: 8; pointer-events: auto; }
[data-theme="dark"] .loading { background: rgba(0,0,0,.45); color: #fff; }
.loading .spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin-right: .6rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* barra de ferramentas 3D */
.toolbar { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: .35rem; align-items: center; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: .35rem .5rem; box-shadow: var(--shadow); flex-wrap: wrap; justify-content: center; max-width: calc(100% - 24px); }
.toolbar .tb { border: 1px solid transparent; background: transparent; color: var(--fg-2); padding: .35rem .5rem; border-radius: 8px; font-size: .8rem; display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.toolbar .tb:hover { background: var(--bg-3); color: var(--fg); }
.toolbar .tb.active { background: var(--accent-2); color: var(--brand-2); border-color: var(--accent); }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 .2rem; }
.toolbar .group { position: relative; }
.toolbar .pop { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: .6rem .8rem; min-width: 230px; display: none; z-index: 20; }
.toolbar .group.open .pop { display: block; }
.pop h5 { margin: 0 0 .4rem; font-size: .78rem; text-transform: uppercase; color: var(--fg-3); letter-spacing: .4px; }
.pop .row { display: flex; align-items: center; gap: .5rem; margin: .3rem 0; font-size: .85rem; }
.pop .row label { flex: 1; }
.pop input[type=range] { width: 130px; }
.pop select { font-size: .85rem; padding: .2rem .3rem; border-radius: 6px; border: 1px solid var(--line); background: var(--bg-2); color: var(--fg); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: .2rem .5rem; font-size: .78rem; color: var(--fg-2); }
.seg button.on { background: var(--accent); color: #fff; }

/* quiz */
.quiz-q { margin-bottom: 1.2rem; }
.quiz-q .opts { display: flex; flex-direction: column; gap: .4rem; margin: .5rem 0; }
.quiz-q .opt { text-align: left; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); color: var(--fg); }
.quiz-q .opt:hover { border-color: var(--accent); }
.quiz-q .opt.sel { border-color: var(--accent); background: var(--accent-2); }
.quiz-q .opt.correct { border-color: var(--ok); background: #dcfce7; color: #14532d; }
.quiz-q .opt.wrong { border-color: var(--err); background: #fee2e2; color: #7f1d1d; }
.quiz-q .expl { font-size: .88rem; padding: .5rem .8rem; background: var(--bg-3); border-radius: 8px; margin-top: .4rem; }
.score { font-size: 2rem; font-weight: 800; color: var(--brand); }

/* atlas (laboratório) */
.lab-panel { position: fixed; z-index: 6; top: calc(var(--topbar-h) + 12px); left: 12px; width: 320px; max-height: calc(100vh - var(--topbar-h) - 24px); overflow: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: .9rem 1rem; }
.lab-panel h3 { margin-bottom: .4rem; }
.lab-panel .field { margin-bottom: .5rem; }
.lab-panel .field label { font-size: .78rem; }
.lab-panel .field input, .lab-panel .field select { padding: .35rem .5rem; font-size: .88rem; }
.lab-panel.collapsed { width: auto; max-height: none; padding: .4rem .6rem; }
.lab-panel.collapsed > *:not(.lab-toggle) { display: none; }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(10,18,32,.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal { background: var(--bg-2); border-radius: 14px; box-shadow: var(--shadow); width: min(520px, 100%); max-height: 90vh; overflow: auto; padding: 1.3rem 1.4rem; }
.modal h2 { margin-bottom: .8rem; }
.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs button { background: transparent; border: 0; padding: .5rem .8rem; color: var(--fg-2); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.toast-root { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: var(--brand); color: #fff; padding: .6rem .9rem; border-radius: 10px; box-shadow: var(--shadow); font-size: .9rem; animation: fadein .2s; }
.toast.ok { background: var(--ok); } .toast.err { background: var(--err); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }
.kbd { font-family: ui-monospace, monospace; font-size: .75rem; background: var(--bg-3); border: 1px solid var(--line); border-bottom-width: 2px; padding: 0 .35em; border-radius: 4px; }

/* ---------- responsivo */
@media (max-width: 1100px) {
  .player { grid-template-columns: 1fr 360px; }
  .player .side { display: none; }
  .player .side.open { display: flex; position: absolute; left: 0; top: 0; bottom: 0; width: 260px; z-index: 7; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .hero { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .only-mobile { display: inline-flex !important; }
  .mainnav { display: none; position: fixed; top: var(--topbar-h); left: 0; right: 0; background: var(--brand); flex-direction: column; padding: .5rem; z-index: 60; }
  .mainnav.open { display: flex; }
  .search input { width: 120px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .player { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .player .lesson-panel { border-left: 0; border-top: 1px solid var(--line); max-height: 46vh; }
  .lab-panel { width: calc(100% - 24px); max-height: 45vh; }
  .toolbar { bottom: 6px; padding: .25rem .3rem; }
  .toolbar .tb span.txt { display: none; }
  .hero h1 { font-size: 1.7rem; }
}
@media print { .topbar, .viewport-host, .toolbar { display: none !important; } .player { position: static; display: block; } }

/* insets do viewport conforme o modo */
.viewport-host.mode-player { left: 250px; right: 380px; }
@media (max-width: 1100px) { .viewport-host.mode-player { left: 0; } }
@media (max-width: 760px) { .viewport-host.mode-player { right: 0; bottom: 46vh; } }
body.immersive { overflow: hidden; }
.lab-panel .lab-toggle { flex: none; }
