:root {
  --ink: #161411;
  --muted: #6f6b64;
  --soft: #9b958c;
  --line: #e5e7eb;
  --line-strong: #cfd3d8;
  --surface: #ffffff;
  --surface-soft: #f7f5f0;
  --stage: #ece8df;
  --accent: #d71920;
  --accent-dark: #a90f15;
  --green: #167d5b;
  --blue: #2454a6;
  --gold: #b98924;
  --shadow: 0 34px 90px rgba(12, 14, 18, .18);
  --shadow-soft: 0 16px 42px rgba(12, 14, 18, .08);
  --radius: 8px;
}

* { box-sizing: border-box; }

html { background: #f4f5f6; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255,255,255,.68), rgba(255,255,255,0) 46%),
    linear-gradient(135deg, #fbfaf7 0%, #ede8de 46%, #dde4e0 100%);
  font-family: "Aptos", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(520px, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: relative;
  padding: 34px 34px 28px;
  background: rgba(255,255,255,.88);
  border-right: 1px solid rgba(17,17,17,.08);
  backdrop-filter: blur(20px) saturate(1.18);
  overflow: auto;
  box-shadow: 18px 0 60px rgba(12,14,18,.05);
}

.sidebar::before {
  content: "";
  position: sticky;
  top: -34px;
  display: block;
  height: 2px;
  margin: -34px -34px 28px;
  background: linear-gradient(90deg, var(--ink), var(--gold), var(--accent), transparent);
}

.brand {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 26px;
}

.mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid #191919;
  border-radius: 50%;
  background: linear-gradient(145deg, #111, #3a332b);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  box-shadow: 0 14px 28px rgba(17,17,17,.22);
}

h1 {
  margin: 0;
  font-size: clamp(22px, 2vw, 28px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: 0;
}

.subtitle {
  max-width: 31em;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.trust-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -10px 0 18px 60px;
}

.trust-strip span {
  border: 1px solid rgba(22,20,17,.1);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  color: #34302b;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(22,20,17,.04);
}

.section {
  padding: 18px 0 20px;
  border-top: 1px solid rgba(17,17,17,.08);
}

.section:first-of-type { border-top: 0; }

.section-title {
  margin: 0 0 8px;
  color: #161616;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.section-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 7px;
}

select, input[type="number"], input[type="text"], textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(17,17,17,.12);
  border-radius: var(--radius);
  background: rgba(255,255,255,.92);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.74);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

select:hover, input[type="number"]:hover, input[type="text"]:hover, textarea:hover {
  border-color: rgba(17,17,17,.28);
  background: #fff;
}

select:focus, input:focus, textarea:focus {
  border-color: #111;
  box-shadow: 0 0 0 4px rgba(17,17,17,.08);
  background: #fff;
}

textarea {
  min-height: 72px;
  resize: vertical;
}

.upload-pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

#pairedUpload {
  display: grid;
  gap: 12px;
}

.extra-pages {
  display: grid;
  gap: 12px;
}

.utility-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.drop {
  position: relative;
  display: grid;
  grid-template-columns: 72px 1fr auto auto;
  align-items: center;
  gap: 14px;
  min-height: 88px;
  padding: 13px;
  border: 1px solid rgba(17,17,17,.11);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(248,246,241,.92));
  cursor: pointer;
  overflow: hidden;
  transition: border-color .18s ease, transform .18s ease, background .18s ease, box-shadow .18s ease;
}

.drop::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid transparent;
  pointer-events: none;
  transition: border-color .18s ease;
}

.drop:hover, .drop.dragging {
  border-color: rgba(17,17,17,.32);
  background: #fff;
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.drop.dragging::after { border-color: var(--accent); }

.drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.thumb {
  width: 72px;
  height: 50px;
  border: 1px solid rgba(17,17,17,.12);
  border-radius: 5px;
  background: linear-gradient(135deg, #fff, #e7e9ec);
  object-fit: cover;
}

.drop strong {
  display: block;
  color: #171717;
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 4px;
}

.drop span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.mini-btn {
  position: relative;
  z-index: 2;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(17,17,17,.14);
  border-radius: 50%;
  background: #fff;
  color: #171717;
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease, background .18s ease, color .18s ease;
}

.mini-btn:hover {
  border-color: #111;
  background: #f1f2f4;
  transform: rotate(8deg);
}

.mini-btn.danger:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.drop.has-file {
  border-color: rgba(22,125,91,.28);
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(237,248,243,.86));
}

.drop.has-file .thumb {
  border-color: rgba(22,125,91,.28);
}

.icon {
  width: 18px;
  height: 18px;
  display: block;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(17,17,17,.1);
  border-radius: var(--radius);
  background: #ede9df;
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease;
}

.segmented button.active {
  color: #fff;
  background: #111;
  box-shadow: 0 8px 20px rgba(17,17,17,.18);
}

.checkline {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 12px 0 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.notice {
  margin: 13px 0 0;
  border: 1px solid rgba(185,137,36,.26);
  border-radius: var(--radius);
  background: rgba(255,249,234,.68);
  color: #68552a;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
}

.checkline input {
  width: 18px;
  height: 18px;
  accent-color: #111;
}

.actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px -6px 0;
  padding: 12px 6px 6px;
  background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.96) 28%);
  backdrop-filter: blur(12px);
}

.btn {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease, color .18s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .46; cursor: not-allowed; transform: none; box-shadow: none; }

.primary {
  background: #111;
  color: #fff;
  box-shadow: 0 16px 28px rgba(17,17,17,.22);
}

.primary:hover {
  background: var(--accent);
  box-shadow: 0 18px 32px rgba(215,25,32,.24);
}

.secondary {
  background: rgba(255,255,255,.72);
  border-color: rgba(17,17,17,.14);
  color: var(--ink);
}

.secondary:hover {
  background: #fff;
  border-color: rgba(17,17,17,.34);
  box-shadow: var(--shadow-soft);
}

.status {
  margin-top: 13px;
  min-height: 38px;
  border: 1px solid rgba(17,17,17,.08);
  border-radius: var(--radius);
  background: rgba(255,255,255,.68);
  color: #34302b;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
  font-weight: 700;
}

.next-step {
  margin-top: 10px;
  border-left: 3px solid var(--blue);
  background: rgba(36,84,166,.07);
  color: #273f70;
  padding: 9px 11px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.5;
}

.workspace {
  position: relative;
  padding: 34px;
  overflow: auto;
}

.workspace::before {
  content: "";
  position: fixed;
  inset: 0 0 0 440px;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(17,17,17,.045) 1px, transparent 1px) center / 96px 96px,
    linear-gradient(rgba(17,17,17,.035) 1px, transparent 1px) center / 96px 96px;
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 80%, transparent);
  opacity: .48;
}

.desk {
  position: relative;
  z-index: 1;
  width: min(100%, 980px);
  margin: 0 auto;
  padding-top: 4px;
}

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

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
}

h2 {
  margin: 0;
  color: #171513;
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: 0;
}

.page-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(17,17,17,.1);
  border-radius: 999px;
  background: rgba(255,255,255,.76);
  padding: 5px;
  box-shadow: 0 12px 26px rgba(12,14,18,.06);
  backdrop-filter: blur(14px);
}

#pageInfo {
  min-width: 76px;
  text-align: center;
  color: #34302b;
  font-size: 12px;
  font-weight: 900;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #111;
  color: #fff;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, opacity .18s ease;
}

.icon-btn:hover { transform: translateY(-1px); background: var(--accent); }
.icon-btn:disabled { opacity: .28; cursor: not-allowed; transform: none; background: #111; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
}

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

.pill {
  border: 1px solid rgba(17,17,17,.1);
  background: rgba(255,255,255,.78);
  border-radius: 999px;
  padding: 7px 12px;
  color: #24262a;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(12,14,18,.04);
  backdrop-filter: blur(12px);
}

#detectInfo {
  color: #4d5157;
  font-weight: 700;
}

.page-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px);
  border-radius: 12px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.66), rgba(255,255,255,.18)),
    repeating-linear-gradient(45deg, rgba(17,17,17,.035) 0 1px, transparent 1px 10px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 18px 48px rgba(12,14,18,.08);
}

.a4 {
  width: 100%;
  aspect-ratio: 210 / 297;
  position: relative;
  background: #fff;
  border: 1px solid rgba(17,17,17,.08);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

canvas#a4Canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 34px;
  color: #7d8188;
  pointer-events: none;
}

.canvas-placeholder strong {
  display: block;
  color: var(--ink);
  font-size: clamp(21px, 2.5vw, 34px);
  font-weight: 700;
  line-height: 1.12;
  margin-bottom: 10px;
}

.canvas-placeholder span {
  font-size: 13px;
  line-height: 1.6;
}

.hidden { display: none !important; }

.fineprint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.inspector {
  width: min(100%, 760px);
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.inspector > div {
  min-height: 82px;
  border: 1px solid rgba(17,17,17,.09);
  border-radius: var(--radius);
  background: rgba(255,255,255,.76);
  padding: 13px 14px;
  box-shadow: 0 12px 30px rgba(12,14,18,.05);
  backdrop-filter: blur(14px);
}

.inspector-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}

.inspector strong {
  display: block;
  color: #171513;
  font-size: 13px;
  line-height: 1.45;
}

.badge-ok { color: var(--green); font-weight: 900; }
.badge-warn { color: var(--accent); font-weight: 900; }

@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(17,17,17,.08);
    box-shadow: 0 18px 48px rgba(12,14,18,.06);
  }
  .workspace { padding: 22px; }
  .workspace::before { inset: 0; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .preview-heading { align-items: flex-start; flex-direction: column; }
  .inspector { grid-template-columns: 1fr; }
  .actions { position: static; }
}

@media (max-width: 520px) {
  .sidebar { padding: 24px 18px 18px; }
  .sidebar::before { margin: -24px -18px 22px; top: -24px; }
  .trust-strip { margin-left: 0; }
  .grid-two, .actions, .utility-actions { grid-template-columns: 1fr; }
  .drop { grid-template-columns: 58px 1fr auto auto; gap: 10px; }
  .thumb { width: 58px; height: 42px; }
  h1 { font-size: 22px; }
  h2 { font-size: 21px; }
  .page-shell { padding: 10px; }
}
