:root {
  --bg: #10120f;
  --card: #191c17;
  --card-light: #20241d;
  --border: #30362b;
  --text: #f4f6ef;
  --muted: #a4aa9a;
  --blue: #b8f34a;
  --blue-light: #b8f34a;
  --green: #b8f34a;
  --red: #ff7777;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.6;
}

button,
input,
a {
  font: inherit;
}

button,
.primary-button,
.secondary-button {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

.site-header {
  width: 100%;
  min-height: 72px;
  padding: 14px max(5%, calc((100% - 1100px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: #131510;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand strong {
  color: var(--blue);
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--blue);
  color: #161a10;
  font-size: 22px;
  font-weight: 800;
}

.back-link {
  color: var(--muted);
  font-size: 14px;
  transition: color 0.2s ease;
}

.back-link:hover {
  color: var(--blue);
}

.container {
  width: min(900px, 92%);
  margin: 0 auto;
}

.hero {
  padding: 48px 0 30px;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid #3b4a29;
  border-radius: 30px;
  background: #1a2113;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.hero h1 {
  margin: 14px 0 8px;
  font-size: clamp(34px, 6vw, 48px);
  line-height: 1.2;
  letter-spacing: -1.5px;
}

.hero h1 span {
  color: var(--blue);
}

.hero p {
  max-width: 620px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 15px;
}

.tool-card {
  padding: clamp(18px, 4vw, 34px);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 18px 55px #00000020;
}

.upload-area {
  padding: 35px 18px;
  border: 2px dashed #424a39;
  border-radius: 16px;
  background: #151811;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.upload-area.drag-over {
  border-color: var(--blue);
  background: #202719;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  border-radius: 18px;
  background: #29351c;
  color: var(--blue);
  font-size: 32px;
}

.upload-area h2 {
  margin: 0 0 5px;
  font-size: 22px;
}

.upload-area p,
.upload-area small {
  color: var(--muted);
}

.upload-area p {
  margin: 0 0 20px;
  font-size: 14px;
}

.upload-area small {
  display: block;
  margin-top: 15px;
  font-size: 12px;
}

#pdfInput {
  display: none;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}

.primary-button {
  background: var(--blue);
  color: #161a10;
}

.primary-button:hover {
  background: #9bd32d;
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--card-light);
  color: var(--text);
}

.secondary-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.primary-button:active,
.secondary-button:active {
  transform: scale(0.98);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin: 28px 0 16px;
}

.section-heading h2,
.settings-box h2,
.result-section h2 {
  margin: 0;
  font-size: 20px;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.file-list {
  display: grid;
  gap: 12px;
}

.file-item {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #151811;
}

.pdf-icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 56px;
  border: 1px solid #5a4430;
  border-radius: 8px;
  background: #2a2117;
  color: #ffb38a;
  font-size: 12px;
  font-weight: 800;
}

.file-info {
  min-width: 0;
}

.file-name {
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 700;
}

.file-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.file-actions button {
  min-width: 34px;
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-light);
  color: var(--text);
}

.file-actions button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.file-actions .remove-file {
  color: #ff9999;
}

.settings-box {
  margin-top: 25px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #151811;
}

.settings-box h2 {
  margin-bottom: 14px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
}

.check-row input {
  width: 17px;
  height: 17px;
  margin-top: 4px;
  accent-color: var(--blue);
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.settings-box .hint {
  margin-bottom: 0;
}

.merge-button {
  width: 100%;
  margin-top: 22px;
  min-height: 50px;
  font-size: 15px;
}

.text-button {
  display: block;
  margin: 12px auto 0;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.text-button:hover {
  color: var(--red);
}

.loading-box,
.progress-box {
  padding: 28px 15px;
  text-align: center;
}

.loading-box p,
.progress-box p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 14px;
  border: 4px solid #30362b;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.progress-box h2 {
  margin: 0;
  font-size: 20px;
}

.progress-track {
  width: min(100%, 420px);
  height: 9px;
  margin: 20px auto 0;
  overflow: hidden;
  border-radius: 10px;
  background: #30362b;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #9bd32d, #b8f34a);
  transition: width 0.2s;
}

.error-box {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid #6e3434;
  border-radius: 12px;
  background: #2a1717;
  color: #ffaaaa;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.result-section {
  margin-top: 30px;
  padding-top: 25px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.success-badge {
  display: inline-block;
  margin-bottom: 12px;
  padding: 6px 12px;
  border-radius: 20px;
  background: #1a2113;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.result-section > p {
  color: var(--muted);
  font-size: 14px;
}

.result-preview {
  margin: 20px auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #151811;
}

#resultCanvas {
  display: block;
  width: 100%;
  max-width: 500px;
  max-height: 650px;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 6px;
  background: white;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.info-section {
  padding: 35px 5px 45px;
}

.info-section h2 {
  font-size: 21px;
}

.info-section ol {
  padding-left: 22px;
  color: #dce4d2;
}

.info-section li {
  margin: 9px 0;
}

.privacy-note {
  margin-top: 22px;
  padding: 14px;
  border: 1px solid #40512a;
  border-radius: 12px;
  background: #1a2113;
  color: #cde9a7;
  font-size: 13px;
}

.site-footer {
  padding: 22px 15px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 600px) {
  .site-header {
    min-height: 64px;
    padding: 12px 4%;
  }

  .brand {
    gap: 7px;
    font-size: 17px;
  }

  .brand-icon {
    width: 33px;
    height: 33px;
    border-radius: 10px;
    font-size: 19px;
  }

  .back-link {
    font-size: 12px;
  }

  .hero {
    padding: 35px 0 23px;
  }

  .hero p {
    font-size: 14px;
  }

  .tool-card {
    padding: 15px;
    border-radius: 16px;
  }

  .upload-area {
    padding: 28px 12px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .section-heading h2 {
    font-size: 17px;
  }

  .section-heading .secondary-button {
    padding: 9px 11px;
    font-size: 12px;
  }

  .file-item {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px;
    padding: 11px;
  }

  .pdf-icon {
    width: 40px;
    height: 48px;
    font-size: 10px;
  }

  .file-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .settings-box {
    padding: 15px;
  }

  .result-actions {
    flex-direction: column;
  }

  .result-actions .primary-button,
  .result-actions .secondary-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}