:root {
  color-scheme: dark;
  --bg: #191919;
  --well: #101010;
  --panel: #222;
  --ink: #f3f2ef;
  --muted: #afafac;
  --line: #373737;
  --edge: clamp(18px, 4.6vw, 30px);
  --top: max(0px, env(safe-area-inset-top));
  --bottom: max(12px, env(safe-area-inset-bottom));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; letter-spacing: -.025em; }
button, input { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; background: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .55; }
button:focus-visible, input:focus-visible, main:focus-visible, a:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
main:focus { outline: none; }
h1, h2, p, ul, ol, figure { margin: 0; }
button, label { -webkit-user-select: none; user-select: none; }
h1, h2 { line-height: 1.2; word-break: keep-all; }
h1 { font-size: clamp(29px, 6vw, 38px); font-weight: 650; letter-spacing: -.07em; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: -.04em; }
.topbar, main { width: 100%; max-width: 700px; margin-inline: auto; }
.topbar { min-height: calc(58px + var(--top)); display: flex; align-items: center; gap: clamp(12px, 2vw, 20px); padding: var(--top) var(--edge) 0; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; flex-shrink: 0; min-height: 47px; }
.brand[aria-disabled="true"] { opacity: .55; cursor: wait; }
.brand img { display: block; width: 116px; height: auto; }
.shelf-link { min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 5px; font-size: 14px; font-weight: 550; white-space: nowrap; }
.shelf-link[aria-current="page"], .shelf-link:active { background: var(--panel); }
.app-footer { width: min(100%, 700px); margin-inline: auto; padding: 0 var(--edge) var(--bottom); }
.app-footer a, .previous-library { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); font-size: 13px; text-underline-offset: .18em; }
.previous-library { margin-top: 4px; }
.page { padding: 30px var(--edge) calc(28px + var(--bottom)); }
.hero { position: relative; isolation: isolate; display: flex; align-items: flex-end; min-height: 295px; height: clamp(295px, 43svh, 395px); padding: clamp(20px, 5vw, 32px); overflow: hidden; border-radius: 8px; background: #303030; }
.hero img, .hero::after { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; object-position: center 42%; }
.hero::after { content: ""; z-index: -1; background: linear-gradient(0deg, rgb(0 0 0 / .80), rgb(0 0 0 / .30) 43%, transparent 74%); }
.hero h1 { max-width: 11em; color: #fff; text-wrap: balance; }
.lead { margin-top: 10px; color: var(--muted); line-height: 1.65; word-break: keep-all; overflow-wrap: anywhere; }
.hero + .lead { margin: 20px 0 18px; }
.note { font-size: 13px; line-height: 1.65; color: var(--muted); word-break: keep-all; }
.button { display: inline-flex; min-height: 50px; width: 100%; align-items: center; justify-content: center; gap: 10px; padding: 10px 15px; border: 1px solid #666; border-radius: 5px; background: transparent; font-weight: 600; text-align: center; line-height: 1.35; }
.button.primary { border-color: var(--ink); background: var(--ink); color: #1a1a1a; }
.button svg, .item-icon { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.button:active, .group-row:active { opacity: .76; }
.actions { display: grid; gap: 10px; margin-top: 24px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.count { color: var(--muted); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.group-list { display: grid; border-top: 1px solid var(--line); }
.group-row { display: flex; align-items: center; gap: 13px; min-height: 76px; width: 100%; text-align: left; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.group-copy { display: grid; flex: 1; min-width: 0; gap: 3px; }
.group-name, .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-name { font-weight: 600; }
.group-meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.folder { display: grid; place-items: center; width: 40px; height: 40px; background: #2c2c2c; border-radius: 4px; }
.go { width: 16px; color: var(--muted); }
.field { display: grid; gap: 8px; margin-top: 26px; }
.field label { font-size: 14px; font-weight: 600; }
.field input { width: 100%; min-height: 49px; border: 1px solid #606060; border-radius: 5px; padding: 10px 12px; background: var(--well); font-size: 16px; }
.field input[type="number"] { width: 7em; font-variant-numeric: tabular-nums; }
.field input::placeholder { color: #8e8e8e; }
.pick-row, .draft-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pick-row { margin-top: 22px; }
.pick-row h2 { font-size: 16px; }
.change-pick, .draft-nav button { min-height: 44px; padding: 7px 3px; font-size: 14px; }
.change-pick { text-decoration: underline; text-underline-offset: 3px; }
.draft-nav button:disabled { opacity: .35; cursor: default; }
.draft-photos { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; padding: 0; list-style: none; }
.draft-tile { display: grid; place-items: center; aspect-ratio: 1; background: var(--well); color: var(--muted); font-size: 12px; border-radius: 5px; overflow: hidden; }
.draft-tile img { display: block; width: 100%; height: 100%; object-fit: contain; }
.draft-filename { display: block; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; margin-top: 4px; }
.import-status { min-height: 24px; margin-top: 12px; color: var(--muted); font-size: 14px; }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; min-width: 0; }
.stage-head h1 { font-size: 19px; font-weight: 600; letter-spacing: -.045em; }
.meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.meter { height: 2px; margin-bottom: 12px; background: #383838; }
.meter span { display: block; width: var(--percent); height: 100%; background: var(--ink); }
.work { display: flex; flex-direction: column; height: calc(100vh - 58px - var(--top)); height: calc(100svh - 58px - var(--top)); min-height: 430px; padding: 14px var(--edge) var(--bottom); }
.frame, .compare-stage { min-height: 0; flex: 1; }
.frame { position: relative; display: grid; place-items: center; overflow: hidden; border-radius: 5px; background: var(--well); }
.swipe-frame { touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none; }
.frame img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: contain; transform: translateX(var(--drag, 0px)); -webkit-user-drag: none; }
.unavailable { max-width: 25ch; padding: 12px; text-align: center; color: var(--muted); font-size: 13px; }
.photo-info { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 0; }
.file-name { font-size: 15px; font-weight: 550; }
.photo-info .meta { flex: none; }
.vote-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.swipe-hint { padding-top: 7px; font-size: 12px; text-align: center; color: var(--muted); }
.transition { padding-top: clamp(38px, 10vh, 95px); }
.transition .meta { display: block; margin-bottom: 10px; }
.compare-stage { position: relative; }
.compare-stage .frame { position: absolute; inset: 0; }
.compare-expand { position: absolute; z-index: 1; right: 6px; top: 6px; display: grid; width: 44px; height: 44px; padding: 0; place-items: center; color: #fff; border-radius: 50%; background: rgb(15 15 15 / 72%); }
.compare-expand .item-icon { width: 20px; height: 20px; }
.compare-controls .photo-info { justify-content: flex-start; align-items: center; gap: 10px; }
.compare-cut { flex: none; font-size: 14px; }
.compare-controls .file-name { color: var(--muted); }
.compare-group { flex: none; max-width: 35%; margin-inline-start: auto; }
.pair-decisions { display: grid; grid-template-columns: 1fr 1fr auto; align-items: center; gap: 8px; margin-top: 8px; }
.pair-decisions .button { min-width: 0; min-height: 44px; padding: 6px 8px; font-size: 14px; }
.final-undo { display: inline-flex; flex: none; justify-content: center; align-items: center; gap: 4px; min-height: 44px; padding: 5px 6px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.final-undo .item-icon { width: 16px; height: 16px; }
.final-undo:disabled { cursor: default; opacity: .4; }
.result-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.final-difference { margin-top: 5px; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.list-exports { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result-followup { display: grid; gap: 8px; }
.coffee-link { border-color: transparent; color: var(--muted); font-size: 15px; text-decoration: none; }
.loading { padding: 40px var(--edge); color: var(--muted); }
#sheet-dialog, .file-dialog, #coffee-dialog { width: min(500px, calc(100% - 24px)); max-height: calc(100dvh - 36px); padding: 14px 16px 18px; color: var(--ink); background: var(--panel); border: 1px solid #494949; border-radius: 8px; overscroll-behavior: contain; }
#sheet-dialog::backdrop, .file-dialog::backdrop, #coffee-dialog::backdrop { background: rgb(0 0 0 / .75); }
#coffee-dialog { width: min(26rem, calc(100% - 24px)); }
.coffee-qr { display: block; width: min(100%, 20rem, 60dvh); height: auto; margin: 10px auto 16px; background: white; }
#coffee-instructions { text-align: center; font-size: 15px; }
.coffee-qr-trigger { display: none; }
.file-dialog .full-photo { display: block; width: 100%; max-height: 60vh; max-height: 60dvh; object-fit: contain; background: var(--well); }
.photo-viewer { --photo-height: min(60dvh, max(9rem, calc(100dvh - 16rem))); }
.viewer-stage { display: grid; place-items: center; height: var(--photo-height); background: var(--well); }
.viewer-stage .full-photo { height: 100%; min-height: 0; max-height: 100%; }
.photo-navigation { display: flex; align-items: center; justify-content: space-between; padding-top: 4px; }
.photo-navigation button { display: grid; place-items: center; width: 48px; height: 44px; border: 1px solid var(--line); border-radius: 5px; }
.photo-navigation button:disabled { opacity: .3; cursor: default; }
.photo-navigation svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.photo-position { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.download-status:not(:empty), .download-note:not(:empty) { margin: 10px 0; }
.file-dialog .sheet-actions { margin-top: 12px; }
.sheet-head, .sheet-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-head h2 { overflow-wrap: anywhere; }
.sheet-close, .sheet-nav button { padding: 8px 4px; min-height: 44px; min-width: 44px; }
.sheet-nav { font-size: 14px; border-top: 1px solid var(--line); }
.sheet-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.sheet-nav button:disabled { opacity: .4; cursor: default; }
.sheet-preview { display: block; width: 100%; max-height: 48vh; max-height: 48dvh; object-fit: contain; background: var(--well); -webkit-touch-callout: default; }
.sheet-status:not(:empty), .sheet-hint { margin: 10px 0; }
.sheet-actions { display: grid; gap: 8px; }
.sheet-actions a { text-decoration: none; }
#notice { position: fixed; z-index: 5; left: 50%; bottom: calc(var(--bottom) + 5px); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 5px; color: #161616; background: #f1efeb; font-size: 14px; pointer-events: none; box-shadow: 0 3px 18px #0003; }
#notice:empty { display: none; }
@media (orientation: landscape) and (min-width: 540px) {
  .work { min-height: 270px; }
}
@media (orientation: landscape) and (min-width: 540px) and (max-height: 540px) {
  .compare-work { display: grid; grid-template-columns: minmax(0, 1fr) minmax(170px, 32%); grid-template-rows: auto 2px minmax(0, 1fr); column-gap: 16px; min-height: 240px; padding: 6px max(var(--edge), env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(var(--edge), env(safe-area-inset-left)); }
  .compare-stage { grid-column: 1; grid-row: 1 / -1; }
  .compare-work > .stage-head, .compare-work > .meter, .compare-controls { grid-column: 2; }
  .compare-work > .meter { margin: 0; }
  .compare-work .stage-head { flex-wrap: wrap; gap: 2px 8px; margin-bottom: 6px; }
  .compare-controls .photo-info { padding-block: 4px; }
  .compare-controls .vote-actions, .compare-controls .pair-decisions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .compare-controls .button { min-height: 44px; padding-inline: 4px; font-size: 14px; }
  .compare-controls .final-undo { grid-column: 1 / -1; }
  .compare-controls .swipe-hint { display: none; }
}
@media (min-width: 720px) {
  .topbar { border-inline: 1px solid var(--line); }
  main { border-inline: 1px solid var(--line); min-height: calc(100svh - 58px - var(--top)); }
}
@media (min-width: 700px) and (min-height: 550px) {
  :root {
    --edge: max(clamp(24px, 3vw, 40px), env(safe-area-inset-left), env(safe-area-inset-right));
    --tablet-bar-height: 64px;
  }
  body { display: flex; flex-direction: column; min-height: 100svh; }
  .topbar, main, .app-footer { width: 100%; max-width: 1440px; border-inline: 0; }
  .topbar { flex: none; min-height: calc(var(--tablet-bar-height) + var(--top)); }
  main { flex: 1 0 auto; min-height: 0; }
  .transition { width: min(100%, 44rem); margin-inline: auto; padding-top: clamp(48px, 12svh, 128px); }
  .transition .meta { overflow-wrap: anywhere; }
  .transition .actions { display: flex; flex-wrap: wrap; }
  .transition .actions .button { width: auto; min-width: 13rem; }
}
