:root {
  --navy: #173b70;
  --blue: #1d5fab;
  --blue-hover: #164b89;
  --blue-soft: #edf5ff;
  --ink: #172235;
  --muted: #5c6979;
  --line: #d8e0e8;
  --surface: #ffffff;
  --background: #f5f7fa;
  --success: #18794e;
  --success-soft: #edf8f2;
  --warning: #8a5700;
  --warning-soft: #fff7e5;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --shadow: 0 10px 30px rgba(20, 45, 80, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--background);
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}
button, input { font: inherit; }
button { touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }
.container { width: min(1120px, calc(100% - 40px)); margin-inline: auto; }
.sr-only {
  position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important;
  margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important; border: 0 !important;
}
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; transform: translateY(-150%); background: #fff; color: var(--navy); padding: 10px 16px; border-radius: 6px; }
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid #f3b61f; outline-offset: 3px; }

.site-header { background: var(--navy); color: #fff; }
.header-inner { min-height: 94px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-block: 18px; }
.site-header h1 { margin: 0; font-size: clamp(1.3rem, 2vw, 1.65rem); line-height: 1.3; }
.site-header p { margin: 4px 0 0; color: #dce8f6; font-size: .9rem; }
.privacy-badge { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; min-height: 36px; padding: 6px 12px; border: 1px solid #ffffff55; border-radius: 99px; background: #ffffff12; font-size: .78rem; }
.privacy-badge svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.main-content { padding-block: 30px 50px; }
.steps { margin-bottom: 34px; padding: 20px 26px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.steps ol { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 0; padding: 0; }
.steps li { position: relative; display: flex; align-items: center; gap: 13px; padding: 0 28px; }
.steps li:first-child { padding-left: 0; }
.steps li:last-child { padding-right: 0; }
.steps li:not(:last-child)::after { content: ""; position: absolute; top: 50%; right: 0; width: 28px; height: 1px; background: var(--line); }
.step-number { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-weight: 800; }
.steps strong, .steps small { display: block; }
.steps strong { font-size: .9rem; line-height: 1.35; }
.steps small { margin-top: 2px; color: var(--muted); font-size: .75rem; }

.section-heading, .confirmation-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-heading { margin-bottom: 16px; }
.eyebrow { margin: 0 0 2px; color: var(--blue); font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h2 { margin: 0; font-size: clamp(1.2rem, 2vw, 1.48rem); line-height: 1.45; }
.required-note { margin: 0; color: var(--muted); font-size: .78rem; }
.required-note span { color: var(--blue); font-size: .58rem; }

.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.upload-card { min-width: 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.upload-card.is-selected { border-color: #91b9e5; }
.upload-card.has-error { border-color: #efaaa4; }
.card-heading { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 11px; margin-bottom: 16px; }
.card-number { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #fff; background: var(--navy); font-size: .85rem; font-weight: 800; }
.card-heading h3 { margin: 0; font-size: 1.05rem; line-height: 1.35; }
.card-heading p { margin: 2px 0 0; color: var(--muted); font-size: .79rem; line-height: 1.45; }
.state-label { align-self: center; padding: 3px 8px; border-radius: 99px; color: var(--muted); background: #eef1f5; font-size: .7rem; font-weight: 700; white-space: nowrap; }
.is-selected .state-label { color: var(--success); background: var(--success-soft); }
.has-error .state-label { color: var(--danger); background: var(--danger-soft); }
.drop-zone { display: flex; min-height: 228px; flex-direction: column; align-items: center; justify-content: center; gap: 7px; cursor: pointer; border: 2px dashed #b7c4d3; border-radius: 9px; background: #fbfcfd; text-align: center; transition: border-color .18s, background .18s; }
.drop-zone:hover, .drop-zone.is-dragover { border-color: var(--blue); background: var(--blue-soft); }
.upload-icon { width: 47px; height: 47px; margin-bottom: 3px; fill: none; stroke: var(--blue); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.drop-main { font-weight: 700; }
.drop-or { color: var(--muted); font-size: .75rem; }
.choose-button { display: inline-flex; min-height: 44px; align-items: center; padding: 8px 20px; border: 1px solid var(--blue); border-radius: 7px; color: var(--blue); background: #fff; font-size: .9rem; font-weight: 700; }
.file-type { color: var(--muted); font-size: .72rem; }
.selected-file { display: grid; min-height: 82px; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid #b8d8c7; border-radius: 9px; background: var(--success-soft); }
.selected-file svg, .output-file svg { width: 26px; height: 26px; fill: none; stroke: var(--success); stroke-width: 1.6; }
.selected-file strong, .selected-file small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-file strong { font-size: .84rem; }
.selected-file small { color: var(--muted); font-size: .72rem; }
.remove-file { min-height: 44px; padding: 6px 10px; border: 0; color: var(--blue); background: transparent; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: .78rem; }
.inline-error { margin: 10px 0 0; padding: 9px 11px; border-radius: 6px; color: var(--danger); background: var(--danger-soft); font-size: .8rem; }

.confirmation-panel { margin-top: 22px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.safe-label { padding: 5px 10px; border-radius: 99px; color: var(--success); background: var(--success-soft); font-size: .75rem; font-weight: 700; white-space: nowrap; }
.rule-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 22px 0 0; padding: 0; list-style: none; }
.rule-list li { display: flex; gap: 11px; min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: #fafbfc; }
.rule-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 8px; color: var(--blue); background: var(--blue-soft); font-size: .68rem; font-weight: 800; }
.rule-list strong { display: block; font-size: .86rem; }
.rule-list p { margin: 3px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.5; }
code { padding: 0 .25em; color: var(--navy); background: #e8eef6; border-radius: 3px; font-family: Consolas, monospace; }
.submit-area { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.submit-area p { margin: 0; color: var(--muted); font-size: .78rem; }
.primary-button, .secondary-button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; gap: 10px; padding: 10px 24px; border-radius: 8px; cursor: pointer; font-weight: 800; transition: background .18s, border-color .18s, opacity .18s; }
.primary-button { border: 1px solid var(--blue); color: #fff; background: var(--blue); }
.primary-button:hover:not(:disabled) { border-color: var(--blue-hover); background: var(--blue-hover); }
.primary-button:disabled { border-color: #adb7c2; color: #f5f6f7; background: #adb7c2; opacity: .8; }
.secondary-button { border: 1px solid var(--blue); color: var(--blue); background: #fff; }
.secondary-button:hover { background: var(--blue-soft); }
.text-button { min-height: 44px; padding: 7px 12px; border: 0; color: var(--blue); background: transparent; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.state-panel { max-width: 900px; margin-inline: auto; padding: clamp(24px, 4vw, 42px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.processing-panel { display: flex; flex-direction: column; align-items: center; text-align: center; }
.processing-panel > p:not(.eyebrow) { margin: 6px 0 24px; color: var(--muted); }
.spinner { width: 46px; height: 46px; margin-bottom: 14px; border: 4px solid #dce8f6; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.processing-steps { width: min(430px, 100%); margin: 0; padding: 0; list-style: none; text-align: left; }
.processing-steps li { display: flex; min-height: 48px; align-items: center; gap: 12px; margin: 6px 0; padding: 8px 12px; border-radius: 7px; color: var(--muted); }
.processing-steps li span { display: grid; place-items: center; width: 26px; height: 26px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 50%; font-size: .75rem; }
.processing-steps li.is-current { color: var(--navy); background: var(--blue-soft); font-weight: 800; }
.processing-steps li.is-current span { border-color: var(--blue); color: #fff; background: var(--blue); }
.processing-steps li.is-done { color: var(--success); }
.processing-steps li.is-done span { border-color: var(--success); color: #fff; background: var(--success); font-size: 0; }
.processing-steps li.is-done span::after { content: "✓"; font-size: .8rem; }
.progress-track { width: min(430px, 100%); height: 9px; margin: 14px 0 12px; overflow: hidden; border-radius: 99px; background: #e7ebf0; }
.progress-track span { display: block; width: 10%; height: 100%; border-radius: inherit; background: var(--blue); transition: width .35s ease; }

.result-heading, .error-heading { display: flex; align-items: center; gap: 14px; }
.result-heading p:last-child { margin: 3px 0 0; color: var(--muted); font-size: .85rem; }
.success-mark, .error-mark { display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 auto; border-radius: 50%; font-size: 1.5rem; font-weight: 900; }
.success-mark { color: var(--success); background: var(--success-soft); }
.success-text { color: var(--success); }
.summary-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 26px 0; }
.summary-grid div { padding: 14px 8px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; text-align: center; }
.summary-grid dt { color: var(--muted); font-size: .75rem; }
.summary-grid dd { margin: 0; color: var(--navy); font-size: 1.55rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.summary-grid dd::after { content: " 件"; font-size: .7rem; font-weight: 500; }
.summary-grid .has-review { border-color: #efc875; background: var(--warning-soft); }
.summary-grid .has-review dd { color: var(--warning); }
.review-details { margin-bottom: 20px; padding: 14px 16px; border: 1px solid #efc875; border-radius: 8px; background: var(--warning-soft); }
.review-details summary { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 20px; cursor: pointer; color: var(--warning); font-weight: 800; }
.review-details summary span:last-child { flex: 0 0 auto; font-size: .78rem; text-decoration: underline; }
.review-details > p { color: #674a19; font-size: .8rem; }
.review-details ul { max-height: 230px; overflow: auto; margin: 0; padding-left: 1.4em; }
.review-details li { padding: 3px 0; font-size: .82rem; }
.output-file { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; }
.output-file div { min-width: 0; }
.output-file small, .output-file strong { display: block; }
.output-file small { color: var(--muted); font-size: .7rem; }
.output-file strong { overflow-wrap: anywhere; font-size: .9rem; }
.result-actions, .error-actions { display: flex; justify-content: center; gap: 12px; margin-top: 24px; }

.error-panel { border-color: #efaaa4; }
.error-mark { color: var(--danger); background: var(--danger-soft); }
.error-text { color: var(--danger); }
.error-panel > p { margin: 20px 0 0; }
.next-action { margin-top: 18px; padding: 14px 16px; border-left: 4px solid var(--danger); border-radius: 5px; background: var(--danger-soft); }
.next-action strong { display: block; color: var(--danger); font-size: .78rem; }
.next-action p { margin: 3px 0 0; }
.error-code { color: var(--muted); font-size: .72rem; }

.site-footer { color: var(--muted); background: #e9eef4; border-top: 1px solid var(--line); }
.footer-inner { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 92px; padding-block: 18px; text-align: left; }
.footer-inner svg { width: 27px; height: 27px; flex: 0 0 auto; fill: none; stroke: var(--blue); stroke-width: 1.6; }
.footer-inner p { margin: 0; }
.footer-inner strong, .footer-inner span { display: block; }
.footer-inner strong { color: var(--ink); font-size: .82rem; }
.footer-inner span { font-size: .75rem; }

@media (max-width: 780px) {
  .container { width: min(100% - 28px, 1120px); }
  .header-inner { min-height: 86px; }
  .site-header p { display: none; }
  .privacy-badge span { max-width: 110px; line-height: 1.25; }
  .steps { padding: 16px; }
  .steps ol, .upload-grid, .rule-list { grid-template-columns: 1fr; }
  .steps ol { gap: 12px; }
  .steps li { padding: 0; }
  .steps li:not(:last-child)::after { top: auto; right: auto; bottom: -9px; left: 16px; width: 1px; height: 8px; }
  .upload-grid { gap: 14px; }
  .drop-zone { min-height: 196px; }
  .confirmation-panel { padding: 20px; }
  .confirmation-heading, .section-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
  .rule-list { gap: 8px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-grid div:last-child { grid-column: span 2; }
  .result-actions, .error-actions { flex-direction: column; }
  .result-actions button, .error-actions button, .submit-area .primary-button { width: 100%; }
}

@media (max-width: 430px) {
  .header-inner { align-items: flex-start; flex-direction: column; gap: 10px; }
  .privacy-badge { align-self: flex-start; }
  .privacy-badge span { max-width: none; }
  .main-content { padding-top: 20px; }
  .card-heading { grid-template-columns: auto 1fr; }
  .state-label { grid-column: 2; justify-self: start; }
  .selected-file { grid-template-columns: auto minmax(0, 1fr); }
  .remove-file { grid-column: 1 / -1; justify-self: stretch; border-top: 1px solid #cce3d7; }
  .safe-label { white-space: normal; }
  .state-panel { padding: 22px 16px; }
  .result-heading, .error-heading { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
