/* 藍星海洋潛水俱樂部品牌色 × Apple 式互動（毛玻璃浮動面板、膠囊按鈕、分段控制） */
:root {
  --bg: #1F1F1F;
  --surface: #363636;
  --band: #3F3F3F;
  --blue: #38B6FF;
  --on-blue: #1F1F1F;
  --text: #FFFFFF;
  --text-2: #E6E6E6;
  --muted: #B8B8B8;
  --line: rgba(255, 255, 255, 0.10);
  --red: #FF4D4D;
  --orange: #E8A13A;
  --green: #2FB36B;
  --glass: rgba(31, 31, 31, 0.78);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --font: "Microsoft JhengHei", -apple-system, "SF Pro TC", "PingFang TC", "Noto Sans TC", Arial, sans-serif;
  --font-lat: Arial, -apple-system, "Helvetica Neue", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); }
html { min-height: 100lvh; }
body { -webkit-font-smoothing: antialiased; }
#map { position: fixed; inset: 0; background: #0d2433; }

.glass { background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--line); box-shadow: var(--shadow); }

/* ---------- 面板 ---------- */
#panel { position: fixed; z-index: 1000; left: 16px; top: calc(16px + var(--safe-t)); bottom: 16px; width: 380px;
  border-radius: 22px; display: flex; flex-direction: column; overflow: hidden; transition: transform .35s cubic-bezier(.2,.8,.2,1); }
#panel.collapsed { transform: translateX(calc(-100% - 24px)); }
.grabber { display: none; }
.scroll { flex: 1; overflow-y: auto; padding: 4px 18px 18px; overscroll-behavior: contain; }

.brand { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 18px 12px; }
.brand-title { position: relative; }
.xxx { font-family: var(--font-lat); font-weight: 700; font-size: 13px; letter-spacing: -1px; color: var(--text); opacity: .9; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: .04em; margin: 2px 0 0; line-height: 1.2; }
.rule { width: 44px; height: 4px; border-radius: 2px; background: var(--blue); margin-top: 8px; }
.logo { display: flex; align-items: center; gap: 8px; }
.logo-text { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.logo-text b { font-family: var(--font-lat); font-weight: 400; font-size: 14px; letter-spacing: .06em; }
.logo-text span { font-size: 11px; color: var(--text-2); }
.logo img { width: 46px; height: auto; }

.seg { display: flex; margin: 0 18px 12px; padding: 3px; background: var(--surface); border-radius: 11px; }
.seg button { flex: 1; border: 0; background: none; color: var(--text-2); font: 500 14px var(--font); padding: 7px 0; border-radius: 8px; cursor: pointer; transition: background .2s, color .2s; }
.seg button.active { background: var(--blue); color: var(--on-blue); font-weight: 700; }

.tab { display: none; }
.tab.active { display: block; animation: fade .3s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

h2 { font-size: 20px; font-weight: 800; letter-spacing: .04em; margin: 2px 0 0; line-height: 1.3; }
.eyebrow { font-size: 12px; color: var(--blue); font-weight: 700; letter-spacing: .06em; font-family: var(--font-lat), var(--font); }
.subhead { font-size: 15px; font-weight: 800; letter-spacing: .04em; margin: 20px 0 6px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 6px 0; }
.small { font-size: 12px; }
.credit a { color: var(--blue); }
.live { margin: 12px 0 4px; }
.live-poster { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; border-radius: var(--radius-sm); overflow: hidden; background: var(--band); cursor: pointer; }
.live-poster img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .85; }
.live-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(31,31,31,.85); color: #fff; border-radius: 980px; padding: 8px 16px; font: 500 14px var(--font); white-space: nowrap; }
.live-dot { color: var(--red); }
.live-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.live-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.live .hint a { color: var(--blue); }
.card-tools { display: flex; gap: 6px; flex: none; }
.icon.fav { font-size: 16px; }
.icon.fav.on { background: #F5C542; color: var(--on-blue); }
.row-search { display: flex; gap: 8px; }
.row-search input { flex: 1; min-width: 0; }
.row-search .pill { flex: none; padding: 8px 12px; }
.list .star { color: #F5C542; margin-right: 6px; }
.list li.active .star { color: var(--on-blue); }
.dm-site.fav { border-color: #F5C542; box-shadow: 0 0 0 3px rgba(245,197,66,.45), 0 0 6px rgba(0,0,0,.6); }
.hidden { display: none !important; }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin: 4px 0 14px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card .subhead { margin-top: 14px; }

.search input, .field input, .field textarea { width: 100%; background: var(--band); color: var(--text); border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 12px; font: 15px var(--font); outline: none; transition: border-color .2s; }
.search input:focus, .field input:focus, .field textarea:focus { border-color: var(--blue); }
.search { margin-bottom: 10px; }
.field { display: block; font-size: 13px; color: var(--muted); margin: 10px 0; }
.field input, .field textarea { margin-top: 4px; }

.slider { display: grid; grid-template-columns: 52px 1fr 58px; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 6px 0; }
.slider output { font-family: var(--font-lat); color: var(--text); text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 2px; background: var(--band); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.4); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 2px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 980px; padding: 8px 16px;
  background: var(--band); color: var(--text); font: 500 14px var(--font); cursor: pointer; text-decoration: none; transition: background .2s, transform .1s; }
.pill:hover { background: #4a4a4a; }
.pill:active { transform: scale(.97); }
.pill.primary, .pill.on { background: var(--blue); color: var(--on-blue); font-weight: 700; }
.pill.danger { color: var(--red); }
.pill.wide { width: 100%; margin-top: 10px; padding: 11px; }
.pill:disabled { opacity: .4; pointer-events: none; }
.icon { background: var(--band); border: 0; color: var(--text); width: 30px; height: 30px; border-radius: 50%; font-size: 14px; cursor: pointer; flex: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 15px; }
.list li + li { border-top: 1px solid var(--line); }
.list li:hover { background: var(--surface); }
.list li.active { background: var(--blue); color: var(--on-blue); font-weight: 700; }
.list li.active .km { color: var(--on-blue); }
.list .km { color: var(--muted); font: 13px var(--font-lat); font-variant-numeric: tabular-nums; flex: none; }
.list .placed { color: var(--green); font-size: 12px; flex: none; }
.list li.group { cursor: default; font-size: 12px; font-weight: 700; color: var(--blue); letter-spacing: .06em; padding: 14px 12px 4px; border-top: 0; }
.list li.group:hover { background: none; }
.prec { font-size: 11px; padding: 2px 7px; border-radius: 980px; flex: none; align-self: center; white-space: nowrap; }
.prec-gps, .prec-aligned, .prec-user { background: rgba(47,179,107,.18); color: var(--green); }
.prec-map, .prec-chart { background: rgba(56,182,255,.16); color: var(--blue); }
.prec-desc, .prec-sketch { background: rgba(232,161,58,.16); color: var(--orange); }
.prec-poi { background: rgba(232,161,58,.16); color: var(--orange); }
.prec-area { background: rgba(255,77,77,.16); color: var(--red); }

details.region { background: var(--surface); border-radius: var(--radius); margin: 0 0 10px; overflow: hidden; }
details.region summary { list-style: none; cursor: pointer; padding: 13px 16px; font-weight: 800; letter-spacing: .04em; display: flex; justify-content: space-between; }
details.region summary::-webkit-details-marker { display: none; }
details.region summary .count { color: var(--muted); font: 13px var(--font-lat); font-weight: 400; }
details.region .list { padding: 0 6px 6px; }
details.region .list li { font-size: 14px; padding: 9px 10px; }
.cat-actions { display: flex; gap: 6px; flex: none; }
.cat-actions .pill { padding: 5px 11px; font-size: 12px; }

.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.palette .pill { justify-content: flex-start; border-radius: var(--radius-sm); padding: 10px 12px; }
.swatch { width: 22px; height: 16px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 3px; }
#legend .item { display: flex; align-items: center; gap: 10px; font-size: 13px; margin: 6px 0; color: var(--text-2); }

/* ---------- 地圖上的浮動元素 ---------- */
#crosshair { position: fixed; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; pointer-events: none; z-index: 500; }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: #fff; box-shadow: 0 0 3px rgba(0,0,0,.8); border-radius: 1px; }
#crosshair::before { left: 12px; top: 0; width: 2px; height: 26px; }
#crosshair::after { top: 12px; left: 0; height: 2px; width: 26px; }
#coordBar { position: fixed; z-index: 800; left: calc(50% + 206px); transform: translateX(-50%); bottom: calc(18px + var(--safe-b));
  border-radius: 980px; padding: 5px 6px 5px 16px; font: 13px var(--font-lat); display: flex; align-items: center; gap: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
#fabs { position: fixed; right: 16px; bottom: calc(76px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; z-index: 800; }
.fab { width: 48px; height: 48px; border-radius: 50%; color: var(--text); font-size: 20px; cursor: pointer; }
.fab.on { background: var(--blue); color: var(--on-blue); }
#toast { position: fixed; left: 50%; top: calc(18px + var(--safe-t)); transform: translate(-50%, -8px); border-radius: 980px; padding: 10px 18px; font-size: 14px;
  z-index: 3000; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.sheet { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 24px; }
.sheet-body { width: min(920px, 100%); border-radius: 22px; padding: 18px; }
.sheet iframe { width: 100%; height: min(62vh, 560px); border: 0; border-radius: var(--radius-sm); margin-top: 12px; background: var(--surface); }

/* Leaflet 控制項套品牌色 */
.leaflet-bar, .leaflet-control-layers { border: 1px solid var(--line) !important; border-radius: 14px !important; overflow: hidden; box-shadow: var(--shadow) !important;
  background: var(--glass) !important; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.leaflet-bar a { background: transparent !important; color: var(--text) !important; border-bottom-color: var(--line) !important; width: 36px !important; height: 36px !important; line-height: 36px !important; }
.leaflet-control-layers { color: var(--text); font-family: var(--font); }
.leaflet-control-layers-expanded { padding: 10px 14px; }
.leaflet-control-layers-separator { border-top-color: var(--line); }
.leaflet-control-layers-toggle { filter: invert(1); }
.leaflet-control-scale-line { background: rgba(31,31,31,.7); color: #fff; border-color: #fff; font-family: var(--font-lat); }
.leaflet-control-attribution { background: rgba(31,31,31,.6) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--blue) !important; }
.leaflet-tooltip { font-family: var(--font); }

/* 地圖上的元件 */
.dm-label { background: none; border: 0; white-space: nowrap; font-weight: 700; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; font-size: 13px; font-family: var(--font); }
.dm-depth { color: #0b2a78; }
.dm-bearing { color: #d4141b; font-size: 12px; font-family: var(--font-lat); }
.dm-name { color: #111; }
.dm-arrowhead > div { width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 14px solid #e5161d; transform-origin: 7px 7px; margin: -7px 0 0 -7px; }
.dm-buoy { color: #1740ff; font-size: 26px; font-weight: 900; line-height: 1; text-shadow: 0 0 3px #fff; }
.dm-site { background: var(--blue); border: 2.5px solid #fff; border-radius: 50%; width: 16px; height: 16px; box-shadow: 0 0 6px rgba(0,0,0,.6); margin: -8px 0 0 -8px; }
.dm-site.approx { background: transparent; border-style: dashed; }
.dm-site.area { background: transparent; border-style: dashed; border-color: var(--orange); }
.hide-site-labels .dm-site-label { display: none; }
.dm-site-label { background: rgba(31,31,31,.85); color: #fff; border: 0; border-radius: 980px; padding: 3px 9px; font-size: 12px; box-shadow: none; }
.dm-site-label::before { display: none; }
.dm-handle { width: 22px; height: 22px; border-radius: 50%; background: var(--blue); border: 3px solid #fff; box-shadow: 0 0 6px #000; margin: -11px 0 0 -11px; cursor: move; }
.dm-me { width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26,115,232,.25); }
.dm-overlay { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; user-select: none; max-width: none !important; }

/* ---------- 手機：三段式底部抽屜（收起／半開／全開，可上下拖） ---------- */
@media (max-width: 760px) {
  /* --os：抽屜往螢幕底部外多延伸的長度。iOS 加入主畫面後，視窗高度有時會比實際螢幕短一截，
     fixed bottom:0 的元素底下就露出一條黑底；多延伸一段就一定蓋得到底 */
  :root { --os: 120px; --peek: calc(106px + var(--safe-b)); --half: 50dvh; --map-b: var(--half); }
  body.sheet-peek { --map-b: var(--peek); }
  body.sheet-half, body.sheet-full { --map-b: var(--half); }
  #panel { left: 0; right: 0; top: auto; bottom: calc(-1 * var(--os)); width: auto; height: calc(100dvh - 56px - var(--safe-t) + var(--os));
    border-radius: 22px 22px 0 0; border-bottom: 0; transform: translateY(calc(100% - var(--half) - var(--os)));
    background: rgba(31, 31, 31, 0.94);
    transition: transform .38s cubic-bezier(.2,.9,.25,1); touch-action: none; }
  body.sheet-peek #panel { transform: translateY(calc(100% - var(--peek) - var(--os))); }
  body.sheet-full #panel { transform: translateY(0); }
  #panel.dragging { transition: none; }
  #panel.collapsed { transform: translateY(calc(100% - var(--peek) - var(--os))); }
  .scroll { padding: 4px 14px calc(28px + var(--safe-b) + var(--os)); touch-action: pan-y; }
  .grabber { display: block; width: 38px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.35); margin: 7px auto 0; cursor: grab; }
  /* 品牌列壓成一行，把高度留給地圖 */
  .brand { align-items: center; padding: 6px 16px 8px; }
  .brand-title { display: flex; align-items: baseline; gap: 8px; }
  .xxx { font-size: 11px; }
  h1 { font-size: 19px; margin: 0; }
  .rule { display: none; }
  .logo-text b { font-size: 12px; }
  .logo-text span { font-size: 10px; }
  .logo img { width: 34px; }
  .seg { margin: 0 12px 8px; }
  .seg button { font-size: 13px; padding: 7px 0; }
  #map { bottom: calc(var(--map-b) - 22px); transition: bottom .38s; }
  #crosshair { top: calc((100dvh - var(--map-b) + 22px) / 2); }
  #coordBar { left: 50%; bottom: auto; top: calc(8px + var(--safe-t)); font-size: 11px; }
  #fabs { bottom: calc(var(--map-b) + 10px); transition: bottom .38s; }
  body.sheet-full #fabs { opacity: 0; pointer-events: none; }
  .leaflet-top.leaflet-left, .leaflet-top.leaflet-right { top: calc(44px + var(--safe-t)); }
  .sheet { padding: 0; align-items: flex-end; }
  .sheet-body { border-radius: 22px 22px 0 0; padding-bottom: calc(18px + var(--safe-b)); max-height: calc(100dvh - var(--safe-t) - 20px); overflow-y: auto; }
  .sheet iframe { height: 58dvh; }
}
@media (min-width: 761px) {
  .leaflet-top.leaflet-left { left: 412px; transition: left .35s; }
  body.panel-collapsed .leaflet-top.leaflet-left { left: 0; }
  body.panel-collapsed #coordBar { left: 50%; }
}
