:root { --fg: #111; --bg: #fff; --muted: #666; --line: #111; --accent: #ffd400; --ng: #b00020; --tile: #eee; --sheet: #fff; }
@media (prefers-color-scheme: dark) {
  :root { --fg: #eee; --bg: #111; --muted: #999; --line: #eee; --ng: #ff6b81; --tile: #222; --sheet: #1b1b1b; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.6 system-ui, sans-serif; color: var(--fg); background: var(--bg); }
button { font: inherit; font-weight: 700; padding: 8px 16px; border: 2px solid var(--line); background: var(--accent); color: #111; cursor: pointer; }
button.plain { background: transparent; color: var(--fg); }
input, select { font: inherit; font-size: 16px; padding: 8px; border: 2px solid var(--line); border-radius: 0; background: var(--bg); color: var(--fg); width: 100%; }
.ng { color: var(--ng); }

.login form { max-width: 320px; margin: 18vh auto 0; padding: 0 16px; display: grid; gap: 10px; }
.login h1 { font-size: 20px; margin: 0 0 8px; }
.login label { font-weight: 700; }

/* 上の検索欄（スクロールしても残す） */
.bar { position: sticky; top: 0; z-index: 2; background: var(--bg); border-bottom: 2px solid var(--line);
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; display: grid; gap: 6px; }
.bar .row { display: flex; gap: 8px; align-items: center; }
.bar select { width: auto; max-width: 60%; padding: 4px 6px; font-size: 14px; }
.status { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 2px; padding: 2px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.tile { display: block; padding: 0; border: 0; aspect-ratio: 1; background: var(--tile); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
#sentinel { height: 1px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.foot { text-align: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.pin { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.pin a { color: var(--fg); font-weight: 700; }

/* 1件の詳しい表示 */
dialog { padding: 0; border: 2px solid var(--line); background: var(--sheet); color: var(--fg); width: min(560px, 100vw - 24px); max-height: 92vh; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog img { display: block; width: 100%; max-height: 62vh; object-fit: contain; background: #000; }
.d-body { padding: 12px 14px 14px; }
.d-src { font-weight: 700; }
.d-alt { color: var(--muted); font-size: 13px; margin: 4px 0 12px; max-height: 6.4em; overflow: auto; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.d-actions a { font-weight: 700; color: var(--fg); padding: 8px 4px; }
