* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.4 system-ui, sans-serif; color: #1d1d1f; background: #f4f4f6; }
header { display: flex; align-items: baseline; gap: 1rem; padding: .75rem 1.25rem; background: #1d1d1f; color: #fff; }
header h1 { margin: 0; font-size: 1.2rem; }
#progress { opacity: .7; font-size: .9rem; }
main { display: grid; grid-template-columns: 160px 1fr 340px; gap: 1rem; padding: 1rem; height: calc(100vh - 52px); }

#gallery { overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; }
#gallery button { position: relative; padding: 0; border: 3px solid transparent; border-radius: 6px; background: none; cursor: pointer; }
#gallery button[aria-current="true"] { border-color: #0a84ff; }
#gallery img { display: block; width: 100%; border-radius: 3px; }
#gallery .badge { position: absolute; top: 4px; right: 4px; background: #30d158; color: #fff; border-radius: 9px; padding: 0 6px; font-size: .75rem; }

#viewer { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; }
#stage { max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; }
#canvas { position: relative; line-height: 0; }
#photo { max-width: 100%; max-height: calc(100vh - 120px); border-radius: 4px; }
.hint { margin: .4rem 0 0; color: #666; font-size: .85rem; }

/* Overlay uses the image's pixel viewBox and stretches with it, so outlines scale with the photo. */
#overlay, #labels { position: absolute; inset: 0; width: 100%; height: 100%; }
#labels { pointer-events: none; }
.person { fill: var(--c); fill-opacity: .12; stroke: var(--c); stroke-width: 3; stroke-linejoin: round;
          vector-effect: non-scaling-stroke; cursor: pointer; transition: fill-opacity .1s; outline: none; }
.person:hover, .person:focus-visible { fill-opacity: .35; }
.person.selected { fill-opacity: .4; stroke-width: 5; }
#overlay.has-selection .person:not(.selected) { stroke-opacity: .55; fill-opacity: .05; }
.label { position: absolute; transform: translate(-50%, -100%); max-width: 180px; overflow: hidden; text-overflow: ellipsis;
         white-space: nowrap; padding: 1px 6px; border-radius: 4px; font-size: 12px; line-height: 1.4; font-weight: 600;
         color: #fff; background: var(--c); text-shadow: 0 0 2px rgba(0,0,0,.6); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.label:not(.named) { opacity: .8; font-weight: 400; }
.person.unknown { stroke-dasharray: 8 5; }
.label.unknown { font-style: italic; }
label.checkbox { display: flex; align-items: center; gap: .4rem; }
label.checkbox input { display: inline; width: auto; margin: 0; }
input:disabled { background: #f2f2f2; }
.label.selected { outline: 2px solid #fff; z-index: 1; }
.swatch { display: inline-block; width: .8em; height: .8em; margin-right: .4em; border-radius: 2px; background: var(--c); vertical-align: -1px; }

#panel { overflow-y: auto; background: #fff; border-radius: 8px; padding: 1rem; }
fieldset { border: 1px solid #ddd; border-radius: 6px; margin: 0 0 1rem; padding: .75rem; }
fieldset[disabled] { opacity: .55; }
legend { font-weight: 600; padding: 0 .3rem; }
label { display: block; margin-bottom: .6rem; font-size: .9rem; }
input, textarea { display: block; width: 100%; margin-top: .2rem; padding: .4rem; font: inherit; border: 1px solid #ccc; border-radius: 4px; }
button { font: inherit; }
#submit, .secondary { padding: .5rem 1rem; border-radius: 6px; border: 0; cursor: pointer; }
#submit { width: 100%; background: #0a84ff; color: #fff; font-weight: 600; }
#submit:disabled { opacity: .6; cursor: progress; }
.secondary { background: #eee; }
.note { margin: 0; color: #777; font-size: .8rem; }
#people-list { list-style: none; padding: 0; margin: 0 0 1rem; font-size: .9rem; }
#people-list li { padding: .2rem 0; cursor: pointer; }
#status { min-height: 1.2em; font-size: .9rem; }
#status.error { color: #d70015; }
#status.ok { color: #248a3d; }

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; height: auto; }
  #gallery { flex-direction: row; overflow-x: auto; }
  #gallery button { flex: 0 0 110px; }
}
