:root {
  --bg: #f8f5f0;
  --surface: #ffffff;
  --surface-muted: #f4efe8;
  --text: #18181b;
  --text-muted: #52525b;
  --border: #e4ddd3;
  --border-strong: #cfc5b7;
  --primary: #9f1239;
  --primary-hover: #881337;
  --primary-soft: #fff1f2;
  --gold: #b45309;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --error: #b91c1c;
  --error-soft: #fef2f2;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 10px 30px -12px rgba(24, 24, 27, 0.12), 0 2px 6px rgba(24, 24, 27, 0.04);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  font-family: "IBM Plex Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at top right, rgba(180, 83, 9, 0.09), transparent 42%),
    radial-gradient(circle at top left, rgba(159, 18, 57, 0.08), transparent 45%),
    var(--bg);
  padding: max(16px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
  line-height: 1.5;
}

.page-shell {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* Header */
.hero {
  text-align: center;
  padding: 12px 4px 20px;
}

.hero-accent {
  width: 48px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--gold));
  margin: 0 auto 14px;
}

.hero-kicker {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold);
}

.hero-title {
  margin: 0;
  font-size: clamp(24px, 6vw, 28px);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

.hero-subtitle {
  margin: 8px 0 0;
  font-size: 15px;
  color: var(--text-muted);
}

.hero-deadline {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
}

/* Main Card */
.main-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px 18px;
}

@media (min-width: 420px) {
  .main-card {
    padding: 26px 24px;
  }
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* State Panels */
.state-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 4px;
}

.state-text {
  margin: 14px 0 0;
  font-size: 15px;
  color: var(--text-muted);
}

.state-heading {
  margin: 14px 0 6px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.state-description {
  margin: 0;
  font-size: 15px;
  color: var(--text-muted);
  max-width: 34ch;
}

.status-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.status-icon svg {
  width: 28px;
  height: 28px;
}

.status-icon-closed {
  background: var(--error-soft);
  color: var(--error);
}

.status-icon-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-icon-success {
  background: var(--success-soft);
  color: var(--success);
}

/* Spinner */
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2.5px;
}

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

/* Alert */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 18px;
  line-height: 1.45;
}

.alert-error {
  background: var(--error-soft);
  color: var(--error);
  border: 1px solid #fecaca;
}

/* Form Fields (16px font-size prevents iOS Safari auto-zoom) */
.field-group {
  margin-bottom: 18px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.required {
  color: var(--primary);
}

.field-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
}

.field-input::placeholder {
  color: #a1a1aa;
}

.field-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(159, 18, 57, 0.14);
}

.field-hint {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* Upload Zone */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 164px;
  padding: 22px 16px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.upload-zone:hover,
.upload-zone:active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.upload-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  box-shadow: 0 2px 6px rgba(24, 24, 27, 0.08);
}

.upload-icon svg {
  width: 24px;
  height: 24px;
}

.upload-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.upload-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.compressing-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Photo Preview */
.preview-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #18181b;
}

.preview-img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  background: #18181b;
}

.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface-muted);
}

.preview-meta {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 12px 20px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.99);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  margin-top: 6px;
}

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

.btn-secondary {
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--border-strong);
  margin-top: 18px;
}

.btn-link {
  background: none;
  border: none;
  padding: 6px 4px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  touch-action: manipulation;
}

/* Success Summary */
.summary-box {
  width: 100%;
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-align: left;
  background: var(--surface-muted);
}

.summary-photo {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  background: #18181b;
}

.summary-list {
  margin: 0;
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.summary-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.summary-row dt {
  color: var(--text-muted);
  flex-shrink: 0;
}

.summary-row dd {
  margin: 0;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  word-break: break-word;
}

/* Footer */
.page-footer {
  text-align: center;
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-muted);
}
