:root {
  color-scheme: dark;
  --ink: #f1f2ef;
  --paper: #0b0c0c;
  --panel: #151716;
  --raised: #202321;
  --yellow: #f4d44d;
  --line: #343836;
  --muted: #9ca29e;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { min-height: 100vh; margin: 0; background: var(--paper); color: var(--ink); font: 13px/1.45 "Helvetica Neue", Helvetica, Arial, sans-serif; }
body.detail-open { overflow: hidden; }
button, input, select { min-height: 36px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 1px; background: var(--raised); color: var(--ink); font: inherit; }
button { cursor: pointer; }
button:hover { border-color: #747b77; }
button:disabled { cursor: default; opacity: .42; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, .region-row:focus-visible, summary:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
a { color: var(--ink); text-underline-offset: 3px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .17em; text-transform: uppercase; }

.site-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 3vw 14px; background: #101211; }
h1 { margin: 0; font-size: clamp(32px, 4vw, 54px); letter-spacing: -.05em; line-height: .95; }
.stats { display: flex; gap: 20px; }
.stat { display: grid; text-align: right; }
.stat b { font-size: 18px; line-height: 1; }
.stat span { color: var(--muted); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; }
.filters { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; gap: 8px; padding: 9px 3vw; border-bottom: 1px solid var(--line); background: #101211ed; backdrop-filter: blur(12px); }
main { padding: 15px 3vw 50px; }
.summary { min-height: 24px; color: var(--muted); font-size: 11px; }
.error { color: #ff8b7e; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 16px; }
.card { min-width: 0; cursor: pointer; }
.card .thumb { position: relative; overflow: hidden; aspect-ratio: 1; background: #202321; }
.card img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform 180ms ease; }
.card:hover img { transform: scale(1.018); }
.card h3 { overflow: hidden; margin: 8px 0 1px; font-size: 14px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.card p { overflow: hidden; margin: 0; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.rank-badge { position: absolute; top: 6px; left: 6px; padding: 3px 6px; background: #0b0c0cda; box-shadow: 0 1px 5px #0008; font: 600 10px/1.2 ui-monospace, Consolas, monospace; }

dialog { width: min(1580px, 98vw); height: min(940px, 97vh); max-width: none; max-height: 97vh; padding: 0; overflow: hidden; border: 1px solid #3c413e; border-radius: 0; background: var(--panel); box-shadow: 0 32px 100px #000d; color: var(--ink); }
dialog::backdrop { background: #050606e8; }
.detail-topbar { height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border-bottom: 1px solid var(--line); background: #101211; }
.detail-controls { display: flex; align-items: center; gap: 10px; }
.detail-topbar button { min-height: 29px; padding: 4px 9px; font-size: 11px; }
.detail-topbar button.active { border-color: var(--yellow); background: var(--yellow); color: #111; }
#position { font: 600 10px/1 ui-monospace, Consolas, monospace; }
.detail-topbar .close { width: 30px; padding: 0; background: transparent; font-size: 19px; }
.detail-layout { height: calc(100% - 44px); display: grid; grid-template-columns: minmax(480px, 1.55fr) minmax(390px, .8fr); overflow: hidden; }
.viewer { position: relative; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 18px; overflow: hidden; background-color: #090a0a; background-image: repeating-linear-gradient(135deg, #090a0a 0, #090a0a 9px, #121413 9px, #121413 10px); }
.viewer img { width: auto; height: auto; max-width: 100%; max-height: 100%; display: block; object-fit: contain; box-shadow: 0 8px 32px #0008; }
.guide-panel { min-width: 0; padding: 20px 20px 28px; overflow-y: auto; border-left: 1px solid var(--line); background: #151716; scrollbar-color: #555 #161817; scrollbar-width: thin; }
.work-heading { padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.work-heading h2 { margin: 3px 0; font-size: clamp(25px, 2.2vw, 36px); letter-spacing: -.035em; line-height: 1.06; }
.artist { margin: 7px 0 0; color: #d6d9d6; font-size: 15px; }
.guide-intro { padding: 18px 0 19px; border-bottom: 1px solid var(--line); }
.guide-panel h3 { margin: 0; font-size: 16px; }
.introduction { margin: 8px 0 0; color: #e1e4e1; font-size: 15px; line-height: 1.55; }
.favorite-regions { padding-top: 17px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
#region-count { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.hint { margin: 3px 0 11px; color: var(--muted); font-size: 10px; }
.region-list { display: grid; gap: 4px; }
.region-row { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; padding: 9px 10px 10px 7px; border-left: 3px solid var(--region-color); background: #202321; transition: opacity 120ms ease, background 120ms ease; }
.region-row:hover, .region-row.solo { background: #292d2a; }
.region-index { padding-top: 2px; color: var(--region-color); font: 700 11px/1 ui-monospace, Consolas, monospace; text-align: center; }
.region-row h4 { margin: 0; font-size: 13px; line-height: 1.25; }
.region-row p { margin: 3px 0 0; color: #c7ccc8; font-size: 11px; line-height: 1.38; }
.region-list.has-solo .region-row:not(.solo), .regions-layer.has-solo .region-box:not(.solo) { opacity: .16; }

.work-details { margin-top: 20px; padding-top: 13px; border-top: 1px solid var(--line); }
.work-details summary { color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.scoreline { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 13px 0; border: 1px solid var(--line); background: var(--line); }
.scoreline span { overflow: hidden; padding: 5px 7px; background: #1e211f; font: 10px/1.25 ui-monospace, Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.metadata { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 7px 10px; margin: 0 0 15px; }
.metadata dt { color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.metadata dd { margin: 0; font-size: 11px; white-space: pre-wrap; }
.rights { margin: 14px 0; color: var(--muted); font-size: 10px; }
.keyboard-hint { margin: 20px 0 0; color: var(--muted); font-size: 10px; }
kbd { padding: 2px 5px; border: 1px solid var(--line); background: var(--raised); color: var(--ink); font: inherit; }

.regions-layer { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.region-box { position: absolute; border: 1px solid var(--region-color); box-shadow: 0 0 0 1px #000b, inset 0 0 0 1px #ffffff38; pointer-events: auto; transition: opacity 120ms ease; }
.region-box span { position: absolute; top: -1px; left: -1px; max-width: 220px; padding: 3px 6px; overflow: hidden; background: var(--region-color); color: #111; box-shadow: 0 1px 4px #0009; font-size: 9px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.region-box.label-below span { top: 100%; margin-top: 2px; }

@media (max-width: 900px) {
  dialog { overflow-y: auto; }
  .detail-layout { height: auto; min-height: calc(100% - 44px); display: block; overflow: visible; }
  .viewer { height: min(64vh, 620px); }
  .guide-panel { overflow: visible; border-top: 1px solid var(--line); border-left: 0; }
}

@media (max-width: 700px) {
  .site-header { align-items: end; }
  .stats { display: none; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  dialog { width: 100vw; height: 100dvh; max-height: none; border: 0; }
  .viewer { height: 52vh; padding: 11px; }
  .guide-panel { padding: 17px 14px 25px; }
}
