:root { font-family: Arial, sans-serif; color: #111; background: #fff; font-size: 16px; }
* { box-sizing: border-box; }
body { margin: 0; overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; min-width: 0; max-width: 100%; }
button, .button { white-space: normal; overflow-wrap: anywhere; text-align: center; }
[hidden] { display: none !important; }
button, .button { border: 1px solid #111; background: #fff; padding: .72rem 1rem; cursor: pointer; border-radius: 0; }
button:hover, .button:hover { background: #eee; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #555; outline-offset: 2px; }
button:disabled { opacity: .5; cursor: wait; }
.primary { background: #111; color: #fff; }
.primary:hover { background: #333; }
.top { border-bottom: 1px solid #111; }
.top-inner { max-width: 1120px; margin: auto; padding: 1rem 1.25rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.brand { border: 0; padding: 0; font-weight: 700; text-align: left; }
.top-caption, .muted { color: #555; }
.top-caption { font-size: .875rem; }
.shell { max-width: 1120px; margin: 0 auto; padding: 2.5rem 1.25rem 5rem; }
.heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.5rem; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: -.04em; line-height: 1.1; margin: 0; }
h2 { font-size: 1.25rem; margin: 0 0 1rem; }
p { line-height: 1.5; }
.eyebrow { color: #555; font-size: .875rem; margin: 0 0 .5rem; }
.toolbar, .actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.panel { border: 1px solid #111; padding: 1.2rem; margin-bottom: 1.2rem; }
.subtle { background: #f2f2f2; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.section-head h2 { margin: 0; }
.project-list { border-top: 1px solid #111; }
.project-row { border-bottom: 1px solid #aaa; padding: 1rem 0; display: flex; align-items: center; gap: 1rem; justify-content: space-between; }
.project-open { border: 0; text-align: left; padding: .3rem 0; font-weight: 700; flex: 1; }
.empty { padding: 2rem 0; color: #555; }
input[type=text], input[type=number], input[type=date], select, textarea { width: 100%; padding: .7rem; border: 1px solid #777; background: #fff; border-radius: 0; font: inherit; }
label { display: block; font-size: .875rem; font-weight: 700; margin-bottom: .35rem; }
.create { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: .6rem; }
.pages { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,240px),1fr)); gap: .8rem; }
.page { border: 1px solid #aaa; min-width: 0; }
.page img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; display: block; background: #eee; }
.page-info { padding: .7rem; overflow-wrap: anywhere; }
.page-info p { margin: 0 0 .6rem; font-size: .875rem; }
.file-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.notice { border-left: 4px solid #555; background: #eee; padding: .8rem 1rem; margin: 1rem 0; }
.row-card, .finding { border-top: 1px solid #bbb; padding: 1rem 0; }
details > summary { cursor: pointer; font-weight: 700; line-height: 1.5; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%,150px), 1fr)); gap: .7rem; margin: 1rem 0; }
.fields > *, .create > *, .heading > *, .section-head > *, .project-row > * { min-width: 0; }
textarea { resize: vertical; }
.row-image { max-width: 100%; max-height: 260px; object-fit: contain; background: #eee; }
.cell-preview { position: sticky; top: 0; z-index: 2; margin: 1rem 0; padding: .5rem; border: 1px solid #aaa; background: #f2f2f2; }
.cell-preview img { display: block; width: auto; max-width: min(100%, 420px); max-height: 25dvh; height: auto; margin-top: .5rem; background: white; image-rendering: auto; }
.crop-canvas { display: block; width: 100%; height: auto; border: 1px solid #111; touch-action: none; }
.scan-view { position: relative; line-height: 0; margin: 1rem 0; background: #eee; }
.scan-view img { width: 100%; height: auto; }
.cell-marker { position: absolute; border: 3px solid #ed1717; background: rgb(237 23 23 / 20%); pointer-events: none; }
.grid-scroll { overflow: auto; max-height: 65dvh; border: 1px solid #111; margin-bottom: 1rem; overscroll-behavior: contain; }
.grid-scroll canvas { display: block; width: max(100%, 1100px); height: auto; touch-action: auto; }
.status { font-size: .875rem; color: #555; }
.finding strong { display: block; margin-bottom: .3rem; }
.message { position: fixed; bottom: max(1rem,env(safe-area-inset-bottom)); right: 1rem; left: 1rem; max-width: 34rem; max-height: 35dvh; overflow-y: auto; margin-left: auto; padding: 1rem; color: #fff; background: #111; z-index: 3; }
.scanner-dialog { border: 1px solid #111; width: min(calc(100% - 1rem), 720px); max-height: calc(100vh - 1rem); max-height: calc(100dvh - 1rem); overflow: auto; overscroll-behavior: contain; padding: 1rem; }
.scanner-dialog::backdrop { background: rgb(0 0 0 / 75%); }
.camera-frame { position: relative; width: fit-content; max-width: 100%; margin-inline: auto; background: #222; line-height: 0; overflow: hidden; }
.camera-frame video { display: block; width: auto; max-width: 100%; height: auto; max-height: 55dvh; }
.camera-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.scanner-dialog .actions { margin-top: 1rem; }
@media(max-width: 600px) {
  .top-caption { display: none; }
  .top-inner { padding: .85rem max(.75rem,env(safe-area-inset-right)) .85rem max(.75rem,env(safe-area-inset-left)); }
  .shell { padding: 1.25rem max(.75rem,env(safe-area-inset-right)) calc(2rem + env(safe-area-inset-bottom)) max(.75rem,env(safe-area-inset-left)); }
  .heading { align-items: stretch; flex-direction: column; }
  .heading > button { align-self: start; }
  .panel { padding: .85rem; }
  .section-head { flex-wrap: wrap; gap: .65rem; }
  .create { grid-template-columns: minmax(0,1fr); }
  .create button { width: 100%; }
  .pages { grid-template-columns: minmax(0,1fr); }
  .toolbar > *, .actions > button { flex: 1 1 9rem; }
  .toolbar > .file-input { flex: none; }
  button, .button, input, select { min-height: 44px; }
  input[type=checkbox] { min-height: auto; flex-shrink: 0; }
  .status { overflow-wrap: anywhere; }
  .project-row { gap: .6rem; }
  .project-row > [data-archive] { flex: 0 0 auto; }
  .cell-preview { top: .25rem; padding: .4rem; }
  .scanner-dialog { padding: .75rem; }
}
