/* Demo 4（工場の機械レイアウトを3D）専用。共通部分は /css/demo.css。 */

.d4-view { position: relative; width: 100%; height: clamp(360px, 52vw, 560px); background: linear-gradient(#f7f8fa, #e9edf5); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.d4-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: grab; }
.d4-view canvas.is-grabbing { cursor: grabbing; }
.d4-view canvas.is-interactive.is-over { cursor: move; }
.d4-view canvas[hidden] { display: none; }
.d4-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.d4-label { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 14px; line-height: 1.4; will-change: transform; }
.d4-label--m { display: flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, .94); border: 1px solid var(--border-2); border-radius: 999px; padding: 1px 10px 1px 2px; color: var(--navy); font-weight: 600; box-shadow: 0 2px 6px -2px rgba(15, 27, 45, .25); }
.d4-label__no { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 999px; background: var(--blue); color: #fff; font-size: 14px; font-weight: 700; }
.d4-label__size { font-weight: 500; color: var(--muted-2); }
.d4-label--g { font-weight: 700; padding: 0 8px; border-radius: 6px; border: 1px solid; }
.d4-label--g.is-ok { background: #e7f6ee; border-color: #8fd0ad; color: #0b6b3a; }
.d4-label--g.is-warn { background: #fff6d6; border-color: #ecd37a; color: #7a5a00; }
.d4-label--door { font-weight: 700; color: var(--blue); background: rgba(255, 255, 255, .9); border-radius: 6px; padding: 0 8px; }
.d4-label--out { color: #0b6b3a; }
.d4-label--m.is-min .d4-label__size, .d4-label--m.is-min .d4-label__name { display: none; }
.d4-label--m.is-min { padding: 0; border: 0; background: none; box-shadow: none; }
.d4-label--m.is-min .d4-label__no { width: 24px; height: 24px; box-shadow: 0 2px 6px -1px rgba(15, 27, 45, .4); }
.d4-view.is-compact .d4-label__size, .d4-view.is-compact .d4-label__name { display: none; }
.d4-view.is-compact .d4-label--m { padding: 0; border: 0; background: none; box-shadow: none; }
.d4-view.is-compact .d4-label__no { width: 24px; height: 24px; box-shadow: 0 2px 6px -1px rgba(15, 27, 45, .4); }
.d4-view.is-compact .d4-label--g.is-ok { display: none; }
.d4-hint { position: absolute; right: 10px; top: 8px; font-size: 14px; color: var(--muted-2); background: rgba(255, 255, 255, .88); border-radius: 6px; padding: 2px 10px; pointer-events: none; }

.d4-fallback { position: absolute; inset: 0; overflow: auto; padding: 14px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.d4-fallback[hidden] { display: none; }
.d4-fallback__title { font-size: 16px; font-weight: 700; color: var(--navy); }
.d4-fallback__body { font-size: 14px; line-height: 1.7; color: var(--muted-2); }
.d4-plan { width: 100%; height: auto; max-height: 100%; }

.d4-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; font-weight: 600; color: var(--navy); margin-top: -8px; }
.d4-legend span { display: inline-flex; align-items: center; gap: 6px; }
.d4-legend i { display: inline-block; width: 22px; height: 6px; border-radius: 3px; }
.d4-legend .ok { background: #1c9a5a; }
.d4-legend .warn { background: #e8a800; }
.d4-legend .route { background: #2250d9; }

.d4-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.d4-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.d4-card__title { font-size: 14px; font-weight: 700; color: var(--blue); letter-spacing: .04em; }
.d4-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.d4-stat { display: flex; flex-direction: column; gap: 2px; background: var(--bg); border-radius: 8px; padding: 8px 12px; }
.d4-stat[hidden] { display: none; }
.d4-stat__l { font-size: 14px; color: var(--muted-2); }
.d4-stat__v { font-size: 24px; font-weight: 700; color: var(--navy); line-height: 1.3; font-variant-numeric: tabular-nums; }
.d4-stat--good .d4-stat__v { color: #0b6b3a; }

.d4-gapsum { font-size: 15px; font-weight: 700; min-height: 1.6em; }
.d4-gapsum.is-ok { color: #0b6b3a; }
.d4-gapsum.is-warn { color: #7a5a00; }
.d4-gaplist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.d4-gap { display: grid; grid-template-columns: 4.6em minmax(0, 1fr) auto; gap: 4px 10px; align-items: baseline; font-size: 14px; line-height: 1.6; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); background: #fff; }
.d4-gap__st { font-weight: 700; }
.d4-gap__v { font-weight: 700; font-variant-numeric: tabular-nums; }
.d4-gap.is-ok { background: #e7f6ee; border-color: #bfe3cf; color: #0b6b3a; }
.d4-gap.is-ok .d4-gap__nm { color: var(--navy); font-weight: 500; }
.d4-gap.is-warn { background: #fff6d6; border-color: #ecd37a; color: #7a5a00; }
.d4-gap.is-warn .d4-gap__nm { color: var(--navy); font-weight: 500; }
.d4-gap--none { display: block; background: var(--bg); color: var(--muted-2); border-color: transparent; }

.d4-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.d4-table th, .d4-table td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); line-height: 1.6; }
.d4-table thead th { color: var(--muted-2); font-weight: 600; }
.d4-table tbody th { width: 3.5em; color: var(--blue); font-weight: 700; }

.d4-touch { background: rgba(34, 80, 217, .06); border: 1px solid rgba(34, 80, 217, .25); }
.d4-touch__lead { font-size: 15px; line-height: 1.7; color: var(--navy); }
.d4-touch__row { display: flex; flex-wrap: wrap; gap: 10px; }
.d4-btn { min-height: 44px; padding: 0 18px; border-radius: 999px; border: 2px solid var(--blue); background: #fff; color: var(--blue); font-size: 15px; font-weight: 700; font-family: inherit; cursor: pointer; }
.d4-btn[aria-pressed="true"] { background: var(--blue); color: #fff; }
.d4-btn--ghost { border-color: var(--border-2); color: var(--navy); font-weight: 600; }
.d4-btn:disabled { opacity: .55; cursor: not-allowed; }
.d4-touch__msg { font-size: 14px; line-height: 1.7; color: var(--muted-2); min-height: 1.7em; }
.d4-touch__note { font-size: 14px; color: var(--muted-2); }

/* 触ってみる：選択・回転・保存 */
.d4-touch__row--sel { align-items: center; }
.d4-sel { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--navy); }
.d4-sel select { min-height: 44px; border: 1px solid var(--border-2); border-radius: 8px; background: #fff; color: var(--navy); font: inherit; font-size: 15px; padding: 0 10px; }
.d4-touch__sel { font-size: 15px; font-weight: 700; color: var(--navy); min-height: 1.6em; }
.d4-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.d4-tools__msg { font-weight: 600; color: var(--navy); }
.d4-btn:focus-visible, .d4-sel select:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.d4-label--m.is-sel { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(34, 80, 217, .35); }
.d4-saveov { position: fixed; inset: 0; z-index: 100; background: rgba(15, 27, 45, .75); display: flex; align-items: center; justify-content: center; padding: 16px; }
.d4-saveov__box { background: #fff; border-radius: 12px; padding: 16px; max-width: 560px; width: 100%; max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.d4-saveov__box p { font-size: 15px; font-weight: 700; color: var(--navy); }
.d4-saveov__box img { width: 100%; height: auto; display: block; border: 1px solid var(--border); }
.d4-steps { margin: 0; padding-left: 1.6em; list-style: decimal; font-size: 14px; line-height: 1.8; color: var(--muted-2); }
.d4-factory { font-size: 14px; color: var(--muted-2); }

@media (max-width: 860px) {
  .d4-view { height: min(400px, 108vw); }
  .d4-cols { grid-template-columns: minmax(0, 1fr); }
  .d4-gap { grid-template-columns: 4.4em minmax(0, 1fr); }
  .d4-gap__v { grid-column: 2; }
}
