:root {
  --bg: #fff;
  --surface: #fff;
  --ink: #000;
  --mute: #555;
  --line: #000;
  --accent: #000;
  --accent-ink: #fff;
  --warn: #000;
  --ok: #555;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

:root:not([data-theme="light"]) {
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000;
    --surface: #000;
    --ink: #fff;
    --mute: #aaa;
    --line: #fff;
    --accent: #fff;
    --accent-ink: #000;
    --warn: #fff;
    --ok: #aaa;
  }
}

:root[data-theme="dark"] {
  --bg: #000;
  --surface: #000;
  --ink: #fff;
  --mute: #aaa;
  --line: #fff;
  --accent: #fff;
  --accent-ink: #000;
  --warn: #fff;
  --ok: #aaa;
  color-scheme: dark;
}

html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
}

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

body {
  margin: 0;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 20px 64px;
}

h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.lede {
  max-width: 60ch;
  margin: 0 0 28px;
  color: var(--mute);
}

.ui {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#drop {
  display: block;
  min-height: 140px;
  padding: 44px 20px;
  border: 2px dashed var(--line);
  border-radius: 0;
  background: var(--surface);
  text-align: center;
  cursor: pointer;
}

#drop.over {
  border-style: solid;
}

#drop b {
  display: block;
  margin-bottom: 4px;
  font-size: 1.1rem;
}

#drop span {
  color: var(--mute);
  font-size: 0.92rem;
}

#file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 24px;
  margin: 18px 0;
  color: var(--mute);
  font-size: 0.92rem;
}

.opts label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.opts input[type=range] {
  min-height: 32px;
  vertical-align: middle;
  accent-color: var(--ink);
}

button,
.btn {
  display: inline-block;
  min-height: 44px;
  padding: 10px 16px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--bg);
  font: 600 0.95rem system-ui, sans-serif;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

button.ghost {
  background: transparent;
  color: var(--ink);
}

button:focus-visible,
.btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

button[disabled] {
  opacity: 0.45;
  cursor: default;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 20px 0 10px;
}

.item {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface);
}

.item .thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  overflow: hidden;
}

.item .thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pdf-mark {
  font: 700 0.82rem system-ui, sans-serif;
  letter-spacing: 0.08em;
}

.name {
  font: 600 0.95rem system-ui, sans-serif;
  overflow-wrap: anywhere;
}

.meta {
  margin-top: 2px;
  color: var(--mute);
  font: 0.84rem system-ui, sans-serif;
}

.found {
  color: var(--warn);
  font-weight: 600;
}

.clean {
  color: var(--ok);
}

.err {
  color: var(--warn);
  font: 0.9rem system-ui, sans-serif;
}

@media (max-width: 600px) {
  main {
    padding: 24px max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left));
  }

  h1 {
    font-size: 1.6rem;
  }

  .lede {
    margin-bottom: 20px;
    font-size: 0.95rem;
  }

  #drop {
    padding: 36px 16px;
  }

  .opts label {
    width: 100%;
  }

  .opts input[type=range] {
    flex: 1;
    min-width: 0;
  }

  .bar {
    flex-direction: column;
    align-items: stretch;
  }

  .bar > span:last-child {
    display: flex;
    gap: 10px;
  }

  .bar button {
    flex: 1;
  }

  .item {
    grid-template-columns: 72px 1fr;
    gap: 12px;
  }

  .item .thumb {
    width: 72px;
    height: 72px;
  }

  .item .act {
    grid-column: 1 / -1;
  }

  .item .act .btn {
    display: block;
    width: 100%;
  }
}
