* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --bg: #f8f7f4;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-sub: #6b7280;
  --success: #10b981;
  --error: #ef4444;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  text-align: center;
  padding: 2.5rem 1rem 2rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

header h1 a {
  color: inherit;
  text-decoration: none;
}

header p {
  font-size: 1.05rem;
  opacity: 0.9;
  margin-bottom: 0.75rem;
}

.main-nav {
  margin-top: 1.1rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  font-size: 0.9rem;
}

.main-nav a {
  color: white;
  opacity: 0.9;
  text-decoration: none;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  transition: background 0.15s;
}

.main-nav a:hover,
.main-nav a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.18);
  opacity: 1;
}

/* Article (legal pages) */
.article-section {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.8rem 1.6rem;
}

.article-section h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.article-meta {
  font-size: 0.82rem;
  color: var(--text-sub);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.article-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.6rem;
  margin-bottom: 0.6rem;
  color: var(--text);
}

.article-section h3 {
  font-size: 0.98rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.4rem;
}

.article-section p,
.article-section li {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text);
}

.article-section ul,
.article-section ol {
  padding-left: 1.4rem;
  margin: 0.4rem 0 0.8rem;
}

.article-section li {
  margin-bottom: 0.3rem;
}

.article-section a {
  color: var(--primary);
}

.article-section table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8rem 0;
  font-size: 0.88rem;
}

.article-section th,
.article-section td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.7rem;
  text-align: left;
}

.article-section th {
  background: #f9fafb;
  font-weight: 600;
}

/* Footer links */
.footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
}

.badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
}

/* Main */
main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Upload */
.upload-section {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.drop-zone {
  border: 2.5px dashed #c4b5fd;
  border-radius: 12px;
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  outline: none;
}

.drop-zone:hover,
.drop-zone.drag-over {
  background: #f5f3ff;
  border-color: var(--primary);
}

.drop-zone:focus-visible {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.3);
}

.drop-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.drop-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.drop-sub {
  font-size: 0.85rem;
  color: var(--text-sub);
}

/* Settings */
.settings-section {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.settings-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.1rem;
  color: var(--text);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 2rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.setting-item label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.range-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.range-wrapper input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
  cursor: pointer;
}

.range-wrapper span {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  min-width: 3rem;
  text-align: right;
}

.hint {
  font-size: 0.78rem;
  color: var(--text-sub);
  margin-top: 0.3rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
}

.checkbox-item label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin-bottom: 0;
}

.checkbox-item input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.btn-restore {
  width: 100%;
  padding: 0.85rem;
  background: var(--primary);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-restore:hover {
  background: var(--primary-hover);
}

.btn-restore:active {
  transform: scale(0.98);
}

.btn-restore:disabled {
  background: #a5b4fc;
  cursor: not-allowed;
  transform: none;
}

/* Preview */
.preview-section {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.preview-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 600px) {
  .preview-container {
    grid-template-columns: 1fr;
  }
}

.preview-box h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-box img {
  width: 100%;
  border-radius: 8px;
  display: block;
  object-fit: contain;
  max-height: 420px;
  background: #f3f4f6;
}

.result-placeholder {
  width: 100%;
  min-height: 200px;
  border-radius: 8px;
  background: #f9fafb;
  border: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--text-sub);
  font-size: 0.9rem;
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3.5px solid #e0e7ff;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Action buttons */
.action-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.btn-download {
  flex: 1;
  min-width: 160px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  background: var(--success);
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-download:hover {
  background: #059669;
}

.btn-reset {
  flex: 1;
  min-width: 160px;
  padding: 0.75rem 1.25rem;
  background: var(--card);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-reset:hover {
  background: #f3f4f6;
}

/* Error */
.error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  color: var(--error);
  font-size: 0.9rem;
}

/* Info section */
.info-section {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.info-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.1rem;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 600px) {
  .info-grid {
    grid-template-columns: 1fr;
  }
}

.info-card {
  background: #f9fafb;
  border-radius: 10px;
  padding: 1rem;
}

.info-icon {
  font-size: 1.6rem;
  display: block;
  margin-bottom: 0.4rem;
}

.info-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.info-card p {
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.5;
}

/* HowTo */
.howto-section {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.howto-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.howto-list {
  list-style: none;
  counter-reset: step-counter;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.howto-list li {
  counter-increment: step-counter;
  position: relative;
  padding-left: 2.6rem;
}

.howto-list li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.9rem;
  height: 1.9rem;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.howto-list li strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.howto-list li p {
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.55;
}

/* FAQ */
.faq-section {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.faq-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.faq-section details {
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 0;
}

.faq-section details:last-of-type {
  border-bottom: none;
}

.faq-section summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text);
  list-style: none;
  position: relative;
  padding-right: 1.5rem;
}

.faq-section summary::-webkit-details-marker {
  display: none;
}

.faq-section summary::after {
  content: "+";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  color: var(--primary);
  font-weight: 700;
  transition: transform 0.2s;
}

.faq-section details[open] summary::after {
  content: "−";
}

.faq-section details p {
  margin-top: 0.55rem;
  font-size: 0.88rem;
  color: var(--text-sub);
  line-height: 1.6;
}

/* Contact */
.contact-section {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.contact-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.contact-desc {
  font-size: 0.88rem;
  color: var(--text-sub);
  margin-bottom: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.form-group label {
  font-size: 0.9rem;
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-submit {
  width: 100%;
  padding: 0.85rem;
  background: var(--primary);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-submit:hover {
  background: var(--primary-hover);
}

.btn-submit:disabled {
  background: #a5b4fc;
  cursor: not-allowed;
}

.form-success {
  margin-top: 0.85rem;
  text-align: center;
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.82rem;
  color: var(--text-sub);
  border-top: 1px solid var(--border);
  line-height: 1.7;
}

footer a {
  color: var(--primary);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

footer small {
  font-size: 0.76rem;
  color: #9ca3af;
}

