/* 版面：左側已選宗地｜中間地圖｜右側工具欄；手機改為上下堆疊。
   深色科技風：深藍黑底、青色（cyan）為操作與選取色，地籍界線用珊瑚橘紅。 */
:root {
  --paper: #070b10;       /* 頁面底色 */
  --panel: #0d131a;       /* 面板 */
  --panel-2: #121a23;     /* 輸入框、卡片 */
  --ink: #e6edf3;
  --muted: #8796a5;
  --line: #1e2a36;
  --line-2: #2a3a4a;
  --cad: #ff7a59;         /* 地籍界線 */
  --sel: #22d3ee;         /* 選取、操作 */
  --sel-2: #0ea5e9;
  --sel-soft: rgba(34, 211, 238, 0.12);
  --glow: 0 0 0 1px rgba(34, 211, 238, 0.35), 0 0 18px rgba(34, 211, 238, 0.18);
  --warn: #fbbf24;
  --f-body: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --panel-w: 368px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--ink);
  background: radial-gradient(1200px 600px at 70% -10%, rgba(14, 165, 233, 0.10), transparent 60%), var(--paper);
  font: 14px/1.55 var(--f-body);
  display: flex; flex-direction: column;
}
h1, h2 { margin: 0; text-wrap: balance; }
code { font-family: var(--f-num); font-size: 0.92em; background: var(--sel-soft); color: var(--sel); padding: 0 4px; border-radius: 3px; }
::selection { background: rgba(34, 211, 238, 0.35); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* ---------- 頁首 ---------- */
.bar {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: linear-gradient(180deg, #0f1720, var(--panel));
  border-bottom: 1px solid var(--line);
}
.bar::after {                         /* 底部發光細線 */
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--sel) 30%, var(--sel-2) 70%, transparent);
  opacity: 0.7;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { flex: none; display: block; filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.45)); }
.brand-en { font-family: var(--f-num); font-weight: 700; color: var(--sel); letter-spacing: 0.02em; text-shadow: 0 0 12px rgba(34, 211, 238, 0.4); }
.brand-dash { margin: 0 4px; color: var(--muted); font-weight: 400; }
h1 { font-size: 17px; font-weight: 700; letter-spacing: 0.06em; }
.brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.meta { margin: 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meta .sep { margin: 0 6px; color: var(--line-2); }
.meta.notice { color: var(--warn); }
.meta.notice a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.meta.notice .big-link {
  font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--cad);
  text-underline-offset: 3px; text-decoration-thickness: 1.5px; margin: 0 2px; white-space: nowrap;
}
.meta.notice .big-link:hover { color: var(--sel); }
.meta a { color: var(--sel); text-decoration: none; }
.meta a:hover { text-decoration: underline; }
.meta a:focus-visible { outline: 2px solid var(--sel); outline-offset: 1px; border-radius: 2px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font: 12px var(--f-body); color: var(--muted); border: 1px solid var(--line-2); border-radius: 999px; padding: 2px 10px;
  background: rgba(255, 255, 255, 0.02);
}
.chip-demo { color: var(--sel); border-color: rgba(34, 211, 238, 0.45); background: var(--sel-soft); }

/* ---------- 三欄 ---------- */
.app { --list-w: clamp(240px, 19vw, 320px); flex: 1; min-height: 0; display: grid; grid-template-columns: var(--list-w) minmax(0, 1fr) var(--panel-w); }
/* 地圖寬度貼齊左右兩欄、靠上，高度 70%；下方留白日後可放廣告。高度比例改 --map-scale 即可 */
.mapwrap {
  --map-scale: 0.7; position: relative; min-height: 0; display: grid; place-items: start stretch;
  background-image:                   /* 空白處的藍圖格線 */
    linear-gradient(rgba(34, 211, 238, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
}
.mapframe {
  position: relative; width: 100%;
  height: calc(100% * var(--map-scale));
  border-bottom: 1px solid var(--line-2); overflow: hidden; background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.mapframe::after {                    /* 四角定位框 */
  content: ""; position: absolute; inset: 8px; z-index: 450; pointer-events: none;
  --c: rgba(34, 211, 238, 0.7);
  background:
    linear-gradient(var(--c), var(--c)) top left / 16px 1.5px, linear-gradient(var(--c), var(--c)) top left / 1.5px 16px,
    linear-gradient(var(--c), var(--c)) top right / 16px 1.5px, linear-gradient(var(--c), var(--c)) top right / 1.5px 16px,
    linear-gradient(var(--c), var(--c)) bottom left / 16px 1.5px, linear-gradient(var(--c), var(--c)) bottom left / 1.5px 16px,
    linear-gradient(var(--c), var(--c)) bottom right / 16px 1.5px, linear-gradient(var(--c), var(--c)) bottom right / 1.5px 16px;
  background-repeat: no-repeat;
}
#map { position: absolute; inset: 0; background: #0a1016; }
/* 地圖下方的空拍機互動區 */
.dronezone {
  position: absolute; left: 0; right: 0; bottom: 0; top: calc(100% * var(--map-scale)); overflow: hidden;
  background: radial-gradient(60% 90% at 50% 50%, rgba(34, 211, 238, 0.06), transparent 70%);
}
.dronezone.on { cursor: none; }
.dronezone canvas { position: absolute; inset: 0; display: block; }
/* 右上角按鈕列：開燈／關燈、起飛／降落 */
.dz-ctrls { position: absolute; top: 10px; right: 12px; z-index: 3; display: flex; gap: 6px; }
.dz-toggle {
  position: relative; z-index: 2; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 11.5px/1 var(--f-body); letter-spacing: 0.12em; color: var(--muted);
  background: rgba(10, 16, 22, 0.8); border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 11px;
  backdrop-filter: blur(4px);
}
.dz-toggle b { color: var(--muted); font-weight: 700; }
.dz-toggle .dz-dot { width: 8px; height: 8px; border-radius: 50%; background: #3a4654; }
.dronezone.on .dz-toggle { border-color: rgba(34, 211, 238, 0.6); color: var(--ink); box-shadow: 0 0 12px rgba(34, 211, 238, 0.2); }
.dronezone.on .dz-toggle b { color: var(--sel); }
.dronezone.on .dz-dot { background: var(--sel); box-shadow: 0 0 8px var(--sel); animation: dzpulse 1.6s ease-in-out infinite; }
.dz-toggle:hover { border-color: var(--sel); }
.dronezone.on .dz-toggle { cursor: pointer; }
@keyframes dzpulse { 50% { opacity: 0.35; } }
/* 時鐘：在互動開關下方，半透明融入背景，空拍機可從前面飛過 */
.dz-clock {
  position: absolute; top: 44px; right: 14px; z-index: 0; pointer-events: none; text-align: right;
  font-family: var(--f-num); font-variant-numeric: tabular-nums; color: rgba(165, 243, 252, 0.34);
  user-select: none;
}
.dz-date { font-size: 12px; letter-spacing: 0.22em; color: rgba(135, 150, 165, 0.6); }
.dz-wd { margin-left: 8px; letter-spacing: 0.1em; color: rgba(34, 211, 238, 0.5); }
.dz-time {
  font-size: clamp(28px, 3.4vw, 44px); font-weight: 400; line-height: 1.05; letter-spacing: 0.06em;
  text-shadow: 0 0 18px rgba(34, 211, 238, 0.18);
}
.dz-time .c { opacity: 0.45; animation: ckblink 1s steps(1) infinite; }
@keyframes ckblink { 50% { opacity: 0.12; } }
.dz-sec { margin-top: 5px; margin-left: auto; width: 100%; height: 1.5px; background: rgba(34, 211, 238, 0.10); overflow: hidden; }
.dz-sec i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.65)); }
.dronezone canvas { z-index: 1; }
.dz-toggle { z-index: 3; }
/* 開燈按鈕：燈亮時圓點是暖黃色 */
.dz-light .dz-dot { background: #3a4654; }
.dz-light.on { border-color: rgba(251, 191, 36, 0.7) !important; box-shadow: 0 0 12px rgba(251, 191, 36, 0.25) !important; color: var(--ink) !important; }
.dz-light.on b { color: #fbbf24 !important; }
.dz-light.on .dz-dot { background: #fbbf24 !important; box-shadow: 0 0 8px #fbbf24 !important; animation: none !important; }
.dronezone .dz-light:not(.on) .dz-dot { background: #3a4654; box-shadow: none; animation: none; }
.dronezone.on .dz-light:not(.on) { border-color: var(--line-2); box-shadow: none; color: var(--muted); }
.dronezone.on .dz-light:not(.on) b { color: var(--muted); }
.dz-hud { z-index: 2; }
/* 贊助廠商：平常半透明融入背景；空拍機飛近時亮起；關閉互動時亮起並可點擊（互動中不能點，避免誤觸） */
.dz-sponsor {
  position: absolute; top: 10px; left: 14px; z-index: 3;
  font: 600 11.5px/1 var(--f-num); letter-spacing: 0.08em; color: rgba(135, 150, 165, 0.42);
  text-decoration: none; padding: 7px 0; pointer-events: none; cursor: default;
  transition: color .45s ease, text-shadow .45s ease;
}
.dz-sponsor.lit { color: #e6fbff; text-shadow: 0 0 8px rgba(34, 211, 238, 0.9), 0 0 18px rgba(34, 211, 238, 0.5); }
.dronezone:not(.on) .dz-sponsor {
  pointer-events: auto; cursor: pointer; color: #e6fbff;
  text-shadow: 0 0 8px rgba(34, 211, 238, 0.85), 0 0 18px rgba(34, 211, 238, 0.45);
  text-decoration: underline; text-decoration-color: rgba(34, 211, 238, 0.6); text-underline-offset: 4px;
}
.dronezone:not(.on) .dz-sponsor:hover { color: var(--sel); }
.dronezone:not(.on) .dz-sponsor:focus-visible { outline: 2px solid var(--sel); outline-offset: 3px; border-radius: 2px; }
/* 白天（藍天）時：時鐘、贊助文字、儀表改深色，維持可讀 */
.dronezone.day .dz-clock { color: rgba(12, 46, 82, 0.5); }
.dronezone.day .dz-time { text-shadow: 0 0 14px rgba(255, 255, 255, 0.35); }
.dronezone.day .dz-date { color: rgba(12, 46, 82, 0.6); }
.dronezone.day .dz-wd { color: rgba(12, 70, 120, 0.7); }
.dronezone.day .dz-sec { background: rgba(12, 46, 82, 0.15); }
.dronezone.day .dz-sec i { background: linear-gradient(90deg, transparent, rgba(12, 70, 120, 0.7)); }
.dronezone.day.on .dz-sponsor:not(.lit) { color: rgba(12, 46, 82, 0.55); }
.dronezone.day .dz-hud { color: rgba(12, 40, 70, 0.75); }
.dz-hud {
  position: absolute; left: 14px; bottom: 10px; z-index: 1; pointer-events: none;
  font: 500 10.5px/1 var(--f-num); letter-spacing: 0.1em; color: rgba(135, 150, 165, 0.75);
}
/* 游標：箭頭工具＝一般箭頭（宗地上為手指）、手工具＝抓取、框選＝十字 */
#map.tool-select { cursor: default; }
#map.tool-pan .leaflet-interactive { cursor: grab; }
#map.tool-pan.leaflet-drag-target, #map.tool-pan.leaflet-drag-target .leaflet-interactive { cursor: grabbing; }
#map.boxmode, #map.boxmode .leaflet-interactive { cursor: crosshair !important; }
#map.midpan, #map.midpan .leaflet-interactive { cursor: move !important; }
/* 地圖工具（箭頭／手），在＋－下面 */
.maptools a { display: grid !important; place-items: center; width: 30px; height: 30px; }
.maptools a svg { display: block; }
.maptools a.on { background: linear-gradient(135deg, var(--sel), var(--sel-2)) !important; color: #04121a !important; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.maptools a.flash { animation: toolflash 1s ease 2; }
@keyframes toolflash { 50% { box-shadow: 0 0 0 3px rgba(34, 211, 238, .8), 0 0 18px rgba(34, 211, 238, .8); } }
.boxrect { pointer-events: none; }
/* 通用電子地圖深色版：反轉色調，讓地籍線與選取更清楚 */
.tiles-dark { filter: invert(1) hue-rotate(180deg) brightness(0.82) contrast(0.92) saturate(0.55); }
.status {
  position: absolute; left: 12px; bottom: 24px; z-index: 500; max-width: calc(100% - 24px);
  background: rgba(10, 16, 22, 0.82); color: var(--ink); border: 1px solid var(--line-2); border-left: 2px solid var(--sel);
  border-radius: 4px; padding: 4px 10px; font-size: 13px; pointer-events: none;
  font-variant-numeric: tabular-nums; backdrop-filter: blur(6px);
}

/* ---------- 面板 ---------- */
.panel {
  min-width: 0; min-height: 0; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.panel.left { border-left: 0; border-right: 1px solid var(--line); overflow: hidden; }
/* 左欄：上方已選宗地可捲動，下方固定約 20% 高的使用說明 */
.panel.left .sel-block { flex: 1 1 auto; min-height: 0; overflow-y: auto; border-bottom: 0; }
.guide {
  flex: 0 0 auto; gap: 8px; padding-block: 12px 14px;   /* 高度依內容，約佔左欄 20% */
  border-top: 1px solid var(--line-2); border-bottom: 0;
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.06), rgba(34, 211, 238, 0.015));
}
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; counter-reset: st; }
.steps li {
  counter-increment: st; display: grid; grid-template-columns: 20px minmax(0, 1fr); column-gap: 9px; align-items: start;
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
}
.steps li::before {
  content: counter(st); width: 20px; height: 20px; margin-top: 0; border-radius: 50%;
  display: grid; place-items: center; font: 700 11.5px/1 var(--f-num); color: #04121a;
  background: linear-gradient(135deg, var(--sel), var(--sel-2)); box-shadow: 0 0 10px rgba(34, 211, 238, 0.35);
}
.steps b { color: var(--ink); font-weight: 700; margin-right: 6px; }
.block { padding: 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.block.grow { flex: 1 0 auto; }
h2 {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--ink); letter-spacing: 0.12em;
}
h2::before { content: ""; width: 3px; height: 13px; background: var(--sel); border-radius: 2px; box-shadow: 0 0 8px var(--sel); }
.selhead h2 { display: flex; }

.layerblock { padding-block: 14px; gap: 10px; }
.bigtoggle {
  display: flex; align-items: center; gap: 14px; cursor: pointer; user-select: none;
  padding: 14px 16px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel-2);
  transition: border-color .15s, box-shadow .15s;
}
.bigtoggle:hover { border-color: rgba(34, 211, 238, 0.5); }
.bigtoggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.bigtoggle .sw {
  flex: none; position: relative; width: 56px; height: 30px; border-radius: 999px;
  background: #1b2633; border: 1px solid var(--line-2); transition: background .15s;
}
.bigtoggle .sw::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #cfd8e1; box-shadow: 0 1px 3px rgba(0,0,0,.5); transition: transform .15s;
}
.bigtoggle .bt-text { font-size: 20px; font-weight: 700; letter-spacing: 0.06em; color: var(--ink); }
.bigtoggle input:checked ~ .sw { background: linear-gradient(90deg, var(--sel-2), var(--sel)); border-color: var(--sel); }
.bigtoggle input:checked ~ .sw::after { transform: translateX(26px); background: #fff; }
.bigtoggle:has(input:checked) { border-color: var(--sel); box-shadow: var(--glow); }
.bigtoggle:has(input:checked) .bt-text { color: #fff; }
.bigtoggle:has(input:focus-visible) { outline: 2px solid var(--sel); outline-offset: 2px; }
.bigtoggle.small { padding: 10px 16px; }
.bigtoggle.small .bt-text { font-size: 16px; }
.bigtoggle.small .sw { width: 46px; height: 26px; }
.bigtoggle.small .sw::after { width: 18px; height: 18px; }
.bigtoggle.small input:checked ~ .sw::after { transform: translateX(20px); }

.legend {
  background: rgba(10, 16, 22, 0.9); color: var(--ink); border: 1px solid var(--line-2); border-radius: 6px;
  padding: 8px 10px; font-size: 12px; line-height: 1.5; display: grid; gap: 2px; max-width: 200px; backdrop-filter: blur(6px);
}
.legend b { font-size: 12.5px; margin-bottom: 2px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 10px; border-radius: 2px; flex: none; opacity: 0.85; }
.legend i.none { background: none; border: 1px dashed var(--muted); }
.legend small { color: var(--muted); margin-top: 4px; }

/* ---------- 表單、按鈕 ---------- */
.qform { display: grid; grid-template-columns: 3.2em minmax(0, 1fr); gap: 8px; align-items: center; }
.qform label { font-size: 13px; color: var(--muted); }
.qform .btn { grid-column: 2; }
.qform .full { grid-column: 2; }
.combo { position: relative; min-width: 0; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 1000; margin: 0; padding: 4px 0; list-style: none;
  max-height: 280px; overflow-y: auto; background: #0f1720; border: 1px solid var(--line-2); border-radius: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
}
.combo-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 6px 10px; cursor: pointer; }
.combo-list li small { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.combo-list li.active, .combo-list li:hover { background: var(--sel-soft); }
.combo-list li mark { background: none; color: var(--sel); font-weight: 700; }
.combo-list .empty { color: var(--muted); cursor: default; }
.combo-list .empty:hover { background: none; }
input[type="text"]#secq { font-family: var(--f-body); }
select, input[type="text"] {
  width: 100%; min-width: 0; font: inherit; color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: 5px; padding: 7px 9px;
  transition: border-color .15s, box-shadow .15s;
}
select option, select optgroup { background: #0f1720; color: var(--ink); }
input[type="text"]::placeholder { color: #5d6b79; }
input[type="text"] { font-family: var(--f-num); }
select:focus-visible, input:focus-visible { outline: none; border-color: var(--sel); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18); }
.btn:focus-visible, .link:focus-visible, .x:focus-visible { outline: 2px solid var(--sel); outline-offset: 1px; }
.btn {
  font: inherit; font-weight: 500; cursor: pointer; border-radius: 5px; padding: 8px 12px;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-2);
  transition: border-color .15s, color .15s, box-shadow .15s, filter .15s;
}
.btn:hover:not(:disabled) { border-color: var(--sel); color: var(--sel); box-shadow: 0 0 12px rgba(34, 211, 238, 0.15); }
.btn.primary {
  background: linear-gradient(135deg, var(--sel), var(--sel-2)); border-color: transparent; color: #04121a; font-weight: 700;
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.25);
}
.btn.primary:hover:not(:disabled) { color: #04121a; filter: brightness(1.1); box-shadow: 0 0 22px rgba(34, 211, 238, 0.4); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.link { font: inherit; font-size: 13px; background: none; border: 0; color: var(--sel); cursor: pointer; padding: 2px 4px; }
.link:disabled { color: var(--muted); opacity: 0.5; cursor: default; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.msg { margin: 0; font-size: 13px; min-height: 1.2em; }
.msg.err { color: var(--cad); }
.msg.ok { color: var(--sel); }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.modes .mode { border-radius: 0; }
.modes .mode:first-child { border-radius: 5px 0 0 5px; }
.modes .mode:last-child { border-radius: 0 5px 5px 0; margin-left: -1px; }
.modes .mode.on {
  background: linear-gradient(135deg, var(--sel), var(--sel-2)); border-color: transparent; color: #04121a; font-weight: 700;
  position: relative; z-index: 1; box-shadow: 0 0 14px rgba(34, 211, 238, 0.3);
}
.modes .mode.on:hover { color: #04121a; }
.upload { text-align: center; display: block; border-style: dashed; }
.upload:hover { border-color: var(--sel); color: var(--sel); }
.upload.busy { opacity: 0.6; pointer-events: none; }

/* ---------- 已選宗地 ---------- */
.selhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.count { font-family: var(--f-num); color: var(--sel); font-weight: 500; margin-left: 4px; letter-spacing: 0; text-shadow: 0 0 10px rgba(34, 211, 238, 0.5); }
.sum { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); }
.sum b { color: var(--ink); font-family: var(--f-num); font-weight: 500; }
.sellist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.sellist li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 7px 6px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; border-radius: 4px;
}
.sellist li:hover { background: rgba(255, 255, 255, 0.025); }
.sellist .nm { min-width: 0; overflow-wrap: anywhere; cursor: pointer; }
.sellist .nm:hover { color: var(--sel); }
.sellist .no { font-family: var(--f-num); color: var(--sel); }
.sellist .ar { font-family: var(--f-num); font-size: 12.5px; color: var(--muted); text-align: right; }
.sellist .zn { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); line-height: 1.45; margin-top: -2px; }
.x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 3px; }
.x:hover { color: var(--cad); background: rgba(255, 122, 89, 0.12); }

.dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dl .hint, .dl .dlmsg { grid-column: 1 / -1; }
.dl .dlmsg:empty { display: none; }
.src { padding: 14px 16px 18px; font-size: 12px; color: var(--muted); }

/* ---------- 警告視窗 ---------- */
.warn {
  width: min(420px, calc(100vw - 32px)); padding: 20px 22px 18px; border: 1px solid var(--line-2); border-top: 3px solid var(--cad);
  border-radius: 8px; background: #0f1720; color: var(--ink); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 122, 89, 0.12);
}
.warn::backdrop { background: rgba(2, 6, 10, 0.65); backdrop-filter: blur(2px); }
.warn h3 { margin: 0 0 8px; font-size: 17px; color: var(--cad); }
.warn h3::before { content: "⚠ "; }
.warn p { margin: 0 0 16px; font-size: 14.5px; line-height: 1.6; }
.warn-act { display: flex; justify-content: flex-end; }

/* ---------- 地圖上的元件 ---------- */
.lotno {
  font: 500 11px/1 var(--f-num); color: #ffb39f; white-space: nowrap; text-align: center;
  text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 4px #000;
  pointer-events: none;
}
.lotno.on { color: #a5f3fc; font-weight: 700; text-shadow: 0 0 3px #000, 0 0 8px rgba(34, 211, 238, 0.8); }
.leaflet-container { font-family: var(--f-body); background: #0a1016; }
.leaflet-bar { border: 1px solid var(--line-2) !important; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45) !important; }
.leaflet-bar a { background: rgba(13, 19, 26, 0.92); color: var(--ink); border-bottom-color: var(--line-2); }
.leaflet-bar a:hover { background: #16212c; color: var(--sel); }
.leaflet-bar a.leaflet-disabled { background: #0d131a; color: #46525e; }
.leaflet-control-layers {
  background: rgba(13, 19, 26, 0.94) !important; color: var(--ink); border: 1px solid var(--line-2) !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45) !important;
}
/* 底圖切換按鈕：放大、青色外框，下方標「底圖」 */
.leaflet-control-layers { border-radius: 6px !important; }
.leaflet-control-layers:not(.leaflet-control-layers-expanded) {
  border: 1px solid rgba(34, 211, 238, 0.7) !important;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.15), 0 0 16px rgba(34, 211, 238, 0.28), 0 4px 14px rgba(0, 0, 0, 0.45) !important;
}
.leaflet-control-layers-toggle {
  position: relative; width: 44px !important; height: 50px !important;
  background-size: 22px 22px !important; background-position: center 7px !important;
  filter: none; background-color: transparent;
}
.leaflet-control-layers-toggle::before {               /* 把深色圖示反白 */
  content: ""; position: absolute; inset: 0; background: inherit; filter: invert(1) brightness(1.5); pointer-events: none;
}
.leaflet-control-layers-toggle span {
  position: absolute; left: 0; right: 0; bottom: 5px; text-align: center;
  font: 700 11px/1 var(--f-body); color: var(--sel); letter-spacing: 0.08em;
}
.leaflet-control-layers-toggle:hover span { color: #fff; }
.leaflet-control-layers-expanded { padding: 8px 12px 8px 10px !important; }
.leaflet-control-layers-expanded::before { content: "底圖"; display: block; font: 700 12px var(--f-body); color: var(--sel); letter-spacing: .1em; margin-bottom: 4px; }
.leaflet-control-layers-base label { padding: 2px 0; cursor: pointer; }
.leaflet-control-layers-base input { accent-color: var(--sel); }
.leaflet-control-layers-separator { border-top-color: var(--line-2); }
.leaflet-control-attribution { background: rgba(7, 11, 16, 0.75) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--sel) !important; }
.leaflet-control-scale-line { background: rgba(7, 11, 16, 0.7); color: var(--ink); border-color: var(--muted); }

@media (max-width: 760px) {
  body { height: auto; min-height: 100%; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .mapwrap { height: 56vh; --map-scale: 1; order: 1; }
  .mapframe { width: 100%; height: 100%; }
  .dronezone { display: none; }
  .panel.right { order: 2; }
  .panel.left { order: 3; }
  .panel.left { border-right: 0; border-top: 1px solid var(--line); overflow: visible; }
  .panel.left .sel-block { overflow: visible; }
  .guide { flex: none; min-height: 0; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .block, .src { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
