/* === KML 合并/分割工具 - 暗色玻璃拟态主题 === */
:root {
  --bg-dark: #0f1117;
  --bg-panel: rgba(22, 26, 37, 0.85);
  --bg-panel-solid: #161a25;
  --bg-input: rgba(30, 35, 50, 0.8);
  --bg-hover: rgba(40, 45, 65, 0.8);
  --border: rgba(80, 90, 120, 0.4);
  --border-active: rgba(100, 180, 255, 0.6);
  --text: #e0e4ec;
  --text-dim: #8a90a0;
  --text-bright: #ffffff;
  --accent: #4a9eff;
  --accent-glow: rgba(74, 158, 255, 0.3);
  --success: #4caf50;
  --warn: #ff9800;
  --error: #f44336;
  --glass-blur: blur(12px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { min-height: 100%; overflow-x: hidden; overflow-y: auto; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 13px; color: var(--text); background: var(--bg-dark);
}
#app { display: flex; flex-direction: column; height: 100vh; min-height: 100vh; }

/* Header */
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 20px; height: 48px;
  background: var(--bg-panel); backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border); z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.app-icon { font-size: 20px; color: var(--accent); }
.app-header h1 { font-size: 15px; font-weight: 600; color: var(--text-bright); }
.btn-icon {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--text-dim); padding: 4px 8px; border-radius: 6px; transition: all 0.2s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-bright); }

/* Main */
.main-content { flex: 1; display: flex; overflow: hidden; }
.control-panel {
  width: 380px; min-width: 380px; overflow-y: auto;
  background: var(--bg-panel); backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border);
}
.control-panel::-webkit-scrollbar { width: 6px; }
.control-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.panel-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.section-title { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 12px; }

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 10px;
  padding: 24px 16px; text-align: center; cursor: pointer;
  transition: all 0.3s; background: var(--bg-input);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--border-active); background: var(--bg-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}
.upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-text { font-size: 13px; color: var(--text); margin-bottom: 4px; }
.upload-hint { font-size: 11px; color: var(--text-dim); line-height: 1.5; }

.upload-zone.small { padding: 14px 8px; }
.upload-icon-small { font-size: 20px; margin-bottom: 4px; }
.upload-text-small { font-size: 12px; color: var(--text); }

/* File List */
.files-list { margin-top: 8px; }
.files-list .file-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px; background: var(--bg-input); border-radius: 6px;
  margin-bottom: 4px; font-size: 12px;
}
.files-list .file-item .file-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.files-list .file-item .file-meta { color: var(--text-dim); margin-left: 8px; white-space: nowrap; }
.files-list .file-item .file-remove {
  color: var(--error); cursor: pointer; margin-left: 8px; font-size: 14px;
}

/* Stats */
.shp-info {
  margin-top: 12px; padding: 12px;
  background: var(--bg-input); border-radius: 8px;
  border-left: 3px solid var(--success);
}
.shp-info .info-row { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 12px; }
.shp-info .info-label { color: var(--text-dim); }
.shp-info .info-value { color: var(--text-bright); font-weight: 500; }
.shp-info .info-tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; margin: 2px 4px 2px 0;
}
.shp-info .tag-point { background: rgba(74, 158, 255, 0.2); color: var(--accent); }
.shp-info .tag-line { background: rgba(76, 175, 80, 0.2); color: var(--success); }
.shp-info .tag-poly { background: rgba(255, 152, 0, 0.2); color: var(--warn); }

/* Operation Tabs */
.op-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.op-tab {
  flex: 1; padding: 8px; text-align: center;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-dim); cursor: pointer;
  font-size: 13px; transition: all 0.2s;
}
.op-tab.active { background: var(--accent); color: white; border-color: var(--accent); }
.op-tab:hover:not(.active) { background: var(--bg-hover); color: var(--text); }

.op-panel { display: none; }
.op-panel.active { display: block; animation: fadeIn 0.3s; }

/* Form */
.form-group { margin-bottom: 12px; }
.form-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim); margin-bottom: 6px; cursor: pointer;
}
.form-label input[type="checkbox"] { cursor: pointer; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-select, .form-text {
  width: 100%; padding: 7px 10px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13px; outline: none; transition: border-color 0.2s;
}
.form-select:focus, .form-text:focus { border-color: var(--border-active); }
.form-select option { background: var(--bg-panel-solid); }
.form-number {
  width: 100%; padding: 6px 10px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13px; outline: none;
}
.form-color {
  width: 100%; height: 32px; padding: 2px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-input); cursor: pointer;
}
.form-color::-webkit-color-swatch { border-radius: 4px; border: none; }
.form-range {
  width: 100%; -webkit-appearance: none; height: 4px;
  background: var(--bg-input); border-radius: 2px; outline: none;
}
.form-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: var(--accent); cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
}
.range-val { display: inline-block; font-size: 11px; color: var(--accent); margin-left: 8px; }
.form-hint { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* Style Group */
.style-group { padding: 10px; background: var(--bg-input); border-radius: 8px; margin-bottom: 10px; }

/* Help Box */
.help-box {
  font-size: 11px; color: var(--text-dim);
  margin-top: 8px; padding: 10px;
  background: rgba(74, 158, 255, 0.05);
  border-radius: 6px; border-left: 2px solid var(--accent);
  line-height: 1.6;
}
.help-box b { color: var(--accent); }

.coord-help {
  font-size: 11px; color: var(--text-dim);
  margin-top: 8px; padding: 8px;
  background: rgba(74, 158, 255, 0.05);
  border-radius: 6px; border-left: 2px solid var(--accent); line-height: 1.6;
}
.coord-help b { color: var(--accent); }

/* Buttons */
.btn-primary {
  width: 100%; padding: 10px;
  background: var(--accent); color: white; border: none;
  border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.2s; margin-bottom: 8px;
}
.btn-primary:hover:not(:disabled) { background: #5aa8ff; box-shadow: 0 4px 16px var(--accent-glow); }
.btn-primary:disabled { background: var(--border); cursor: not-allowed; opacity: 0.5; }
.btn-secondary {
  width: 100%; padding: 10px;
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border-active); border-radius: 8px;
  font-size: 14px; cursor: pointer; transition: all 0.2s;
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-small {
  padding: 4px 10px; background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px; font-size: 14px; cursor: pointer;
}
.btn-small:hover { background: var(--bg-hover); border-color: var(--border-active); }

.status-msg { margin-top: 8px; font-size: 12px; color: var(--text-dim); text-align: center; }
.status-msg.success { color: var(--success); }
.status-msg.error { color: var(--error); }

/* Map Panel */
.map-panel { flex: 1; display: flex; flex-direction: column; position: relative; }
.map-panel.hidden { display: none; }
.map-toolbar {
  display: flex; gap: 8px; padding: 8px 12px;
  background: var(--bg-panel); backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border); align-items: center;
}
.map-select {
  padding: 5px 10px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 12px; outline: none; cursor: pointer;
}
.map-select option { background: var(--bg-panel-solid); }
.map-input {
  flex: 1; padding: 5px 10px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 12px; outline: none;
}
.map-input:focus { border-color: var(--border-active); }
.map-container { flex: 1; background: var(--bg-dark); z-index: 1; }

/* Leaflet dark overrides */
.leaflet-container { background: var(--bg-dark); }
.leaflet-control-zoom a { background: var(--bg-panel) !important; color: var(--text) !important; border-color: var(--border) !important; }
.leaflet-control-attribution { background: rgba(0,0,0,0.5) !important; color: var(--text-dim) !important; }
.leaflet-control-attribution a { color: var(--accent) !important; }

/* Status Bar */
.status-bar {
  height: 28px; display: flex; align-items: center;
  padding: 0 16px; background: var(--bg-panel);
  border-top: 1px solid var(--border); font-size: 11px; color: var(--text-dim);
}

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); display: flex;
  align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-panel-solid); border: 1px solid var(--border);
  border-radius: 12px; width: 420px; max-width: 90%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; color: var(--text-bright); }
.modal-close { background: none; border: none; font-size: 18px; color: var(--text-dim); cursor: pointer; }
.modal-close:hover { color: var(--text-bright); }
.modal-body { padding: 20px; }
.modal-footer { padding: 0 20px 20px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

.split-config { animation: fadeIn 0.3s ease; }

/* ============================================================
   响应式 / 多端适配 (Responsive · 电脑 / 平板 / 手机)
   ============================================================ */

/* 动态视口高度，规避移动端地址栏导致的 100vh 抖动 */
#app { height: 100dvh; }
body { -webkit-tap-highlight-color: transparent; }

/* 移动端底部导航（默认隐藏，窄屏显示） */
.mobile-nav { display: none; }

/* —— 平板 (≤1024px)：收窄侧栏 —— */
@media (max-width: 1024px) {
  .control-panel { width: 320px; min-width: 320px; }
}

/* —— 手机 / 竖屏平板 (≤768px)：上下切换式布局 —— */
@media (max-width: 768px) {
  .app-header { padding: 0 12px; height: 46px; }
  .app-header h1 { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .main-content { flex-direction: column; position: relative; }

  .control-panel,
  .map-panel {
    width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 auto;
    height: auto;
    border-right: none;
  }
  .control-panel { border-bottom: 1px solid var(--border); }

  /* 一次只显示一个视图，另一个隐藏；显示的保留自身 display */
  body.mv-panel .map-panel { display: none; }
  body.mv-map   .control-panel { display: none; }

  .map-toolbar { flex-wrap: wrap; }

  /* 底部导航栏 */
  .mobile-nav {
    display: flex;
    height: 54px;
    min-height: 54px;
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border);
    z-index: 200;
  }
  .mnav-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
    background: none; border: none; color: var(--text-dim);
    font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
    transition: all 0.2s;
  }
  .mnav-btn.active { color: var(--accent); background: rgba(74,158,255,0.08); box-shadow: inset 0 2px 0 var(--accent); }

  /* 隐藏桌面状态栏，节省竖屏空间 */
  .status-bar { display: none; }

  /* 触摸友好：加大点击目标 & 防止 iOS 聚焦缩放 */
  .form-select, .form-text, .form-number, .map-select, .map-input { font-size: 16px; padding: 9px 12px; }
  .btn-primary, .btn-secondary { padding: 12px; font-size: 15px; }
  .btn-small { padding: 8px 12px; font-size: 14px; }
  .op-tab { padding: 10px; font-size: 14px; }

  /* 弹窗自适应高度 */
  .modal { width: 94vw; max-width: 94vw; max-height: 88vh; display: flex; flex-direction: column; }
  .modal-body { overflow-y: auto; }
}

/* —— 超窄屏 (≤380px) 微调 —— */
@media (max-width: 380px) {
  .panel-section { padding: 12px 14px; }
  .form-row { gap: 8px; }
}

/* ====== SEO/GEO 内容区样式（深色主题协调）====== */
.tool-content {
  max-width: 880px; margin: 0 auto; padding: 32px 24px 48px;
  color: var(--text); line-height: 1.7;
}
.tc-block { margin-bottom: 36px; }
.tc-title {
  font-size: 1.35em; color: var(--text-bright); margin-bottom: 14px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.tool-content p { margin-bottom: 12px; color: var(--text); }
.tool-content strong { color: var(--text-bright); font-weight: 600; }
.tool-content a { color: var(--accent); text-decoration: none; }
.tool-content a:hover { text-decoration: underline; }
.tc-steps { margin: 12px 0 12px 22px; }
.tc-steps li { margin-bottom: 10px; color: var(--text); }
.tc-steps strong { color: var(--accent); }
.tc-related { list-style: none; margin-left: 0; }
.tc-related li { margin-bottom: 8px; padding-left: 18px; position: relative; color: var(--text-dim); }
.tc-related li::before { content: "→"; position: absolute; left: 0; color: var(--accent); }
.tc-related a { color: var(--text); }
.tc-related a:hover { color: var(--accent); }
.tc-faq {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 6px;
  margin-bottom: 10px; padding: 0; overflow: hidden;
}
.tc-faq summary {
  cursor: pointer; padding: 14px 18px; color: var(--text-bright); font-weight: 500;
  list-style: none; display: flex; align-items: center;
}
.tc-faq summary::-webkit-details-marker { display: none; }
.tc-faq summary::before { content: "+"; margin-right: 10px; color: var(--accent); font-weight: 700; }
.tc-faq[open] summary::before { content: "−"; }
.tc-faq summary:hover { background: var(--bg-hover); }
.tc-faq p { padding: 0 18px 16px 32px; color: var(--text); margin: 0; }
@media (max-width: 768px) {
  .tool-content { padding: 24px 16px 36px; }
  .tc-title { font-size: 1.2em; }
}
