/* ==========================================================================
   CAD viewer styled after the Onshape Part Studio interface.
   It stays light in both site themes, like the real thing.
   ========================================================================== */

.os {
  --os-bg: #ffffff;
  --os-chrome: #f3f3f3;
  --os-chrome-2: #e9e9e9;
  --os-line: #d6d6d6;
  --os-text: #1f1f1f;
  --os-text-2: #555;
  --os-muted: #8a8a8a;
  --os-blue: #1f5fbf;
  --os-blue-2: #0b5cff;
  --os-hover: #e3ecf8;
  --os-sel: #fbe3b4;
  position: relative;
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 44px 40px 1fr 32px;
  grid-template-areas:
    "top top"
    "tools tools"
    "side view"
    "tabs tabs";
  height: min(78vh, 760px);
  min-height: 460px;
  border: 1px solid var(--line-2, #d6d6d6);
  border-radius: 14px;
  overflow: hidden;
  background: var(--os-bg);
  color: var(--os-text);
  font: 13px/1.3 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: var(--shadow, 0 18px 50px rgba(0,0,0,.25));
  color-scheme: light;
  user-select: none;
  -webkit-user-select: none;
}
.os.is-compact { height: min(70vh, 620px); }
.os button { font: inherit; color: inherit; }

/* Top bar: logo mark, document name, branch */
.os-top {
  grid-area: top; display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--os-chrome); border-bottom: 1px solid var(--os-line); min-width: 0;
}
.os-logo { width: 22px; height: 22px; border-radius: 50%; background: #3e9b45; display: grid; place-items: center; flex: none; }
.os-logo svg { width: 13px; height: 13px; }
.os-ham { width: 18px; height: 14px; flex: none; display: grid; gap: 3px; }
.os-ham i { display: block; height: 2px; background: #3a3a3a; border-radius: 1px; }
.os-doc { font-size: 17px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.os-branch { color: var(--os-muted); font-size: 13px; white-space: nowrap; }
.os-top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: none; }
.os-share { background: #1f5fbf; color: #fff; border: 0; border-radius: 4px; padding: 6px 12px; font-weight: 600; font-size: 13px; cursor: pointer; }
.os-share:hover { background: #174f9f; }

/* Toolbar */
.os-tools {
  grid-area: tools; display: flex; align-items: center; gap: 2px; padding: 0 8px;
  background: var(--os-bg); border-bottom: 1px solid var(--os-line); overflow-x: auto; scrollbar-width: none;
}
.os-tools::-webkit-scrollbar { display: none; }
.os-tool {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; min-width: 30px; padding: 0 7px;
  border: 1px solid transparent; border-radius: 4px; background: transparent; cursor: pointer; white-space: nowrap; flex: none;
}
.os-tool:hover { background: var(--os-hover); border-color: #c9d8ee; }
.os-tool.is-on { background: #dfe9f7; border-color: #a9c1e6; }
.os-tool svg { width: 18px; height: 18px; color: #3d3d3d; }
.os-tool span { font-size: 12.5px; color: #333; }
.os-sep { width: 1px; height: 22px; background: var(--os-line); margin: 0 6px; flex: none; }
.os-select { position: relative; flex: none; }
.os-select select {
  appearance: none; height: 30px; border: 1px solid var(--os-line); border-radius: 4px; background: #fff;
  padding: 0 26px 0 9px; font: 12.5px "Inter", sans-serif; color: #333; cursor: pointer;
}
.os-select::after { content: ""; position: absolute; right: 10px; top: 12px; border: 4px solid transparent; border-top-color: #555; pointer-events: none; }
.os-tools .os-help { margin-left: auto; font-size: 12px; color: var(--os-muted); white-space: nowrap; padding: 0 6px; flex: none; }

/* Left panel: parts list */
.os-side { grid-area: side; border-right: 1px solid var(--os-line); background: #fff; display: flex; flex-direction: column; min-height: 0; }
.os-filter { margin: 8px; display: flex; align-items: center; gap: 6px; }
.os-filter svg { width: 15px; height: 15px; color: #666; flex: none; }
.os-filter input { width: 100%; height: 28px; border: 1px solid var(--os-line); border-radius: 3px; padding: 0 8px; font: 12.5px "Inter", sans-serif; color: #222; background: #fff; }
.os-filter input::placeholder { color: #9a9a9a; font-style: italic; }
.os-sec { display: flex; align-items: center; gap: 6px; padding: 6px 10px; font-weight: 600; font-size: 13px; color: #222; }
.os-sec svg { width: 10px; height: 10px; }
.os-feat { padding: 0 0 6px 0; border-bottom: 1px solid var(--os-line); }
.os-row { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 26px; font-size: 13px; color: #222; cursor: default; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.os-row.dim { color: #9a9a9a; }
.os-row svg { width: 15px; height: 15px; flex: none; color: #777; }
.os-parts { overflow: auto; flex: 1; padding-bottom: 8px; }
.os-part { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; }
.os-part:hover { background: var(--os-hover); }
.os-part.is-sel { background: var(--os-sel); }
.os-part .sw { width: 10px; height: 10px; border-radius: 2px; border: 1px solid rgba(0,0,0,.25); flex: none; margin-left: auto; }
.os-part .nm { overflow: hidden; text-overflow: ellipsis; }

/* Viewport */
.os-view { grid-area: view; position: relative; min-width: 0; min-height: 0; background: #fff; }
.os-view canvas.main { position: absolute; inset: 0; width: 100% !important; height: 100% !important; outline: none; touch-action: none; }
.os-cube { position: absolute; top: 6px; right: 6px; width: 132px; height: 132px; z-index: 2; }
.os-cube canvas { width: 100% !important; height: 100% !important; cursor: pointer; }
.os-arrow {
  position: absolute; z-index: 3; width: 0; height: 0; border: 7px solid transparent; background: none; padding: 0; cursor: pointer; opacity: .55;
}
.os-arrow:hover { opacity: 1; }
.os-arrow.up { top: 2px; left: 59px; border-bottom: 9px solid #9fb3c8; border-top: 0; }
.os-arrow.down { bottom: 2px; left: 59px; border-top: 9px solid #9fb3c8; border-bottom: 0; }
.os-arrow.left { left: 0; top: 59px; border-right: 9px solid #9fb3c8; border-left: 0; }
.os-arrow.right { right: 0; top: 59px; border-left: 9px solid #9fb3c8; border-right: 0; }
.os-viewmenu { position: absolute; top: 140px; right: 14px; z-index: 2; }
.os-viewmenu .os-tool { background: rgba(255,255,255,.9); }
.os-status {
  position: absolute; left: 10px; bottom: 8px; z-index: 2; font-size: 12px; color: #555; background: rgba(255,255,255,.88);
  padding: 3px 8px; border-radius: 3px; border: 1px solid #e2e2e2; pointer-events: none; max-width: calc(100% - 20px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.os-loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 4; background: #fff; color: #666; font-size: 13px; }
.os-loading .bar { width: 160px; height: 3px; background: #e8e8e8; border-radius: 3px; overflow: hidden; margin-top: 10px; }
.os-loading .bar i { display: block; height: 100%; width: 0; background: var(--os-blue-2); transition: width .2s; }
.os-tip {
  position: absolute; z-index: 5; pointer-events: none; background: #333; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 3px;
  white-space: nowrap; transform: translate(12px, 12px); display: none;
}
.os-mass { position: absolute; right: 10px; bottom: 8px; z-index: 2; display: flex; gap: 2px; }
.os-panel-btn { display: none; }

/* Bottom tabs */
.os-tabs { grid-area: tabs; display: flex; align-items: stretch; background: #e4e4e4; border-top: 1px solid var(--os-line); overflow-x: auto; scrollbar-width: none; }
.os-tabs::-webkit-scrollbar { display: none; }
.os-plus { width: 36px; flex: none; display: grid; place-items: center; color: #444; font-size: 18px; border-right: 1px solid #d2d2d2; }
.os-tab {
  display: flex; align-items: center; gap: 7px; padding: 0 14px; min-width: 150px; max-width: 240px; border: 0;
  border-right: 1px solid #d2d2d2; background: transparent; cursor: pointer; font-size: 13px; color: #333; white-space: nowrap; flex: none;
}
.os-tab svg { width: 15px; height: 15px; color: #555; flex: none; }
.os-tab:hover { background: #ececec; }
.os-tab.is-on { background: #fff; box-shadow: inset 0 -2px 0 #1f5fbf; }
.os-tab span { overflow: hidden; text-overflow: ellipsis; }

/* Fullscreen */
.os:fullscreen { height: 100vh; border-radius: 0; border: 0; }

/* Responsive */
@media (max-width: 860px) {
  .os { grid-template-columns: 1fr; grid-template-areas: "top" "tools" "view" "tabs"; height: 70svh; min-height: 420px; }
  .os-side { position: absolute; z-index: 6; top: 84px; bottom: 32px; left: 0; width: min(260px, 80%); box-shadow: 6px 0 24px rgba(0,0,0,.15); transform: translateX(-102%); transition: transform .25s; }
  .os.side-open .os-side { transform: none; }
  .os-panel-btn { display: inline-flex; }
  .os-tools .os-help, .os-branch, .os-share { display: none; }
  .os-cube { width: 104px; height: 104px; }
  .os-arrow.up, .os-arrow.down { left: 45px; }
  .os-arrow.left, .os-arrow.right { top: 45px; }
  .os-viewmenu { top: 112px; right: 8px; }
  .os-doc { font-size: 15px; }
  .os-tool span.lbl { display: none; }
  .os-tab { min-width: 0; }
}
