/* Large, high-contrast, low-clutter. Theme: blue, purple and green.
   Every text colour pair below has at least 7:1 contrast (WCAG AAA). */
:root {
  --font: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --bg: #f4f2fb;
  --surface: #ffffff;
  --text: #16142a;
  --muted: #45405e;
  --border: #7b7499;
  --heading: #33176e;
  --accent: #1b45ab;          /* links: blue */
  --accent-hover: #12337f;
  --primary: #5b2bb3;         /* main buttons: purple */
  --primary-hover: #47208f;
  --primary-text: #ffffff;
  --accent-text: #ffffff;
  --green: #12805c;
  --header-from: #1e3a8a;     /* header: blue to purple */
  --header-to: #4c1d95;
  --header-text: #ffffff;
  --stripe: linear-gradient(90deg, #2f5fd0, #7a3fd6, #19a378);
  --focus: #ffbf00;
  --ok-bg: #e1f4ea;   --ok-text: #0d5a40;
  --err-bg: #fde6e4;  --err-text: #8a1308;
  --info-bg: #e6edfc; --info-text: #1a3d8f;
  --wait-bg: #efe8fb; --wait-text: #4a2690;
  --welcome-bg: #e3f5ee; --welcome-text: #0d4a3a;
  --tint: #f3eefc;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14122a;
    --surface: #1d1a36;
    --text: #f3f1ff;
    --muted: #cdc8e6;
    --border: #9d96bf;
    --heading: #e2d4ff;
    --accent: #9fbcff;
    --accent-hover: #c4d5ff;
    --primary: #c3aaff;
    --primary-hover: #d6c5ff;
    --primary-text: #14122a;
    --accent-text: #14122a;
    --green: #5fd3a3;
    --header-from: #1c2f73;
    --header-to: #3b1a78;
    --stripe: linear-gradient(90deg, #6f95ff, #b08cff, #5fd3a3);
    --ok-bg: #12352c;   --ok-text: #b9f0d8;
    --err-bg: #3d1410;  --err-text: #ffc9c2;
    --info-bg: #172a55; --info-text: #cfdcff;
    --wait-bg: #2c1f52; --wait-text: #e2d4ff;
    --welcome-bg: #12352c; --welcome-text: #b9f0d8;
    --tint: #241f45;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 125%; } /* 20px base; respects the user's own browser zoom */

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  letter-spacing: 0.01em;
  color: var(--text);
  background: var(--bg);
}

h1, h2 { line-height: 1.25; margin: 0 0 1rem; color: var(--heading); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.35rem; }
p { margin: 0 0 0.75rem; }

a { color: var(--accent); text-underline-offset: 0.2em; }
a:hover { color: var(--accent-hover); }

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

.wrap { max-width: 46rem; margin: 0 auto; padding: 0 1rem; }

.skip-link {
  position: absolute; left: 1rem; top: -4rem;
  background: var(--surface); padding: 0.5rem 1rem; z-index: 10;
}
.skip-link:focus { top: 1rem; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header: blue-to-purple band with a blue/purple/green stripe under it */
.site-header {
  background: linear-gradient(120deg, var(--header-from), var(--header-to));
  color: var(--header-text); border-bottom: 6px solid transparent;
  border-image: var(--stripe) 1;
}
.site-header a, .site-header .link-button { color: var(--header-text); }
.site-header a:hover, .site-header .link-button:hover { color: var(--header-text); text-decoration-thickness: 3px; }

/* Welcome message */
.welcome { background: var(--welcome-bg); color: var(--welcome-text); margin-bottom: 1.5rem; }
.welcome p { margin: 0 auto; padding-top: 0.85rem; padding-bottom: 0.85rem; font-size: 1.05rem; font-weight: 700; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; min-height: 4rem; }
.brand { font-weight: 700; font-size: 1.4rem; letter-spacing: 0.02em; text-decoration: none; }
.header-nav { display: flex; align-items: center; gap: 1.25rem; }
.header-nav form { margin: 0; }
.link-button {
  font: inherit; color: var(--accent); background: none; border: 0; padding: 0;
  text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer;
}

main { padding-bottom: 3rem; }
main:focus { outline: none; }

.card {
  background: var(--stripe) top / 100% 6px no-repeat, var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card.narrow { max-width: 28rem; margin-left: auto; margin-right: auto; }

/* Messages */
.messages { margin-bottom: 1.5rem; }
.message { padding: 0.85rem 1rem; border-radius: var(--radius); border-left: 6px solid currentColor; font-weight: 700; }
.message-success { background: var(--ok-bg); color: var(--ok-text); }
.message-error { background: var(--err-bg); color: var(--err-text); }
.message-info { background: var(--info-bg); color: var(--info-text); }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 1.1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
label { font-weight: 700; }
.hint { color: var(--muted); margin: 0; font-size: 0.9rem; }
input[type="text"], input[type="password"] {
  font: inherit; color: var(--text); background: var(--surface);
  border: 2px solid var(--border); border-radius: 8px;
  padding: 0.65rem 0.8rem; min-height: 3rem; width: 100%;
}
.checkbox { display: flex; align-items: center; gap: 0.6rem; font-weight: 400; cursor: pointer; }
.checkbox input { width: 1.4rem; height: 1.4rem; margin: 0; }

.button {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-weight: 700; text-decoration: none;
  min-height: 3rem; padding: 0.6rem 1.4rem;
  border-radius: 8px; border: 2px solid transparent; cursor: pointer;
}
.button-primary { background: var(--primary); color: var(--primary-text); }
.button-primary:hover { background: var(--primary-hover); color: var(--primary-text); }
.button-quiet { background: transparent; color: var(--text); border-color: var(--border); }
.button-quiet:hover { background: var(--bg); }
.button[disabled] { opacity: 0.6; cursor: wait; }

/* Upload */
.file-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.35rem; text-align: center; cursor: pointer;
  min-height: 12rem; padding: 1.5rem;
  border: 3px dashed var(--primary); border-radius: var(--radius);
  background: var(--tint); margin-bottom: 1rem;
}
.dropzone:hover, .dropzone.is-dragging { border-color: var(--green); border-style: solid; background: var(--ok-bg); }
.file-input:focus-visible + .dropzone { outline: 4px solid var(--focus); outline-offset: 3px; }
.dropzone-icon { color: var(--green); }
.dropzone-title { font-size: 1.35rem; font-weight: 700; color: var(--primary); }
.dropzone-hint { font-weight: 400; color: var(--muted); }

.js .file-input + .dropzone ~ #upload-button { display: none; }

.upload-progress progress { width: 100%; height: 1.25rem; accent-color: var(--green); }
.upload-progress p { font-weight: 700; margin-top: 0.5rem; }

/* Document list */
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc {
  display: grid; grid-template-columns: 1fr auto; gap: 0.5rem 1rem; align-items: center;
  padding: 1rem 0; border-top: 1px solid var(--border);
}
.doc:first-child { border-top: 0; padding-top: 0; }
.doc-name { font-weight: 700; margin: 0; overflow-wrap: anywhere; }
.doc-meta { color: var(--muted); margin: 0; font-size: 0.9rem; }
.status { margin: 0; padding: 0.25rem 0.75rem; border-radius: 999px; font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.status-ready { background: var(--ok-bg); color: var(--ok-text); }
.status-failed { background: var(--err-bg); color: var(--err-text); }
.status-converting { background: var(--info-bg); color: var(--info-text); }
.status-waiting { background: var(--wait-bg); color: var(--wait-text); }
.doc-actions { grid-column: 1 / -1; display: flex; gap: 0.75rem; flex-wrap: wrap; }
.doc-actions form { margin: 0; }
.empty { color: var(--muted); }

@media (max-width: 30rem) {
  html { font-size: 112.5%; }
  .card { padding: 1rem; }
  .doc { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Code entry */
.code-input {
  font: inherit; font-size: 2rem; font-weight: 700; letter-spacing: 0.35em; text-align: center;
  color: var(--text); background: var(--surface);
  border: 2px solid var(--border); border-radius: 8px; padding: 0.5rem; width: 100%;
}
.muted { color: var(--muted); font-weight: 400; }

/* Admin */
.account-list, .event-list { list-style: none; margin: 0; padding: 0; }
.account { padding: 1rem 0; border-top: 1px solid var(--border); }
.account:first-child { border-top: 0; padding-top: 0; }
.account .status { display: inline-block; margin-left: 0.5rem; vertical-align: middle; }
.danger-zone { margin-top: 0.5rem; }
.danger-zone summary {
  display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0.3rem 1rem;
  border: 2px solid var(--border); border-radius: 8px; cursor: pointer; font-weight: 700;
}
.danger-zone[open] summary { margin-bottom: 1rem; }
.danger-zone form { padding: 1rem; border: 2px solid var(--err-text); border-radius: var(--radius); }
.button-danger { background: var(--err-text); color: var(--surface); }
.button-danger:hover { filter: brightness(1.15); }
.event { display: flex; flex-direction: column; padding: 0.6rem 0; border-top: 1px solid var(--border); }
.event:first-child { border-top: 0; }
.event-warn .event-what { color: var(--err-text); font-weight: 700; }

/* Upload options and conversion status */
.options { margin-bottom: 1rem; }
.options summary { cursor: pointer; font-weight: 700; color: var(--primary); min-height: 2.5rem; display: flex; align-items: center; gap: 0.4rem; }
.options[open] { padding: 0 0 0.5rem; }
.options .field { margin-top: 0.75rem; }
.doc-progress { margin: 0; color: var(--info-text); font-weight: 700; }

/* Conversion bar: fills by stage; a light band sweeps across so it visibly moves between updates. */
.doc-work { grid-column: 1 / -1; display: grid; gap: 0.4rem; }
.work-bar {
  position: relative; display: block; height: 1.25rem; overflow: hidden;
  border: 2px solid var(--info-text); border-radius: 999px; background: var(--info-bg);
}
.work-bar progress {
  -webkit-appearance: none; appearance: none; display: block;
  width: 100%; height: 100%; border: 0; background: transparent; color: var(--green);
}
.work-bar progress::-webkit-progress-bar { background: transparent; }
.work-bar progress::-webkit-progress-value { background: var(--green); border-radius: 999px; transition: width 0.6s ease; }
.work-bar progress::-moz-progress-bar { background: var(--green); border-radius: 999px; }
.work-bar::after {
  content: ""; position: absolute; inset: 0; width: 40%;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.55), transparent);
  animation: work-sweep 1.6s ease-in-out infinite;
}
.doc-work-waiting .work-bar { border-color: var(--wait-text); background: var(--wait-bg); }
.doc-work-waiting .work-bar::after { animation-duration: 2.8s; background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.7), transparent); }
.doc-work-waiting .doc-progress { color: var(--wait-text); }
@keyframes work-sweep {
  from { transform: translateX(-100%); }
  to { transform: translateX(250%); }
}
@media (prefers-color-scheme: dark) {
  .work-bar::after { background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.3), transparent); }
}
.doc-note { grid-column: 1 / -1; margin: 0; padding: 0.5rem 0.75rem 0.5rem 1.75rem; background: var(--wait-bg); color: var(--wait-text); border-radius: 8px; font-size: 0.9rem; }
.doc-note-error { padding-left: 0.75rem; background: var(--err-bg); color: var(--err-text); }
