:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --fg: #1d2329;
  --muted: #5f6b76;
  --card: #ffffff;
  --line: #d7dde3;
  --accent: #3d6f8f;
  --ok: #2e7d4f;
  --warn: #b7791f;
  --err: #b42318;
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181c;
    --fg: #e6ebef;
    --muted: #9aa6b1;
    --card: #1d2329;
    --line: #2f3841;
    --accent: #7fb0cf;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); line-height: 1.5; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
/* ホーム画面から開いたとき(viewport-fit=cover)に、ノッチ・角・ホームバーに文字やボタンが重ならないようにする。
   ふつうのブラウザでは env() は 0 なので、今までと同じ見た目になる */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line);
}
header h1 { font-size: 18px; margin: 0; }
main {
  max-width: 960px; margin: 0 auto; display: grid; gap: 16px;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
section { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
section h2 { font-size: 16px; margin: 0 0 12px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 8px 0 4px; }
input, select { width: 100%; padding: 10px; font-size: 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
button { padding: 10px 16px; font-size: 16px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.small { padding: 2px 8px; font-size: 13px; }
.strong { font-weight: bold; }
button:disabled { opacity: 0.5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); font-size: 14px; }
.hidden { display: none !important; }
/* HTML の style 属性の代わり(CSP で style-src の unsafe-inline を許さないため、style="..." は書かない) */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.m-0 { margin: 0; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.w-auto { width: auto; }
.status { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; white-space: pre-wrap; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.err { color: var(--err); }
/* 撮影ページの「画面を消す」:全体を黒で覆う(有機 EL では黒い画素は光らない) */
.screen-off { position: fixed; inset: 0; z-index: 1000; background: #000; cursor: none; display: flex; align-items: center; justify-content: center; }
.screen-off p { color: #555; font-size: 14px; margin: 0; transition: opacity 1s; }
.screen-off p.faded { opacity: 0; }
video { width: 100%; background: #000; border-radius: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.grid figure { margin: 0; }
.grid img { width: 100%; border-radius: 4px; display: block; }
.grid figcaption { font-size: 12px; color: var(--muted); }
/* 視聴ページのカメラ一覧。名前の前の点で ON(緑)/ OFF(灰色)を示す */
.camera-btn { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--muted); opacity: 0.6; }
/* 画面には出さず、読み上げにだけ使う文字 */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* 写真のページ送り「‹ 最新 2 3 [4] 5 6 … 12 ›」。今のページは塗りつぶしで示す */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.pager button { min-width: 40px; padding: 6px 10px; font-size: 14px; }
.pager button[aria-current="page"] { background: var(--accent); color: #fff; opacity: 1; }
.pager-info { flex-basis: 100%; font-size: 13px; }
.code { font-size: 32px; letter-spacing: 6px; font-weight: bold; }
.code-sm { font-family: ui-monospace, monospace; font-size: 20px; letter-spacing: 3px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { border-bottom: 1px solid var(--line); padding: 6px; text-align: left; }
h3 { font-size: 15px; margin: 0 0 4px; }
/* 横に広い表は、狭い画面では横スクロールにする(文字が縦に折り返さないように) */
.scroll-x { overflow-x: auto; }
.scroll-x th, .scroll-x td { white-space: nowrap; }
/* 狭い画面では、表の1行をカードのように縦に並べる(td の data-label を見出しにする) */
@media (max-width: 640px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.stack td { border: 0; padding: 2px 0; }
  table.stack td[data-label]::before { content: attr(data-label) ":"; color: var(--muted); margin-right: 6px; }
}
