/* HandSpace 3D — phòng thí nghiệm ảo, tông sáng.
   Nền trắng lạnh như bàn thí nghiệm, chữ xanh than, nhấn xanh đồng sunfat; vàng an toàn chỉ dùng cho nút bật camera. */
:root {
  --paper: #eeeff7;      /* nền trang: xám tím lạnh */
  --panel: #ffffff;
  --ink: #17163a;        /* mực chàm: chữ chính, thanh điều hướng, hero */
  --ink-2: #24225a;
  --muted: #5d5c86;
  --line: #dcdcec;
  --soft: #ecebf7;
  --accent: #5b4cf0;     /* tím iris */
  --accent-ink: #4334d6;
  --signal: #ff7a3d;     /* cam: camera, thanh giữ tay */
  --signal-ink: #e85f20;
  --ok: #12b386;
  --bad: #d93d4a;
  --stage: #e6e7f3;      /* nền cảnh 3D (đồng bộ với world.js) */
  --shadow: 0 1px 2px rgba(23,22,58,.06), 0 10px 30px rgba(23,22,58,.08);
  --r-lg: 22px; --r-md: 14px; --r-sm: 10px;
  --font-display: 'Bricolage Grotesque', 'Be Vietnam Pro', system-ui, sans-serif;
  --bs-body-font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  --bs-body-bg: var(--paper);
  --bs-body-color: var(--ink);
  --bs-secondary-color: var(--muted);
  --bs-border-color: var(--line);
  --bs-link-color: var(--accent);
  --bs-link-color-rgb: 91, 76, 240;
  --bs-link-hover-color: var(--accent-ink);
  --bs-link-hover-color-rgb: 67, 52, 214;
  --bs-primary: var(--accent);
  --bs-primary-rgb: 91, 76, 240;
}
body { background: var(--paper); color: var(--ink); min-height: 100vh; font-family: var(--bs-body-font-family); }
h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.text-secondary { color: var(--muted) !important; }
.text-accent { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-accent, .btn-primary { background: var(--accent); border: 1px solid var(--accent); color: #fff; }
.btn-accent:hover, .btn-accent:focus, .btn-primary:hover, .btn-primary:focus { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn-outline-secondary { --bs-btn-color: var(--ink); --bs-btn-border-color: var(--line); --bs-btn-bg: var(--panel);
  --bs-btn-hover-bg: var(--soft); --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: #c9c8e2;
  --bs-btn-active-bg: #e1e0f2; --bs-btn-active-color: var(--ink); --bs-btn-active-border-color: #c9c8e2; }
.form-control, .form-select { border-color: var(--line); }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 76, 240, .15); }
.list-group-item { border-color: var(--line); }

.app-nav { background: var(--panel); border-bottom: 1px solid var(--line); }
.app-nav .navbar-brand { color: var(--ink); letter-spacing: -.02em; }
.app-nav .navbar-brand i { color: var(--accent); }
.app-nav .nav-link { color: var(--muted); font-weight: 500; }
.app-nav .nav-link:hover { color: var(--ink); }
.app-nav .nav-link.active { color: var(--ink); }
.app-nav .nav-link.active i { color: var(--accent); }

.role-badge { display: inline-block; padding: .15rem .55rem; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.role-viewer { background: #e9e8f3; color: #4d4b75; }
.role-controller { background: #e6e3ff; color: var(--accent-ink); }
.role-admin { background: #fbecd0; color: #8a5a00; }

.toast-stack { position: fixed; top: 70px; right: 16px; z-index: 2000; max-width: 420px; }
.auth-card { max-width: 440px; margin: 3rem auto; background: var(--panel); padding: 2rem; border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.auth-card.wide { max-width: 640px; }

/* trang chủ */
.hero { padding: 2.25rem 2.5rem; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.hero h1 { font-size: clamp(1.6rem, 3.4vw, 2.6rem); font-weight: 800; letter-spacing: -.03em; margin-bottom: 1.25rem; max-width: 18ch; }
.gesture-table { --bs-table-bg: transparent; }
.gesture-table td { font-size: .9rem; color: var(--ink); border-color: var(--line); }
.gesture-table td:first-child { width: 48%; color: var(--muted); }

/* thư viện */
.obj-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; height: 100%; }
.obj-card.inactive { opacity: .5; }
.obj-thumb { position: relative; height: 150px; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--c) 22%, transparent), transparent 70%), var(--soft); }
.obj-thumb img { width: 100%; height: 100%; object-fit: cover; }
.obj-desc { min-height: 2.5em; }
.prim-icon { width: 64px; height: 64px; background: var(--c); box-shadow: 0 10px 24px color-mix(in srgb, var(--c) 35%, transparent), inset 0 0 0 1px rgba(23,22,58,.12); }
.prim-box, .prim-file { border-radius: 8px; transform: rotate(12deg); }
.prim-sphere, .prim-joint { border-radius: 50%; }
.prim-cylinder { border-radius: 30px / 12px; width: 50px; }
.prim-cone { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.prim-torus { border-radius: 50%; background: transparent; border: 16px solid var(--c); }
.prim-rod { width: 14px; height: 90px; border-radius: 7px; transform: rotate(35deg); }
.prim-plate { height: 18px; width: 100px; border-radius: 4px; }
.prim-wheel { border-radius: 50%; background: radial-gradient(circle, #c9ced6 35%, var(--c) 37%); }
.kind-tag { position: absolute; top: 8px; left: 8px; font-size: .72rem; padding: .1rem .5rem; border-radius: 99px; font-weight: 600; }
.kind-module { background: #e6e3ff; color: var(--accent-ink); }
.kind-object { background: #fbecd0; color: #8a5a00; }
.kind-extra { background: #ece6f6; color: #5a3d8a; }
.preview-box { height: 380px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--stage); }

/* ================= studio ================= */
.studio-page { overflow: hidden; }
.studio { display: flex; height: calc(100vh - 57px); height: calc(var(--app-h, 100vh) - var(--hdr-h, 57px)); }
.cam-box.cam-collapsed { display: none; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.studio-side { width: 270px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.side-head, .side-foot { padding: .75rem; border-bottom: 1px solid var(--line); }
.side-foot { border-bottom: 0; border-top: 1px solid var(--line); }
.lib-list { flex: 1; overflow-y: auto; padding: .4rem; }
.lib-item { position: relative; width: 100%; display: flex; align-items: center; gap: .6rem; text-align: left; padding: .5rem;
  border: 1px solid transparent; border-radius: 10px; background: transparent; color: inherit; }
.lib-item:hover { background: var(--soft); border-color: var(--line); }
.lib-item img, .lib-item .swatch { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(23,22,58,.12); }
.lib-name { flex: 1; font-size: .88rem; line-height: 1.2; font-weight: 500; }
.lib-name small { display: block; color: var(--muted); font-size: .72rem; font-weight: 400; }
.lib-item .kind-tag { position: static; }

.studio-stage { position: relative; flex: 1; min-width: 0; background: var(--stage); }
.viewport, .hand-overlay { position: absolute; inset: 0 0 40px 0; }
.viewport canvas { display: block; touch-action: none; }
.ar-bg { position: absolute; inset: 0 0 40px 0; width: 100%; height: calc(100% - 40px); object-fit: cover; transform: scaleX(-1); }
.studio-stage.ar-on { background: #000; }
.hand-overlay { pointer-events: none; width: 100%; height: calc(100% - 40px); }

/* các bảng nổi trên cảnh: trắng mờ, viền mảnh */
.optics-panel, .cam-zoom, .help-panel {
  background: rgba(255, 255, 255, .92); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(8px); color: var(--ink); }
.cam-box { position: absolute; top: 12px; right: 12px; width: 300px; border-radius: 12px; overflow: hidden;
  border: 2px solid var(--panel); background: #000; box-shadow: 0 10px 30px rgba(23,22,58,.25); }
.cam-box video, .cam-box canvas { width: 100%; display: block; transform: scaleX(-1); }
.cam-box canvas { position: absolute; inset: 0; height: 100%; }
.cam-label { position: absolute; bottom: 0; left: 0; right: 0; font-size: .75rem; padding: 3px 8px; background: rgba(23,22,58,.65); color: #fff; }
#chem-lamp.active { background: #ff8a3c; border-color: #ff8a3c; color: var(--ink); }
.optics-panel { position: absolute; left: 50%; transform: translateX(-50%); bottom: 124px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  justify-content: center; max-width: calc(100% - 24px); padding: 6px 10px; font-size: .85rem; z-index: 4; border-radius: 12px; }
.optics-panel[hidden] { display: none; }
.optics-title { font-weight: 600; margin-right: 2px; }
.optics-colors { display: flex; gap: 5px; }
.optics-colors[hidden] { display: none; }
.optics-colors .swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: var(--c);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink); padding: 0; }
.optics-colors .swatch.active { border-color: var(--panel); box-shadow: 0 0 0 2px var(--accent); }
.cam-zoom { position: absolute; right: 12px; bottom: 124px; display: flex; align-items: center; gap: 8px; margin: 0; padding: 6px 12px; font-size: .85rem; z-index: 4; border-radius: 10px; }
.cam-zoom[hidden] { display: none; }
.cam-zoom input { width: 150px; }
.cam-zoom span { min-width: 3em; text-align: right; font-variant-numeric: tabular-nums; }
#status-scene, #status-assembly { color: var(--muted); }
#status-gesture[data-kind="ok"] { color: var(--ok); }
#status-gesture[data-kind="error"] { color: var(--bad); }
.help-panel { position: absolute; top: 64px; left: 12px; width: 480px; max-width: calc(100% - 24px); border-radius: 12px; padding: 1rem; z-index: 5; }
@media (max-width: 800px) {
  .studio-side { width: 200px; }
  .cam-box { width: 180px; }
}

/* camera sau: không lật gương */
.no-mirror .ar-bg, .no-mirror .cam-box video, .no-mirror .cam-box canvas { transform: none; }

/* ================= điện thoại / máy tính bảng (kiểu app) ================= */
:root { --tab-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px); }
.side-backdrop { display: none; }

@media (max-width: 991.98px) {
  body.has-tabbar { padding-bottom: calc(var(--tab-h) + var(--safe-b)); }
  .app-nav { position: sticky; top: 0; z-index: 1030; padding-top: calc(env(safe-area-inset-top, 0px) + .35rem);
    padding-bottom: .35rem; background: rgba(255,255,255,.94); backdrop-filter: blur(10px); }
  .app-nav .navbar-brand { font-size: 1.1rem; }
  .toast-stack { top: 64px; left: 12px; right: 12px; max-width: none; }
  main.container { padding-top: 1rem !important; padding-bottom: 1.25rem !important; }

  /* thanh tab dưới cùng */
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1045; display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: rgba(255,255,255,.96); backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
  .tabbar > a, .tabbar > button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: .68rem; font-weight: 500; background: none; border: 0; padding: 0;
    -webkit-tap-highlight-color: transparent; }
  .tabbar i { font-size: 1.3rem; line-height: 1; }
  .tabbar .active { color: var(--ink); }
  .tabbar .active i { color: var(--accent); }
  .tabbar > :focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 10px; }
  .tab-main-dot { display: grid; place-items: center; width: 52px; height: 52px; margin-top: -24px; border-radius: 50%;
    background: var(--accent); color: #fff; box-shadow: 0 0 0 5px var(--paper), 0 8px 18px rgba(91,76,240,.35); }
  .tab-main-dot i { font-size: 1.45rem; color: #fff !important; }
  .tabbar .tab-main.active .tab-main-dot { box-shadow: 0 0 0 5px var(--paper), 0 0 0 7px rgba(91,76,240,.35), 0 8px 18px rgba(91,76,240,.35); }

  /* bảng "Tôi" trượt từ dưới lên */
  .me-sheet { height: auto !important; max-height: 80dvh; border-radius: 20px 20px 0 0; background: var(--panel);
    border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 1060; }
  .sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: #c9c8e2; margin: 8px auto 0; flex-shrink: 0; }
  .sheet-list .list-group-item { background: transparent; border-color: var(--line); padding: .85rem .25rem; display: flex; gap: .75rem; align-items: center; }
  .sheet-list .list-group-item i { font-size: 1.15rem; width: 1.4rem; text-align: center; color: var(--muted); }
  .sheet-group { font-size: .75rem; color: var(--muted); padding: 1rem .25rem .25rem; }

  /* trang thường */
  .hero { padding: 1.25rem; border-radius: 14px; }
  .hero .btn-lg { width: 100%; margin: 0 0 .5rem !important; }
  .obj-thumb { height: 112px; }
  .prim-icon { transform-origin: center; scale: .8; }
  .obj-card .p-3 { padding: .75rem !important; }
  .obj-card .obj-desc { display: none; }
  .obj-card h6 { font-size: .9rem; }
  .page-head { flex-wrap: wrap; gap: .5rem; }
  .page-head h3 { font-size: 1.3rem; }
  .auth-card { margin: 1.25rem auto; padding: 1.5rem; }

  /* studio toàn màn hình: vùng cố định giữa header và thanh tab, chiều cao đo bằng JS (--app-h) */
  body.studio-page .studio { position: fixed; left: 0; right: 0; top: var(--hdr-h, 49px);
    height: calc(100vh - var(--hdr-h, 49px) - var(--tab-h) - var(--safe-b));
    height: calc(var(--app-h, 100vh) - var(--hdr-h, 49px) - var(--tab-h) - var(--safe-b)); }
  .studio-stage { overflow: hidden; }
  /* iOS tự phóng to trang khi ô nhập chữ < 16px */
  .form-control, .form-select { font-size: 16px; }
  .tabbar span { white-space: nowrap; }
  .studio-side { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); width: auto; height: min(68vh, 560px); height: min(calc(var(--app-h, 100vh) * .7), 560px);
    z-index: 1040; border: 0; border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
    box-shadow: 0 -12px 40px rgba(23,22,58,.18); transform: translateY(calc(100% + var(--tab-h) + 40px));
    transition: transform .28s cubic-bezier(.2,.8,.2,1); }
  body.lib-open .studio-side { transform: none; }
  .side-backdrop { position: fixed; inset: 0; z-index: 1035; background: rgba(23,22,58,.35); }
  body.lib-open .side-backdrop { display: block; }
  .side-head { border-bottom: 0; padding-bottom: .25rem; }
  .side-foot { display: none; }
  .lib-list { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; align-content: start; padding: .5rem .75rem 1rem; }
  .lib-item { flex-direction: column; align-items: flex-start; gap: .4rem; padding: .6rem; min-height: 96px;
    background: var(--paper); border-color: var(--line); }
  .lib-item .kind-tag { position: absolute; top: .55rem; right: .55rem; left: auto; }
  .lib-item:active { background: var(--soft); }

  .optics-panel { bottom: 110px; }
  .cam-box { top: 62px; right: 8px; width: 30vw; max-width: 150px; min-width: 104px; border-radius: 10px; }
  .cam-label { font-size: .65rem; }
  .help-panel { top: 64px; left: 8px; right: 8px; width: auto; max-height: calc(100% - 130px); overflow-y: auto; }
  .lib-fab { position: absolute; right: 12px; bottom: 52px; z-index: 4; display: inline-flex; align-items: center; gap: 6px;
    height: 46px; padding: 0 18px; border: 0; border-radius: 23px; color: #fff; font-weight: 600; font-size: .9rem;
    background: var(--accent); box-shadow: 0 8px 20px rgba(91,76,240,.35); }
  .lib-fab i { font-size: 1.15rem; }
}
.fab-short { display: none; }
@media (max-width: 380px) {
  .tabbar span:not(.tab-main-dot) { font-size: .62rem; }
  .fab-long { display: none; }
  .fab-short { display: inline; }
  .lib-fab { padding: 0 16px; }
  .cam-box { min-width: 96px; }
}
/* điện thoại xoay ngang: thu gọn header & thanh tab để còn chỗ cho cảnh 3D */
@media (max-width: 991.98px) and (max-height: 500px) {
  :root { --tab-h: 46px; }
  body.studio-page .app-nav { display: none; }
  body.studio-page .studio { top: 0; }
  .tabbar span:not(.tab-main-dot) { display: none; }
  .tab-main-dot { width: 40px; height: 40px; margin-top: -8px; }
  .tab-main-dot i { font-size: 1.15rem; }
  .status-bar { height: 28px; }
  .viewport, .hand-overlay, .ar-bg { bottom: 28px; }
  .hand-overlay, .ar-bg { height: calc(100% - 28px); }
  .lib-fab { bottom: 38px; height: 40px; }
  .lib-list { grid-template-columns: repeat(3, 1fr); }
  .lib-item { min-height: 76px; }
}
@media (prefers-reduced-motion: reduce) {
  .studio-side { transition: none; }
}

/* bài học */
.lesson-box { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .65rem; margin-bottom: .5rem; font-size: .82rem; }
.lesson-head { display: flex; flex-direction: column; gap: .45rem; }
.lesson-title { font-weight: 700; color: var(--ink); line-height: 1.25; }
.lesson-sub { color: var(--muted); font-size: .76rem; margin-top: 2px; }
.lesson-head .btn { width: 100%; }
.lesson-box details { margin-top: .45rem; }
.lesson-box summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.lesson-box ol { margin: .3rem 0 0; padding-left: 1.1rem; max-height: 9.5rem; overflow-y: auto; color: var(--ink); }
.lesson-box li { margin-bottom: .2rem; }

/* AR mặt thật (WebXR, DOM overlay): nổi trên hình camera thật nên giữ nền tối trong suốt */
.xr-ui { position: absolute; inset: 0; z-index: 30; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; }
.xr-ui[hidden] { display: none; }
.studio-stage.xr-on, .studio-stage:xr-overlay { background: transparent !important; }
.studio-stage.xr-on > :not(.xr-ui):not(.viewport) { display: none !important; }
.studio-stage.xr-on .viewport { opacity: 0; inset: 0; } /* hình do phiên AR vẽ; canvas chỉ để nhận chạm / kéo vật */
.xr-top { pointer-events: auto; padding: 10px; padding-top: max(10px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 8px; }
.xr-status { align-self: flex-start; max-width: 100%; background: rgba(255,255,255,.92); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; font-size: .9rem; }
.xr-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.xr-cross { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.9); box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.xr-tray { pointer-events: auto; display: flex; gap: 8px; overflow-x: auto; padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(255,255,255,.85) 35%); scrollbar-width: none; }
.xr-tray.disabled { opacity: .45; }
.xr-item { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; max-width: 190px; padding: 8px 10px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); text-align: left; font-size: .82rem; line-height: 1.15; }
.xr-item img, .xr-item .swatch { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.xr-item small { display: block; color: var(--muted); font-size: .7rem; }

/* menu ảo điều khiển bằng tay */
.vmenu { position: absolute; right: max(14px, 5%); top: 50%; transform: translateY(-50%); z-index: 6; display: flex; flex-direction: row-reverse;
  align-items: center; gap: 8px; pointer-events: none; }
.vmenu[hidden] { display: none; }
.vmenu-btn { pointer-events: auto; width: 68px; height: 68px; flex-direction: column; justify-content: center; gap: 0 !important; border-radius: 18px !important;
  background: var(--panel) !important; border: 1px solid var(--line) !important; box-shadow: var(--shadow); font-size: .72rem; font-weight: 600; color: var(--ink); }
.vmenu-btn i { font-size: 1.6rem; line-height: 1; color: var(--accent); }
.vmenu-panel { pointer-events: auto; width: min(290px, 62vw); max-height: min(62vh, 440px); display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.vmenu-panel[hidden] { display: none; }
.vmenu-title { padding: .55rem .8rem; font-weight: 700; border-bottom: 1px solid var(--line); }
.vmenu-list { overflow-y: auto; overscroll-behavior: contain; }
.vm-row { position: relative; width: 100%; display: flex; align-items: center; gap: .65rem; min-height: 56px; padding: .5rem .8rem; text-align: left;
  background: transparent; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); font-size: .9rem; font-weight: 500; line-height: 1.2; overflow: hidden; }
.vm-row:hover, .vm-row.vm-hover { background: var(--soft); }
.vm-row small { display: block; color: var(--muted); font-size: .72rem; font-weight: 400; }
.vm-row > i { font-size: 1.2rem; color: var(--accent); flex-shrink: 0; }
.vm-row img, .vm-row .swatch { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(23,22,58,.12); }
.vm-back { color: var(--muted); min-height: 44px; }
/* thanh đếm 2 giây khi giữ tay trên một mục */
.vm-row::after { content: ''; position: absolute; left: 0; bottom: 0; height: 5px; width: calc(var(--p, 0) * 100%); background: var(--signal); }
.vm-cursor { position: absolute; left: 0; top: 0; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; z-index: 8; pointer-events: none;
  background: rgba(255,122,61,.35); border: 3px solid var(--signal); box-shadow: 0 0 0 2px #fff; }
.vm-cursor[hidden] { display: none; }
.slam-bar { position: absolute; left: 50%; transform: translateX(-50%); bottom: 124px; z-index: 5; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  justify-content: center; max-width: calc(100% - 24px); padding: 6px 10px; font-size: .85rem; border-radius: 12px;
  background: rgba(255,255,255,.92); border: 1px solid var(--line); box-shadow: var(--shadow); }
.slam-bar[hidden] { display: none; }
#slam-status { flex-basis: 100%; text-align: center; font-weight: 500; }
@media (max-width: 991.98px) {
  .vmenu { right: 12px; }
  .vmenu-btn { width: 60px; height: 60px; }
  .slam-bar { bottom: 100px; }
}

/* ---------- phân bài ---------- */
.assign-users { max-height: 70vh; overflow: auto; }
.assign-users small { color: var(--muted); }
.assign-users .active small { color: rgba(255,255,255,.8); }
.assign-group { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .75rem 1rem .85rem; margin-bottom: .75rem; }
.assign-head { font-size: 1rem; margin-bottom: .1rem; }
.assign-title { font-size: .85rem; color: var(--muted); margin: .5rem 0 .2rem; }
.assign-save { padding-top: .5rem; }
.vmenu-empty { padding: .6rem .8rem; font-size: .85rem; color: var(--muted); }

/* ================= studio: bảng điều khiển (bản sáng, chuyên nghiệp) =================
   Một thanh công cụ duy nhất kiểu bảng phím thiết bị đo: phím vuông, biểu tượng trên, nhãn dưới, cùng một nền.
   Màu chỉ đổi dần (transition), không có phím màu chói cạnh nhau. Đỏ chỉ hiện khi rê chuột lên phím xoá. */
:root { --t-fast: .18s; --t-ease: cubic-bezier(.2,.7,.2,1); --accent-soft: #ecebff; --ok-soft: #e3f4ec; --bad-soft: #fbeae7; --warn: #b26b00; --warn-soft: #fff3dc; }
.dock { position: absolute; top: 12px; left: 12px; z-index: 7; display: flex; align-items: stretch; gap: 0; padding: 5px;
  background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 28px rgba(23,22,58,.12); backdrop-filter: blur(10px); }
.dock-group { display: flex; gap: 2px; padding: 0 5px; }
.dock-group + .dock-group { border-left: 1px solid var(--line); }
.tool { position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 58px; height: 54px; padding: 0 8px; border: 1px solid transparent; border-radius: 11px; background: transparent;
  color: var(--ink); font: 600 .72rem/1.1 var(--bs-body-font-family); letter-spacing: .005em; white-space: nowrap; cursor: pointer;
  transition: background-color var(--t-fast) var(--t-ease), color var(--t-fast) var(--t-ease), border-color var(--t-fast) var(--t-ease), box-shadow var(--t-fast) var(--t-ease); }
.tool i { font-size: 1.25rem; line-height: 1; color: #3c3a66; transition: color var(--t-fast) var(--t-ease); }
.tool:hover { background: var(--soft); }
.tool:hover i { color: var(--ink); }
.tool:active { background: #e1e0f2; }
.tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tool.active, .tool[aria-expanded="true"] { background: var(--accent-soft); border-color: #d2ccff; color: var(--accent-ink); }
.tool.active i, .tool[aria-expanded="true"] i { color: var(--accent); }
.tool:disabled { opacity: .5; cursor: progress; }
.tool[hidden] { display: none; }
.tool-danger:hover { background: var(--bad-soft); color: var(--bad); }
.tool-danger:hover i { color: var(--bad); }
/* phím chính: bật camera — nền xanh đặc; khi đang bật chuyển dần sang nền đỏ nhạt "Tắt camera" */
.tool-primary { min-width: 92px; flex-direction: row; gap: 8px; padding: 0 16px; font-size: .86rem; color: #fff; background: var(--accent); border-color: var(--accent); }
.tool-primary i { color: #fff; font-size: 1.2rem; }
.tool-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.tool-primary:hover i { color: #fff; }
.tool-primary.is-on { background: var(--bad-soft); border-color: #f2c9c1; color: var(--bad); }
.tool-primary.is-on i { color: var(--bad); }
.tool-primary.is-on:hover { background: #f8ddd8; }
/* bảng "Thêm": lưới phím nổi dưới thanh công cụ */
.tool-more { display: none; position: absolute; top: calc(100% + 8px); right: 0; width: 300px; max-width: calc(100vw - 16px);
  grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 8px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--panel); box-shadow: 0 18px 44px rgba(23,22,58,.18); }
body.more-open .tool-more { display: grid; animation: pop-in .16s var(--t-ease); }
.tool-more .tool { width: 100%; height: 66px; font-size: .74rem; font-weight: 500; white-space: normal; text-align: center; }
.tool-more .tool i { font-size: 1.35rem; }

/* tuỳ chọn: bảng nổi từ thanh công cụ, ẩn sẵn */
.settings-box { position: absolute; top: 82px; left: 12px; z-index: 8; width: 320px; max-width: calc(100% - 24px); max-height: calc(100% - 140px); overflow-y: auto;
  display: none; flex-direction: column; gap: 12px; padding: 14px 16px 16px; font-size: .88rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 44px rgba(23,22,58,.18); color: var(--ink); }
body.settings-open .settings-box { display: flex; animation: pop-in .16s var(--t-ease); }
.set-title { font-weight: 700; font-size: 1rem; }
.set-range { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; margin: 0; }
.set-range span { color: var(--muted); font-size: .8rem; }
.set-range input { grid-column: 1; grid-row: 2; }
.set-range output { grid-column: 2; grid-row: 1 / span 2; min-width: 3.4em; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.set-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.set-check { display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; }
.set-check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.set-report { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper); color: var(--muted); font-size: .8rem; transition: background-color var(--t-fast) var(--t-ease), color var(--t-fast) var(--t-ease); }
.set-report:hover { background: var(--warn-soft); color: var(--warn); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* thông báo lớn: thẻ giữa phía trên cảnh, hiện dần rồi ẩn dần */
.toast-msg { position: absolute; left: 50%; top: 84px; z-index: 9; max-width: min(560px, calc(100% - 24px)); transform: translate(-50%, -6px);
  display: flex; align-items: center; gap: 10px; padding: 12px 20px 12px 16px; border-radius: 14px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(23,22,58,.2);
  font-size: 1.08rem; font-weight: 600; line-height: 1.35; opacity: 0; pointer-events: none;
  transition: opacity .22s var(--t-ease), transform .22s var(--t-ease); }
.toast-msg::before { content: ''; flex: 0 0 6px; align-self: stretch; border-radius: 3px; background: var(--accent); }
.toast-msg.show { opacity: 1; transform: translate(-50%, 0); }
.toast-msg[data-kind="ok"]::before { background: var(--ok); }
.toast-msg[data-kind="error"] { background: #fff8f6; border-color: #f2c9c1; color: #8f2a1c; }
.toast-msg[data-kind="error"]::before { background: var(--bad); }
.toast-msg i { font-size: 1.2rem; }

/* bảng số đo (mạch điện, ánh sáng, hoá học): chữ to, số thẳng hàng, màu trạng thái đổi dần */
.badge-stack { position: absolute; top: 84px; left: 12px; max-width: min(460px, calc(100% - 380px)); display: flex; flex-direction: column; align-items: stretch;
  gap: 8px; pointer-events: none; z-index: 4; }
.circuit-badge { padding: 10px 14px; border-radius: 14px; font-size: .95rem; line-height: 1.4; color: var(--ink);
  background: rgba(255,255,255,.96); border: 1px solid var(--line); border-left: 5px solid var(--muted); box-shadow: 0 8px 24px rgba(23,22,58,.1);
  transition: background-color .3s var(--t-ease), border-color .3s var(--t-ease), color .3s var(--t-ease); }
.circuit-badge[data-kind="on"] { border-left-color: var(--ok); }
.circuit-badge[data-kind="short"] { border-left-color: var(--bad); background: #fff8f6; }
.ro-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1rem; }
.ro-head i { font-size: 1.15rem; color: var(--muted); transition: color .3s var(--t-ease); }
[data-kind="on"] .ro-head i { color: var(--ok); }
[data-kind="short"] .ro-head { color: var(--bad); }
[data-kind="short"] .ro-head i { color: var(--bad); }
.ro-meters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ro-chip { display: inline-flex; align-items: baseline; padding: 5px 10px; border-radius: 9px; background: var(--paper); border: 1px solid var(--line);
  font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ro-chip b { margin-right: 1px; padding-right: 2px; color: var(--accent-ink); font-weight: 700; }
.ro-chip.warn { background: var(--warn-soft); border-color: #f0d39a; color: var(--warn); white-space: normal; }
.optics-badge { border-left-color: #e0a000; }
.chem-badge { border-left-color: var(--accent); }

/* thanh trạng thái dưới cảnh: lệnh tay đang nhận, vật đang chọn */
.status-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 40px; display: flex; align-items: center; gap: 1rem;
  padding: 0 16px; font-size: .95rem; font-weight: 500; background: var(--panel); border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; color: var(--ink); }
#status-gesture { transition: color .3s var(--t-ease); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#status-scene { font-weight: 600; color: var(--accent-ink) !important; }
.lib-fab, .vmenu-btn { transition: background-color var(--t-fast) var(--t-ease), box-shadow var(--t-fast) var(--t-ease); }

@media (max-width: 991.98px) {
  .dock { top: 8px; left: 8px; right: 8px; padding: 4px; border-radius: 14px; justify-content: space-between; }
  .dock-group { padding: 0 3px; }
  .tool { min-width: 44px; height: 46px; padding: 0 6px; }
  .tool .lbl { display: none; }
  .tool-primary .lbl, .tool-more .tool .lbl { display: inline; }
  .tool-primary { min-width: 0; padding: 0 12px; font-size: .8rem; }
  .tool-more { right: 0; width: min(320px, calc(100vw - 16px)); }
  .settings-box { top: 66px; left: 8px; right: 8px; width: auto; max-width: none; max-height: calc(100% - 120px); }
  .toast-msg { top: auto; bottom: 112px; left: 12px; right: 12px; max-width: none; transform: translateY(6px); font-size: 1rem; padding: 12px 16px 12px 12px; }
  .toast-msg.show { transform: none; }
  .badge-stack { top: 66px; left: 8px; max-width: calc(100% - 84px); gap: 6px; }
  .circuit-badge { padding: 7px 10px; font-size: .82rem; border-radius: 12px; }
  .ro-head { font-size: .86rem; }
  .ro-chip { font-size: .9rem; padding: 3px 8px; }
  .status-bar { font-size: .82rem; gap: 8px; justify-content: space-between; padding: 0 10px; }
  .status-bar > span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .status-bar #status-scene { margin-left: 0 !important; text-align: right; max-width: 45%; }
  .status-bar #status-assembly { display: none; }
  .cam-box { top: 66px; }
}
@media (max-width: 380px) {
  .tool-primary .lbl { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tool, .toast-msg, .circuit-badge, body.more-open .tool-more, body.settings-open .settings-box { transition: none; animation: none; }
}
.form-range::-webkit-slider-thumb { background: var(--accent); }
.form-range::-moz-range-thumb { background: var(--accent); }
.form-range:focus::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(91,76,240,.2); }
@media (max-width: 991.98px) {
  .status-bar #status-gesture { flex: 1 1 auto; }
  .status-bar #status-scene { flex: 0 0 auto; max-width: 45%; }
}

/* =====================================================================
   Giao diện "Mực chàm" — thanh điều hướng & hero màu mực, nền giấy xám tím,
   nhấn tím iris; cam chỉ dành cho camera / Studio / con trỏ đầu ngón tay.
   ===================================================================== */
h1, h2, h3, .page-title, .auth-title, .navbar-brand { font-family: var(--font-display); font-optical-sizing: auto; }
h1, h2, h3 { letter-spacing: -.025em; }
::selection { background: #d9d4ff; color: var(--ink); }

/* nút */
.btn { border-radius: 12px; font-weight: 600; }
.btn-lg { border-radius: 14px; padding: .8rem 1.35rem; font-size: 1.02rem; }
.btn-sm { border-radius: 9px; }
.btn-accent, .btn-primary { background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 6px 16px rgba(91,76,240,.28); }
.btn-signal { background: var(--signal); border: 1px solid var(--signal); color: #1c0d05;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 10px 26px rgba(255,122,61,.35); }
.btn-signal:hover, .btn-signal:focus { background: #ff8c55; border-color: #ff8c55; color: #1c0d05; }
.btn-ghost { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.22); color: #fff; }
.btn-ghost:hover, .btn-ghost:focus { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.4); color: #fff; }
.btn-ink { background: var(--ink); border: 1px solid var(--ink); color: #fff; }
.btn-ink:hover, .btn-ink:focus { background: var(--ink-2); border-color: var(--ink-2); color: #fff; }
.btn-outline-danger { --bs-btn-color: var(--bad); --bs-btn-border-color: #f1c6cb; --bs-btn-hover-bg: var(--bad); --bs-btn-hover-border-color: var(--bad); }
.form-control, .form-select { border-radius: 12px; padding: .62rem .9rem; background-color: #fff; }
.form-label { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.dropdown-menu { border: 1px solid var(--line); border-radius: 14px; padding: .4rem; box-shadow: 0 18px 44px rgba(23,22,58,.18); }
.dropdown-item { border-radius: 9px; padding: .5rem .75rem; font-weight: 500; }
.dropdown-item:active { background: var(--accent); }
.alert { border-radius: 14px; border-width: 0; box-shadow: 0 12px 30px rgba(23,22,58,.15); }

/* thanh điều hướng màu mực */
.app-nav { background: var(--ink); border-bottom: 1px solid rgba(255,255,255,.06); padding-top: .55rem; padding-bottom: .55rem; }
.app-nav .navbar-brand { display: inline-flex; align-items: center; gap: .6rem; color: #fff; font-weight: 600; font-size: 1.2rem; letter-spacing: -.02em; }
.app-nav .navbar-brand b { font-weight: 800; color: #b9b0ff; margin-left: 1px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--signal); color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4); }
.brand-mark i { color: var(--ink) !important; font-size: 1.05rem; }
.app-nav .nav-link { color: rgba(236,234,255,.68); border-radius: 10px; padding: .45rem .8rem !important; transition: color .15s, background-color .15s; }
.app-nav .nav-link:hover, .app-nav .nav-link:focus { color: #fff; background: rgba(255,255,255,.07); }
.app-nav .nav-link.active { color: #fff; background: rgba(255,255,255,.11); }
.app-nav .nav-link.active i { color: #b9b0ff; }
.app-nav .navbar-nav { gap: 2px; margin-left: 1.25rem; }
.user-chip { display: inline-flex !important; align-items: center; gap: .5rem; }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #3a3780; color: #fff; font-weight: 700; font-size: .8rem; }
.app-nav :focus-visible { outline-color: #b9b0ff; }

/* trang chủ: khối hero màu mực có cảnh 3D thật */
.hero-slab { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: center; gap: 1rem;
  padding: clamp(2rem, 5vw, 4.5rem) max(1.5rem, calc((100vw - 1296px) / 2 + 12px)) clamp(2rem, 4vw, 3.5rem);
  background: radial-gradient(60% 90% at 78% 45%, #3a2fb8 0%, rgba(58,47,184,0) 70%), var(--ink); color: #fff; overflow: hidden; }
.hero-copy { position: relative; z-index: 1; }
.hero-hello { color: #b9b0ff; font-weight: 600; margin-bottom: .9rem; }
.hero-slab h1 { color: #fff; font-size: clamp(2.3rem, 4.8vw, 4.1rem); font-weight: 700; line-height: 1.02; letter-spacing: -.035em; max-width: 13ch; margin-bottom: 1.1rem; }
.hero-lead { color: #cfccf3; font-size: 1.08rem; line-height: 1.6; max-width: 46ch; margin-bottom: 1.75rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.hero-facts { margin: 1.75rem 0 0; color: #a9a6db; font-size: .92rem; }
.hero-facts b { color: #fff; font-variant-numeric: tabular-nums; }
.hero-stage { position: relative; height: clamp(320px, 38vw, 470px); cursor: crosshair; }
.hero-stage canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.hero-stage.no-webgl { background: radial-gradient(circle at 50% 50%, rgba(185,176,255,.25), transparent 60%); }

.home-body { padding-top: 2rem; padding-bottom: 2.5rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 1.25rem 1.4rem 1.35rem; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .85rem; }
.panel-head h2 { font-size: 1.3rem; font-weight: 700; margin: 0; }
.panel-head a { font-weight: 600; font-size: .9rem; text-decoration: none; }
.note-view { display: flex; gap: .75rem; align-items: flex-start; padding: .9rem 1.1rem; margin-bottom: 1.5rem; border-radius: var(--r-md);
  background: #ecebff; color: #2e2a7a; border: 1px solid #d8d3ff; }
.note-view i { font-size: 1.15rem; color: var(--accent); }
.recent-list { display: flex; flex-direction: column; gap: 4px; }
.recent-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .9rem; padding: .7rem .75rem; border-radius: 14px;
  color: var(--ink); text-decoration: none; transition: background-color .15s; }
.recent-item:hover, .recent-item:focus-visible { background: var(--soft); color: var(--ink); }
.recent-ico { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: #ecebff; color: var(--accent); font-size: 1.15rem; }
.recent-name { font-weight: 600; line-height: 1.25; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.recent-name small { display: block; color: var(--muted); font-weight: 400; font-size: .8rem; }
.recent-item time { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty-state > i { display: block; font-size: 2rem; color: #b9b0ff; margin-bottom: .5rem; }
.empty-state p { max-width: 40ch; margin: 0 auto 1rem; }

/* bảng cử chỉ: cột tư thế tay nổi bật như phím */
.gesture-table { --bs-table-bg: transparent; border-collapse: separate; border-spacing: 0 6px; margin-top: -6px; }
.gesture-table td { border: 0; padding: .6rem .75rem; vertical-align: middle; font-size: .9rem; }
.gesture-table td:first-child { width: 48%; color: var(--ink); font-weight: 600; background: var(--soft); border-radius: 12px 0 0 12px; }
.gesture-table td:last-child { color: var(--muted); background: #f6f6fb; border-radius: 0 12px 12px 0; }

/* đầu trang thường */
main.container { padding-top: 2rem !important; padding-bottom: 2.5rem !important; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-title, .page-head h3 { font-size: clamp(1.8rem, 3vw, 2.5rem); font-weight: 700; letter-spacing: -.03em; margin: 0; }
.page-sub { color: var(--muted); margin: .35rem 0 0; }
.section-title { font-size: 1.2rem; font-weight: 700; margin-bottom: .75rem; }
.table-soft { --bs-table-bg: transparent; }
.table-soft thead th { color: var(--muted); font-weight: 600; font-size: .82rem; border-bottom-color: var(--line); padding: .85rem 1rem; }
.table-soft td { padding: .8rem 1rem; border-color: var(--line); }
.table-soft tbody tr:last-child td { border-bottom: 0; }
.table-soft tbody tr:hover td { background: #f7f7fc; }

/* thư viện */
.lib-filter { display: grid; grid-template-columns: minmax(0, 1fr) 190px 210px auto; gap: .6rem; padding: .6rem; margin-bottom: 1.5rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.lib-filter .form-control, .lib-filter .form-select { border-color: transparent; background-color: var(--soft); }
.lib-filter .form-control:focus, .lib-filter .form-select:focus { background-color: #fff; }
.lib-search { position: relative; margin: 0; }
.lib-search i { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.lib-search .form-control { padding-left: 2.4rem; }
.lib-filter .btn { padding-left: 1.4rem; padding-right: 1.4rem; }
.obj-card { display: flex; flex-direction: column; border-radius: 20px; box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s; }
.obj-card:hover { box-shadow: 0 2px 4px rgba(23,22,58,.06), 0 18px 40px rgba(23,22,58,.14); transform: translateY(-2px); }
.obj-thumb { height: 172px; margin: 6px 6px 0; border-radius: 15px; overflow: hidden; text-decoration: none;
  background:
    linear-gradient(to top, rgba(91,76,240,.10), transparent 45%),
    repeating-linear-gradient(90deg, rgba(91,76,240,.07) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(0deg, rgba(91,76,240,.07) 0 1px, transparent 1px 28px),
    radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--c) 30%, transparent), transparent 65%), #e9e8f6; }
.obj-thumb .prim-icon { transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.obj-card:hover .obj-thumb .prim-icon { transform: translateY(-6px) rotate(-8deg); }
.obj-body { display: flex; flex-direction: column; flex: 1; padding: .9rem 1rem 1rem; }
.obj-name { font-size: 1.05rem; font-weight: 700; margin: 0 0 .15rem; letter-spacing: -.015em; }
.obj-cat { color: var(--muted); font-size: .8rem; margin: 0 0 .5rem; }
.obj-desc { color: var(--muted); font-size: .85rem; flex: 1; margin-bottom: .85rem; }
.obj-actions { display: flex; gap: .4rem; }
.kind-tag { top: 10px; left: 10px; padding: .2rem .6rem; background: rgba(255,255,255,.88); backdrop-filter: blur(6px); }
.kind-object { color: #a2420f; }
.kind-module { color: var(--accent-ink); }
.hidden-tag { position: absolute; top: 10px; right: 10px; font-size: .72rem; padding: .2rem .6rem; border-radius: 99px; background: var(--ink); color: #fff; font-weight: 600; }

/* đăng nhập / đăng ký: nửa trái là cảnh 3D */
body.auth-page { background: var(--paper); }
.auth-split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: calc(100vh - var(--hdr-h, 62px)); min-height: calc(var(--app-h, 100vh) - var(--hdr-h, 62px)); }
.auth-visual { position: relative; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden;
  background: radial-gradient(70% 70% at 50% 40%, #3a2fb8 0%, rgba(58,47,184,0) 70%), var(--ink); }
.auth-visual .hero-stage { position: absolute; inset: 0; height: auto; }
.auth-visual-copy { position: relative; padding: 2rem clamp(1.5rem, 4vw, 3.5rem) 2.5rem; pointer-events: none;
  background: linear-gradient(to top, rgba(23,22,58,.9), transparent); }
.auth-tag { color: #dcd9ff; font-family: var(--font-display); font-size: clamp(1.25rem, 2vw, 1.7rem); font-weight: 600; line-height: 1.25; letter-spacing: -.02em; max-width: 26ch; margin: 0; }
.auth-pane { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-card { border-radius: var(--r-lg); padding: 2.25rem; }
.auth-pane .auth-card { width: 100%; max-width: 420px; margin: 0; box-shadow: none; border: 0; background: transparent; padding: 0; }
.auth-title { font-size: 2.1rem; font-weight: 700; letter-spacing: -.03em; margin-bottom: .35rem; }
.auth-card > h1.auth-title { font-size: 1.7rem; margin-bottom: 1.25rem; }
.auth-sub { color: var(--muted); margin-bottom: 1.75rem; }
.auth-alt { margin: 1.25rem 0 0; color: var(--muted); text-align: center; }
.auth-alt a { font-weight: 600; }

/* studio: phím camera dùng màu cam như nút "Mở Studio" */
.tool-primary { background: var(--signal); border-color: var(--signal); color: #1c0d05; }
.tool-primary i { color: #1c0d05; }
.tool-primary:hover { background: #ff8c55; border-color: #ff8c55; }
.tool-primary:hover i { color: #1c0d05; }
.dock { border-radius: 18px; box-shadow: 0 1px 2px rgba(23,22,58,.08), 0 14px 34px rgba(23,22,58,.14); }
.status-bar #status-scene { color: var(--accent-ink) !important; }

@media (max-width: 991.98px) {
  .app-nav { background: rgba(23,22,58,.96); }
  .app-nav .navbar-brand { font-size: 1.08rem; }
  .brand-mark { width: 30px; height: 30px; border-radius: 10px; }
  .tab-main-dot { background: var(--ink); box-shadow: 0 0 0 5px var(--paper), 0 8px 18px rgba(23,22,58,.35); }
  .tab-main-dot i { color: var(--signal) !important; }
  .tabbar .tab-main.active .tab-main-dot { box-shadow: 0 0 0 5px var(--paper), 0 0 0 7px rgba(255,122,61,.5), 0 8px 18px rgba(23,22,58,.35); }
  .lib-fab { background: var(--ink); box-shadow: 0 8px 20px rgba(23,22,58,.35); }
  .lib-fab i { color: var(--signal); }

  .hero-slab { grid-template-columns: 1fr; padding: 1.75rem 1.25rem 1rem; gap: 0; }
  .hero-slab h1 { font-size: clamp(2rem, 8.5vw, 2.8rem); }
  .hero-lead { font-size: 1rem; margin-bottom: 1.25rem; }
  .hero-actions .btn-lg { flex: 1 1 auto; }
  .hero-stage { height: 240px; margin: 0 -1.25rem; }
  .hero-facts { margin-top: 1.25rem; }
  .home-body { padding-top: 1.25rem; }
  .panel { padding: 1rem 1rem 1.1rem; border-radius: 18px; }
  .page-head { margin-bottom: 1rem; }
  .page-title, .page-head h3 { font-size: 1.7rem; }
  .lib-filter { grid-template-columns: 1fr 1fr; }
  .lib-search { grid-column: 1 / -1; }
  .lib-filter .btn { grid-column: 1 / -1; }
  .obj-thumb { height: 120px; }
  .obj-body { padding: .7rem .75rem .8rem; }
  .obj-name { font-size: .95rem; }
  .obj-actions .btn-accent { font-size: .8rem; padding-left: .4rem; padding-right: .4rem; }

  .auth-split { grid-template-columns: 1fr; grid-template-rows: 240px auto; min-height: 0; }
  .auth-visual-copy { padding: 1rem 1.25rem 1.1rem; }
  .auth-tag { font-size: 1.05rem; }
  .auth-pane { place-items: start center; padding: 1.75rem 1.25rem 2rem; }
  .auth-title { font-size: 1.7rem; }
}
@media (prefers-reduced-motion: reduce) {
  .obj-card, .obj-thumb .prim-icon, .recent-item, .app-nav .nav-link { transition: none; }
  .obj-card:hover { transform: none; }
  .obj-card:hover .obj-thumb .prim-icon { transform: none; }
}
/* biểu tượng khối trong thẻ thư viện: thêm mặt sáng để không bị phẳng */
.obj-thumb .prim-box, .obj-thumb .prim-file, .obj-thumb .prim-cylinder, .obj-thumb .prim-plate, .obj-thumb .prim-rod {
  background: linear-gradient(150deg, rgba(255,255,255,.45), rgba(255,255,255,0) 45%, rgba(23,22,58,.18)), var(--c); }
.obj-thumb .prim-sphere, .obj-thumb .prim-joint { background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.7), rgba(255,255,255,0) 40%), var(--c); }
.obj-thumb .prim-file { transform: rotate(12deg); }
.obj-card:hover .obj-thumb .prim-file, .obj-card:hover .obj-thumb .prim-box { transform: translateY(-6px) rotate(4deg); }
.auth-visual-copy { background: linear-gradient(to top, rgba(23,22,58,.95) 30%, rgba(23,22,58,0)); padding-top: 4rem; }
