:root {
  color-scheme: light;
  --cream: #fffaf0;
  --ink: #191c18;
  --muted: #525b54;
  --line: #d8ddd5;
  --green: #285744;
  --focus: #2159b2;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1160px, calc(100% - 32px));
  margin-inline: auto;
}

a { color: var(--green); text-underline-offset: 3px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  z-index: 200;
  inset: 10px auto auto 12px;
  padding: 10px 16px;
  transform: translateY(-150%);
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.skip-link:focus { transform: none; }
#workspace, #preview-heading, .help h2, #faq { scroll-margin-top: 100px; }

.intro { padding-block: clamp(24px, 4vw, 48px) 22px; }
.breadcrumb { font-size: .875rem; font-weight: 650; }
h1, h2, h3 { margin: 0; line-height: 1.16; letter-spacing: -.025em; }
h1 { margin-top: 8px; font-size: clamp(2rem, 5vw, 3.15rem); }
h2 { font-size: clamp(1.2rem, 2vw, 1.4rem); }
h3 { font-size: 1.1rem; }

.intro-copy {
  max-width: 64ch;
  margin: 12px 0 16px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.125rem);
}

.privacy-note {
  width: fit-content;
  margin: 0;
  padding: 8px 14px;
  border: 1px solid #c9dfd0;
  border-radius: 9px;
  background: #eaf5ed;
  color: #244b38;
  font-size: .875rem;
}

.workspace { display: grid; gap: 14px; }

.panel {
  min-width: 0;
  padding: clamp(16px, 2.1vw, 24px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 12px #1928190b;
}

.panel > h2 { margin-bottom: 14px; }
.muted { color: var(--muted); font-size: .875rem; }

.drop-zone {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 16px 12px;
  border: 1.5px dashed #718579;
  border-radius: 12px;
  background: #f4f9f5;
  text-align: center;
}

.drop-zone[data-dragging="true"], .drop-zone.is-dragging {
  border-color: var(--green);
  background: #e3f2e7;
  box-shadow: inset 0 0 0 1px var(--green);
}

.drop-zone p { margin: 0; }
.drop-caption { font-weight: 680; }

.button {
  display: inline-flex;
  min-height: 44px;
  justify-content: center;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid #77857b;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: .91rem;
  font-weight: 680;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button:hover:not(:disabled) { border-color: var(--ink); background: #f5f6f3; }
.button:disabled { border-color: var(--line); background: #f1f3ef; color: var(--muted); cursor: default; }
.button-primary { padding-inline: 18px; border-color: var(--ink); background: #ffdf62; }
.button-primary:hover:not(:disabled) { background: #ffd544; }
.button-link { padding-inline: 4px; border-color: transparent; background: transparent; color: var(--green); text-decoration: underline; }
.button-link:hover:not(:disabled) { border-color: transparent; background: #eaf5ed; }

.file-details {
  padding: 13px 14px 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8faf7;
}

.drop-zone:not([hidden]) + .file-details { margin-top: 14px; }
.file-name { display: block; overflow-wrap: anywhere; }
.file-facts { display: grid; gap: 4px; margin: 8px 0 2px; color: var(--muted); font-size: .875rem; }
.file-facts > div { display: flex; gap: 6px 12px; flex-wrap: wrap; justify-content: space-between; }
.file-facts dd { margin: 0; color: var(--ink); font-weight: 600; }

.password-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.password-form label { font-weight: 650; }
.password-row { display: flex; flex-wrap: wrap; gap: 8px; }
.password-row input {
  min-width: min(100%, 11ch);
  min-height: 44px;
  flex: 1 1 12ch;
  padding: 7px 10px;
  border: 1px solid #88958b;
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}

.password-form p { margin: 0; }
.error-box, .error-text { color: #811f21; }
.error-box { margin: 12px 0 0; padding: 9px 12px; border: 1px solid #d9a5a3; border-radius: 8px; background: #fff2f0; }
.error-text:empty { display: none; }

.preview-panel { display: flex; min-height: 0; flex-direction: column; }
.preview-stage {
  display: grid;
  flex: 1 1 auto;
  min-height: 242px;
  overflow: hidden;
  place-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #edf0ec;
  text-align: center;
}

.preview-stage p { max-width: 28ch; margin: 0; color: var(--muted); }
.preview-stage canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 62vh;
  background: #fff;
  box-shadow: 0 1px 7px #26342b26;
  object-fit: contain;
}

.page-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  color: var(--muted);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.page-controls .button { min-width: 68px; padding-inline: 10px; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.conversion-options { display: grid; gap: 8px; }

.conversion-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}

.conversion-option:has(input:checked) { border-color: #668c76; background: #f1f8f2; }
.conversion-option:has(input:disabled) { cursor: default; }
.conversion-option:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.conversion-option input { width: 17px; height: 17px; flex: 0 0 auto; margin: 4px 0 0; accent-color: var(--green); }
.conversion-option strong { font-size: .94rem; }
.conversion-option small { display: block; margin-top: 2px; color: var(--muted); font-size: .875rem; line-height: 1.35; }
.scan-note { margin: 10px 0 14px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.status { margin: 8px 0 0; color: var(--muted); font-size: .875rem; }
.status:empty, .warning-list:empty { display: none; }

progress {
  display: block;
  width: 100%;
  height: 12px;
  margin-top: 9px;
  accent-color: var(--green);
}

.result-panel { margin-top: 14px; padding: 13px; border: 1px solid #bccfc0; border-radius: 10px; background: #f4faf5; }
.result-panel p { margin: 7px 0 11px; color: var(--muted); font-size: .875rem; }
.warning-list { max-height: 14rem; overflow: auto; margin: 6px 0 13px; padding: 7px 12px 7px 26px; border-radius: 6px; background: #fff4d5; color: #624008; font-size: .875rem; }
.warning-list li + li { margin-top: 4px; }

.help { max-width: 78ch; margin-block: 40px 50px; }
.help section + section { margin-top: 25px; }
.help p { margin: 8px 0; color: var(--muted); }
.help details { border-bottom: 1px solid var(--line); }
.help summary { padding-block: 11px; font-weight: 650; cursor: pointer; }
.help details p { margin: 0 0 12px; }

@media (min-width: 800px) {
  .workspace { grid-template-columns: minmax(320px, .82fr) minmax(0, 1.18fr); grid-template-rows: auto 1fr; gap: 16px; }
  .source-panel { grid-area: 1 / 1; }
  .preview-panel { grid-area: 1 / 2 / 3 / 3; }
  .convert-panel { grid-area: 2 / 1; }
}

@media (max-width: 460px) {
  .page-controls { gap: 4px; }
  .page-controls .button { min-width: 0; }
}
