/* アプリと同じダーク基調（CLAUDE.md の主要色） */
[hidden] { display: none !important; }
:root {
  --bg: #0B0E13;
  --surface: #151A21;
  --line: #2A313B;
  --grid: #222933;
  --text: #ECEFF3;
  --muted: #9AA4B1;
  --ok: #5CC8FF;
  --warn: #FFB547;
  --stop: #FF5F57;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
}
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.error { color: var(--stop); }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.top h1 { font-size: 18px; margin: 0; }
.link { background: none; border: 0; color: var(--ok); min-height: 44px; padding: 0 8px; }
.link.danger { color: var(--muted); margin-left: auto; }
.link.danger:hover { color: var(--stop); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.login { max-width: 420px; margin: 48px auto; }
.login h2 { margin: 0 0 4px; font-size: 18px; }
.login form, .form-stack { display: grid; gap: 6px; }
.login label, .form-stack label { font-size: 13px; color: var(--muted); margin-top: 6px; }
.login input, .form-stack input:not([type=checkbox]) { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.login button[type=submit], .form-stack button[type=submit] { margin-top: 12px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--ok); color: #06202E; font-weight: 700; }
.login button[disabled], .form-stack button[disabled] { opacity: .6; }
.who { display: flex; align-items: center; gap: 4px; }

main#app { display: grid; grid-template-columns: 320px 1fr; min-height: calc(100vh - 69px); }
.list { border-right: 1px solid var(--line); padding: 12px; overflow-y: auto; max-height: calc(100vh - 69px); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filters button { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); }
.filters button[aria-pressed=true] { background: var(--surface); color: var(--text); border-color: var(--muted); }
.download { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 12px; margin-bottom: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.download div { display: grid; }
.download #download-info { font-size: 12px; }
.download button { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--ok); color: #06202E; font-weight: 700; }
.download .note { grid-column: 1 / -1; margin: 0; font-size: 12px; line-height: 1.5; }
#clips { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#clips button { width: 100%; text-align: left; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: grid; gap: 2px; }
#clips button[aria-current=true] { border-color: var(--ok); }
#clips .row { display: flex; gap: 8px; align-items: center; }
#clips .sub { color: var(--muted); font-size: 13px; }

/* 種類のバッジ。色だけでなく文字で区別する。赤は停止・異常専用なので衝撃は琥珀 */
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; }
.badge.impact, .badge.brake { color: var(--warn); }
.badge.manual { color: var(--ok); }
.badge.latest, .badge.recording { color: var(--muted); }
.beta { margin-top: 20px; font-size: 13px; color: var(--muted); border-left: 3px solid var(--warn); padding-left: 10px; }
.beta strong { color: var(--warn); }

.detail { padding: 16px 20px 40px; min-width: 0; }
.placeholder { margin-top: 40px; text-align: center; }
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.detail-head h2 { margin: 0; font-size: 20px; }
.media { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; }
video { width: 100%; background: #000; border-radius: 12px; aspect-ratio: 16 / 9; }
.map { min-height: 240px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.map .no-data { display: grid; place-items: center; height: 100%; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; }
.tile .label { color: var(--muted); font-size: 12px; }
.tile .value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile .value a { color: var(--ok); }

.chart { margin: 0 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 4px; }
.chart figcaption { font-size: 13px; font-weight: 700; display: flex; gap: 12px; flex-wrap: wrap; }
.chart .stat { font-weight: 400; }
.plot { position: relative; height: 160px; }
.plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.plot .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.plot .grid line { stroke: var(--grid); stroke-width: 1; }
.plot .series { fill: none; stroke: var(--ok); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.plot .ref { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.plot .ref-label { fill: var(--muted); font-size: 11px; }
.plot .event { stroke: var(--warn); stroke-width: 2; }
.plot .event-label { fill: var(--text); font-size: 11px; font-weight: 700; }
.plot .cursor { stroke: var(--text); stroke-width: 1; }
.plot .hover { stroke: var(--muted); stroke-width: 1; }
.plot .hover-dot { fill: var(--ok); stroke: var(--surface); stroke-width: 2; }
.plot .empty { fill: var(--muted); font-size: 13px; }
.tooltip { position: absolute; pointer-events: none; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); }

.table-view summary { cursor: pointer; color: var(--ok); min-height: 44px; display: flex; align-items: center; }
.table-view table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { text-align: right; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.table-view th:first-child, .table-view td:first-child { text-align: left; }

/* Leaflet をダークに合わせる */
.leaflet-container { background: var(--surface); border-radius: 12px; }
.leaflet-control-attribution { background: rgba(11, 14, 19, .8) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--ok) !important; }

@media (max-width: 900px) {
  main#app { grid-template-columns: 1fr; }
  .list { border-right: 0; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .media { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail { padding: 16px; }
}
.plot .hit { cursor: pointer; }
.refreshed { display: flex; align-items: center; justify-content: space-between; margin: 0 0 4px; font-size: 12px; }

/* 出来事（衝撃を検知した・ボタンを押した時刻）がこの動画のどこか */
.event { border: 1px solid var(--warn); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; }
.event p { margin: 4px 0; }
.event-what strong { color: var(--warn); }
.event .link { min-height: 36px; }
.event .link:disabled { color: var(--muted); }
.parts { color: var(--muted); }

/* 管理者：利用状況 */
.admin { max-width: 1200px; margin: 24px auto; }
.table-wrap { overflow-x: auto; }
.admin-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.admin-table th, .admin-table td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; white-space: nowrap; }
.admin-table th { color: var(--muted); font-weight: normal; }
.admin-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table .link { min-height: 0; padding: 0; }
.admin-detail { margin-top: 16px; }
.admin-detail h3 { margin: 8px 0; }
@media (max-width: 600px) { .admin { margin: 8px; padding: 12px; } }
.issues-title { margin-top: 32px; }
.excerpt { white-space: normal; max-width: 420px; font-size: 12px; }
.st-open { color: var(--warn); }
.st-in_progress { color: var(--ok); }
.st-done, .st-wontfix { color: var(--muted); }
.issue-body { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.thread { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.msg { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; white-space: pre-wrap; max-width: 720px; }
.msg.from-admin { border-color: var(--ok); }
.reply { display: flex; flex-direction: column; gap: 8px; max-width: 720px; }
.reply textarea, .admin select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; }
.reply button { align-self: flex-start; }

/* プライバシーポリシーなどの文書 */
.home { color: inherit; text-decoration: none; }
.doc { display: block; max-width: 820px; margin: 24px auto 64px; padding: 0 16px; line-height: 1.8; }
.doc h1 { font-size: 26px; }
.doc h2 { font-size: 19px; margin-top: 36px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.doc h3 { font-size: 16px; margin-top: 24px; }
.doc a { color: var(--ok); }
.doc table { border-collapse: collapse; width: 100%; font-size: 14px; }
.doc th, .doc td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.doc th { color: var(--muted); font-weight: normal; }
.doc code { background: var(--surface); padding: 1px 6px; border-radius: 4px; }
.site-footer { text-align: center; padding: 16px; font-size: 13px; }
.site-footer a { color: var(--muted); }
.form-stack .check, .check { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 0; font-size: 14px; color: var(--text); }
.check input { width: auto; min-height: 0; margin-top: 4px; }
.danger-button { background: #C62F28 !important; color: #fff !important; }
.narrow { max-width: 420px; }
