:root {
  --ink: #152e33;
  --blue: #144f99;
  --paper: #f8f8f4;
  --line: #cdd4cd;
  --muted: #536466;
  --mint: #d8e9d7;
  font:
    16px/1.48 "DM Sans",
    "Helvetica Neue",
    sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
textarea {
  font: inherit;
}
button,
label.file {
  cursor: pointer;
}
button,
a {
  color: inherit;
}
button {
  background: none;
  border: none;
}
a {
  text-decoration: none;
}
[hidden] {
  display: none !important;
}
header {
  border-bottom: 1px solid var(--line);
  background: #f1f3ed;
}
.bar,
main {
  max-width: 1160px;
  margin: auto;
  padding: 0 clamp(20px, 5vw, 72px);
}
.bar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -1.2px;
}
.brand i {
  width: 24px;
  height: 29px;
  background: var(--blue);
  border-radius: 2px;
  transform: rotate(-8deg);
  position: relative;
  box-shadow: 4px 3px 0 #9cb5ce;
}
.brand i:after {
  content: "";
  position: absolute;
  inset: 7px 5px;
  background: repeating-linear-gradient(0deg, transparent 0 4px, #fff 4px 5px);
}
nav {
  display: flex;
  gap: 8px;
}
nav button {
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 20px;
}
nav .selected {
  background: var(--ink);
  color: white;
}
main {
  padding-bottom: 64px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font:
    normal clamp(38px, 5.3vw, 72px) / 1.04 "Instrument Serif",
    Georgia,
    serif;
  letter-spacing: -0.05em;
  margin: 14px 0;
}
h1 span {
  color: var(--blue);
}
h2 {
  font-size: 24px;
  letter-spacing: -0.04em;
  line-height: 1.2;
}
h3 {
  font-size: 17px;
}
.intro {
  padding: clamp(32px, 6vw, 68px) 0 30px;
  max-width: 690px;
}
.intro p,
.capture p,
article p,
.review-head p,
.sheet p,
small,
dialog p {
  color: var(--muted);
}
.eyebrow,
.section-label {
  font:
    600 11px "IBM Plex Mono",
    monospace;
  letter-spacing: 0.13em;
}
.eyebrow {
  color: var(--blue);
}
.eyebrow span {
  padding: 0 5px;
}
.desk {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 34px;
}
.capture,
.source,
.checkpanel,
details,
.listItem,
.previewgrid article {
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  overflow: hidden;
}
.finder {
  height: 200px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background-color: #d6e3db;
  background-image: radial-gradient(#90aba240 0.9px, transparent 1px);
  background-size: 5px 5px;
}
.paper {
  width: 204px;
  padding: 20px 16px;
  background: #fffef8;
  transform: rotate(-8deg);
  box-shadow: 5px 8px 13px #253b3027;
  line-height: 1.2;
  border-bottom: 4px double #bbb;
}
.paper b {
  font:
    700 14px "Courier New",
    monospace;
  color: #33493f;
}
.paper span,
.paper small {
  display: block;
  font: 9px monospace;
  margin: 8px 0;
}
.ruled {
  height: 48px;
  background:
    repeating-linear-gradient(#8c9e9055 0 1px, transparent 1px 10px),
    repeating-linear-gradient(90deg, #8c9e9055 0 1px, transparent 1px 53px);
}
.frame {
  position: absolute;
  width: 250px;
  height: 150px;
  background:
    linear-gradient(var(--blue), var(--blue)) left top/19px 2px,
    linear-gradient(var(--blue), var(--blue)) left top/2px 19px,
    linear-gradient(var(--blue), var(--blue)) right bottom/19px 2px,
    linear-gradient(var(--blue), var(--blue)) right bottom/2px 19px;
  background-repeat: no-repeat;
}
.capture-copy {
  padding: 24px 28px;
}
.capture-copy p {
  margin-top: 6px;
}
.buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0 10px;
}
.primary,
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  padding: 11px 17px;
  font-size: 15px;
  font-weight: 650;
  min-height: 44px;
}
.primary {
  background: var(--blue);
  color: white;
}
.secondary {
  border: 1px solid #aebbb8;
  background: white;
}
.file {
  position: relative;
  overflow: hidden;
}
.file input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.file:focus-within,
button:focus-visible,
a:focus-visible {
  outline: 3px solid #4991cf;
  outline-offset: 2px;
}
aside {
  padding: 12px 0;
}
.sheet {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.sheet i {
  width: 36px;
  height: 42px;
  border: 1px solid #9fb5a5;
  background: #e8f1e7;
  color: #2d6047;
  display: grid;
  place-items: center;
  border-radius: 3px;
  font-style: normal;
}
.sheet p {
  font-size: 14px;
}
.sheet b {
  font-size: 17px;
}
.section-label {
  margin-bottom: 10px;
}
.back {
  margin: 24px 0 4px;
  padding: 8px 0;
  color: var(--blue);
}
.previewgrid,
.reviewgrid {
  display: grid;
  grid-template-columns: 1fr 1.24fr;
  gap: 20px;
  margin: 22px 0;
}
.source,
.previewgrid article,
.checkpanel {
  padding: 18px;
}
.source img {
  width: 100%;
  object-fit: contain;
  max-height: 65vh;
}
.source {
  align-self: start;
  text-align: center;
}
.original {
  position: sticky;
  top: 12px;
}
.previewgrid article {
  align-self: start;
}
.previewgrid article p {
  margin: 12px 0;
}
.notice {
  font-size: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}
.review-head h1 {
  font-size: clamp(32px, 5vw, 48px);
  overflow-wrap: anywhere;
}
.checkpanel {
  background: #eef3e9;
}
.checkpanel h2 {
  font-size: 21px;
}
.checkpanel ul {
  padding-left: 18px;
}
.checkpanel li {
  margin: 8px 0;
}
.checkpanel p {
  font-size: 14px;
}
.checkpanel details {
  background: transparent;
}
.loader {
  width: 36px;
  height: 36px;
  border: 3px solid #d5e2de;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 1s infinite linear;
  margin-top: 80px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
details {
  margin-top: 10px;
  padding: 12px;
}
summary {
  font-weight: 650;
  cursor: pointer;
  padding: 4px;
}
.field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  margin: 12px 0;
}
.field span {
  grid-column: 1/-1;
  color: var(--muted);
  font-size: 13px;
}
.field input,
textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid #aebbb8;
  border-radius: 4px;
  padding: 9px;
  color: var(--ink);
  background: white;
}
.field button {
  color: var(--blue);
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.listItem {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
  margin: 10px 0;
  padding: 15px;
}
.listItem small {
  display: block;
}
.close {
  float: right;
  font-size: 25px;
}
.secondary:disabled,
.primary:disabled {
  opacity: 0.55;
}
#error {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 8px;
  background: #792f28;
  color: white;
  width: max-content;
  max-width: 90vw;
  z-index: 8;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: min(94vw, 620px);
  max-height: 90dvh;
  color: var(--ink);
}
dialog::backdrop {
  background: #122b31aa;
}
dialog p {
  margin: 9px 0;
}
#crop {
  position: relative;
  touch-action: none;
  width: fit-content;
  max-width: 100%;
  margin: 12px auto;
}
#crop img {
  display: block;
  max-width: 100%;
  max-height: 43vh;
}
#rectangle {
  position: absolute;
  border: 2px solid #187eb3;
  background: #479aff26;
  pointer-events: none;
}
.clearNote {
  font-size: 14px;
  color: var(--muted);
}
@media (max-width: 760px) {
  .desk,
  .previewgrid,
  .reviewgrid {
    grid-template-columns: 1fr;
  }
  .bar {
    height: 62px;
  }
  .brand {
    font-size: 21px;
  }
  nav {
    gap: 0;
  }
  nav button {
    padding: 7px 10px;
  }
  .finder {
    height: 156px;
  }
  .paper {
    transform: rotate(-8deg) scale(0.86);
  }
  .frame {
    width: 210px;
    height: 124px;
  }
  .capture-copy {
    padding: 18px;
  }
  .desk {
    gap: 18px;
  }
  .sheet {
    padding: 13px 0;
  }
  .review-head {
    align-items: start;
    flex-direction: column;
  }
  .original {
    position: static;
  }
  .original img {
    max-height: 220px;
  }
  .intro {
    padding-top: 32px;
  }
  .buttons {
    gap: 8px;
  }
  .primary,
  .secondary {
    padding: 10px 13px;
  }
  .source {
    padding: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .loader {
    animation: none;
  }
}
.inspect,
.textAction {
  display: block;
  text-align: left;
  font-size: 14px;
  color: var(--blue);
  padding: 8px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
#home, #review { max-width: 740px; margin-inline: auto; }
#home .capture-copy { padding: 0; }
#home .intro { padding-bottom: 0; }
#articles { margin-block: 24px 12px; }
.article-list { margin: 10px 0; }
.article-list details { margin: 0; border-radius: 0; border-bottom: none; padding: 0 12px; }
.article-list details:first-of-type { border-radius: 8px 8px 0 0; }
.article-list details:last-of-type { border-bottom: 1px solid var(--line); border-radius: 0 0 8px 8px; }
.article-list summary { display: grid; grid-template-columns: minmax(0,1fr) auto 1em; align-items: center; gap: 8px; min-height: 48px; overflow-wrap: anywhere; }
.article-list summary strong { color: var(--blue); font-size: .92rem; max-width: 32vw; }
.article-list summary::after { content: "⌄"; text-align: center; }
.article-list details[open] > summary::after { transform: rotate(180deg); }
#checks { margin-block: 14px; }
#checks h2 { color: #88410c; }
.verified { padding: 10px 12px; background: var(--mint); border-radius: 6px; }
.original-photo img { display: block; width: 100%; max-height: 65vh; object-fit: contain; }
#fields summary, .original-photo summary { min-height: 44px; align-content: center; }
@media (max-width: 760px) {
  #home .buttons { display: grid; }
  #export, #upload { width: 100%; }
  #previewImg { max-height: 36dvh; }
  #review h1 { overflow-wrap: anywhere; }
}
#cameraDialog { width: min(95vw, 520px); }
#cameraView { display: block; width: 100%; max-height: 54dvh; background: var(--ink); border-radius: 8px; margin-block: 12px; }
.scan-card { background: white; border: 1px solid var(--line); padding: 15px; border-radius: 8px; margin-block: 12px; }
.scan-card progress { display: block; width: 100%; height: 12px; accent-color: var(--blue); margin-block: 10px; }
.sheet-heading { display: flex; justify-content: space-between; padding: 8px 32px 8px 12px; margin-top: 10px; background: var(--mint); font-weight: 650; }
.sheet-heading + .article-list { margin-top: 0; }
