:root {
  --bg: #111418;
  --panel: #1b2027;
  --line: #2c333d;
  --text: #f1f3f5;
  --muted: #9aa4b1;
  --accent: #1e90ff;
  --orange: #ff8a00;
  --good: #35e07a;
  --warn: #ffd400;
  --bad: #ff5a5a;
  --tabh: 58px;
  --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%; background: var(--bg); color: var(--text); font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif; font-size: 15px; overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--bad); }

/* はじめの画面 */
.start { position: fixed; inset: 0; z-index: 50; background: radial-gradient(circle at 50% 0%, #22303f, #0e1115 70%); overflow: auto; padding: calc(24px + var(--safe-t)) 16px 24px; }
.start-box { max-width: 520px; margin: 0 auto; }
.start-icon img { width: 72px; height: 72px; border-radius: 18px; }
.start h1 { margin: 10px 0 6px; font-size: 26px; }
.lead { line-height: 1.6; }
.start-list { padding-left: 0; list-style: none; line-height: 1.9; margin: 10px 0 18px; }
.fine { font-size: 12px; color: var(--muted); line-height: 1.6; }
.cta { display: block; width: 100%; background: var(--accent); border: 0; border-radius: 14px; padding: 14px 16px; font-size: 18px; font-weight: 700; color: #fff; }
.cta small { display: block; font-size: 12px; font-weight: 400; opacity: 0.9; margin-top: 2px; }
.cta.small { width: auto; display: inline-block; font-size: 15px; padding: 9px 14px; border-radius: 10px; }
.ghost { display: block; width: 100%; margin-top: 10px; background: transparent; border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; color: var(--text); }
.ghost.small { width: auto; display: inline-block; padding: 8px 12px; border-radius: 10px; margin-top: 0; }

/* 画面の切り替え */
.pane { position: fixed; top: 0; left: 0; right: 0; bottom: calc(var(--tabh) + var(--safe-b)); display: none; }
.pane.active { display: block; }
.pane.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pad { padding: calc(14px + var(--safe-t)) 16px 40px; max-width: 760px; margin: 0 auto; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabh) + var(--safe-b)); padding-bottom: var(--safe-b); display: flex; background: #0c0f12; border-top: 1px solid var(--line); z-index: 20; }
.tabs button { flex: 1; background: none; border: 0; color: var(--muted); font-size: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.tabs button span { font-size: 11px; }
.tabs button.active { color: #fff; }
.tabs button.active span { color: var(--accent); font-weight: 700; }

/* カメラ */
#paneCam { background: #000; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
#ov { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hud { position: absolute; left: 8px; right: 8px; top: calc(36px + var(--safe-t)); background: rgba(0, 0, 0, 0.5); border-radius: 10px; padding: 4px 10px; font-size: 13.5px; pointer-events: none; }
.hud-row { display: flex; gap: 12px; flex-wrap: wrap; }
.hud-row.small { font-size: 11.5px; color: #dfe5ea; margin-top: 1px; column-gap: 8px; }
.hud-row.tiny { font-size: 11px; color: #b9c3cc; margin-top: 1px; }
.camtop { position: absolute; left: 8px; right: 8px; top: calc(4px + var(--safe-t)); display: flex; gap: 6px; }
.chip { background: rgba(20, 24, 30, 0.82); border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 18px; padding: 7px 11px; font-size: 13px; color: #fff; white-space: nowrap; }
.chip small { display: block; font-size: 10px; color: #b9c3cc; }
select.chip { -webkit-appearance: none; appearance: none; }
.cambar { position: absolute; left: 0; right: 0; bottom: 8px; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 0 8px; }
.cb-side { display: flex; flex-direction: column; gap: 6px; flex: 1; align-items: center; min-width: 0; }
.cb-side .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; padding: 7px 9px; }
.shutter { width: 74px; height: 74px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 0; flex: 0 0 auto; }
.shutter span { display: block; width: 58px; height: 58px; margin: 4px auto; border-radius: 50%; background: #fff; transition: transform 0.1s; }
.shutter:active span { transform: scale(0.88); }
.quality { position: absolute; left: 50%; transform: translateX(-50%); bottom: 96px; background: rgba(0, 0, 0, 0.6); border-radius: 14px; padding: 4px 12px; font-size: 13px; white-space: nowrap; pointer-events: none; }
.quality.good { color: var(--good); }
.quality.ok { color: var(--warn); }
.quality.bad { color: var(--bad); }
.planhint { position: absolute; top: 46%; background: rgba(255, 138, 0, 0.9); color: #111; font-weight: 700; border-radius: 10px; padding: 6px 10px; font-size: 13px; pointer-events: none; }
.planhint.left { left: 8px; }
.planhint.right { right: 8px; }
.calpanel { position: absolute; left: 10px; right: 10px; bottom: 110px; background: rgba(20, 10, 40, 0.92); border: 1px solid #b07cff; border-radius: 14px; padding: 12px; font-size: 14px; line-height: 1.6; z-index: 5; }
.calbtns { display: flex; gap: 10px; margin-top: 8px; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.flash.on { opacity: 0.7; transition: none; }

/* 地図 */
#map { position: absolute; inset: 0; background: #222; }
.mapbar { position: absolute; top: calc(8px + var(--safe-t)); left: 8px; right: 52px; display: flex; gap: 6px; flex-wrap: wrap; z-index: 500; }
.maphelp { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 500; background: rgba(0, 0, 0, 0.65); border-radius: 10px; padding: 6px 10px; font-size: 12px; line-height: 1.7; }
.lg { display: block; color: #ccd; }
.lg i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin: 0 3px 0 8px; vertical-align: -1px; }
.lg-plan { background: var(--orange); }
.lg-sg { border: 2px dashed #fff; border-radius: 50% !important; }
.lg-vp { background: #2a7fff; border-radius: 50% !important; }
.lg-me { background: #1e90ff; border: 2px solid #fff; border-radius: 50% !important; }
.vpicon { position: relative; width: 34px; height: 34px; }
.vpicon span { position: absolute; inset: 7px; border-radius: 50%; background: #2a7fff; color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; }
.vpicon.cur span { background: #ff3b7a; }
.vpicon.sg span { background: rgba(255, 255, 255, 0.15); border: 2px dashed #fff; }
.vpar { position: absolute; inset: 0; }
.vpar::before { content: ""; position: absolute; left: 50%; top: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 12px solid #fff; }
.lmicon { font-size: 22px; text-align: center; line-height: 28px; filter: drop-shadow(0 0 2px #000); }
.mapmenu { display: flex; flex-direction: column; gap: 6px; min-width: 220px; }
.mapmenu .mm-t { font-weight: 700; color: #222; }
.mapmenu button { text-align: left; background: #f2f5f8; border: 1px solid #ccd; border-radius: 8px; padding: 8px; color: #111; font-size: 14px; }
.mapmenu button small { display: block; color: #555; font-size: 11px; }
.sheet { position: absolute; left: 8px; right: 8px; bottom: 74px; z-index: 600; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; max-height: 60%; overflow: auto; }
.sheet h3 { margin: 0 0 6px; font-size: 16px; }
.lightbar { display: flex; height: 16px; border-radius: 4px; overflow: hidden; margin: 6px 0 2px; }
.lightbar i { display: block; height: 100%; }
.lk-front { background: #ffd84d; }
.lk-side { background: #8fd16a; }
.lk-back { background: #5b6b80; }
.lk-low { background: #c08a5a; }
.lightlegend { font-size: 11px; color: var(--muted); }
.lightlegend i { display: inline-block; width: 10px; height: 10px; margin: 0 3px 0 8px; vertical-align: -1px; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.row.wrap { flex-wrap: wrap; }

/* 記録 */
h2 { font-size: 20px; margin: 4px 0 8px; }
h3 { font-size: 16px; margin: 18px 0 6px; }
.hint { font-size: 12px; color: #c9d3dc; background: #18324a; border-radius: 8px; padding: 8px 10px; line-height: 1.6; }
.shot { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.shot img { width: 92px; height: 69px; object-fit: cover; border-radius: 6px; background: #222; flex: 0 0 auto; }
.shot .meta { flex: 1; font-size: 13px; line-height: 1.55; min-width: 0; }
.shot .meta b { font-size: 14px; }
.shot input[type="checkbox"] { width: 22px; height: 22px; margin-top: 4px; }
.badge { display: inline-block; font-size: 11px; border-radius: 6px; padding: 0 6px; margin-right: 4px; border: 1px solid currentColor; }
.badge.good { color: var(--good); }
.badge.ok { color: var(--warn); }
.badge.bad { color: var(--bad); }
.daylabel { margin-top: 14px; font-weight: 700; color: var(--muted); font-size: 13px; }

/* 設定 */
.set-sec { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 12px 0; }
.set-sec h3 { margin-top: 0; }
.set-sec label { display: block; margin: 8px 0 4px; font-size: 13px; color: #cfd6dd; }
.set-sec input[type="number"], .set-sec input[type="text"], .set-sec select { width: 100%; background: #0f1317; border: 1px solid var(--line); border-radius: 8px; padding: 9px; }
.set-sec .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.set-sec .three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.set-sec p { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 6px 0; }
.toggle { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 14px; }
.toggle input { width: 22px; height: 22px; }
.plist { margin: 6px 0; }
.plist .pi { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.plist .pi.cur b { color: var(--accent); }
.danger { color: var(--bad); border-color: rgba(255, 90, 90, 0.5) !important; }

/* 使い方 */
.help { line-height: 1.7; }
.steps li { margin: 6px 0; }
.tips { border-collapse: collapse; width: 100%; font-size: 13px; }
.tips th { text-align: left; white-space: nowrap; vertical-align: top; padding: 6px 10px 6px 0; color: #e6ebf0; }
.tips td { padding: 6px 0; border-bottom: 1px solid var(--line); color: #cfd6dd; }

/* 小窓・お知らせ */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); z-index: 60; display: flex; align-items: flex-end; justify-content: center; padding: 10px; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; padding: 14px; padding-bottom: calc(14px + var(--safe-b)); }
.modal-box img { width: 100%; border-radius: 8px; }
.modal-box table { font-size: 12px; width: 100%; border-collapse: collapse; }
.modal-box td { border-bottom: 1px solid var(--line); padding: 4px 6px 4px 0; vertical-align: top; }
.modal-box td:first-child { color: var(--muted); white-space: nowrap; }
.modal-box textarea { width: 100%; min-height: 60px; background: #0f1317; border: 1px solid var(--line); border-radius: 8px; padding: 8px; color: var(--text); }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabh) + var(--safe-b) + 110px); transform: translateX(-50%); background: rgba(10, 12, 15, 0.92); border: 1px solid var(--line); color: #fff; padding: 9px 14px; border-radius: 12px; font-size: 14px; z-index: 70; opacity: 0; transition: opacity 0.3s; pointer-events: none; max-width: 92vw; text-align: center; }
.toast.on { opacity: 1; }

/* 横向き：ボタンを右側に寄せる */
@media (orientation: landscape) and (max-height: 520px) {
  .cambar { left: auto; right: 6px; top: 0; bottom: 0; width: 210px; flex-direction: column; justify-content: center; }
  .cb-side { flex: 0 0 auto; }
  .quality { bottom: 10px; left: 40%; }
  .hud { right: 220px; }
  .calpanel { right: 220px; bottom: 10px; }
}
.leaflet-container { font-family: inherit; }
