* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* ============================================================
   スキン（テーマ）トークン
   新しいスキンを追加するには body[data-skin="名前"] ブロックを
   追加して、js/app.js の SKINS 配列と index.html のラジオに登録する
   ============================================================ */
:root {
  /* helm: マリン計器盤（標準） */
  --c-bar-bg: #0B2740;
  --c-bar-line: rgba(255, 255, 255, .14);
  --c-bar-text: #F2F7FB;
  --c-accent: #FF6B35;          /* 記録・自船・警報系のシグナル色 */
  --c-primary: #0E63B8;         /* アクティブ・リンク・見出し */
  --c-bg: #FFFFFF;
  --c-text: #16222E;
  --c-sub: #5B6B7A;
  --c-line: #D9E2EA;
  --c-card: #F4F8FB;
  --c-card-line: #DCE7F0;
  --c-toolbar-bg: #FFFFFF;
  --c-toolbar-text: #3A4A58;
  --font-num: "Chakra Petch", "Yu Gothic UI", sans-serif;
  --font-ui: "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
  --radius: 12px;
  --radius-lg: 16px;
  --glow: none;
}
body[data-skin="sakura"] {
  --c-bar-bg: #FF9FBE;
  --c-bar-line: rgba(255, 255, 255, .4);
  --c-bar-text: #FFFFFF;
  --c-accent: #FF4F8B;
  --c-primary: #2FA8E0;
  --c-bg: #FFF7FA;
  --c-text: #4A3540;
  --c-sub: #9A7A88;
  --c-line: #F3D9E3;
  --c-card: #FFF0F5;
  --c-card-line: #F5D4E1;
  --c-toolbar-bg: #FFFFFF;
  --c-toolbar-text: #C97D9C;
  --font-num: "M PLUS Rounded 1c", "Yu Gothic UI", sans-serif;
  --radius: 18px;
  --radius-lg: 22px;
}
body[data-skin="neon"] {
  --c-bar-bg: #0D1026;
  --c-bar-line: rgba(94, 234, 255, .2);
  --c-bar-text: #E8F4FF;
  --c-accent: #FF3D81;
  --c-primary: #23D5F0;
  --c-bg: #151A33;
  --c-text: #E8F0FF;
  --c-sub: #8FA0C8;
  --c-line: #2A3155;
  --c-card: #1C2240;
  --c-card-line: #323C6B;
  --c-toolbar-bg: #0D1026;
  --c-toolbar-text: #8FA0C8;
  --glow: 0 0 10px rgba(35, 213, 240, .55);
}

html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--font-ui);
  background: var(--c-bg); color: var(--c-text);
  display: flex; flex-direction: column;
}

/* ===== 上部：計器バー ===== */
#topbar {
  display: flex; align-items: stretch;
  padding: 0 8px;
  padding-top: env(safe-area-inset-top);
  background: var(--c-bar-bg); color: var(--c-bar-text);
  z-index: 1200; flex: 0 0 auto;
}
/* モード表示: 地図右下・文字のみ（枠なし）。既定は実行モードでメニューからのみ切替 */
#modeBadge {
  position: absolute; z-index: 1100; cursor: pointer;
  right: 10px; bottom: calc(88px + env(safe-area-inset-bottom));
  font-size: 13px; font-weight: bold; white-space: nowrap;
  text-shadow: 0 0 3px #ffffff, 0 0 3px #ffffff, 0 0 2px #ffffff;
}
.mode-test { color: #B85C00; }
.mode-live { color: #1E7A34; }
.inst {
  display: flex; flex-direction: column; justify-content: center;
  padding: 5px 12px 6px;
  border-left: 1px solid var(--c-bar-line);
}
#instSpeed { flex: 1; min-width: 0; }
#instHdg { flex-direction: row; align-items: center; gap: 7px; }
#instHdg .hdg-txt { display: flex; flex-direction: column; justify-content: center; }
#cogDial { width: 40px; height: 40px; flex: 0 0 auto; display: block; }
#cogNeedle { transform-origin: center; transform-box: fill-box; transition: transform .25s linear; }
.inst-label {
  font-size: 9px; font-weight: 700; letter-spacing: .14em;
  opacity: .65; text-transform: uppercase; white-space: nowrap;
}
.inst-label small { font-size: 9px; letter-spacing: 0; font-weight: normal; }
.inst-value { line-height: 1; display: flex; align-items: baseline; gap: 3px; }
.inst-value b {
  font-family: var(--font-num);
  font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums;
  text-shadow: var(--glow);
}
.inst-value i { font-style: normal; font-size: 12px; opacity: .75; }
.inst-sub { font-size: 10px; opacity: .7; white-space: nowrap; }
#gpsStat {
  align-self: center; margin-left: auto; padding-left: 10px;
  font-size: 10px; text-align: right; opacity: .85; white-space: pre-line;
}

/* ===== 地図 ===== */
#map { flex: 1 1 auto; width: 100%; background: #c8e0f0; }

/* 船上のスマホ操作向けにズームボタンを標準の倍サイズにする（タッチ判定含む） */
.leaflet-control-zoom a,
.leaflet-touch .leaflet-control-zoom a {
  width: 60px; height: 60px; line-height: 60px; font-size: 30px;
}

/* 縮尺バー（Googleマップ風に大きく・読みやすく。スキン非依存の固定色） */
.leaflet-control-scale { margin-bottom: 36px !important; margin-left: 10px !important; }
.leaflet-control-scale-line {
  font-size: 13px; font-weight: bold; color: #16222E;
  background: rgba(255, 255, 255, .75);
  border: 2px solid #16222E; border-top: none;
  padding: 2px 6px 1px; line-height: 1.3;
  text-shadow: 0 0 2px #ffffff;
  box-sizing: content-box;
}
.boat-icon { pointer-events: none; }
.boat-icon svg { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.boat-icon polygon { fill: var(--c-accent); }
.catch-icon { font-size: 22px; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.anchor-icon { font-size: 24px; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.depth-label {
  font-size: 11px; font-weight: bold; color: #0b3d66; text-align: center;
  text-shadow: 0 0 3px #ffffff, 0 0 3px #ffffff, 0 0 3px #ffffff;
  pointer-events: none; white-space: nowrap;
}
.depth-label-enc { font-size: 12px; color: #0D3A5C; }
.sediment-label {
  /* kk要望(2026-07-19): 底質は水深数字(12px)の2/3の大きさに抑える */
  color: #17212b; font-size: 8px; font-weight: 800; text-align: center;
  text-shadow: 0 0 3px #ffffff, 0 0 3px #ffffff, 0 0 2px #ffffff;
  white-space: nowrap;
}
.structure-label {
  color: #263440; font-size: 11px; font-weight: 800; font-style: italic; text-align: center;
  text-shadow: 0 0 3px #ffffff, 0 0 3px #ffffff, 0 0 2px #ffffff;
  white-space: nowrap;
}
.track-start-icon {
  color: #ff5a1f; font-size: 16px; line-height: 18px; text-align: center;
  text-shadow: 0 0 3px #ffffff, 0 0 3px #ffffff, 0 0 2px #ffffff;
  pointer-events: none;
}

/* ===== 下部ツールバー ===== */
#toolbar {
  flex: 0 0 auto; display: flex; z-index: 1200;
  background: var(--c-toolbar-bg); border-top: 1px solid var(--c-line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tb {
  flex: 1; border: none; background: transparent; color: var(--c-toolbar-text);
  font-family: var(--font-ui);
  font-size: 10px; padding: 7px 0 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tb svg.ic { width: 22px; height: 22px; display: block; }
.tb:active { opacity: .55; }
.tb.on { color: var(--c-primary); font-weight: bold; }
body[data-skin="neon"] .tb.on svg.ic { filter: drop-shadow(0 0 6px rgba(35,213,240,.7)); }
/* ===== アンカー警報バナー（安全色はスキンに依らず固定） ===== */
#anchorBanner {
  position: absolute; top: calc(64px + env(safe-area-inset-top)); left: 8px; right: 8px; z-index: 1300;
  background: #d32f2f; color: #ffffff; font-weight: bold; font-size: 14px;
  padding: 10px 12px; border-radius: var(--radius); box-shadow: 0 2px 8px rgba(0,0,0,.5);
  animation: alarmflash .8s infinite;
}
@keyframes alarmflash { 50% { background: #ff6f00; } }
.banner-btns { display: flex; gap: 8px; margin-top: 8px; }
.banner-btns button {
  flex: 1; padding: 8px; border: none; border-radius: 8px;
  background: #ffffff; color: #b71c1c; font-weight: bold; font-size: 14px;
}

/* ===== パネル（下からのシート） ===== */
.panel {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1400;
  max-height: 78%; display: flex; flex-direction: column;
  background: var(--c-bg); color: var(--c-text);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,.3);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--c-line); flex: 0 0 auto;
}
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-head .close {
  border: 1px solid var(--c-line); background: var(--c-card); color: var(--c-text);
  border-radius: 50%; width: 32px; height: 32px; font-size: 15px; cursor: pointer;
}
.panel-body { overflow-y: auto; padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); }

.row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.row label { font-size: 13px; }
.infobox {
  background: var(--c-card); border: 1px solid var(--c-card-line);
  border-radius: var(--radius);
  padding: 10px; margin-bottom: 10px; font-size: 13px; color: var(--c-text);
}
.infobox h4 { margin: 0 0 6px; font-size: 13px; color: var(--c-primary); }
.tide-svg { width: 100%; height: auto; display: block; border-radius: 6px; }
.tide-times { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 13px; }
.tide-times b { color: var(--c-primary); }
.wx-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 12px; font-size: 13px; }
.wx-grid b { font-size: 16px; }

/* ===== メニュー ===== */
.menu-sec { border-bottom: 1px solid var(--c-line); padding: 10px 0; }
.menu-sec h3 {
  margin: 0 0 8px; font-size: 11px; font-weight: 700;
  letter-spacing: .12em; color: var(--c-primary);
}
.menu-sec details summary {
  margin: 0; font-size: 11px; font-weight: 700;
  letter-spacing: .12em; color: var(--c-primary);
  cursor: pointer; list-style: none;
}
.menu-sec details summary::-webkit-details-marker { display: none; }
.menu-sec details summary::before { content: "▶ "; font-size: 9px; }
.menu-sec details[open] summary::before { content: "▼ "; }
.menu-sec details[open] summary { margin-bottom: 8px; }
.radio, .check { display: block; padding: 7px 2px; font-size: 14px; color: var(--c-text); }
.note { font-size: 12px; color: var(--c-sub); margin: 6px 0; }
button.wide, .wide-link {
  display: block; width: 100%; margin: 6px 0; padding: 11px;
  border: 1px solid var(--c-line); border-radius: var(--radius); text-align: center;
  background: var(--c-bg); color: var(--c-primary); font-size: 14px; font-weight: bold;
  cursor: pointer; text-decoration: none; font-family: var(--font-ui);
}
button.wide:active, .wide-link:active { opacity: .55; }
button.small {
  padding: 6px 12px; border: 1px solid var(--c-line); border-radius: 8px;
  background: var(--c-bg); color: var(--c-primary); font-size: 13px; cursor: pointer;
}

.legend-grid { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 6px 0; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--c-text); }
.legend-dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); flex: 0 0 auto; }

.list { font-size: 13px; }
.list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 4px; border-bottom: 1px solid var(--c-line);
}
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: bold; color: var(--c-text); }
.list-item .li-sub { font-size: 11px; color: var(--c-sub); }
.list-item button {
  padding: 6px 10px; border: 1px solid var(--c-line); border-radius: 8px;
  background: var(--c-bg); color: var(--c-text); font-size: 12px; cursor: pointer; white-space: nowrap;
}
.list-item button.danger { color: #c62828; border-color: #e0b4b4; }
body[data-skin="neon"] .list-item button.danger { color: #ff7a9c; border-color: #7a3550; }

/* ===== ダイアログ（入力欄は全スキン共通で白背景＋濃色文字） ===== */
dialog {
  border: none; border-radius: 14px; padding: 16px;
  width: min(92vw, 400px); box-shadow: 0 4px 24px rgba(0,0,0,.35);
  background: #ffffff; color: #111111;
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin: 0 0 8px; font-size: 17px; }
dialog .note { color: #555555; }
dialog label { display: block; font-size: 13px; margin: 10px 0; color: #333333; }
dialog input[type="text"], dialog input[type="number"], dialog textarea, dialog select,
#panelTide select {
  display: block; width: 100%; margin-top: 4px; padding: 10px;
  font-size: 16px; border: 1px solid #bbbbbb; border-radius: 8px;
  background: #ffffff; color: #111111;
}
#panelTide select { display: inline-block; width: auto; padding: 8px; }
.row2 { display: flex; gap: 10px; }
.row2 label { flex: 1; }
.dlg-btns { display: flex; gap: 10px; margin-top: 14px; }
.dlg-btns button {
  flex: 1; padding: 12px; border-radius: 10px; font-size: 15px; cursor: pointer;
  border: 1px solid #bbbbbb; background: #ffffff; color: #333333;
}
.dlg-btns button.primary { background: var(--c-primary); border-color: var(--c-primary); color: #ffffff; font-weight: bold; }

/* Leaflet 微調整 */
.leaflet-control-attribution { font-size: 9px; }
.leaflet-popup-content { font-size: 13px; color: #111111; }
.popup-btns { display: flex; gap: 6px; margin-top: 6px; }
.popup-btns button {
  padding: 5px 9px; font-size: 12px; border: 1px solid #cccccc;
  border-radius: 6px; background: #ffffff; color: #333333; cursor: pointer;
}

/* ===== 起動スプラッシュ（安全注意。スキン非依存の固定ダーク） ===== */
#splash {
  position: fixed; inset: 0; z-index: 3000;
  background: #0b2740; color: #f2f7fb;
  display: flex; align-items: center; justify-content: center;
  padding: calc(24px + env(safe-area-inset-top)) 22px calc(24px + env(safe-area-inset-bottom));
  cursor: pointer; -webkit-user-select: none; user-select: none;
}
#splash.fade-out { animation: splashOut .4s ease forwards; }
@keyframes splashOut { to { opacity: 0; visibility: hidden; } }
.splash-inner {
  width: 100%; max-width: 460px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.splash-brand { text-align: center; opacity: 0; animation: splashBrandIn .7s ease .1s forwards; }
.splash-wave { width: 96px; height: 24px; color: #23d5f0; display: block; margin: 0 auto 6px; }
.splash-wave path { stroke-dasharray: 220; stroke-dashoffset: 220; animation: splashWave 1.1s ease .2s forwards; }
@keyframes splashWave { to { stroke-dashoffset: 0; } }
.splash-brand h1 {
  margin: 0; font-family: var(--font-num); font-size: 40px; font-weight: 700;
  letter-spacing: .04em; text-shadow: 0 0 18px rgba(35,213,240,.5);
}
.splash-sub { margin: 4px 0 0; font-size: 13px; opacity: .8; }
@keyframes splashBrandIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* 2つの注意を同じ場所で1つずつ切り替える（グリッドで重ね、show有無でクロスフェード） */
.splash-notices { display: grid; width: 100%; }
.splash-msg {
  grid-area: 1 / 1;
  display: flex; gap: 12px; align-items: flex-start;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px; padding: 16px 18px;
  opacity: 0; transform: translateY(16px); pointer-events: none;
  transition: opacity .55s ease, transform .55s ease;
}
.splash-msg.show { opacity: 1; transform: none; }
.splash-icon { font-size: 26px; line-height: 1.3; flex: 0 0 auto; }
.splash-msg p { margin: 0; font-size: 15px; line-height: 1.7; }
/* 特に伝えたい一文（軌跡はバックグラウンドでは記録できないこと）を一回り大きく */
.splash-em { display: inline-block; font-size: 1.3em; line-height: 1.5; margin-bottom: 5px; }
#splashMsg1 { border-color: rgba(255,176,32,.5); }
#splashMsg1 .splash-icon { filter: drop-shadow(0 0 6px rgba(255,176,32,.5)); }

.splash-skip {
  font-size: 12px; opacity: 0; margin-top: 4px;
  animation: splashSkipIn .5s ease 2s forwards;
}
@keyframes splashSkipIn { to { opacity: .55; } }
