:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d8dee8;
  --soft: #eef2f6;
  --accent: #1769e0;
  --accent-strong: #0f4fae;
  --success: #157347;
  --warning: #a15c00;
  --danger: #b42318;
  --shadow: 0 14px 40px rgba(20, 31, 51, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input { font: inherit; }

button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

.prepare-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(40px, env(safe-area-inset-bottom));
}

.prepare-hero {
  padding: 18px 2px 22px;
}

.eyebrow,
.step-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1,
h2,
h3,
p { overflow-wrap: anywhere; }

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 7vw, 3.4rem);
  line-height: 1.06;
  letter-spacing: -0.035em;
}

h2 { margin: 0; font-size: clamp(1.3rem, 4vw, 2rem); }
h3 { margin: 4px 0 0; font-size: 1.05rem; }

.hero-copy {
  max-width: 760px;
  margin: 14px 0 18px;
  color: var(--muted);
  line-height: 1.65;
}

.privacy-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid #b8dfcb;
  background: #effaf4;
  border-radius: 14px;
  color: #205c3d;
  line-height: 1.45;
}

.privacy-dot {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  margin-top: 5px;
  border-radius: 999px;
  background: #2f9e63;
  box-shadow: 0 0 0 5px rgba(47, 158, 99, 0.13);
}

.stepper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
  overflow-x: auto;
}

.step-chip {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.step-chip span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
}

.step-chip.is-active {
  border-color: #9fc3f7;
  background: #edf5ff;
  color: var(--accent-strong);
}

.step-chip.is-active span {
  background: var(--accent);
  color: white;
}

.step-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: clamp(16px, 4vw, 28px);
}

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

.muted { color: var(--muted); line-height: 1.55; }

.local-pill {
  border-radius: 999px;
  padding: 7px 10px;
  background: #effaf4;
  color: var(--success);
  font-weight: 800;
  white-space: nowrap;
}

.import-card {
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
  border: 2px dashed #b8c4d6;
  border-radius: 18px;
  padding: 28px 18px;
  background: #fbfcfe;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.import-card.is-dragover {
  border-color: var(--accent);
  background: #eef6ff;
  transform: translateY(-1px);
}

.import-card p { margin: 4px 0 0; color: var(--muted); }
.import-card small { color: var(--muted); max-width: 640px; line-height: 1.45; }

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.document-tools button,
.page-actions button {
  min-height: 42px;
  border-radius: 10px;
  padding: 9px 14px;
  border: 1px solid transparent;
  font-weight: 750;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.primary-button:hover:not(:disabled) { background: var(--accent-strong); }

.secondary-button,
.document-tools button,
.page-actions button,
.icon-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

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

.action-row,
.panel-footer,
.document-tools,
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-row { margin-top: 14px; justify-content: space-between; }
.panel-footer {
  margin-top: 20px;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--soft);
  padding-top: 16px;
}

.sticky-footer {
  position: sticky;
  bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.workspace-summary {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--soft);
  color: #344054;
  line-height: 1.5;
}

.message-stack { margin-top: 12px; display: grid; gap: 8px; }
.message {
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: #344054;
}
.message.is-warning { border-color: #f2cd8f; background: #fff8e8; color: #7a4700; }
.message.is-error { border-color: #f1b5b0; background: #fff2f1; color: #8c2018; }

.document-list { display: grid; gap: 14px; }
.document-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #fff;
}

.document-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}
.document-meta { margin: 6px 0 0; color: var(--muted); font-size: 0.92rem; }
.document-type {
  display: inline-block;
  color: var(--accent-strong);
  background: #edf5ff;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.75rem;
}

.document-tools { margin: 14px 0; }
.document-tools button { min-height: 36px; padding: 7px 10px; font-size: 0.88rem; }

.pdf-placeholder {
  margin-top: 14px;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-radius: 12px;
  background: var(--soft);
}
.pdf-placeholder p { margin: 5px 0 0; color: var(--muted); }
.pdf-icon {
  display: grid;
  place-items: center;
  flex: 0 0 56px;
  height: 70px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--danger);
  font-weight: 900;
}

.image-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.image-page-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 10px;
  box-shadow: 0 5px 18px rgba(25, 35, 50, 0.05);
}
.image-page-card:focus { outline: 3px solid rgba(23, 105, 224, 0.2); outline-offset: 2px; }
.image-page-card.is-dragging { opacity: 0.45; }
.image-page-card.is-drag-target { border-color: var(--accent); background: #f4f9ff; }

.page-number {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(23, 32, 51, 0.9);
  color: white;
  font-weight: 850;
}

.thumb-frame {
  height: 170px;
  border-radius: 10px;
  background: #eef1f5;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.page-thumb {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center;
  transition: transform 120ms ease;
}
.page-info { margin-top: 9px; display: grid; gap: 3px; }
.page-file-name { font-size: 0.88rem; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.page-dimensions { color: var(--muted); font-size: 0.78rem; }
.page-actions { margin-top: 9px; }
.page-actions button { min-height: 34px; padding: 5px 9px; font-size: 0.8rem; flex: 1 1 auto; }

.confirm-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 16px;
  padding: 13px 14px;
  border-radius: 12px;
  background: #fff8e8;
  border: 1px solid #f2cd8f;
  color: #674000;
  font-weight: 750;
}
.confirm-row input { margin-top: 3px; width: 18px; height: 18px; }

.empty-state {
  padding: 34px 16px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
}

.locked-panel { color: #344054; }
.locked-panel p:last-child { margin-bottom: 0; }

.analysis-results { display: grid; gap: 12px; margin: 18px 0; }
.analysis-card { border: 1px solid var(--line); border-radius: 14px; padding: 15px; background: #fff; }
.analysis-card p { color: var(--muted); }
.download-link { display: inline-flex; align-items: center; text-decoration: none; margin-top: 8px; }

.danger-text { color: var(--danger) !important; }

.page-footer {
  padding: 18px 4px 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

@media (max-width: 720px) {
  .prepare-shell { padding-left: 10px; padding-right: 10px; }
  .stepper { grid-template-columns: repeat(4, minmax(128px, 1fr)); padding-bottom: 3px; }
  .step-panel { border-radius: 15px; padding: 15px; }
  .panel-heading { display: block; }
  .local-pill { display: inline-block; margin-top: 10px; }
  .image-page-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .thumb-frame { height: 145px; }
  .page-actions button { min-width: calc(33% - 8px); }
  .panel-footer > * { flex: 1 1 auto; }
  .panel-footer button { width: 100%; }
  .sticky-footer { margin-left: -15px; margin-right: -15px; padding-left: 15px; padding-right: 15px; padding-bottom: max(2px, env(safe-area-inset-bottom)); }
}

@media (max-width: 420px) {
  .image-page-grid { grid-template-columns: 1fr; }
  .thumb-frame { height: 210px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

