:root {
  --bg: #14181f;
  --panel: #1d232d;
  --fg: #e8ecf2;
  --muted: #98a2b3;
  --accent: #6aa9ff;
  --danger: #ff7b7b;
  --gap: 3px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --fg: #1a2030;
    --muted: #5b6577;
    --accent: #1f6feb;
    --danger: #c62828;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 system-ui, "Hiragino Sans", "Noto Sans JP", sans-serif; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.center { min-height: 100dvh; display: grid; place-content: center; gap: 16px;
  padding: 24px max(16px, env(safe-area-inset-left)); text-align: center; }
.center h1 { margin: 0; font-size: 1.4rem; }
.center p { margin: 0; color: var(--muted); max-width: 32rem; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 12px 20px; min-height: 44px; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.field { background: var(--panel); border: 1px solid var(--muted); border-radius: 10px;
  padding: 12px; min-height: 44px; width: min(22rem, 100%); }
.error { color: var(--danger); min-height: 1.5em; }
.link { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 8px; }

header.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: 8px max(12px, env(safe-area-inset-left)); background: var(--bg);
  border-bottom: 1px solid var(--panel); }
header.bar h1 { font-size: 1.05rem; margin: 0; flex: 1; }
.chip { background: var(--panel); border: 1px solid transparent; border-radius: 999px;
  padding: 6px 14px; min-height: 36px; }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.icon-btn { background: none; border: 0; min-width: 44px; min-height: 44px; font-size: 1.3rem; }
.menu { position: absolute; right: 8px; top: 52px; background: var(--panel); border-radius: 10px;
  box-shadow: 0 6px 24px #0008; display: grid; min-width: 14rem; z-index: 6; }
.menu button { background: none; border: 0; text-align: left; padding: 12px 16px; min-height: 44px; }
.menu button + button { border-top: 1px solid var(--bg); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--gap);
  padding: var(--gap) 0; }
.cell { position: relative; aspect-ratio: 1; background: var(--panel); border: 0; padding: 0;
  overflow: hidden; content-visibility: auto; contain-intrinsic-size: 110px 110px; }
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge { position: absolute; right: 4px; bottom: 4px; background: #000a; color: #fff;
  font-size: 12px; padding: 1px 6px; border-radius: 6px; }
.status { padding: 16px; color: var(--muted); text-align: center; }

#viewer { position: fixed; inset: 0; z-index: 20; background: #000; color: #fff;
  display: grid; place-items: center; touch-action: none; }
#viewer .stage { width: 100%; height: 100%; display: grid; place-items: center; overflow: hidden; }
#viewer img.photo { max-width: 100%; max-height: 100%; transform-origin: center; will-change: transform; }
#viewer video { width: 100%; max-height: 100%; background: #000; }
#viewer .top { position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 8px 8px; background: linear-gradient(#000a, #0000);
  z-index: 2; }
#viewer .top .title { flex: 1; align-self: center; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 14px; }
#viewer .top button { background: #0006; color: #fff; border: 0; border-radius: 999px;
  min-width: 44px; min-height: 44px; }
#viewer .msg { position: absolute; bottom: 24px; left: 16px; right: 16px; text-align: center;
  background: #000c; padding: 12px; border-radius: 10px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  background: var(--panel); color: var(--fg); padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 6px 24px #0008; max-width: 90vw; }

.diag { padding: 16px max(16px, env(safe-area-inset-left)); max-width: 40rem; margin: 0 auto; }
.diag dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.diag dt { color: var(--muted); }
.diag dd { margin: 0; font-variant-numeric: tabular-nums; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); opacity: 0; }
