/* ============================================================
   Screenshot Stitcher — clean utility UI, light + dark themes
   ============================================================ */

/* ---------- Theme tokens ---------- */
:root,
[data-theme="light"] {
  --bg: #fafaf8;
  --bg-elevated: #ffffff;
  --bg-sunken: #f1f1ee;
  --ink: #1a1a1a;
  --ink-soft: #4a4a48;
  --ink-muted: #8a8a86;
  --rule: #e2e2dc;
  --rule-strong: #c9c9c2;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #dbeafe;
  --accent-on: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #15803d;
  --success-soft: #dcfce7;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --loading-veil: rgba(20, 20, 20, 0.55);
  --loading-fg: #ffffff;
}

[data-theme="dark"] {
  --bg: #15171a;
  --bg-elevated: #1c1f23;
  --bg-sunken: #101216;
  --ink: #ececec;
  --ink-soft: #b8b8b6;
  --ink-muted: #7a7a78;
  --rule: #2a2d31;
  --rule-strong: #3a3d41;
  --accent: #4f8cf7;
  --accent-hover: #6a9cf8;
  --accent-soft: #1e2a44;
  --accent-on: #0b0d10;
  --danger: #f87171;
  --danger-soft: #3a1d1d;
  --success: #4ade80;
  --success-soft: #14321f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.45);
  --loading-veil: rgba(0, 0, 0, 0.7);
  --loading-fg: #ececec;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--ink);
  scrollbar-color: var(--rule-strong) var(--bg);
  scrollbar-width: thin;
}

body.body,
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, system-ui, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  width: 100%;
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.15s ease, color 0.15s ease;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
header#pageHeader {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--rule);
  padding: 0.9rem 1.25rem;
}
.masthead {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.masthead .logo { margin: 0; padding: 0; text-align: left; }
.masthead .logo h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.2;
  color: var(--ink);
}

.theme-toggle {
  font-family: inherit;
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  padding: 0.42rem 0.75rem;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  line-height: 1;
}
.theme-toggle:hover { background: var(--bg-sunken); border-color: var(--ink-muted); }
.theme-toggle .glyph { display: block; }
.theme-toggle .glyph-light { display: none; }
.theme-toggle .glyph-dark  { display: block; }
[data-theme="dark"] .theme-toggle .glyph-light { display: block; }
[data-theme="dark"] .theme-toggle .glyph-dark  { display: none; }

/* ---------- Status messages ---------- */
.toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.message {
  pointer-events: auto;
  margin: 1rem auto 0;
  padding: 0.7rem 1.1rem;
  font-size: 14px;
  background: var(--bg-elevated);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  width: max-content;
  max-width: min(560px, calc(100vw - 2rem));
  text-align: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.message.hidden { opacity: 0; transform: translateY(-12px); pointer-events: none; }
#errMsg {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}
#normalMsg {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- Article wrapper ---------- */
.wrapper {
  position: relative;
  width: 100%;
  padding: 1.5rem 1.25rem 3rem;
  display: flex;
  justify-content: center;
  margin: 0;
}
#detail {
  width: 100%;
  max-width: 1080px;
  background: transparent;
  padding: 0;
  text-align: left;
}
section { margin: 1.5rem 0; }

/* Hidden but still focusable (the file input is reached via its label) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Section heads ---------- */
h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.6rem;
  letter-spacing: -0.005em;
}

/* ---------- News dispatch ---------- */
#infomation {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
}
#infomation h3 { margin-bottom: 0.3rem; font-size: 0.92rem; color: var(--ink-soft); }
#infomation .markdown-body {
  font-size: 0.92rem;
  color: var(--ink-soft);
  background: transparent;
  margin: 0;
  padding: 0;
}

.intro {
  margin: 0 0 1rem;
  font-size: 0.98rem;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- Drop zone ---------- */
#dragDropArea {
  position: relative;
  background: var(--bg-elevated);
  border: 2px dashed var(--rule-strong);
  border-radius: 10px;
  padding: 2.4rem 1.2rem;
  text-align: center;
  margin: 0.5rem 0 1rem;
  transition: background 0.15s, border-color 0.15s;
}
#dragDropArea.dragover {
  background: var(--accent-soft);
  border-color: var(--accent);
  border-style: solid;
}
#dragDropArea p {
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--ink-muted);
  margin: 0.35rem 0;
}
#dragDropArea .drag-drop-info {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.35rem;
  line-height: 1.3;
}
.uploadButtons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1rem;
}
#btnChooseFiles {
  background: var(--accent);
  color: var(--accent-on);
  border-color: var(--accent);
  font-weight: 600;
}
#btnChooseFiles:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
#fileInput:focus-visible + #btnChooseFiles { outline: 2px solid var(--accent); outline-offset: 2px; }
.uploadTip {
  margin: -0.4rem 0 1rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
  text-align: center;
}
/* Drag-and-drop and Ctrl+V don't apply on touch screens */
@media (hover: none) and (pointer: coarse) {
  .drag-drop-hint { display: none; }
  #dragDropArea { padding: 1.4rem 1rem; }
}

/* ---------- Preview grid ---------- */
#previewArea { margin: 0.6rem 0 1rem; }
.previewCaption {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.previewCaption strong { color: var(--ink); font-weight: 600; }
.container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
}
.containerItem {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-elevated);
  padding: 4px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: opacity 0.12s, box-shadow 0.12s;
}
.containerItem:active { cursor: grabbing; }
.containerItem.dragging { opacity: 0.4; }
.containerItem.drag-over-before { box-shadow: -3px 0 0 var(--accent), var(--shadow-sm); }
.containerItem.drag-over-after  { box-shadow:  3px 0 0 var(--accent), var(--shadow-sm); }
/* Fixed-height frame so portrait (phone) and landscape (PC) shots line up */
.thumbFrame {
  position: relative;
  height: 140px;
  background: var(--bg-sunken);
  border-radius: 3px;
  overflow: hidden;
}
.previewImage {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  margin: 0;
  cursor: zoom-in;
  pointer-events: auto;
}
.thumbNumber {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 1;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 24px;
  text-align: center;
  pointer-events: none;
}
.thumbRemove {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 1;
  width: 32px;
  height: 32px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s;
}
.thumbRemove:hover { background: var(--danger); }
.thumbMove { display: flex; gap: 4px; }
.thumbMoveBtn {
  flex: 1;
  height: 32px;
  border: 1px solid var(--rule-strong);
  border-radius: 5px;
  background: var(--bg-sunken);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.thumbMoveBtn:hover:not(:disabled) { background: var(--bg-elevated); border-color: var(--ink-muted); }
.thumbMoveBtn:disabled { opacity: 0.35; cursor: default; }
.thumbRemove:focus-visible,
.thumbMoveBtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* The tap flash lingers on a button that becomes disabled by its own tap */
.thumbRemove,
.thumbMoveBtn { -webkit-tap-highlight-color: transparent; }
/* Bigger touch targets on phones and tablets */
@media (pointer: coarse) {
  .thumbRemove { width: 40px; height: 40px; top: 0; right: 0; }
  .thumbMoveBtn { height: 44px; }
}

/* Lightbox preview */
#previewModal {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  padding: 2rem;
}
#previewModal.hidden { display: none; }
#previewModalImage {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
}
/* ---------- Options ---------- */
#formOption {
  margin: 0.8rem 0;
  padding: 0.6rem 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.formItem {
  display: flex;
  flex-direction: row;
  margin: 0;
  justify-content: flex-start;
  align-items: center;
}
.formItem > label {
  font-size: 0.85rem;
  font-weight: 500;
  flex: 0 0 auto;
  margin-right: 0.7rem;
  color: var(--ink-soft);
}
.optionsTitle {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.inputWrap { display: flex; flex-direction: row; flex-wrap: wrap; }
.inputWrap ul {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.considerWrap { display: inline-block; }
.checkInput { display: none; }
.checkLabel {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem 0.4rem 1.95rem;
  font-size: 0.88rem;
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  border-radius: 6px;
  position: relative;
  transition: background 0.12s, border-color 0.12s;
  margin: 0;
}
.checkLabel::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 8px;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  background: var(--bg);
  border: 1.5px solid var(--rule-strong);
  border-radius: 3px;
  transition: background 0.12s, border-color 0.12s;
}
.checkLabel::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 12px;
  width: 5px;
  height: 9px;
  margin-top: -7px;
  border: solid var(--accent-on);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  opacity: 0;
  transition: opacity 0.12s;
}
.checkLabel:hover { border-color: var(--ink-muted); }
input[type=checkbox]:checked + .checkLabel {
  border-color: var(--accent);
  background: var(--accent-soft);
}
input[type=checkbox]:checked + .checkLabel::before {
  background: var(--accent);
  border-color: var(--accent);
}
input[type=checkbox]:checked + .checkLabel::after { opacity: 1; }

/* ---------- Buttons ---------- */
.buttonArea {
  text-align: center;
  margin: 1.2rem 0 0.4rem;
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}
.btn {
  display: inline-block;
  padding: 0.55rem 1.2rem;
  margin: 0;
  font-family: inherit;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--bg-elevated);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  vertical-align: baseline;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  box-shadow: var(--shadow-sm);
  line-height: 1.4;
}
.btn:hover {
  background: var(--bg-sunken);
  border-color: var(--ink-muted);
}
.btn:active { transform: translateY(1px); }
#btnSubmit {
  background: var(--accent);
  color: var(--accent-on);
  border-color: var(--accent);
  padding: 0.65rem 1.6rem;
  font-size: 1rem;
  font-weight: 600;
}
#btnSubmit:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-on);
}
.btn.weak { /* explicit weak styling: same as default for now */ }
.btn.disable {
  background: var(--bg-sunken);
  color: var(--ink-muted);
  border-color: var(--rule);
  cursor: not-allowed;
  box-shadow: none;
}
.btn.disable:hover {
  background: var(--bg-sunken);
  color: var(--ink-muted);
  border-color: var(--rule);
}
.btn.disable:active { transform: none; }
#btnSubmit.disable {
  background: var(--bg-sunken);
  color: var(--ink-muted);
  border-color: var(--rule);
}
#btnReset { /* default styling */ }

/* ---------- Result panel ---------- */
#overview {
  text-align: center;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}
.resultTitle {
  margin: 0 0 0.3rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
}
#SaveBtnArea {
  margin-top: 0.6rem;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.overviewTitle {
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink-muted);
  margin: 1rem 0;
}
.overviewSubTitle {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  margin: 0.5rem 0;
}
/* Scrolls sideways when the result is shown at actual size, so the page doesn't */
#outputImageWrap {
  overflow-x: auto;
}
#outputImage {
  max-width: 100%;
  height: auto;
  margin: 0.6rem auto;
  border: 1px solid var(--rule);
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  cursor: zoom-in;
}
#outputImage.full-width-image {
  max-width: none;
  cursor: zoom-out;
}
/* Already shown at actual size: nothing to toggle */
#outputImage.no-toggle { cursor: default; }

#overviewOCRResult {
  text-align: left;
  margin: 1.2rem auto 0.6rem;
  padding: 0.9rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  max-width: 720px;
}
#overviewOCRResult p { font-size: 0.9rem; color: var(--ink-soft); margin: 0 0 0.45rem; line-height: 1.5; }
#overviewOCRResult .overviewSubTitle { color: var(--ink); margin-bottom: 0.4rem; }
#overviewOCRResult a { color: var(--accent); }
#outputOCRResult {
  width: 100%;
  font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  resize: vertical;
}

/* ---------- Markdown bodies ---------- */
.markdown-body {
  font-family: inherit;
  font-size: 0.94rem;
  line-height: 1.6;
  color: var(--ink-soft);
  background: transparent;
  width: inherit;
  margin: 0;
}
.markdown-body p { margin: 0 0 0.85rem; }
.markdown-body p b {
  display: block;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.2rem;
  font-size: 0.95rem;
}
.markdown-body h4 {
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
}
.markdown-body ul {
  list-style: disc;
  margin: 0 0 0.85rem;
  padding-left: 1.2rem;
}
.markdown-body li { margin: 0.1rem 0; }
.markdown-body a { color: var(--accent); }
.markdown-body a:hover { text-decoration: underline; }

/* ---------- Collapsibles ---------- */
details.collapsible {
  border-top: 1px solid var(--rule);
  padding-top: 0.45rem;
}
details.collapsible > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0 0.5rem;
  margin: 0;
}
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::before {
  content: "▸";
  font-size: 0.85em;
  color: var(--ink-muted);
  transition: transform 0.15s ease;
  display: inline-block;
}
details.collapsible[open] > summary::before { transform: rotate(90deg); }
details.collapsible > summary > h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  display: inline-block;
}
details.collapsible > summary:hover > h3 { color: var(--accent); }
details.collapsible > .markdown-body {
  margin-top: 0.5rem;
  padding-left: 1.1rem;
}
#updateLog details.collapsible > .markdown-body p {
  font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--ink-soft);
}

/* ---------- Footer ---------- */
footer {
  position: relative;
  max-width: 1080px;
  margin: 2rem auto 1.5rem;
  padding: 1.2rem 1.25rem;
  border-top: 1px solid var(--rule);
  text-align: center;
}
.resources {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem 1.4rem;
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin: 0;
}
.resources a {
  color: var(--ink-soft);
  text-decoration: none;
}
.resources a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Loading overlay ---------- */
#loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--loading-veil);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  width: 100vw;
  height: 100vh;
  transition: opacity 0.3s;
  color: var(--loading-fg);
}
#percentage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(56px, 12vh, 120px);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--loading-fg);
  text-align: center;
  line-height: 1;
}

.sk-fading-circle {
  margin: 0;
  position: absolute;
  top: 22vh;
  left: 50%;
  transform: translateX(-50%);
  width: 14vh;
  height: 14vh;
}
.sk-fading-circle .sk-circle {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
}
.sk-fading-circle .sk-circle:before {
  content: '';
  display: block;
  margin: 0 auto;
  width: 13%;
  height: 13%;
  background-color: var(--loading-fg);
  border-radius: 100%;
  animation: sk-circleFadeDelay 1.2s infinite ease-in-out both;
}
.sk-fading-circle .sk-circle2  { transform: rotate(30deg);  }
.sk-fading-circle .sk-circle3  { transform: rotate(60deg);  }
.sk-fading-circle .sk-circle4  { transform: rotate(90deg);  }
.sk-fading-circle .sk-circle5  { transform: rotate(120deg); }
.sk-fading-circle .sk-circle6  { transform: rotate(150deg); }
.sk-fading-circle .sk-circle7  { transform: rotate(180deg); }
.sk-fading-circle .sk-circle8  { transform: rotate(210deg); }
.sk-fading-circle .sk-circle9  { transform: rotate(240deg); }
.sk-fading-circle .sk-circle10 { transform: rotate(270deg); }
.sk-fading-circle .sk-circle11 { transform: rotate(300deg); }
.sk-fading-circle .sk-circle12 { transform: rotate(330deg); }
.sk-fading-circle .sk-circle2:before  { animation-delay: -1.1s; }
.sk-fading-circle .sk-circle3:before  { animation-delay: -1.0s; }
.sk-fading-circle .sk-circle4:before  { animation-delay: -0.9s; }
.sk-fading-circle .sk-circle5:before  { animation-delay: -0.8s; }
.sk-fading-circle .sk-circle6:before  { animation-delay: -0.7s; }
.sk-fading-circle .sk-circle7:before  { animation-delay: -0.6s; }
.sk-fading-circle .sk-circle8:before  { animation-delay: -0.5s; }
.sk-fading-circle .sk-circle9:before  { animation-delay: -0.4s; }
.sk-fading-circle .sk-circle10:before { animation-delay: -0.3s; }
.sk-fading-circle .sk-circle11:before { animation-delay: -0.2s; }
.sk-fading-circle .sk-circle12:before { animation-delay: -0.1s; }
@keyframes sk-circleFadeDelay {
  0%, 39%, 100% { opacity: 0; }
  40%           { opacity: 1; }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .masthead { flex-direction: row; }
  .masthead .logo h1 { font-size: 1rem; }
  .wrapper { padding: 1rem 0.9rem 2rem; }
  .btn { padding: 0.5rem 1rem; }
  #btnSubmit { padding: 0.6rem 1.3rem; }

  /* Action bars pinned to the bottom of the screen: Generate/Reset while screenshots are
     loaded (until you scroll past the form), and Save/Copy while scrolling the result */
  #top:has(.containerItem) .buttonArea,
  #SaveBtnArea {
    position: sticky;
    bottom: 0;
    z-index: 5;
    flex-wrap: nowrap;
    margin-left: -0.9rem;
    margin-right: -0.9rem;
    padding: 0.6rem 0.9rem calc(0.6rem + env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid var(--rule);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  }
  #top:has(.containerItem) .buttonArea .btn,
  #SaveBtnArea .btn { flex: 1; padding-left: 0.5rem; padding-right: 0.5rem; }
  #top:has(.containerItem) #btnSubmit { flex: 2; }
  /* Put Save/Copy below the image so the bar follows the result as you scroll it */
  #overview { display: flex; flex-direction: column; }
  #SaveBtnArea { order: 1; }
  #overviewOCRResult { order: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
