/* ui.css — 全画面共通のテーマ。fl4obd の配色語彙に揃える（暗所の車内で読める前提） */

:root {
  --bg:      #070b0f;
  --panel:   #0a1520;
  --panel2:  #0c1a24;
  --line:    #1a2a3a;
  --line2:   #16303f;
  --fg:      #c8d8e8;
  --dim:     #2a5a7a;
  --dim2:    #4a6a80;
  --accent:  #3a8aff;
  --ok:      #00ff88;
  --warn:    #ffaa00;
  --err:     #cc3333;
  --cyan:    #00ffcc;
  --safe-b:  env(safe-area-inset-bottom, 0px);
  --safe-t:  env(safe-area-inset-top, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Courier New', ui-monospace, monospace;
  overscroll-behavior: none;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- ヘッダ ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(6px + var(--safe-t)) 10px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.brand { font-size: 11px; letter-spacing: 3px; color: var(--accent); font-weight: bold; white-space: nowrap; }
.nav { display: flex; gap: 4px; }
.nav a {
  font-size: 10px; letter-spacing: 1.5px; padding: 5px 9px; border-radius: 5px;
  border: 1px solid var(--line); color: var(--dim); text-decoration: none;
}
.nav a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.nav a.on { border-color: var(--accent); color: var(--accent); background: #0d1e30; }

/* ---- ステータスチップ ---- */
.chips { display: flex; flex-wrap: wrap; gap: 5px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; letter-spacing: 1px; color: var(--dim);
  border: 1px solid var(--line); border-radius: 20px; padding: 3px 9px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: #1e2e3e; border: 1.5px solid #2a4a6a; transition: all .3s; }
.chip.on  { color: var(--ok);   border-color: #14503a; }
.chip.on  .dot { background: var(--ok); border-color: #00cc66; box-shadow: 0 0 7px #00ff8860; }
.chip.warn { color: var(--warn); border-color: #4a3a10; }
.chip.warn .dot { background: var(--warn); border-color: #cc8800; animation: blink 1s infinite; }
.chip.err { color: var(--err); border-color: #4a1a1a; }
.chip.err .dot { background: var(--err); border-color: #aa2222; }
@keyframes blink { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

/* ---- ボタン ---- */
button, .btn {
  font-family: inherit; font-size: 11px; letter-spacing: 1.5px;
  background: #0d1e30; border: 1px solid #2a5a8c; border-radius: 7px;
  color: #4a9eff; padding: 9px 14px; cursor: pointer; transition: all .15s;
}
button:hover:not(:disabled), .btn:hover { background: #122840; border-color: #4a9eff; }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .3; cursor: not-allowed; }
button.primary  { border-color: #1a7a4a; color: var(--ok); background: #08201a; }
button.primary:hover:not(:disabled)  { background: #0d3025; border-color: var(--ok); }
button.danger   { border-color: #6a2222; color: #ff6666; background: #200c0c; }
button.danger:hover:not(:disabled)   { background: #301010; border-color: #cc4444; }
button.rec { border-color: var(--err); color: #ff5555; background: #200c0c; animation: blink 1.2s infinite; }
button.ghost { border-color: var(--line); color: var(--dim); background: transparent; }
button.ghost:hover:not(:disabled) { border-color: var(--dim2); color: var(--fg); background: transparent; }

/* ---- カード / 値の表示 ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 6px; }
.ro { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 7px 6px 6px; text-align: center; }
.ro .l { font-size: 9px; letter-spacing: 2px; color: var(--dim); }
.ro .v { font-size: 26px; font-weight: bold; line-height: 1.05; margin-top: 2px; font-variant-numeric: tabular-nums; }
.ro .u { font-size: 9px; color: var(--dim); letter-spacing: 1px; }
.ro.spd .v { color: var(--ok); }
.ro.dst .v { color: #4a9eff; }
.ro.tim .v { color: var(--fg); }
.ro.alt .v { color: var(--warn); }
.ro.acc .v { color: var(--cyan); }

/* ---- 地図 ---- */
#map { width: 100%; background: #0a1520; }
.leaflet-container { background: #0a1520; font-family: 'Courier New', monospace; }
.leaflet-control-attribution { background: rgba(7,11,15,.8) !important; color: #4a6a80 !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: #4a9eff !important; }
.leaflet-bar a { background: #0d1e30 !important; color: #4a9eff !important; border-color: #1a2a3a !important; }
.leaflet-bar a:hover { background: #122840 !important; }

/* ---- テーブル ---- */
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th, td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--dim); font-size: 10px; letter-spacing: 1px; font-weight: normal; position: sticky; top: 0; background: var(--bg); }
tbody tr:hover { background: #0c1826; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- 汎用 ---- */
.muted { color: var(--dim); }
.small { font-size: 10px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.hidden { display: none !important; }
input[type=text], textarea, select {
  font-family: inherit; font-size: 11px; background: #050a10; color: var(--fg);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%;
}
input[type=text]:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* ---- トースト ---- */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + var(--safe-b)); z-index: 9999;
  display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none;
}
#toast div {
  background: #0d1e30; border: 1px solid #2a5a8c; color: #a8c8e8;
  border-radius: 8px; padding: 9px 16px; font-size: 11px; letter-spacing: 1px;
  box-shadow: 0 4px 20px #000a; animation: pop .2s ease-out;
}
#toast div.err { border-color: #6a2222; color: #ff8888; }
#toast div.ok  { border-color: #1a7a4a; color: var(--ok); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
