/* ファルコンビューアー 画面デザイン
   配色はビューアーの世界観（夜空の紺・地形の緑・計測マーカーの赤）に合わせる */
:root {
  --bg: #151A23;          /* 3D画面のまわり（夜空の紺） */
  --panel: #1E2530;       /* 左メニューの下地 */
  --panel-2: #262E3C;     /* ボタンなどの下地 */
  --ink: #E6E9E3;         /* 文字色 */
  --muted: #99A39B;       /* 補足文字 */
  --line: #303A46;        /* 区切り線 */
  --green: #63BE8F;       /* アクセント（測量の緑） */
  --red: #E37166;         /* 計測・アクティブ（マーカーの赤） */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic Medium", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 14px; line-height: 1.6;
  display: flex;
}

/* ---------- 左メニュー ---------- */
#panel {
  width: 288px; flex: none; height: 100vh; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 14px 14px 40px; z-index: 20;
}
.brand h1 {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 19px; font-weight: 600; margin: 0;
}
.brand .ver {
  font-size: 11px; color: var(--muted); letter-spacing: 0.08em;
}
#panel section, #panel .sec { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
#panel h2 {
  font-size: 12px; color: var(--muted); font-weight: 600;
  letter-spacing: 0.12em; margin: 0 0 8px;
}
/* 折りたたみ見出し（クリックで開閉） */
#panel .sec > summary {
  font-size: 12px; color: var(--muted); font-weight: 600;
  letter-spacing: 0.12em; margin: 0 0 8px;
  cursor: pointer; list-style: none; user-select: none;
  display: flex; align-items: center; gap: 6px; min-height: 22px;
}
#panel .sec > summary::-webkit-details-marker { display: none; }
#panel .sec > summary::before {
  content: "▸"; font-size: 10px; color: var(--muted); transition: transform 0.15s;
}
#panel .sec[open] > summary::before { transform: rotate(90deg); }
#panel .sec > summary:hover { color: var(--ink); }
#panel .sec > summary:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { #panel .sec > summary::before { transition: none; } }
.hint { font-size: 11px; color: var(--muted); margin: 6px 0 8px; }

select, button, .button {
  font-family: inherit; font-size: 13px; color: var(--ink);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 9px 10px; cursor: pointer;
  text-decoration: none; text-align: center; display: inline-block;
}
select { width: 100%; }
button:hover, .button:hover { border-color: var(--muted); }
button:focus-visible, select:focus-visible, .button:focus-visible {
  outline: 2px solid var(--green); outline-offset: 1px;
}
button.wide, .button.wide { width: 100%; }
.btn-row { display: flex; gap: 6px; margin: 6px 0; }
.btn-row button, .btn-row .button { flex: 1; min-height: 40px; }
button.mode.active { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }

button.bg.active { background: var(--green); border-color: var(--green); color: #10241A; font-weight: 700; }

/* チェックボックス・スライダー */
.check-row { display: flex; gap: 14px; margin: 4px 0 8px; }
.check-row label, .check-line {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; cursor: pointer;
}
.check-line { margin: 8px 0 2px; }
.check-row input, .check-line input { width: 17px; height: 17px; accent-color: var(--green); }
.slider-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  gap: 2px 8px; margin: 8px 0; font-size: 12px; color: var(--muted);
}
.slider-row output {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.slider-row input[type="range"] {
  grid-column: 1 / -1; width: 100%; accent-color: var(--green); margin: 0;
}
.slider-row input[type="range"]:disabled { opacity: 0.4; }

/* 計測一覧 */
#measure-list { display: flex; flex-direction: column; gap: 5px; margin: 8px 0; }
.m-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; font-size: 12px;
}
.m-row .m-type { color: var(--muted); flex: none; }
.m-row .m-val {
  flex: 1; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
.m-row .m-name {
  display: block; color: var(--green); font-family: inherit;
  font-size: 12px; word-break: break-word;
}
.m-row .m-del, .m-row .m-edit {
  flex: none; padding: 2px 8px; min-height: 0; font-size: 12px;
  background: transparent; border-color: transparent; color: var(--muted);
}
.m-row .m-edit:hover { color: var(--green); border-color: var(--green); }
.m-row .m-del:hover { color: var(--red); border-color: var(--red); }
.m-empty { font-size: 12px; color: var(--muted); }

/* 視点ブックマーク */
#bookmark-list { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }
.b-row { display: flex; gap: 6px; }
.b-row .b-go { flex: 1; text-align: left; }
.b-row .b-del { flex: none; color: var(--muted); }

/* ---------- 3D画面 ---------- */
#view { position: relative; flex: 1; height: 100vh; overflow: hidden; }
#view canvas { display: block; }
#labels { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.measure-label {
  position: absolute; transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75); color: #fff;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px; padding: 2px 7px; border-radius: 3px; white-space: nowrap;
}
#status {
  position: absolute; left: 10px; bottom: 10px; z-index: 6;
  font-size: 12px; color: var(--muted);
  background: rgba(15, 20, 28, 0.75); border-radius: 5px; padding: 4px 10px;
  pointer-events: none;
}
/* 納品モード: 社内用の操作を隠す */
body.mode-client [data-internal],
body.mode-view [data-internal],
body.mode-view [data-measure] { display: none !important; }

/* 納品モードの表示（会社名・案件名） */
#delivery {
  position: absolute; right: 10px; top: 10px; z-index: 6;
  background: rgba(15, 20, 28, 0.8); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 12px; pointer-events: none;
  display: flex; flex-direction: column; gap: 1px; text-align: right;
}
#delivery[hidden] { display: none; }
#delivery .d-company {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 13px; color: var(--green); letter-spacing: 0.06em;
}
#delivery .d-project { font-size: 12px; color: var(--ink); }

#coord {
  position: absolute; right: 10px; bottom: 10px; z-index: 6;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink);
  background: rgba(15, 20, 28, 0.8); border: 1px solid var(--line);
  border-radius: 5px; padding: 4px 10px; pointer-events: none; white-space: nowrap;
}
#coord[hidden] { display: none; }

#toast {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 30; background: var(--green); color: #10241A;
  font-weight: 700; font-size: 13px; padding: 8px 18px; border-radius: 999px;
  opacity: 0; transition: opacity 0.25s; pointer-events: none;
}
#toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* ---------- 操作ガイド ---------- */
#help {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 14, 20, 0.7);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
#help[hidden] { display: none; }
.help-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 22px; max-width: 440px; width: 100%;
}
.help-card h2 {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  margin: 0 0 12px; font-size: 18px;
}
.help-card table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.help-card th, .help-card td {
  text-align: left; font-size: 13px; padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}
.help-card th { color: var(--muted); font-weight: 600; white-space: nowrap; padding-right: 14px; }

/* ---------- スマホ・タブレット ---------- */
#menu-toggle {
  display: none; position: fixed; top: 10px; left: 10px; z-index: 40;
  width: 44px; height: 44px; font-size: 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink);
}
@media (max-width: 760px) {
  #menu-toggle { display: block; }
  #panel {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform 0.2s;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }
  #panel.open { transform: translateX(0); }
  @media (prefers-reduced-motion: reduce) { #panel { transition: none; } }
  #view { width: 100vw; }
}

/* ---------- 座標計算（座標管理・線形計算） ---------- */
.coord-add { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr auto; gap: 4px; margin: 6px 0; }
.coord-add input { min-width: 0; font-size: 12px; padding: 4px; background: #0F1420;
  border: 1px solid var(--line); border-radius: 4px; color: var(--ink); }
.coord-table { max-height: 180px; overflow-y: auto; margin: 6px 0; font-size: 12px; }
.coord-table table { width: 100%; border-collapse: collapse; }
.coord-table th, .coord-table td { padding: 2px 4px; border-bottom: 1px solid var(--line);
  text-align: right; white-space: nowrap; }
.coord-table th { color: var(--muted); font-weight: normal; text-align: right; }
.coord-table td:first-child, .coord-table th:first-child { text-align: left; }
.coord-table input { width: 70px; font-size: 12px; padding: 2px 3px; background: #0F1420;
  border: 1px solid var(--line); border-radius: 3px; color: var(--ink); }
.coord-table button.del { padding: 1px 6px; font-size: 11px; }
.color-line { display: inline-flex; align-items: center; gap: 4px; }
.color-line input[type=color] { width: 26px; height: 20px; padding: 0; border: 1px solid var(--line);
  border-radius: 4px; background: none; }
hr.thin { border: none; border-top: 1px solid var(--line); margin: 10px 0 6px; }
