:root {
  color-scheme: light;
  --bg: #f3f6f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #5e6d7e;
  --line: #d5dee7;
  --soft-line: #edf1f5;
  --accent: #1267b1;
  --accent-dark: #0d4f88;
  --accent-soft: #edf6ff;
  --ok: #0f7b4f;
  --ok-soft: #eef9f4;
  --danger: #b42318;
  --danger-dark: #8f1c13;
  --danger-soft: #fff1ef;
  --warn-bg: #fff7e6;
  --warn-line: #edbd59;
  --radius: 10px;
  --shadow: 0 8px 28px rgba(28, 50, 72, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 22px auto 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 850;
  letter-spacing: 0.01em;
}

.topbar p,
.pdf-card-head p,
.folder-meta,
.result-header p,
.section-heading > p {
  margin: 4px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.app-version {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 9px;
  border-radius: 7px;
  background: #e9edf1;
  color: #5d6976;
  font-size: 12px;
  font-weight: 750;
}

.status-pill {
  min-width: 108px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  text-align: center;
  font-weight: 800;
  color: var(--muted);
}

.status-pill.busy {
  border-color: #75aeda;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.status-pill.error {
  border-color: #e7a29b;
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill.success {
  border-color: #91cbb2;
  background: var(--ok-soft);
  color: var(--ok);
}

.status-pill.cancelled {
  border-color: #b8c2cc;
  background: #f7f8fa;
  color: #53606d;
}

.workflow-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.workflow-guide li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
}

.workflow-guide span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 850;
}

.workspace {
  display: grid;
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px;
  box-shadow: 0 1px 2px rgba(28, 50, 72, 0.03);
}

.panel h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.section-heading > p {
  max-width: 520px;
  text-align: right;
}

.step-label {
  margin: 0 0 2px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.pdf-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.pdf-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.pdf-card.selected {
  border-color: #91cbb2;
  box-shadow: 0 0 0 2px rgba(15, 123, 79, 0.07);
}

.pdf-card.has-error,
.save-panel.has-error {
  border-color: #e7a29b;
  box-shadow: 0 0 0 2px rgba(180, 35, 24, 0.06);
}

.pdf-card.dragover {
  outline: 3px solid rgba(18, 103, 177, 0.22);
  outline-offset: 2px;
}

.pdf-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.pdf-card-head h3 {
  margin: 1px 0 0;
  font-size: 18px;
}

.pdf-card-head p {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.pdf-card-head p.selected {
  color: var(--ok);
  font-weight: 750;
}

.file-role {
  display: inline-block;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
}
.file-requirement {
  margin: 2px 0 4px;
  color: #9a5a00;
  font-size: 13px;
  font-weight: 800;
}


.file-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pdf-preview-wrap {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  border: 1px dashed #99aabd;
  border-radius: var(--radius);
  background: #f7f9fb;
  cursor: pointer;
}

.pdf-card.selected .pdf-preview-wrap {
  cursor: zoom-in;
}

.pdf-preview-expand {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(17, 39, 62, 0.86);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  pointer-events: none;
}

.pdf-preview-wrap:hover,
.pdf-preview-wrap:focus-visible,
.pdf-preview-wrap.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.pdf-preview-wrap:focus-visible {
  box-shadow: 0 0 0 3px rgba(18, 103, 177, 0.18);
}

.pdf-preview {
  display: block;
  width: 100%;
  height: 360px;
  border: 0;
  background: #f7f9fb;
  pointer-events: none;
}

.pdf-preview.empty {
  display: none;
}

.pdf-preview-empty {
  display: grid;
  min-height: 360px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  place-content: center;
}

.pdf-preview-empty strong,
.pdf-preview-empty span {
  display: block;
}

.pdf-preview-empty strong {
  color: var(--text);
  font-size: 17px;
}

.pdf-preview-empty span {
  margin-top: 8px;
}

.pdf-preview:not(.empty) ~ .pdf-preview-empty {
  display: none;
}
.pdf-preview-drop {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 2px dashed transparent;
  background: rgba(237, 246, 255, 0.9);
  color: var(--accent-dark);
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, border-color 160ms ease;
}

body.drop-active .pdf-preview-drop {
  opacity: 1;
  pointer-events: auto;
}

body.drop-active .pdf-preview-wrap {
  border-color: #8bb9e0;
}

.pdf-preview-wrap.dragover .pdf-preview-drop {
  border-color: var(--accent);
}

.save-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.save-options label,
.color-group label,
.toggle,
.check-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-weight: 700;
}

.save-options label:has(input:checked),
.color-group label:has(input:checked),
.toggle:has(input:checked) {
  border-color: #8bb9e0;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.folder-meta {
  overflow-wrap: anywhere;
}

.folder-meta.confirmed {
  color: var(--ok);
  font-weight: 750;
}

.settings-panel {
  display: grid;
  gap: 0;
}

.mark-row {
  display: grid;
  grid-template-columns: 48px minmax(420px, 1fr) 180px;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--soft-line);
}

.mark-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.mark-title {
  font-weight: 850;
  font-size: 20px;
}

.color-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mark-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.color-group.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.swatch.red {
  background: #dc0000;
}

.swatch.blue {
  background: #0070c0;
}

.swatch.green {
  background: #009650;
}

.swatch.multi {
  background: linear-gradient(135deg, #dc0000 0 33%, #0070c0 33% 66%, #009650 66% 100%);
}

input[type="checkbox"],
input[type="radio"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.count-field {
  display: grid;
  gap: 4px;
  justify-self: start;
  color: var(--muted);
  font-weight: 750;
}

.count-field > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.count-field small,
details summary span {
  padding: 1px 6px;
  border-radius: 999px;
  background: #eef1f4;
  color: #667482;
  font-size: 11px;
  font-weight: 800;
}

.count-field input {
  width: 76px;
}

input[type="number"],
input[type="text"],
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  background: #fff;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(18, 103, 177, 0.22);
  outline-offset: 2px;
}

.helper-text {
  margin: 2px 0 0 60px;
  color: var(--muted);
  font-size: 13px;
}

.field-error {
  margin: 0;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 750;
}

details summary {
  cursor: pointer;
  font-weight: 850;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.detail-grid label:not(.check-line) {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.progress-panel {
  display: grid;
  gap: 12px;
  border-color: #8bb9e0;
  box-shadow: var(--shadow);
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.progress-head h2 {
  margin: 0;
}

.progress-head p {
  margin: 4px 0 0;
  color: var(--accent-dark);
  font-weight: 850;
}

.progress-note {
  margin: 0;
  color: var(--muted);
}

.progress-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.progress-step {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 20px;
  gap: 8px;
  align-items: center;
  min-height: 50px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
}

.progress-step span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #e8eef4;
  font-weight: 850;
}

.progress-step strong {
  overflow-wrap: anywhere;
}

.progress-step.active {
  border-color: #8bb9e0;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.progress-step.active.running {
  animation: quietPulse 1.5s ease-in-out infinite;
}

.progress-step.active span {
  background: var(--accent);
  color: #fff;
}

.progress-step.done {
  border-color: #9fd0b9;
  color: var(--ok);
  background: var(--ok-soft);
}

.progress-step.done span {
  background: var(--ok);
  color: #fff;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(18, 103, 177, 0.22);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}

.action-bar {
  position: static;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow);
}

.readiness {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.readiness span {
  padding: 5px 8px;
  border-radius: 7px;
  background: #f1f3f5;
  color: #667482;
  font-size: 12px;
  font-weight: 800;
}

.readiness span.ready {
  background: var(--ok-soft);
  color: var(--ok);
}

.action-buttons,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

button,
.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.download:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  min-height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

button.secondary:hover:not(:disabled) {
  border-color: #8bb9e0;
  background: var(--accent-soft);
}

button.quiet {
  min-height: 34px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
}

button.quiet:hover:not(:disabled) {
  background: #f0f3f6;
  color: var(--text);
}

button.danger {
  background: var(--danger);
}

button.danger:hover:not(:disabled) {
  background: var(--danger-dark);
}

.busy .input-panel,
.busy .settings-panel,
.busy .save-panel,
.busy .details-panel {
  opacity: 0.72;
}

.result-panel {
  margin-top: 14px;
  box-shadow: var(--shadow);
}

.download-location-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f2f7fc;
  color: var(--muted);
  font-size: 13px;
}

body.modal-open {
  overflow: hidden;
}

.pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  padding: 24px;
  background: rgba(16, 30, 45, 0.72);
  place-items: center;
}

.pdf-modal-dialog {
  display: grid;
  width: min(96vw, 1500px);
  height: min(94vh, 1050px);
  padding: 16px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.pdf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pdf-modal-header h2,
.pdf-modal-header p,
.pdf-modal-help {
  margin: 0;
}

.pdf-modal-header h2 {
  max-width: min(75vw, 1100px);
  overflow: hidden;
  font-size: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-modal-frame {
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1f4;
}

.pdf-modal-help {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.result-header h2 {
  margin: 0;
  font-size: 21px;
}

.result-header p {
  overflow-wrap: anywhere;
}

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 8px;
  color: var(--accent-dark);
  font-weight: 750;
}

.warnings {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  background: var(--warn-bg);
}

.warnings strong {
  display: block;
  margin-bottom: 6px;
}

.warnings ul {
  margin: 0;
  padding-left: 20px;
}

.log-details {
  margin-top: 12px;
}

pre {
  max-height: 320px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101820;
  color: #e8edf2;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes quietPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(18, 103, 177, 0);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(18, 103, 177, 0.13);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .spinner,
  .progress-step.active.running {
    animation: none;
  }

  .pdf-preview-drop,
  .pdf-card {
    transition: none;
  }
}

@media (max-width: 880px) {
  .shell {
    width: min(100vw - 20px, 1180px);
    margin-top: 14px;
  }

  .topbar,
  .section-heading,
  .result-header,
  .progress-head,
  .action-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-heading > p {
    text-align: left;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .workflow-guide,
  .pdf-grid,
  .detail-grid,
  .progress-steps {
    grid-template-columns: 1fr;
  }

  .workflow-guide {
    gap: 6px;
  }

  .workflow-guide li {
    min-height: 44px;
  }

  .mark-row {
    grid-template-columns: 1fr;
  }

  .pdf-modal {
    padding: 8px;
  }

  .pdf-modal-dialog {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    padding: 10px;
  }

  .pdf-modal-header h2 {
    max-width: 58vw;
    font-size: 16px;
  }

  .helper-text {
    margin-left: 0;
  }


  .action-buttons,
  .result-actions {
    width: 100%;
  }

  .action-buttons button,
  .result-actions button {
    flex: 1 1 auto;
  }
}

@media (max-width: 560px) {
  .panel {
    padding: 14px;
  }

  .pdf-card-head {
    flex-direction: column;
  }

  .file-actions,
  .action-buttons,
  .result-actions {
    width: 100%;
    justify-content: stretch;
  }

  .file-actions button,
  .action-buttons button,
  .result-actions button {
    width: 100%;
  }
}

/* Cloud版固有の表示 */
.privacy-note {
  margin: 18px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.logout-button {
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(430px, 100%);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-panel h1 { margin: 0 0 8px; font-size: 32px; }
.login-panel > p { color: var(--muted); }
.login-panel form,
.login-panel label { display: grid; gap: 10px; }
.login-panel input { width: 100%; }
.login-error { min-height: 1.5em; color: var(--danger) !important; }

@media (max-width: 700px) {
  .topbar-actions { justify-content: flex-start; }
  .logout-button { min-height: 32px; }
}