/*
 * 하랑드론 UI 공용 디자인 시스템 (H-GIS · 3D 뷰어)
 * 방향: SuperSplat / Scaniverse / World Labs Atlas 처럼 정돈된 다크 UI
 *  - 블랙 배경 + 시안 포인트, 이모지 없이 선형 아이콘(hd-icons.js)
 *  - 얇은 1px 경계, 낮은 채도의 면, 일관된 8px 간격 체계
 */
:root {
  --hd-bg-0: #050608;            /* 캔버스 뒤 */
  --hd-bg-1: rgba(12, 14, 18, 0.92); /* 패널·바 */
  --hd-bg-1-solid: #0c0e12;
  --hd-bg-2: rgba(255, 255, 255, 0.04); /* 컨트롤 바탕 */
  --hd-bg-3: rgba(255, 255, 255, 0.08); /* hover */
  --hd-line: rgba(255, 255, 255, 0.08);
  --hd-line-2: rgba(255, 255, 255, 0.14);
  --hd-text: #e8edf2;
  --hd-text-2: #a3adb8;
  --hd-text-3: #6b7480;
  --hd-accent: #22d3ee;
  --hd-accent-strong: #00e5ff;
  --hd-accent-soft: rgba(34, 211, 238, 0.12);
  --hd-accent-line: rgba(34, 211, 238, 0.45);
  --hd-danger: #f87171;
  --hd-radius: 12px;
  --hd-radius-sm: 8px;
  --hd-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --hd-font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --hd-topbar-h: 52px;
}

.hd-ic { display: block; flex: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hd-panel [hidden], .hd-section[hidden] { display: none !important; }

/* ── 상단 바 ── */
.hd-topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 40;
  height: var(--hd-topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 12px 0 14px;
  background: var(--hd-bg-1);
  border-bottom: 1px solid var(--hd-line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  font-family: var(--hd-font);
}
.hd-topbar-left, .hd-topbar-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hd-brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--hd-text); flex: none; }
.hd-topbar-left { overflow: hidden; }
.hd-product { flex: none; }
.hd-topbar-right { flex: none; }
.hd-brand img { width: 26px; height: 26px; object-fit: contain; display: block; flex: none; }
.hd-brand-name { font-size: 13px; font-weight: 800; letter-spacing: 0.16em; color: #fff; white-space: nowrap; }
.hd-brand-sep { width: 1px; height: 18px; background: var(--hd-line-2); margin: 0 4px; flex: none; }
.hd-product { font-size: 13px; font-weight: 600; color: var(--hd-text-2); white-space: nowrap; }
.hd-title-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 46vw; min-width: 0; flex: 0 1 auto;
  font-size: 12.5px; font-weight: 600; color: var(--hd-text);
  padding: 6px 10px; border-radius: 999px; background: var(--hd-bg-2); border: 1px solid var(--hd-line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hd-title-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--hd-accent); flex: none; box-shadow: 0 0 8px var(--hd-accent); }

/* ── 버튼 ── */
.hd-iconbtn {
  width: 36px; height: 36px; border-radius: 9px; flex: none;
  display: inline-grid; place-items: center;
  background: transparent; border: 1px solid transparent; color: var(--hd-text-2);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s; text-decoration: none;
}
.hd-iconbtn:hover { background: var(--hd-bg-3); color: var(--hd-text); }
.hd-iconbtn.active, .hd-iconbtn[aria-pressed="true"] { background: var(--hd-accent-soft); color: var(--hd-accent); border-color: var(--hd-accent-line); }
.hd-iconbtn:focus-visible, .hd-btn:focus-visible, .hd-tool:focus-visible { outline: 2px solid var(--hd-accent); outline-offset: 2px; }

.hd-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 12px; border-radius: 9px;
  font-family: var(--hd-font); font-size: 12.5px; font-weight: 600; white-space: nowrap;
  color: var(--hd-text); background: var(--hd-bg-2); border: 1px solid var(--hd-line-2);
  cursor: pointer; transition: background .15s, border-color .15s, color .15s; text-decoration: none;
}
.hd-btn:hover { background: var(--hd-bg-3); border-color: rgba(255,255,255,0.22); }
.hd-btn.primary { background: var(--hd-accent); border-color: var(--hd-accent); color: #031317; font-weight: 700; }
.hd-btn.primary:hover { background: var(--hd-accent-strong); }
.hd-btn.accent { background: var(--hd-accent-soft); border-color: var(--hd-accent-line); color: var(--hd-accent); }
.hd-btn.ghost { background: transparent; border-color: transparent; color: var(--hd-text-2); }
.hd-btn.ghost:hover { background: var(--hd-bg-3); color: var(--hd-text); }
.hd-btn.danger { color: var(--hd-danger); border-color: rgba(248,113,113,0.35); background: rgba(248,113,113,0.06); }
.hd-btn.block { width: 100%; }
.hd-btn.sm { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.hd-btn[aria-pressed="true"], .hd-btn.active { background: var(--hd-accent-soft); border-color: var(--hd-accent-line); color: var(--hd-accent); }

/* ── 세로 도구 막대 ── */
.hd-toolbar {
  position: absolute; z-index: 45; display: flex; flex-direction: column; gap: 2px; padding: 5px;
  background: var(--hd-bg-1); border: 1px solid var(--hd-line); border-radius: 14px;
  box-shadow: var(--hd-shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.hd-tool {
  position: relative; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--hd-text-2);
  transition: background .15s, color .15s;
}
.hd-tool:hover { background: var(--hd-bg-3); color: var(--hd-text); }
.hd-tool.active, .hd-tool[aria-pressed="true"] { background: var(--hd-accent-soft); color: var(--hd-accent); border-color: var(--hd-accent-line); }
.hd-toolbar-sep { height: 1px; margin: 4px 6px; background: var(--hd-line); }
/* 툴팁 */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: #000; color: var(--hd-text); font: 600 11.5px/1 var(--hd-font); white-space: nowrap;
  padding: 7px 9px; border-radius: 7px; border: 1px solid var(--hd-line-2); pointer-events: none; z-index: 100;
}
[data-tip-pos="bottom"]:hover::after { left: 50%; top: calc(100% + 8px); transform: translateX(-50%); }
[data-tip-pos="left"]:hover::after { left: auto; right: calc(100% + 10px); }
@media (hover: none) { [data-tip]:hover::after { display: none; } }

/* ── 패널 ── */
.hd-panel {
  position: absolute; z-index: 55; width: 320px; max-width: calc(100vw - 24px);
  display: none; flex-direction: column;
  background: var(--hd-bg-1); border: 1px solid var(--hd-line); border-radius: var(--hd-radius);
  box-shadow: var(--hd-shadow); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  color: var(--hd-text); font-family: var(--hd-font); overflow: hidden;
}
.hd-panel.open { display: flex; }
.hd-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 10px 12px 14px; border-bottom: 1px solid var(--hd-line);
}
.hd-panel-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; color: #fff; }
.hd-panel-title .hd-ic { color: var(--hd-accent); }
.hd-panel-sub { font-size: 11.5px; color: var(--hd-text-3); font-weight: 500; margin-top: 2px; }
.hd-panel-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.hd-panel-foot { padding: 10px 14px; border-top: 1px solid var(--hd-line); display: flex; gap: 8px; flex-wrap: wrap; }
.hd-section { display: flex; flex-direction: column; gap: 8px; }
.hd-section + .hd-section { padding-top: 12px; border-top: 1px solid var(--hd-line); }
.hd-section-title { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--hd-text-3); }
.hd-hint { font-size: 11.5px; line-height: 1.55; color: var(--hd-text-2); }
.hd-note { font-size: 11px; line-height: 1.5; color: var(--hd-text-3); }
.hd-note code { color: var(--hd-text-2); font-size: 10.5px; }

/* 세그먼트 */
.hd-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border-radius: 10px; background: rgba(255,255,255,0.04); border: 1px solid var(--hd-line); }
.hd-seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 6px;
  border: none; border-radius: 7px; background: transparent; color: var(--hd-text-2);
  font: 600 12px var(--hd-font); cursor: pointer; white-space: nowrap;
}
.hd-seg button:hover { color: var(--hd-text); }
.hd-seg button.active { background: rgba(255,255,255,0.09); color: #fff; box-shadow: inset 0 0 0 1px var(--hd-line-2); }
.hd-seg button.active .hd-ic { color: var(--hd-accent); }

/* 필드 */
.hd-field { display: grid; grid-template-columns: 76px 1fr 64px; align-items: center; gap: 10px; font-size: 12px; color: var(--hd-text-2); }
.hd-field[hidden] { display: none; }
.hd-field > b, .hd-field > output { font-size: 12px; font-weight: 600; color: var(--hd-text); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hd-field.wide { grid-template-columns: 76px 1fr; }
.hd-input, .hd-select {
  width: 100%; height: 30px; padding: 0 8px; border-radius: 7px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--hd-line-2); color: var(--hd-text);
  font: 500 12px var(--hd-font); font-variant-numeric: tabular-nums;
}
.hd-input:focus, .hd-select:focus { outline: none; border-color: var(--hd-accent-line); }
.hd-select { appearance: none; -webkit-appearance: none; padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a3adb8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; }
.hd-select option { background: #0c0e12; color: var(--hd-text); }

/* 슬라이더 */
.hd-range { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 4px; background: rgba(255,255,255,0.12); outline: none; cursor: pointer; }
.hd-range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--hd-accent); box-shadow: 0 0 0 3px rgba(34,211,238,0.18); }
.hd-range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--hd-accent); }
.hd-range:focus-visible { outline: 2px solid var(--hd-accent); outline-offset: 4px; }

/* 체크 / 스위치 */
.hd-check { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--hd-text-2); cursor: pointer; }
.hd-check input { width: 14px; height: 14px; accent-color: var(--hd-accent); }
.hd-switch { position: relative; width: 32px; height: 18px; flex: none; display: inline-block; }
.hd-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.hd-switch span { position: absolute; inset: 0; border-radius: 18px; background: rgba(255,255,255,0.14); transition: .2s; cursor: pointer; }
.hd-switch span::before { content: ""; position: absolute; width: 12px; height: 12px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.hd-switch input:checked + span { background: var(--hd-accent); }
.hd-switch input:checked + span::before { transform: translateX(14px); background: #031317; }
.hd-switch input:focus-visible + span { outline: 2px solid var(--hd-accent); outline-offset: 2px; }

/* 리스트 행 */
.hd-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; background: rgba(255,255,255,0.03); border: 1px solid var(--hd-line); }
.hd-row:hover { border-color: var(--hd-line-2); }
.hd-row-main { flex: 1; min-width: 0; cursor: pointer; }
.hd-row-title { font-size: 12.5px; font-weight: 600; color: var(--hd-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-row-sub { font-size: 11px; color: var(--hd-text-3); margin-top: 2px; }
.hd-row-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--hd-accent-soft); color: var(--hd-accent); flex: none; }

/* 결과 카드 */
.hd-result { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.hd-result:empty { display: none; }
.hd-result-item { padding: 9px 10px; border-radius: 9px; background: rgba(255,255,255,0.03); border: 1px solid var(--hd-line); line-height: 1.6; color: var(--hd-text-2); }
.hd-result-item b { color: var(--hd-accent); font-weight: 700; }
.hd-big { font-size: 17px; font-weight: 700; color: #fff; letter-spacing: -0.01em; }
.hd-kbd { display: inline-block; min-width: 20px; padding: 2px 5px; border-radius: 5px; border: 1px solid var(--hd-line-2); border-bottom-width: 2px; font: 600 10.5px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--hd-text); text-align: center; background: rgba(255,255,255,0.04); }

/* 팝오버 */
.hd-popover { position: absolute; z-index: 70; display: none; min-width: 220px; padding: 6px; border-radius: 11px; background: var(--hd-bg-1-solid); border: 1px solid var(--hd-line-2); box-shadow: var(--hd-shadow); font-family: var(--hd-font); }
.hd-popover.open { display: block; }
.hd-menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 9px; border-radius: 7px; border: none; background: transparent; color: var(--hd-text); font: 500 12.5px var(--hd-font); text-align: left; cursor: pointer; text-decoration: none; }
.hd-menu-item:hover { background: var(--hd-bg-3); }
.hd-menu-item .hd-ic { color: var(--hd-text-2); }
.hd-menu-item small { margin-left: auto; color: var(--hd-text-3); font-size: 11px; }
.hd-menu-label { padding: 8px 9px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--hd-text-3); }
.hd-menu-sep { height: 1px; margin: 4px 2px; background: var(--hd-line); }

/* 키 안내 표 */
.hd-keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; align-items: center; font-size: 12px; color: var(--hd-text-2); }

@media (max-width: 1000px) {
  .hd-topbar .model-chip ~ * { }
  .hd-brand-name.hide-md { display: none; }
}
@media (max-width: 640px) {
  :root { --hd-topbar-h: 48px; }
  .hd-brand-name { display: none; }
  .hd-product { font-size: 12.5px; }
  .hd-tool { width: 38px; height: 38px; }
  .hd-field { grid-template-columns: 64px 1fr 56px; gap: 8px; font-size: 11.5px; }
}

/* 이동 속도 조절 (H-GIS · 3D 뷰어 키보드 비행) */
.hd-speed { display: flex; align-items: center; gap: 6px; }
.hd-speed .hd-speed-label { flex: 1; font-size: 12px; color: var(--hd-text-2); display: flex; align-items: center; gap: 6px; }
.hd-speed .hd-speed-val { min-width: 54px; text-align: center; font: 600 12.5px/1 var(--hd-font); color: var(--hd-text); font-variant-numeric: tabular-nums; }
.hd-speed button { width: 28px; height: 28px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--hd-line-2); background: rgba(255,255,255,0.04); color: var(--hd-text); cursor: pointer; padding: 0; }
.hd-speed button:hover { border-color: var(--hd-accent-line); color: var(--hd-accent); }
.hd-speed button:disabled { opacity: .35; cursor: default; }
.hd-speed button:focus-visible { outline: 2px solid var(--hd-accent); outline-offset: 2px; }

/* 짧은 알림 (속도 변경 등) */
.hd-toast { position: fixed; left: 50%; top: calc(var(--hd-topbar-h, 52px) + 14px); transform: translate(-50%, -6px); z-index: 200; padding: 8px 14px; border-radius: 999px; background: var(--hd-bg-1, rgba(10,12,16,.92)); border: 1px solid var(--hd-line-2); color: var(--hd-text); font: 600 12.5px/1.2 var(--hd-font); display: flex; align-items: center; gap: 8px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; backdrop-filter: blur(10px); }
.hd-toast.show { opacity: 1; transform: translate(-50%, 0); }
.hd-toast .hd-ic { color: var(--hd-accent); }
