/* 未来3D打印-地形工坊 —— 户外硬核风
   设计语言：深炭底、锐利直角、细线分隔、大写字距小标、
   单一岩橙色点缀（凯乐石式信号色），克制的地形分层配色。 */

* { box-sizing: border-box; }

:root {
  --bg: #0f1113;
  --panel: #16181b;
  --panel2: #1c1f23;
  --line: #2a2e33;
  --line-strong: #3a4046;
  --text: #e8e6e1;
  --muted: #8d9196;
  --accent: #ff5a1f;
  --accent-dim: rgba(255, 90, 31, 0.14);
  --ok: #58b368;
  --err: #e5484d;
  --radius: 2px;
}

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  font-family: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--muted); }
a:hover { color: var(--text); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2c3136; border-radius: 0; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 通用按钮：直角细边，悬停点亮 ---------- */
.btn {
  background: var(--panel2);
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: border-color .15s, color .15s, background .15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #131110;
  font-weight: 800;
}
.btn.primary:hover:not(:disabled) { background: #ff6f3a; color: #131110; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--line-strong); }
.btn.small { padding: 6px 10px; font-size: 11px; }
.btn.grow { flex: 1; }
.mini {
  background: none; border: 1px solid transparent; color: var(--muted);
  padding: 2px 5px; font-size: 11px; border-radius: var(--radius); line-height: 1.4;
}
.mini:hover { color: var(--text); border-color: var(--line-strong); }
.mini.danger:hover { color: var(--err); border-color: var(--err); }

/* ---------- 启动遮罩 ---------- */
#boot {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  transition: opacity .5s;
}
#boot.done { opacity: 0; pointer-events: none; }
.boot-mark { display: flex; align-items: center; gap: 14px; color: var(--accent); }
.boot-name { color: var(--text); line-height: 1.25; }
.boot-name em { display: block; font-style: normal; font-weight: 800; font-size: 20px; letter-spacing: .08em; }
.boot-name span { display: block; font-size: 11px; letter-spacing: .55em; color: var(--muted); }
.boot-bar { width: 220px; height: 2px; background: var(--line); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 40%; background: var(--accent); animation: bootslide 1.1s linear infinite; }
@keyframes bootslide { from { transform: translateX(-100%);} to { transform: translateX(560%);} }
.boot-text { font-size: 11px; letter-spacing: .3em; color: var(--muted); }
.boot-copy { position: fixed; bottom: 18px; font-size: 11px; color: var(--muted); }

/* ---------- 顶栏 ---------- */
#topbar {
  flex: 0 0 52px;
  display: flex; align-items: center; gap: 26px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--accent); }
.brand-name { line-height: 1.2; }
.brand-name em { font-style: normal; font-weight: 800; font-size: 15px; letter-spacing: .05em; color: var(--text); }
.brand-name span { display: block; font-size: 10px; letter-spacing: .5em; color: var(--muted); }
#steps { display: flex; gap: 22px; flex: 1; justify-content: center; }
.step {
  font-size: 11px; letter-spacing: .14em; color: var(--muted);
  padding-bottom: 3px; border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
}
.step.on { color: var(--text); border-bottom-color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- 开关 ---------- */
.switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 11px; color: var(--muted); letter-spacing: .06em; }
.switch input { display: none; }
.switch i {
  width: 28px; height: 15px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  position: relative; transition: background .15s, border-color .15s;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 9px; height: 9px;
  background: var(--muted); transition: transform .15s, background .15s;
}
.switch input:checked + i { border-color: var(--accent); background: var(--accent-dim); }
.switch input:checked + i::after { transform: translateX(13px); background: var(--accent); }
.switch input:not(:checked) + i + span { opacity: .75; }

.check { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); cursor: pointer; margin-top: 10px; }
.check input { accent-color: var(--accent); }

/* ---------- 主布局 ---------- */
#layout { flex: 1; display: flex; min-height: 0; }

#mapPanel { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #14161a; }
.amap-container { font: inherit; }

.map-tools {
  position: absolute; top: 14px; left: 14px; z-index: 40;
  display: flex; flex-direction: column; gap: 8px;
}
.tool {
  width: 52px; padding: 8px 0 6px;
  background: rgba(18, 20, 23, 0.92);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  backdrop-filter: blur(4px);
  transition: color .15s, border-color .15s, background .15s;
}
.tool svg { width: 19px; height: 19px; }
.tool span { font-size: 10px; letter-spacing: .05em; }
.tool:hover { color: var(--text); border-color: var(--text); }
.tool.active { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.tool:disabled { opacity: .4; cursor: not-allowed; }

#mapHint {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 40; padding: 7px 16px;
  background: rgba(18, 20, 23, 0.92); border: 1px solid var(--accent); color: var(--accent);
  font-size: 12px; letter-spacing: .08em; border-radius: var(--radius);
  display: none; backdrop-filter: blur(4px);
}
#mapHint:not(:empty) { display: block; }

/* ---------- 地图搜索 ---------- */
#searchBox {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 45; width: min(380px, 58%);
}
#searchInput {
  width: 100%;
  background: rgba(18, 20, 23, 0.92);
  border: 1px solid var(--line-strong); border-left: 2px solid var(--accent);
  color: var(--text); padding: 9px 14px; font: inherit; font-size: 13px;
  border-radius: var(--radius); outline: none; backdrop-filter: blur(4px);
  transition: border-color .15s;
}
#searchInput:focus { border-color: var(--accent); }
#searchInput::placeholder { color: var(--muted); }
#searchResults {
  display: none; margin-top: 6px;
  background: rgba(18, 20, 23, 0.96); border: 1px solid var(--line-strong);
  border-radius: var(--radius); overflow: hidden; backdrop-filter: blur(4px);
  max-height: 300px; overflow-y: auto;
}
.search-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 14px; cursor: pointer; border-bottom: 1px solid var(--line);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--accent-dim); }
.s-name { color: var(--text); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.s-district { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-pin {
  width: 14px; height: 14px; background: var(--accent);
  border: 2px solid #131110; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); box-shadow: 0 0 0 2px rgba(255, 90, 31, 0.3);
}

.status-bar {
  position: absolute; left: 14px; bottom: 10px; z-index: 40;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; color: var(--muted);
  background: rgba(18, 20, 23, 0.88);
  border: 1px solid var(--line); border-left: 2px solid var(--muted);
  padding: 6px 12px; border-radius: var(--radius);
  max-width: 62%; backdrop-filter: blur(4px);
}
.status-bar.ok { border-left-color: var(--ok); color: var(--text); }
.status-bar.err { border-left-color: var(--err); color: var(--err); }

/* ---------- 高程下载遮罩 ---------- */
#demOverlay {
  position: absolute; inset: 0; z-index: 60;
  background: rgba(10, 11, 13, 0.72);
  backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center;
}
#demOverlay.show { display: flex; }
.dem-box { width: 300px; text-align: center; }
.dem-title {
  font-size: 12px; font-weight: 800; letter-spacing: .3em; color: var(--text);
}
.dem-pct {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 46px; font-weight: 800; color: var(--accent);
  margin: 10px 0 12px; font-variant-numeric: tabular-nums;
}
.dem-bar { height: 3px; background: var(--line-strong); overflow: hidden; }
.dem-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.dem-sub { margin-top: 14px; font-size: 11px; color: var(--muted); letter-spacing: .12em; }

/* 生成模型模式：隐藏百分比，进度条流动动画 */
#demOverlay.build .dem-pct { display: none; }
#demOverlay.build .dem-bar i { width: 34% !important; animation: demIndet 1.1s linear infinite; }
@keyframes demIndet {
  from { transform: translateX(-110%); }
  to { transform: translateX(320%); }
}

/* ---------- 右侧面板 ---------- */
#sidePanel {
  flex: 0 0 400px;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--panel);
  min-height: 0;
}
#viewWrap { position: relative; flex: 0 0 44%; min-height: 220px; background: var(--bg); }
#view3d { position: absolute; inset: 0; }
#view3d canvas { display: block; }
.view-btn { position: absolute; right: 10px; top: 10px; z-index: 5; }

#controls { flex: 1; overflow-y: auto; min-height: 0; }

.sec { padding: 14px 18px 16px; border-bottom: 1px solid var(--line); }
.sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 12px; font-weight: 800; letter-spacing: .12em; margin-bottom: 12px;
}
.sec-head span { font-size: 9px; letter-spacing: .3em; color: var(--muted); font-weight: 600; }

.row { display: flex; gap: 10px; }
.fld { flex: 1; display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--muted); letter-spacing: .06em; }
.fld select {
  background: var(--panel2); border: 1px solid var(--line-strong); color: var(--text);
  padding: 7px 9px; border-radius: var(--radius); font: inherit; outline: none;
}
.fld select:focus { border-color: var(--accent); }

.demo-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.demo-cap { font-size: 11px; color: var(--muted); letter-spacing: .06em; }

/* ---------- 滑杆 ---------- */
.slider { display: grid; grid-template-columns: 64px 1fr 56px; align-items: center; gap: 10px; margin: 9px 0; font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.slider b { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 600; font-size: 11px; color: var(--text); text-align: right; }
.slider.grow { display: flex; flex: 1; }
.slider.grow b { min-width: 48px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--line-strong); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 11px; margin-top: -4.5px;
  background: var(--panel); border: 2px solid var(--accent); border-radius: 1px;
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--line-strong); }
input[type="range"]::-moz-range-thumb { width: 8px; height: 8px; background: var(--panel); border: 2px solid var(--accent); border-radius: 1px; }
input[type="range"]:disabled::-webkit-slider-thumb { border-color: var(--line-strong); }
input[type="range"]:disabled { opacity: .4; }

.water-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }

/* ---------- 线路颜色选择 ---------- */
.color-row { display: flex; gap: 8px; margin-bottom: 12px; }
.swatch {
  width: 24px; height: 24px; border-radius: 2px;
  border: 2px solid var(--line-strong); cursor: pointer;
  transition: transform .1s, border-color .1s, box-shadow .1s;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--accent); }

/* ---------- 线路列表 ---------- */
#routeList { display: flex; flex-direction: column; gap: 6px; }
.route-empty { color: var(--muted); font-size: 11.5px; line-height: 1.8; opacity: .8; }
.route-item {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel2); border: 1px solid var(--line);
  padding: 7px 10px; border-radius: var(--radius);
}
.route-item .dot { width: 9px; height: 9px; border-radius: 1px; flex: 0 0 auto; }
.route-item .name { font-weight: 700; font-size: 12px; }
.route-item .len { flex: 1; color: var(--muted); font-size: 11px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ---------- 导出 ---------- */
.model-info {
  font-size: 12px; color: var(--muted); line-height: 1.9;
  border: 1px solid var(--line); background: var(--panel2);
  padding: 10px 12px; border-radius: var(--radius); margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}
.model-info b { color: var(--accent); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 600; }
.export-row { display: flex; gap: 10px; }
.export-row .primary { padding: 11px 14px; font-size: 13px; letter-spacing: .1em; }
.tip { color: var(--muted); font-size: 11px; line-height: 1.7; margin: 10px 0 0; }

/* ---------- 页脚 ---------- */
.ver {
  display: inline-block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.05em;
  vertical-align: 1px;
}

#footer {
  flex: 0 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 10.5px; color: var(--muted); letter-spacing: .05em;
}
.foot-right { opacity: .75; }

/* ---------- Toast ---------- */
#toasts {
  position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(18, 20, 23, 0.95); border: 1px solid var(--line-strong); border-left: 3px solid var(--muted);
  color: var(--text); font-size: 12px; padding: 10px 18px; border-radius: var(--radius);
  opacity: 0; transform: translateY(8px); transition: opacity .3s, transform .3s;
  max-width: 70vw; backdrop-filter: blur(4px);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }

/* ---------- 窄屏 ---------- */
@media (max-width: 980px) {
  #layout { flex-direction: column; }
  #mapPanel { flex: 0 0 46%; }
  #sidePanel { flex: 1; border-left: none; border-top: 1px solid var(--line); flex-basis: auto; }
  #steps { display: none; }
}
