/* копия из ../BOARDVIEW/integration v0.2.0 (19.11.2026). Правки — в BOARDVIEW, потом копировать заново. */
/* КОПИЯ ИЗ BOARDVIEW v0.2.0, 2026-11-18. Правки — в BOARDVIEW/src, затем скопировать снова. */
/* ============================================================
   REMX BoardView — стили оболочки просмотрщика плат
   Вся отрисовка платы — на canvas, здесь только рамка,
   подсказка и масштаб. Файл самостоятельный: подключается
   рядом с boardview.js и не требует сборки.
   ============================================================ */

.bvw, .bvw * { box-sizing: border-box; }

.bvw {
  --bv-frame: var(--line, #28322D);
  --bv-panel: var(--card, #171D1A);
  --bv-text: var(--text, #E9EEEB);
  --bv-muted: var(--muted, #98A59E);
  --bv-green: var(--green, #45BD78);
  position: relative;
  display: block;
  width: 100%;
  height: 420px;
  min-height: 220px;
  overflow: hidden;
  border: 1.5px solid var(--bv-frame);
  border-radius: 16px;
  background: #0B100D;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  font: 13px/1.35 Onest, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--bv-text);
  outline: none;
}

.bvw:focus-visible {
  box-shadow: 0 0 0 2px var(--bv-green);
}

.bvw canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  outline: none;
}

.bvw.bvw-dragging canvas { cursor: grabbing; }
.bvw.bvw-pointer canvas { cursor: pointer; }

/* ---- подсказка при наведении ---- */
.bvw-tooltip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  max-width: 240px;
  padding: 5px 9px;
  border: 1px solid rgba(150, 170, 160, .28);
  border-radius: 9px;
  background: rgba(10, 16, 13, .93);
  color: #EDF3EF;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -125%);
  transition: opacity .12s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.bvw-tooltip.on { opacity: 1; }
.bvw-tooltip b { font-weight: 700; }
.bvw-tooltip .n { color: #E9B37A; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 11.5px; }
.bvw-tooltip .m { color: #9FB0A8; }

/* ---- масштаб в углу ---- */
.bvw-hud {
  position: absolute;
  left: 9px;
  bottom: 9px;
  z-index: 4;
  padding: 3px 7px;
  border: 1px solid rgba(150, 170, 160, .18);
  border-radius: 7px;
  background: rgba(10, 16, 13, .72);
  color: rgba(226, 238, 231, .66);
  font: 11px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  pointer-events: none;
  transition: opacity .2s ease;
}

/* ---- светлая тема: оболочка светлая, сама плата остаётся тёмной ---- */
[data-theme="light"] .bvw,
.bvw[data-theme="light"] {
  --bv-frame: var(--line, #DCE2DE);
  --bv-panel: var(--card, #FFFFFF);
  --bv-text: var(--text, #111715);
  --bv-muted: var(--muted, #56625C);
  --bv-green: var(--green, #17703F);
  background: #E7ECE9;
}

[data-theme="light"] .bvw-hud,
.bvw[data-theme="light"] .bvw-hud {
  background: rgba(255, 255, 255, .8);
  border-color: rgba(20, 40, 30, .12);
  color: rgba(20, 35, 28, .6);
}

/* Встроенный просмотрщик в тесной карточке */
.bvw.bvw-compact { height: 260px; }

@media (prefers-reduced-motion: reduce) {
  .bvw-tooltip, .bvw-hud { transition: none; }
}

/* Выбор модели: категории/бренды в нативном select, без зависимостей. */
.rx-modelpick {
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--line);
  background-color: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 30px 7px 12px;
  font: 600 12.5px/1.2 Onest, -apple-system, "SF Pro Text", "Segoe UI", sans-serif;
  max-width: 220px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2398A59E' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.rx-modelpick:focus { outline: 2px solid var(--green); outline-offset: 2px; }
.rx-modelpick option, .rx-modelpick optgroup { background: var(--card); color: var(--text); }
@media (max-width: 620px) { .rx-modelpick { max-width: 165px; font-size: 11.5px; } }

/* Диод-тест / прозвонка */
.net-row .volt { color: var(--amber); font: 600 10px ui-monospace, Menlo, monospace; }
.diode-val { font-size: 12.5px; color: var(--muted); padding: 3px 0; }
.diode-val b { color: var(--amber); font-family: ui-monospace, Menlo, monospace; }

/* 3D-просмотр платы */
.b3d-overlay { position:fixed; inset:0; z-index:1000; display:none; background:#080D0A; color:var(--text); }
.b3d-overlay.on { display:flex; flex-direction:column; }
.b3d-top { display:flex; align-items:center; gap:10px; padding:12px 16px; border-bottom:1px solid var(--line); flex-wrap:wrap; }
.b3d-top b { font-size:15px; display:block; } .b3d-top span { color:var(--dim); font-size:11.5px; }
.b3d-actions { margin-left:auto; display:flex; gap:6px; flex-wrap:wrap; }
.b3d-btn { border:1.5px solid var(--line); background:var(--card); color:var(--text); border-radius:999px; padding:6px 11px; font-size:12px; font-weight:600; cursor:pointer; }
.b3d-btn:hover { border-color:var(--frame); } .b3d-btn.on { background:var(--green); border-color:var(--green); color:#08110C; }
.b3d-close { border-color:var(--frame); }
.b3d-stage { position:relative; flex:1; min-height:0; perspective:1400px; display:grid; place-items:center; background:radial-gradient(circle at 50% 45%, #15221B 0, #070C09 70%); touch-action:none; overflow:hidden; }
.b3d-board { position:absolute; left:50%; top:50%; width:min(78vw,900px); aspect-ratio:var(--ratio,1.55); transform-style:preserve-3d; transform:translate(-50%,-50%) rotateX(var(--rx,-18deg)) rotateY(var(--ry,22deg)) scale(var(--zoom,1)); transition:transform .08s linear; }
.b3d-face { position:absolute; inset:0; background-color:#0B1A12; background-repeat:no-repeat; background-position:center; background-size:contain; backface-visibility:hidden; border-radius:8px; box-shadow:0 24px 60px rgba(0,0,0,.5); }
.b3d-top-face { transform:translateZ(calc(var(--t,16px)/2)); } .b3d-bottom-face { transform:rotateY(180deg) translateZ(calc(var(--t,16px)/2)); }
.b3d-face.empty { background:repeating-linear-gradient(45deg,#0B1A12,#0B1A12 8px,#0E2118 8px,#0E2118 16px); }
.b3d-face.empty::after { content:'нет фото'; position:absolute; inset:0; display:grid; place-items:center; color:rgba(180,200,190,.35); font-size:12px; }
.b3d-edge { position:absolute; background:#0D2117; border:1px solid rgba(130,160,140,.2); }
.b3d-edge.e1,.b3d-edge.e2 { left:0; width:100%; height:var(--t,16px); } .b3d-edge.e1 { top:0; transform:rotateX(90deg) translateZ(calc(var(--t,16px)/2)); transform-origin:top; } .b3d-edge.e2 { bottom:0; transform:rotateX(-90deg) translateZ(calc(var(--t,16px)/2)); transform-origin:bottom; }
.b3d-edge.e3,.b3d-edge.e4 { top:0; height:100%; width:var(--t,16px); } .b3d-edge.e3 { left:0; transform:rotateY(-90deg) translateZ(calc(var(--t,16px)/2)); transform-origin:left; } .b3d-edge.e4 { right:0; transform:rotateY(90deg) translateZ(calc(var(--t,16px)/2)); transform-origin:right; }
.b3d-status { position:absolute; right:14px; top:12px; border:1px solid var(--line); background:rgba(10,16,13,.75); color:var(--dim); border-radius:999px; padding:4px 9px; font-size:11px; }
.b3d-tip { position:absolute; left:14px; top:12px; color:var(--dim); font-size:11px; }
@media(max-width:620px){ .b3d-board{width:92vw} .b3d-top{padding:9px 10px} .b3d-actions{gap:4px} .b3d-btn{padding:5px 8px;font-size:11px} }

/* объёмные компоненты в 3D */
.b3d-cube { position:absolute; transform-style:preserve-3d; pointer-events:none; }
.b3d-cf { position:absolute; background:#1A2620; border:1px solid rgba(201,139,78,.32); box-shadow:0 0 6px rgba(0,0,0,.35); }
.b3d-cf.ct { inset:0; transform:translateZ(var(--d,4px)); background:linear-gradient(145deg,#27342D,#18231D); border-color:rgba(220,170,110,.45); }
.b3d-cf.cl { left:0; top:0; width:var(--d,4px); height:100%; transform-origin:left; transform:rotateY(90deg); background:#0E1913; }
.b3d-cf.cr { right:0; top:0; width:var(--d,4px); height:100%; transform-origin:right; transform:rotateY(-90deg); background:#0E1913; }
.b3d-cf.ctop { left:0; top:0; width:100%; height:var(--d,4px); transform-origin:top; transform:rotateX(-90deg); background:#15211A; }
.b3d-cf.cbot { left:0; bottom:0; width:100%; height:var(--d,4px); transform-origin:bottom; transform:rotateX(90deg); background:#0B1510; }

/* ── мобильный / встроенный режим ───────────────────────────────────── */
@media (max-width: 620px) {
  .bvw { touch-action: none; }
  .b3d-stage { min-height: 0; }
  .b3d-actions { max-width: 100%; overflow-x: auto; }
}

html.embed, html.embed body { height:100%; overflow:hidden; background:#050807; }
html.embed .app { display:block !important; padding:0 !important; margin:0 !important; max-width:none !important; min-height:0 !important; height:100dvh; }
html.embed header, html.embed .side, html.embed .info, html.embed .boot, html.embed .hint,
html.embed .notice, html.embed .foot, html.embed .toast { display:none !important; }
html.embed .main { height:100dvh; display:flex; flex-direction:column; gap:0; min-width:0; }
html.embed .toolbar {
  flex:none; border-radius:0; border-left:0; border-right:0; border-top:0;
  padding: calc(6px + env(safe-area-inset-top)) 8px 6px;
  overflow-x:auto; flex-wrap:nowrap; scrollbar-width:none;
}
html.embed .toolbar::-webkit-scrollbar { display:none; }
html.embed .toolbar .title { display:none; }
html.embed .viewer { flex:1; height:auto; min-height:0; border:0; border-radius:0; }
html.embed .viewer .bvw { border:0; border-radius:0; }
html.embed .b3d-overlay .b3d-top { padding-top:calc(8px + env(safe-area-inset-top)); }
html.embed .b3d-overlay .b3d-bottom { padding-bottom:calc(8px + env(safe-area-inset-bottom)); }

/* мобильная раскладка плат: доска первой, панель — ниже */
@media (max-width: 1000px) {
  html:not(.embed) .app { grid-template-columns: 1fr !important; padding-top: calc(10px + env(safe-area-inset-top)) !important; padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important; }
  html:not(.embed) .main { order: 1; }
  html:not(.embed) .side { order: 2; }
}
@media (max-width: 620px) {
  html:not(.embed) header { gap: 7px; }
  html:not(.embed) header h1 { font-size: 16px; }
  html:not(.embed) header p { display: none; }
  html:not(.embed) .rx-modelpick { max-width: 150px !important; }
  html:not(.embed) .viewer { height: 50dvh !important; min-height: 300px !important; }
  html:not(.embed) .toolbar .title { width: 100%; margin: 0 0 2px; }
  html:not(.embed) .side .nets { max-height: 26vh; }
  html:not(.embed) .info { grid-template-columns: 1fr !important; }
}

@media (max-width: 620px) {
  html:not(.embed) header a[href="../catalog.html"] { display:none; }
  html:not(.embed) header #themeBtn { font-size:0; width:38px; height:38px; padding:0; display:grid; place-items:center; }
  html:not(.embed) header #themeBtn::after { content:'◐'; font-size:16px; }
  html:not(.embed) .toolbar { flex-wrap:nowrap !important; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
  html:not(.embed) .toolbar::-webkit-scrollbar { display:none; }
  html:not(.embed) .toolbar .title { display:none; }
  html:not(.embed) .toolbar .btn, html:not(.embed) .toolbar .chip { min-height:36px; }
  html:not(.embed) .hint { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
}

/* ── финальная мобильная полировка ─────────────────────────────────── */
@media (max-width: 620px) {
  html:not(.embed) header > a.btn { display:none !important; }
  html:not(.embed) header { width:100%; max-width:100%; overflow:hidden; }
  html:not(.embed) header > div { min-width:0; overflow:hidden; }
  html:not(.embed) header h1 { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; }
  html:not(.embed) header .mark { display:none; }
  html:not(.embed) header .spacer, html:not(.embed) header .sp { display:none !important; }
  html:not(.embed) header > div { flex:1 1 auto; }
  html:not(.embed) header h1 { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  html:not(.embed) .rx-modelpick { flex:0 0 132px; width:132px; max-width:132px !important; min-width:0; }
  html:not(.embed) header #themeBtn::after { content:'☀'; font-size:17px; }
  html:not(.embed) .app { width:100%; max-width:100%; overflow:hidden; }
  html:not(.embed) .main { order:1; min-width:0; }
  html:not(.embed) .side { order:2; min-width:0; }
  html:not(.embed) .stage { width:100%; max-width:100%; overflow:hidden; }
  html:not(.embed) .toolbar { width:100%; max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
  html:not(.embed) .toolbar::-webkit-scrollbar { display:none; }
  html:not(.embed) .toolbar .title { display:none; }
  html:not(.embed) .toolbar .btn, html:not(.embed) .toolbar .chip { min-height:36px; }
  html:not(.embed) .boot-steps { flex-wrap:wrap !important; overflow:visible !important; max-height:none; }
  html:not(.embed) .hint { white-space:normal !important; overflow:visible !important; text-overflow:clip !important; line-height:1.4; }
  html:not(.embed) .pages { max-height:180px; }
  html:not(.embed) .viewer { height:50dvh !important; min-height:300px; }
  html:not(.embed) .info { grid-template-columns:1fr !important; }
}

@media (max-width: 620px) {
  html:not(.embed) .toolbar { align-items:center; }
  html:not(.embed) #fit { order:1; } html:not(.embed) #zoomOut { order:2; } html:not(.embed) #zoomIn { order:3; }
  html:not(.embed) #btn3d { order:4; } html:not(.embed) #bootBtn { order:5; } html:not(.embed) #diodeBtn { order:6; }
  html:not(.embed) #photoBtn { order:7; } html:not(.embed) #reset { order:8; }
  html:not(.embed) .toolbar .btn { flex:none; }
}

/* доступность: палец, а не курсор */
@media (max-width: 620px) {
  html:not(.embed) .toolbar .btn,
  html:not(.embed) .toolbar .chip,
  html:not(.embed) .bstep,
  html:not(.embed) .refs .chip,
  html:not(.embed) .chips .chip,
  html:not(.embed) .chip { min-height:44px; }
  html:not(.embed) .page-row { min-height:44px; }
  html:not(.embed) .net-row { min-height:44px; }
  html:not(.embed) header #themeBtn { min-width:44px; min-height:44px; }
  html:not(.embed) .rx-modelpick { min-height:44px; }
}

/* телефон в ландшафте: плата на весь экран, панели плавающие */
@media (orientation: landscape) and (max-height: 520px) {
  html:not(.embed) body { overflow:hidden; }
  html:not(.embed) .app { display:block !important; height:100dvh; min-height:0; padding:0 !important; overflow:hidden; }
  html:not(.embed) header {
    position:absolute; z-index:20; top:0; left:0; right:0; height:46px;
    padding:calc(3px + env(safe-area-inset-top)) 10px 3px;
    background:rgba(15,20,18,.94); border-bottom:1px solid var(--line);
  }
  html:not(.embed) header .mark { display:none; }
  html:not(.embed) header .spacer, html:not(.embed) header .sp { display:none; }
  html:not(.embed) header h1 { font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  html:not(.embed) header > div { min-width:0; flex:1; }
  html:not(.embed) header a.btn { display:none !important; }
  html:not(.embed) .rx-modelpick { height:34px; min-height:34px; max-width:160px !important; flex-basis:160px; width:160px; }
  html:not(.embed) .side, html:not(.embed) .info, html:not(.embed) .boot, html:not(.embed) .hint,
  html:not(.embed) .notice { display:none !important; }
  html:not(.embed) .main { height:100dvh; padding:46px 0 0; overflow:hidden; }
  html:not(.embed) .toolbar {
    position:absolute; z-index:12; top:50px; left:8px; right:8px;
    width:auto; max-width:none; padding:4px 6px; border-radius:10px;
    background:rgba(23,29,26,.94); border:1px solid var(--line);
    flex-wrap:nowrap; overflow-x:auto;
  }
  html:not(.embed) .toolbar .title { display:none; }
  html:not(.embed) .toolbar .btn { min-height:32px; padding:5px 9px; font-size:11px; }
  html:not(.embed) .viewer { height:calc(100dvh - 46px) !important; min-height:0 !important; border:0; border-radius:0; }
  html:not(.embed) .pages { max-height:160px; }
  html:not(.embed) .side { display:none; }
}

@media (max-width: 620px) {
  html:not(.embed) .views button { min-height:44px; }
  html:not(.embed) .boot-actions .btn { min-height:44px; }
}
