:root {
  --bg: #fff;
  --ink: #111;
  --sub: #5f6368;
  --line: #e5e5e5;
  --fill: #f2f2f2;
  --tile: #ececec;
  --accent: #111;
  --gap: 4px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul { list-style: none; }
[hidden] { display: none !important; }

/* header */
.hd { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 28px;
  height: 68px; padding: 0 24px; background: #fff; border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; flex: none; }
.sb { flex: 1; max-width: 760px; display: flex; align-items: center; height: 44px;
  background: var(--fill); border: 1px solid transparent; border-radius: 8px; padding-left: 14px; transition: background .15s, border-color .15s; }
.sb:focus-within { background: #fff; border-color: #bbb; }
.sb-ic { color: var(--sub); flex: none; }
.sb input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; padding: 0 12px; font: inherit; font-size: 15px; color: var(--ink); }
.sb input:focus { outline: 0; }
.sb input::-webkit-search-cancel-button { -webkit-appearance: none; }
.sb button { height: 100%; padding: 0 22px; background: var(--accent); color: #fff; font-weight: 600; border-radius: 0 7px 7px 0; }
.sb button:hover { background: #333; }

/* category chips */
.cats { border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats ul { display: flex; gap: 8px; padding: 12px 24px; width: max-content; }
.cats button { height: 34px; padding: 0 16px; border: 1px solid var(--line); border-radius: 17px; font-size: 13px; white-space: nowrap; transition: border-color .15s, background .15s; }
.cats button:hover { border-color: #999; }
.cats button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* layout */
.wrap { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 128px); }
.side { border-right: 1px solid var(--line); padding: 20px 20px; position: sticky; top: 68px; align-self: start; max-height: calc(100vh - 68px); overflow-y: auto; }
.side section + section { margin-top: 26px; }
.side h3 { font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button { height: 32px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.seg button:hover { border-color: #999; }
.seg button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 600; }
.checks li + li { margin-top: 4px; }
.checks label { white-space: nowrap; display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; font-size: 13px; }
.checks input { width: 16px; height: 16px; accent-color: var(--ink); }
.checks .n { margin-left: auto; color: var(--sub); font-size: 12px; }
.checks label.off { color: #aaa; cursor: default; }
.checks label.err .n { color: #c5221f; }

.main { padding: 18px 24px 40px; min-width: 0; }
.bar { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.bar h1 { font-size: 18px; font-weight: 700; }
.count { color: var(--sub); font-size: 13px; }

/* justified grid */
.grid { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; gap: var(--gap); }
.cell { position: relative; flex: none; min-width: 0; overflow: hidden; background: var(--tile); cursor: pointer; }
.cell img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s; }
.cell img.on { opacity: 1; }
.cell .ov { position: absolute; inset: auto 0 0 0; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px;
  padding: 28px 10px 9px; background: linear-gradient(transparent, rgba(0,0,0,.6)); color: #fff; font-size: 12px; opacity: 0; transition: opacity .15s; }
.cell:hover .ov, .cell:focus-visible .ov { opacity: 1; }
.cell .ov span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .ov .src { flex: none; padding: 2px 7px; background: rgba(255,255,255,.92); color: #111; border-radius: 3px; font-size: 11px; font-weight: 600; }
.cell:focus-visible { outline: 3px solid #1a73e8; outline-offset: -3px; }

.status { color: var(--sub); text-align: center; padding: 26px 0 0; font-size: 13px; }
.status:empty { display: none; }
.empty { text-align: center; padding: 90px 20px; color: var(--sub); }
.empty b { display: block; color: var(--ink); font-size: 18px; margin-bottom: 6px; }
.sentinel { height: 100px; }

/* modal */
.md { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.72); display: grid; place-items: center; padding: 24px; }
.md-box { position: relative; display: grid; grid-template-columns: 1fr 340px; width: min(1320px, 100%); height: min(860px, 100%);
  background: #fff; border-radius: 10px; overflow: hidden; }
.md-x { position: absolute; top: 12px; right: 12px; z-index: 2; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--sub); }
.md-x:hover { background: var(--fill); color: var(--ink); }
.md-img { position: relative; background: #f7f7f7; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 24px; }
.md-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.md-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.18); display: grid; place-items: center; }
.md-nav:hover { background: var(--fill); }
.md-nav.prev { left: 16px; } .md-nav.next { right: 16px; }
.md-nav:disabled { opacity: 0; pointer-events: none; }
.md-info { padding: 56px 28px 28px; border-left: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; }
.badge { align-self: flex-start; padding: 3px 9px; border-radius: 4px; background: var(--fill); font-size: 12px; font-weight: 600; margin-bottom: 12px; }
.md-info h2 { font-size: 17px; font-weight: 700; line-height: 1.45; margin-bottom: 20px; word-break: break-word; }
.md-info dl { display: grid; grid-template-columns: 84px 1fr; gap: 10px 12px; font-size: 13px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.md-info dt { color: var(--sub); }
.md-info dd { word-break: break-word; }
.md-info dd a { text-decoration: underline; text-underline-offset: 2px; }
.btn-main { display: block; margin-top: 22px; height: 46px; line-height: 46px; text-align: center; background: var(--ink); color: #fff; border-radius: 6px; font-weight: 600; }
.btn-main:hover { background: #333; }
.md-note { margin-top: 10px; font-size: 12px; color: var(--sub); text-align: center; }

@media (max-width: 960px) {
  .wrap { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); display: flex; gap: 24px; flex-wrap: wrap; padding: 14px 16px; }
  .side section + section { margin-top: 0; }
  .seg { grid-template-columns: repeat(4, auto); }
  .seg button { padding: 0 12px; }
  .checks { display: flex; gap: 14px; }
  .checks li + li { margin-top: 0; }
  .md { padding: 0; }
  .md-box { grid-template-columns: 1fr; grid-template-rows: 1fr auto; height: 100%; border-radius: 0; }
  .md-info { border-left: 0; border-top: 1px solid var(--line); padding: 18px; max-height: 42vh; }
}
@media (max-width: 640px) {
  .hd { gap: 12px; padding: 0 12px; height: 60px; }
  .logo span { display: none; }
  .sb button { padding: 0 14px; }
  .cats ul { padding: 10px 12px; }
  .main { padding: 14px 8px 30px; }
  .bar { padding: 0 4px; }
}
