/* ============================================================
   Pavement Design — gambar sambungan & tulangan (pd-joints.js) dan model 3D (pd-slab3d.js).
   Kelas v3- mengikuti model 3D Earth Retaining Design / Frame Design (panel kaca grafit di atas
   kanvas WebGL); aksen biru langit keluarga modul desain. Kelas pdj- untuk lembar gambar 2D.
   ============================================================ */
:root { --pd3-accent: #38BDF8; --pd3-accent-hover: #7DD3FC; --pd3-accent-ink: #04131C; }
.v3-root { position: absolute; inset: 0; overflow: hidden; font-family: Barlow, ui-sans-serif, system-ui, sans-serif; color: var(--graphite-ink, #C3CDCF); font-size: 12px; line-height: 1.35; -webkit-user-select: none; user-select: none; }
.v3-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; cursor: grab; }
.v3-canvas:active { cursor: grabbing; }
.v3-panel { background: rgba(20, 29, 34, .80); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border: 1px solid rgba(195, 205, 207, .13); border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, .22); }
.v3-root button { font: inherit; color: inherit; }

/* ---- bilah alat kiri atas ----------------------------------- */
.v3-tl { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; width: max-content; max-width: calc(100% - 330px); z-index: 2; }
.v3-seg { display: inline-flex; padding: 3px; gap: 2px; }
.v3-seg button { appearance: none; border: 0; background: transparent; color: var(--graphite-ink, #C3CDCF); font-size: 12px; font-weight: 500; line-height: 1; padding: 6px 10px; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.v3-seg button:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.v3-seg button.on { background: var(--pd3-accent); color: var(--pd3-accent-ink); font-weight: 600; }
.v3-seg button:focus-visible, .v3-tog:focus-visible, .v3-ib:focus-visible, .v3-card-btn:focus-visible, .v3-sel:focus-visible { outline: 2px solid var(--pd3-accent); outline-offset: 1px; }
.v3-ctx { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; flex-wrap: nowrap; }
.v3-sel { appearance: none; -webkit-appearance: none; background: #162026 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23AEBBBF' stroke-width='1.4' fill='none'/%3E%3C/svg%3E") no-repeat right 8px center; color: #E6ECEE; border: 1px solid rgba(195, 205, 207, .2); border-radius: 5px; font: inherit; font-size: 12px; padding: 5px 26px 5px 8px; max-width: 260px; width: auto; cursor: pointer; font-variant-numeric: tabular-nums; }
.v3-sel option { background: #1F2A30; color: #E6ECEE; }
.v3-amp { display: inline-flex; align-items: center; gap: 6px; color: #AEBBBF; font-size: 11.5px; }
.v3-amp input { width: 76px; accent-color: var(--pd3-accent); margin: 0; }
.v3-amp output { min-width: 32px; color: #E6ECEE; font-variant-numeric: tabular-nums; }
.v3-ib { appearance: none; width: 28px; height: 26px; display: inline-grid; place-items: center; border: 1px solid rgba(195, 205, 207, .2); border-radius: 5px; background: #162026; cursor: pointer; color: #E6ECEE; padding: 0; }
.v3-ib svg { width: 13px; height: 13px; }
.v3-ib:hover { border-color: rgba(56, 189, 248, .7); }
.v3-ib.on { color: var(--pd3-accent); }
.v3-muted { color: #8A979B; }

/* ---- kanan atas: arah pandang, lapisan, kartu ---------------- */
.v3-tr { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; z-index: 2; max-width: calc(100% - 300px); }
.v3-trow { display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: 6px; }
.v3-togs { display: inline-flex; gap: 2px; padding: 3px; }
.v3-tog { appearance: none; border: 0; background: transparent; color: #AEBBBF; font-size: 11.5px; padding: 5px 8px; border-radius: 5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.v3-tog i { width: 10px; height: 10px; border-radius: 2px; border: 1.4px solid currentColor; display: inline-block; box-sizing: border-box; }
.v3-tog.on { color: #E6ECEE; }
.v3-tog.on i { background: var(--pd3-accent); border-color: var(--pd3-accent); }
.v3-tog:hover { background: rgba(255, 255, 255, .07); }

.v3-card { width: 262px; padding: 10px 12px 11px; color: #DCE4E6; pointer-events: auto; }
.v3-card-h { display: flex; align-items: flex-start; gap: 8px; }
.v3-card-t { flex: 1; font-size: 13px; font-weight: 600; color: #fff; line-height: 1.3; }
.v3-x { appearance: none; border: 0; background: transparent; width: 22px; height: 22px; margin: -3px -5px 0 0; padding: 4px; border-radius: 4px; cursor: pointer; color: #8A979B; flex: none; }
.v3-x svg { width: 14px; height: 14px; display: block; }
.v3-x:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.v3-card-m { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; font-size: 12px; color: #AEBBBF; font-variant-numeric: tabular-nums; }
.v3-card-m b { color: var(--pd3-accent); font-weight: 600; font-family: var(--mono, ui-monospace, monospace); font-size: 11.5px; }
.v3-card-r { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.v3-badge { flex: none; min-width: 44px; text-align: center; padding: 3px 7px; border-radius: 5px; font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; color: #fff; }
.v3-badge.ok { background: var(--ok, #2E8B57); } .v3-badge.warn { background: var(--warn, #C98A0B); } .v3-badge.bad { background: var(--bad, #C2412D); }
.v3-gov { font-size: 11.5px; color: #C3CDCF; line-height: 1.3; }
.v3-card-d { margin-top: 7px; font-size: 11.5px; color: #AEBBBF; } .v3-card-d b { color: #E4F2FF; font-variant-numeric: tabular-nums; }
.v3-card-btn { appearance: none; margin-top: 10px; width: 100%; border: 0; border-radius: 6px; background: var(--pd3-accent); color: var(--pd3-accent-ink) !important; font-weight: 600; font-size: 12.5px; padding: 7px 10px; cursor: pointer; }
.v3-card-btn:hover { background: var(--pd3-accent-hover); }

/* ---- legenda kiri bawah --------------------------------------- */
.v3-legend { position: absolute; left: 10px; bottom: 10px; padding: 8px 11px 9px; min-width: 210px; max-width: min(360px, calc(100% - 120px)); z-index: 2; font-variant-numeric: tabular-nums; }
.v3-legend:empty { display: none; }
.v3-lg-t { font-size: 12px; font-weight: 600; color: #F1F4F5; }
.v3-lg-s { font-size: 11px; color: #8FA0A5; margin-top: 5px; }
.v3-lg-v { display: flex; align-items: baseline; gap: 6px; margin-top: 4px; font-size: 11.5px; color: #AEBBBF; flex-wrap: wrap; }
.v3-lg-v b { color: #fff; font-size: 13px; font-weight: 600; }
.v3-lg-v i { font-style: normal; font-size: 11px; color: #8FA0A5; }
.v3-ramp { height: 8px; border-radius: 2px; margin-top: 7px; }
.v3-ramp-ax { position: relative; height: 14px; font-size: 10.5px; color: #9FB0B5; }
.v3-ramp-ax span { position: absolute; top: 2px; transform: translateX(-50%); white-space: nowrap; }
.v3-ramp-ax span:first-child { transform: none; }
.v3-ramp-ax span:last-child { transform: translateX(-100%); }
.v3-bins, .v3-keys { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 5px; font-size: 11.5px; color: #C3CDCF; }
.v3-bins span, .v3-keys span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.v3-bins b, .v3-keys b { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.v3-bins b.ok, .v3-keys b.ok { background: var(--ok, #2E8B57); } .v3-bins b.warn { background: var(--pd3-accent); } .v3-bins b.bad, .v3-keys b.bad { background: var(--bad, #C2412D); }
.v3-keys b.dot { border-radius: 50%; } .v3-keys b.dot.ok { background: #46C285; } .v3-keys b.dot.bad { background: #E2553F; } .v3-keys b.dot.gov { background: #F2B51C; }
.v3-bins em, .v3-keys em { font-style: normal; color: #fff; font-weight: 600; }
.v3-parts { display: grid; gap: 3px; margin-top: 6px; font-size: 11px; color: #C3CDCF; }
.v3-parts span { display: grid; grid-template-columns: 20px 1fr 44px; align-items: center; gap: 6px; text-align: right; }
.v3-parts em { font-style: normal; color: #8FA0A5; text-align: left; }
.v3-parts s { display: block; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; text-decoration: none; }
.v3-parts s i { display: block; height: 100%; background: #78B3E6; border-radius: 3px; }

/* ---- petunjuk & tooltip --------------------------------------- */
.v3-hint { position: absolute; right: 80px; bottom: 12px; font-size: 10.5px; color: rgba(195, 205, 207, .5); pointer-events: none; white-space: nowrap; z-index: 1; }
.v3-tip { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; background: rgba(12, 18, 21, .94); color: #E6ECEE; font-size: 11.5px; padding: 5px 8px; border-radius: 5px; white-space: nowrap; border: 1px solid rgba(195, 205, 207, .14); font-variant-numeric: tabular-nums; }
.v3-tip b { color: var(--pd3-accent); font-weight: 600; }
.v3-tip .ok { color: #5BBF8A; font-weight: 600; } .v3-tip .warn { color: #F0B93A; font-weight: 600; } .v3-tip .bad { color: #F07A64; font-weight: 600; }

/* ---- ringkas & sempit ----------------------------------------- */
.v3-compact .v3-tl, .v3-compact .v3-togs, .v3-compact .v3-hint { display: none; }
.v3-compact .v3-legend { padding: 6px 9px; min-width: 0; }
.v3-compact .v3-lg-s { display: none; }
.v3-compact .v3-bins { margin-top: 0; }
.v3-compact .v3-lg-t { font-weight: 500; font-size: 11.5px; }
.v3-narrow .v3-hint, .v3-narrow .v3-lg-s, .v3-narrow .v3-parts, .v3-narrow .v3-ramp, .v3-narrow .v3-ramp-ax { display: none; }
.v3-narrow .v3-legend { min-width: 0; }
.v3-narrow .v3-tl { max-width: calc(100% - 20px); }
.v3-narrow .v3-ctx { flex-wrap: wrap; }
.v3-narrow .v3-tr { top: auto; bottom: 10px; right: 10px; max-width: calc(100% - 20px); }
.v3-compact .v3-tr { max-width: calc(100% - 20px); }
.v3-narrow .v3-tr .v3-card { position: absolute; bottom: calc(100% + 6px); right: 0; }
.v3-narrow .v3-togs { display: none; }
.v3-narrow .v3-legend { bottom: 52px; }
.v3-narrow .v3-seg button { padding: 6px 8px; }

/* ---- permukaan P–M -------------------------------------------- */
.v3-pm-head { position: absolute; top: 10px; left: 10px; padding: 8px 11px 9px; max-width: calc(100% - 20px); z-index: 2; }
.v3-pm .v3-hint { right: 12px; }

/* ---- cadangan tanpa WebGL & kosong ----------------------------- */
.v3-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #F7F9F8; padding: 10px; }
.v3-fallback .v3-svg { width: 100%; height: 100%; max-height: 100%; }
.v3-note { position: absolute; top: 10px; left: 10px; font-size: 12px; color: var(--ink-2, #4A5552); background: rgba(255, 255, 255, .92); border: 1px solid var(--line, #DDE2DF); border-radius: 6px; padding: 5px 9px; }
.v3-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: #AEBBBF; font-size: 13px; }
.v3-svg { width: 100%; height: auto; display: block; }
.v3-svg text { font-variant-numeric: tabular-nums; }

@media print {
  .v3-root .v3-tl, .v3-root .v3-tr, .v3-root .v3-hint, .v3-root .v3-tip { display: none !important; }
  .v3-note { display: none; }
  .v3-fallback { background: none; }
}


/* ---- wadah model 3D ------------------------------------------------ */
.pd3-host { position: relative; width: 100%; height: 540px; overflow: hidden; background: #1F2A30; border-radius: 14px; }
@media (max-width: 720px) { .pd3-host { height: 460px; } }
.pd3-host:fullscreen { width: 100vw; height: 100vh; border-radius: 0; }
.pd3-host:-webkit-full-screen { width: 100vw; height: 100vh; border-radius: 0; }
.pd3-host.v3-fs { position: fixed; inset: 0; z-index: 2000; width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; }
html.v3-fs-lock, html.v3-fs-lock body { overflow: hidden; }
.v3-fsw { padding: 3px; }
.v3-fsw .v3-fsb { display: inline-grid; place-items: center; padding: 5px 7px; }
.v3-fsw .v3-fsb svg { width: 15px; height: 15px; display: block; }
.v3-fs-only { display: none; }
.v3-isfs .v3-fs-only { display: inline; }
.v3-isfs .v3-legend { max-width: min(460px, calc(100% - 120px)); }
.v3-tl .v3-togs { display: inline-flex; }
.v3-bars3 { display: grid; gap: 3px; margin-top: 6px; font-size: 11.5px; }
.v3-bars3 b { width: 14px; height: 5px; border-radius: 1px; }
.pd3-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
.v3-card-d b { color: #fff; }
.v3-narrow .v3-bars3 { display: none; }
@media print { .pd3-card { display: none !important; } }

/* ---- lembar gambar 2D ------------------------------------------------ */
.pdj-frame { position: relative; border-radius: 14px; background: #F4F5F3; box-shadow: inset 0 0 0 1px rgba(17,24,39,.08); }
.pdj-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; }
.pdj-tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 10px; background: rgba(17,24,39,.06); }
.pdj-tabs button { appearance: none; border: 0; background: transparent; font: inherit; font-size: 13.5px; font-weight: 600; color: #4B5563; padding: 6px 11px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.pdj-tabs button:hover { color: #111827; }
.pdj-tabs button[aria-selected="true"] { background: #fff; color: #111827; box-shadow: 0 1px 2px rgba(17,24,39,.08), inset 0 0 0 1px rgba(17,24,39,.08); }
.pdj-tools { display: inline-flex; align-items: center; gap: 4px; }
.pdj-tools button, .pdj-tools a { appearance: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; min-width: 32px; justify-content: center; padding: 0 9px; border: 0; border-radius: 8px; background: #fff; color: #1F2937; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(17,24,39,.12); }
.pdj-tools button:hover { box-shadow: inset 0 0 0 1px rgba(17,24,39,.3); }
.pdj-tools button:focus-visible, .pdj-tabs button:focus-visible { outline: 2px solid #2F6FDB; outline-offset: 1px; }
.pdj-tools svg { width: 15px; height: 15px; }
.pdj-tools .pdj-zl { min-width: 52px; font-variant-numeric: tabular-nums; font-weight: 500; color: #4B5563; }
.pdj-stage { margin: 0 8px 8px; border-radius: 10px; background: #fff; overflow: hidden; box-shadow: 0 1px 2px rgba(17,24,39,.06), inset 0 0 0 1px rgba(17,24,39,.06); }
.pdj-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; padding: 10px 14px 6px; border-bottom: 1px solid #EEF0EE; font-size: 13px; color: #4B5563; }
.pdj-head b { font-size: 14.5px; color: #111827; font-weight: 700; }
.pdj-view { position: relative; overflow: hidden; touch-action: pan-y; cursor: default; }
.pdj-view.pdj-zoomed { cursor: grab; touch-action: none; }
.pdj-view.pdj-drag { cursor: grabbing; }
.pdj-view svg.pdj-svg { display: block; width: 100%; height: auto; max-width: 100%; }
.pdj-hint { padding: 6px 14px 9px; font-size: 12px; color: #6B7280; }
.pdj-frame.pdj-isfs { position: fixed; inset: 0; z-index: 2000; border-radius: 0; display: flex; flex-direction: column; background: #E9ECEA; }
.pdj-frame:fullscreen { display: flex; flex-direction: column; border-radius: 0; background: #E9ECEA; width: 100vw; height: 100vh; }
.pdj-frame:-webkit-full-screen { display: flex; flex-direction: column; border-radius: 0; background: #E9ECEA; width: 100vw; height: 100vh; }
:is(.pdj-frame:fullscreen, .pdj-frame.pdj-isfs) .pdj-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; }
:is(.pdj-frame:fullscreen, .pdj-frame.pdj-isfs) .pdj-view { flex: 1; min-height: 0; }
:is(.pdj-frame:fullscreen, .pdj-frame.pdj-isfs) .pdj-view svg.pdj-svg { position: absolute; inset: 0; width: 100% !important; height: 100% !important; max-width: none !important; }
.pdj-steel { margin-top: 14px; }
@media print {
  .pdj-bar, .pdj-hint { display: none !important; }
  .pdj-frame { background: none; box-shadow: none; }
  .pdj-stage { margin: 0; box-shadow: none; }
}
.v3-narrow .v3-tl .v3-togs { display: inline-flex; flex-wrap: wrap; }
.v3-narrow .v3-tl { max-width: calc(100% - 20px); }

/* ---- tema gelap: bingkai gelap, kertas gambar tetap putih (.qw-paper) ---- */
@media screen {
  html[data-theme="dark"] .pdj-frame { background: rgba(255,255,255,.035); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
  html[data-theme="dark"] .pdj-tabs { background: rgba(255,255,255,.06); }
  html[data-theme="dark"] .pdj-tabs button { color: #A9B4C0; }
  html[data-theme="dark"] .pdj-tabs button:hover { color: #E6EDF3; }
  html[data-theme="dark"] .pdj-tabs button[aria-selected="true"] { background: #1B2530; color: #E6EDF3; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
  html[data-theme="dark"] .pdj-tools button { background: #1B2530; color: #E6EDF3; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
  html[data-theme="dark"] .pdj-tools .pdj-zl { color: #A9B4C0; }
  html[data-theme="dark"] :is(.pdj-frame:fullscreen, .pdj-frame.pdj-isfs) { background: #0B1016; }
}
.v3-narrow .v3-tr { left: 10px; align-items: flex-end; }
.v3-narrow .v3-trow { flex-wrap: wrap-reverse; justify-content: flex-end; }
.v3-narrow .v3-views { flex-wrap: wrap; justify-content: flex-end; }
.v3-narrow .v3-legend { bottom: 96px; }
