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

:root {
  --bg-1: #ffedd5;
  --bg-2: #ffe4e6;
  --bg-3: #fce7f3;
  --surface: #ffffff;
  --surface-alt: #fffbfb;
  --border: #e5e7eb;
  --border-soft: #f1f5f9;
  --text: #1c1917;
  --text-soft: #44403c;
  --muted: #78716c;
  --muted-light: #a8a29e;
  --primary: #e11d48;
  --primary-hover: #be123c;
  --primary-grad: linear-gradient(135deg, #fb923c 0%, #ef4444 45%, #ec4899 100%);
  --primary-grad-hover: linear-gradient(135deg, #ea580c 0%, #dc2626 45%, #db2777 100%);
  --primary-soft: #fff5f5;
  --primary-soft-2: #ffe4e6;
  --primary-border-soft: #fecdd3;
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --error: #b91c1c;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --code-bg: #f5f5f4;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow-md: 0 4px 16px rgba(220, 38, 38, 0.08), 0 2px 4px rgba(28, 25, 23, 0.04);
  --shadow-lg: 0 12px 40px rgba(220, 38, 38, 0.14), 0 4px 12px rgba(28, 25, 23, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Sarabun", "Segoe UI", "TH Sarabun New", -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--bg-1), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, var(--bg-2), transparent 50%),
    radial-gradient(800px 400px at 50% 100%, var(--bg-3), transparent 60%),
    #fbfcff;
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  padding: 2.5rem 1rem 3rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 760px;
  margin: 0 auto;
}

/* --- Header / Hero --- */
header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: var(--primary-grad);
  border-radius: 20px;
  margin-bottom: 1.25rem;
  box-shadow: 0 12px 32px rgba(236, 72, 153, 0.28), 0 4px 8px rgba(249, 115, 22, 0.16);
  transform: rotate(-4deg);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hero-icon:hover {
  transform: rotate(0deg) scale(1.04);
}

.hero-icon svg {
  width: 38px;
  height: 38px;
  color: white;
}

header h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #1c1917 0%, #f97316 35%, #ef4444 65%, #ec4899 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.15;
}

.subtitle {
  color: var(--muted);
  font-size: 1rem;
  max-width: 560px;
  margin: 0 auto 1rem;
}

.subtitle code {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-weight: 600;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.18);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

code {
  font-family: "JetBrains Mono", "SF Mono", Monaco, Consolas, monospace;
  background: var(--code-bg);
  padding: 0.12em 0.45em;
  border-radius: 5px;
  font-size: 0.88em;
  color: #475569;
}

/* --- Dropzone --- */
.dropzone {
  border: 2px dashed var(--primary-border-soft);
  border-radius: var(--radius-lg);
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: linear-gradient(180deg, #fffbfb 0%, var(--primary-soft) 100%);
  position: relative;
  overflow: hidden;
}

.dropzone::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(220, 38, 38, 0.08), transparent 40%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.dropzone:hover::before {
  opacity: 1;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: linear-gradient(180deg, var(--primary-soft) 0%, var(--primary-soft-2) 100%);
  transform: translateY(-2px);
}

.dropzone.dragover {
  border-style: solid;
  box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.14);
}

.dropzone-content {
  position: relative;
  z-index: 1;
}

.dropzone-content .icon {
  width: 56px;
  height: 56px;
  color: var(--primary);
  margin-bottom: 1rem;
  background: white;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(220, 38, 38, 0.16);
  transition: transform 0.2s ease;
}

.dropzone:hover .icon,
.dropzone.dragover .icon {
  transform: translateY(-3px) scale(1.04);
}

.dropzone-title {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.dropzone-sub {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.dropzone-hint {
  color: var(--muted-light);
  font-size: 0.8rem;
}

.dropzone-selected {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  position: relative;
  z-index: 1;
}

.dropzone-selected::before {
  content: "";
  display: inline-block;
  width: 32px;
  height: 32px;
  background: var(--primary-grad);
  border-radius: 8px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.28);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 18px;
}

.dropzone-selected #file-name {
  font-weight: 600;
  word-break: break-all;
  color: var(--text);
  font-size: 0.95rem;
  text-align: left;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  font-weight: 600;
  text-decoration: none;
  padding: 0;
  border-bottom: 1px dashed var(--primary);
  transition: color 0.15s, border-color 0.15s;
}

.link-btn:hover {
  color: var(--primary-hover);
  border-bottom-color: var(--primary-hover);
  border-bottom-style: solid;
}

/* --- Options --- */
.options {
  margin: 1.5rem 0 1.25rem;
  border-top: 1px solid var(--border-soft);
  padding-top: 1.25rem;
}

.options summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.4rem 0;
  user-select: none;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  transition: color 0.15s;
}

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

.options summary::before {
  content: "›";
  display: inline-block;
  font-size: 1.4rem;
  color: var(--muted-light);
  transition: transform 0.2s ease;
  line-height: 1;
}

.options[open] summary::before {
  transform: rotate(90deg);
}

.options summary:hover {
  color: var(--primary);
}

.options-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.option {
  display: flex;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--surface);
}

.option:hover {
  background: var(--surface-alt);
  border-color: var(--primary-border-soft);
}

.option:has(input:checked) {
  background: var(--primary-soft);
  border-color: var(--primary-border-soft);
}

.option input[type="checkbox"] {
  margin-top: 0.18rem;
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.option div {
  display: flex;
  flex-direction: column;
}

.option strong {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.option span {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
  line-height: 1.5;
}

/* --- Buttons --- */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  background: var(--primary-grad);
  color: white;
  border: none;
  padding: 0.95rem 1.5rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-family: inherit;
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.26), 0 2px 4px rgba(236, 72, 153, 0.12);
  position: relative;
  overflow: hidden;
}

.primary-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.18) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(239, 68, 68, 0.34), 0 4px 8px rgba(249, 115, 22, 0.18);
}

.primary-btn:hover:not(:disabled)::after {
  transform: translateX(100%);
}

.primary-btn:active:not(:disabled) {
  transform: translateY(0);
}

.primary-btn:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* --- Result / Error cards --- */
.result-card {
  border-color: var(--success-border);
  background: linear-gradient(180deg, #ffffff 0%, var(--success-bg) 100%);
  animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-card h2 {
  color: var(--success);
  font-size: 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.result-card h2::before {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--success);
  color: white;
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat {
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  transition: transform 0.15s ease;
}

.stat:hover {
  transform: translateY(-2px);
  border-color: var(--primary-border-soft);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  background: var(--primary-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.error-card {
  border-color: var(--error-border);
  background: linear-gradient(180deg, #ffffff 0%, var(--error-bg) 100%);
  animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.error-card h2 {
  color: var(--error);
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.error-card h2::before {
  content: "!";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--error);
  color: white;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 700;
}

.error-card p {
  color: var(--text);
  margin-bottom: 1.25rem;
}

/* --- Info section --- */
.info {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  font-size: 0.92rem;
  box-shadow: var(--shadow-sm);
}

.info h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info h3::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--primary-grad);
  border-radius: 2px;
}

.info ol {
  list-style: none;
  counter-reset: info-counter;
  padding: 0;
}

.info li {
  counter-increment: info-counter;
  padding-left: 2.25rem;
  position: relative;
  margin-bottom: 0.85rem;
  color: var(--text-soft);
  line-height: 1.6;
}

.info li::before {
  content: counter(info-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 7px;
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.info strong {
  color: var(--text);
  font-weight: 600;
}

/* --- Donate (subtle, not prominent) --- */
.donate {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.1rem 1.25rem;
  margin-top: 1.5rem;
  background: linear-gradient(135deg, #fff7ed 0%, #fff1f2 60%, #fdf2f8 100%);
  border: 1px solid #fed7aa;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.donate-text {
  flex: 1;
  min-width: 0;
}

.donate-text h4 {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 0.4rem;
  letter-spacing: 0.005em;
}

.donate-text h4 svg {
  width: 14px;
  height: 14px;
  color: #ec4899;
  flex-shrink: 0;
}

.donate-text p {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
  margin: 0;
}

.donate-qr {
  flex-shrink: 0;
  text-align: center;
  margin: 0;
}

.donate-qr img {
  width: 132px;
  height: auto;
  display: block;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: white;
  padding: 6px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.donate-qr img:hover {
  transform: scale(1.04);
  box-shadow: 0 8px 20px rgba(236, 72, 153, 0.18);
}

.donate-qr figcaption {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.4rem;
  font-weight: 500;
}

@media (max-width: 600px) {
  .donate {
    flex-direction: column;
    text-align: center;
    gap: 0.85rem;
    padding: 1.25rem 1rem;
  }
  .donate-text h4 { justify-content: center; }
}

/* --- Footer / Credit --- */
footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-soft);
}

.privacy-note {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.privacy-note svg {
  width: 14px;
  height: 14px;
  color: var(--success);
}

.credit {
  font-size: 0.8rem;
  color: var(--muted-light);
  letter-spacing: 0.01em;
}

.credit strong {
  color: var(--muted);
  font-weight: 600;
}

.credit a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s;
}

.credit a:hover {
  color: var(--primary-hover);
}

/* --- Responsive --- */
@media (max-width: 600px) {
  body { padding: 1.5rem 0.75rem 2rem; }
  .card { padding: 1.5rem; border-radius: var(--radius-lg); }
  .info { padding: 1.5rem; border-radius: var(--radius-lg); }
  header h1 { font-size: 1.85rem; }
  .subtitle { font-size: 0.92rem; }
  .hero-icon { width: 60px; height: 60px; }
  .hero-icon svg { width: 30px; height: 30px; }
  .dropzone { padding: 2rem 1rem; }
  .dropzone-content .icon { width: 48px; height: 48px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

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

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d6d3d1;
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
  background-clip: content-box;
  border: 2px solid transparent;
}

/* --- Selection --- */
::selection {
  background: rgba(220, 38, 38, 0.22);
  color: var(--text);
}
