:root {
  color-scheme: light;
  --blue: #2458a6;
  --blue-dark: #173d73;
  --border: #d8dee8;
  --background: #f4f6fa;
  --text: #1d2733;
  --muted: #657184;
  --success: #287a4d;
  --danger: #b33a3a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}
.app-shell {
  width: min(980px, calc(100% - 32px));
  margin: 28px auto 56px;
}
.app-header {
  margin-bottom: 18px;
  padding: 22px 24px;
  color: #fff;
  background: var(--blue);
  border-radius: 8px;
}
.app-header h1 { margin: 0 0 6px; font-size: 24px; }
.app-header p { margin: 0; opacity: 0.88; }
.panel {
  margin-bottom: 14px;
  padding: 18px 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 17px;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.check-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
}
.check-grid label, .radio-grid label {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfc;
  cursor: pointer;
}
input[type="checkbox"], input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0 8px 0 0;
  accent-color: var(--blue);
}
.radio-grid { display: flex; gap: 8px; }
.radio-grid label { min-width: 180px; }
.inline-actions { display: flex; gap: 8px; }
.text-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
}
.primary-button, .download-button {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}
.primary-button {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
  font-weight: 700;
}
.primary-button:hover, .download-button:hover { background: var(--blue-dark); }
.primary-button:disabled { opacity: 0.55; cursor: wait; }
.progress-bar {
  height: 10px;
  overflow: hidden;
  background: #e7ebf1;
  border-radius: 99px;
}
.progress-bar div {
  width: 0;
  height: 100%;
  background: var(--blue);
  transition: width 200ms ease;
}
.count-row { display: flex; gap: 24px; color: var(--muted); }
.download-button {
  display: inline-block;
  padding: 9px 12px;
  font-size: 14px;
}
.result-card {
  display: grid;
  grid-template-columns: 150px 110px 80px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.result-card:first-child { border-top: 0; }
.result-card.error { color: var(--danger); }
.result-card.ambiguous { color: #8a6417; }
.preview {
  width: 140px;
  max-height: 180px;
  object-fit: contain;
  border: 1px solid var(--border);
  background: #fff;
}
.card-actions { display: flex; flex-direction: column; gap: 6px; }
.card-actions a { text-align: center; }
dialog {
  width: min(980px, calc(100% - 32px));
  max-height: 88vh;
  border: 0;
  border-radius: 8px;
  padding: 0;
}
.manual-dialog {
  padding: 20px;
}
.manual-pages {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  max-height: 58vh;
  overflow: auto;
  margin: 12px 0;
}
.manual-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.manual-page img {
  width: 100%;
  max-height: 170px;
  object-fit: contain;
  border: 1px solid var(--border);
}
.manual-output {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
@media (max-width: 760px) {
  .check-grid { grid-template-columns: repeat(2, 1fr); }
  .radio-grid { flex-direction: column; }
  .result-card { grid-template-columns: 1fr auto; }
  .preview { width: 100px; }
}
