:root {
  color-scheme: light;
  --ink: #111;
  --paper: #f6f6f2;
  --line: #111;
  --soft-line: #b8b8b3;
  --muted: #555;
  --wash: #e8e8e2;
  --success: #d9ead7;
  --error: #f2d8d5;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  line-height: 1.45;
}
.shell { width: min(100% - 32px, 760px); margin: 0 auto; padding: 34px 0 28px; }
.masthead { border-bottom: 3px solid var(--line); padding-bottom: 24px; }
.masthead.compact { padding-bottom: 20px; }
.eyebrow, .section-label {
  margin: 0 0 8px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
h1 { margin: 0; font-size: clamp(3.2rem, 15vw, 6rem); letter-spacing: -.07em; line-height: .9; }
h2 { margin: 0 0 8px; font-size: clamp(1.5rem, 6vw, 2.25rem); line-height: 1.05; }
.status { display: flex; align-items: center; gap: 9px; margin: 20px 0 0; font-weight: 700; }
.status-dot { width: 13px; height: 13px; border-radius: 50%; background: var(--ink); display: inline-block; }
.muted { color: var(--muted); margin: 0; }
.panel { background: var(--wash); border: 2px solid var(--line); padding: 22px; margin-top: 24px; }
.upload-panel form { display: grid; gap: 12px; margin-top: 22px; }
.file-picker {
  display: flex; align-items: center; min-height: 58px; padding: 12px 14px;
  background: var(--paper); border: 2px dashed var(--line); cursor: pointer; font-weight: 700;
}
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.button {
  min-height: 58px; padding: 14px 16px; border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center; gap: 12px;
  color: var(--ink); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.button-primary { background: var(--ink); color: var(--paper); }
.button-secondary { background: transparent; justify-content: flex-start; }
.button-secondary:hover, .button-secondary:focus-visible { background: var(--ink); color: var(--paper); }
.actions { display: grid; gap: 10px; margin-top: 24px; }
.button-index { font-size: .8rem; min-width: 25px; }
.arrow { margin-left: auto; font-size: 1.6rem; line-height: 1; }
.tag { margin-left: auto; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
.disabled { opacity: .48; cursor: not-allowed; }
.disabled:hover, .disabled:focus-visible { background: transparent; color: var(--ink); }
.notice { border: 2px solid var(--line); padding: 14px 16px; margin-top: 18px; }
.notice-success { background: var(--success); }
.notice-error { background: var(--error); }
.footer { display: flex; justify-content: space-between; gap: 16px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--soft-line); color: var(--muted); font-size: .85rem; }
.footer a, .back-link { color: var(--ink); font-weight: 700; }
.back-link { display: inline-block; margin-bottom: 24px; text-decoration: none; }
.file-list { display: grid; gap: 10px; margin-top: 24px; }
.file-row { display: flex; align-items: center; gap: 14px; border: 2px solid var(--line); padding: 14px; background: var(--wash); }
.file-mark { font-size: .75rem; font-weight: 800; border: 2px solid var(--line); padding: 9px 6px; }
.file-details { display: grid; min-width: 0; flex: 1; }
.file-details strong { overflow-wrap: anywhere; }
.file-details span { color: var(--muted); font-size: .85rem; }
.file-state { font-size: .75rem; font-weight: 700; }
.file-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.small-button, .image-link {
  border: 2px solid var(--line); background: var(--paper); color: var(--ink);
  padding: 8px 10px; font: inherit; font-size: .75rem; font-weight: 700;
  text-decoration: none; cursor: pointer;
}
.small-button:hover, .small-button:focus-visible, .image-link:hover, .image-link:focus-visible {
  background: var(--ink); color: var(--paper);
}
.small-button:disabled { opacity: .5; cursor: wait; }
.inline-form { display: inline; }
.parse-result { flex-basis: 100%; margin: 4px 0 0; color: var(--muted); font-size: .82rem; }
.rendered-preview { display: block; margin-top: 24px; border: 2px solid var(--line); background: var(--wash); }
.rendered-preview img { display: block; width: 100%; height: auto; max-height: 65vh; object-fit: contain; }
.calibration-preview img { max-height: none; }
.calibration-data ul { margin-bottom: 0; padding-left: 22px; }
.slot-sync-form { display: grid; gap: 10px; }
.slot-sync-form h2 { margin-bottom: 0; }
.recognised-form { display: grid; gap: 12px; margin-top: 24px; }
.recognised-form label { font-weight: 700; }
.recognised-form textarea {
  width: 100%; min-height: 240px; padding: 14px; border: 2px solid var(--line);
  background: var(--paper); color: var(--ink); font: inherit; resize: vertical;
}
.recognised-actions, .task-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.task-summary {
  display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0;
}
.task-summary span { border: 2px solid var(--line); padding: 10px 12px; }
.tasks-form { display: grid; gap: 18px; }
.task-list { display: grid; gap: 10px; }
.task-editor {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  border: 2px solid var(--line); padding: 10px;
}
.task-editor input[type="text"] {
  min-width: 0; border: 0; border-bottom: 2px solid var(--line);
  background: transparent; color: var(--ink); font: inherit; padding: 8px 2px;
}
.task-selected { width: 20px; height: 20px; accent-color: var(--ink); }
.delete-task { border: 0; background: transparent; color: var(--ink); font: inherit; cursor: pointer; text-decoration: underline; }
.microsoft-panel { display: grid; gap: 14px; border: 2px solid var(--line); padding: 16px; margin: 24px 0; background: var(--wash); }
.microsoft-status { margin: 0; }
.send-form { display: grid; gap: 10px; }
.send-form label { font-weight: 700; }
.send-form select, .microsoft-panel select {
  min-height: 52px; padding: 10px; border: 2px solid var(--line);
  background: var(--paper); color: var(--ink); font: inherit;
}
.disconnect-form { margin-top: 4px; }
.send-results { display: grid; gap: 10px; list-style: none; padding: 0; margin: 24px 0; }
.send-result { display: grid; grid-template-columns: 28px 1fr; gap: 8px; border: 2px solid var(--line); padding: 12px; }
.send-result small { grid-column: 2; color: var(--muted); }
.send-result.sent { background: var(--success); }
.send-result.failed { background: var(--error); }
.send-result.skipped { background: var(--wash); }
.review-panel {
  flex-basis: 100%;
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--soft-line);
}
.review-panel[hidden] { display: none; }
.review-panel label { font-size: .8rem; font-weight: 700; }
.review-text {
  width: 100%;
  min-height: 130px;
  padding: 10px;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: .9rem;
  resize: vertical;
}
.extract-button { justify-self: start; }
.task-list { margin: 0; padding-left: 24px; font-size: .9rem; }
.empty-state .button { margin-top: 22px; }
.setup-secret {
  width: 100%;
  margin: 8px 0 12px;
  padding: 12px;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  overflow-wrap: anywhere;
}
@media (min-width: 600px) {
  .upload-panel form { grid-template-columns: 1fr 180px; align-items: stretch; }
  .upload-panel form .button { min-height: 100%; }
}
@media (max-width: 560px) {
  .file-row { align-items: flex-start; flex-wrap: wrap; }
  .file-actions { width: 100%; justify-content: flex-start; padding-left: 0; }
  .file-state { margin-left: auto; }
}