/* === Design System === */
:root {
  --color-bg: #ffffff;
  --color-surface: #f5f7fb;
  --color-border: #e5e7eb;
  --color-text: #111827;
  --color-text-secondary: #6b7280;
  --color-text-muted: #9ca3af;
  --color-primary: #111827;
  --color-primary-hover: #1f2937;
  --color-accent: #4f46e5;
  --color-unfair: #ef4444;
  --color-unfair-bg: #fef2f2;
  --color-fair: #22c55e;
  --color-fair-bg: #f0fdf4;
  --color-conditional: #f59e0b;
  --color-conditional-bg: #fffbeb;
  --color-error: #dc2626;
  --color-error-bg: #fef2f2;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 8px rgba(15,23,42,0.06);
  --shadow-md: 0 10px 24px rgba(15,23,42,0.1);
  --shadow-lg: 0 20px 40px rgba(15,23,42,0.14);
  --transition-base: 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  --max-width: 480px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: linear-gradient(180deg, #f9fbff 0%, #ffffff 160px);
  line-height: 1.72;
  letter-spacing: 0.01em;
  text-rendering: optimizeLegibility;
  font-feature-settings: "palt" 1;
  min-height: 100dvh;
}

/* === Layout === */
.app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #e3e8f1;
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.header-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-lang {
  padding: 5px 11px;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  background: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #526075;
  transition: all var(--transition-base);
}

.btn-lang:hover {
  background: #f8fafd;
  border-color: #bac4d3;
}

/* === Sections / Steps === */
.section {
  display: none;
  flex: 1;
  padding: 26px 20px 24px;
  animation: fadeIn 0.24s ease;
}

.section.active {
  display: flex;
  flex-direction: column;
}

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

.section-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.025em;
  line-height: 1.35;
}

.section-desc {
  font-size: 14.5px;
  color: var(--color-text-secondary);
  margin-bottom: 24px;
  line-height: 1.72;
}

/* === Upload === */
.upload-area {
  border: 2px dashed #ccd7e5;
  border-radius: var(--radius-lg);
  padding: 42px 20px;
  text-align: center;
  cursor: pointer;
  transition: transform var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base), background var(--transition-base);
  margin-bottom: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: var(--shadow-sm);
}

.upload-area:hover {
  border-color: var(--color-accent);
  background: #ffffff;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.upload-area:active {
  transform: translateY(0);
}

.upload-area.has-image {
  border-style: solid;
  border-color: var(--color-accent);
  padding: 12px;
  background: #ffffff;
}

.upload-icon {
  font-size: 46px;
  margin-bottom: 14px;
  filter: drop-shadow(0 4px 10px rgba(79,70,229,0.16));
}

.upload-text {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.65;
  letter-spacing: 0.01em;
}

.upload-text strong {
  display: block;
  color: var(--color-text);
  font-size: 17px;
  margin-bottom: 5px;
  letter-spacing: -0.01em;
}

.upload-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: center;
}

.upload-preview {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.history-link {
  text-align: center;
  margin-top: 8px;
}

.history-link a {
  font-size: 13px;
  color: #708198;
  text-decoration: none;
  transition: color var(--transition-base);
}

.history-link a:hover {
  color: #415068;
  text-decoration: underline;
}

/* === Form === */
.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
  cursor: pointer;
}

.consent-check input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
}

.form-group {
  margin-bottom: 20px;
}

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

.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: var(--font-sans);
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(17,24,39,0.08);
}

.form-unit {
  font-size: 14px;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: transform var(--transition-base), background-color var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base), color var(--transition-base);
  width: 100%;
  letter-spacing: 0.01em;
}

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

.btn-primary {
  background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #0f172a 0%, #111827 100%);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #ffffff;
  border: 1px solid #d7dee9;
  color: var(--color-text);
}

.btn-secondary:hover:not(:disabled) {
  background: #f9fbff;
  border-color: #bbc7d8;
  transform: translateY(-1px);
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 14px;
  padding: 8px 16px;
}

.btn-ghost:hover {
  color: var(--color-text);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

/* === Loading === */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 24px;
  padding: 40px 20px;
}

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

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

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.loading-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--color-text-muted);
  transition: color 0.3s;
}

.loading-step.active {
  color: var(--color-text);
}

.loading-step.done {
  color: var(--color-fair);
}

.loading-step-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* === Error === */
.error-banner {
  padding: 12px 16px;
  background: var(--color-error-bg);
  color: var(--color-error);
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

.error-banner.visible {
  display: block;
}

/* === Disclaimer === */
/* === Hero === */
.hero {
  text-align: left;
  padding: 24px 20px 22px;
  margin: 2px 0 18px;
  border-radius: 20px;
  border: 1px solid #dbe5f3;
  background: linear-gradient(148deg, #f8fbff 0%, #f3f7ff 58%, #eef2ff 100%);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  width: 180px;
  height: 180px;
  top: -70px;
  right: -70px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79,70,229,0.2) 0%, rgba(79,70,229,0) 72%);
  pointer-events: none;
}

.hero-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.23;
  color: var(--color-text);
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.hero-subtitle {
  font-size: 14.5px;
  color: #475569;
  line-height: 1.74;
  letter-spacing: 0.01em;
  position: relative;
  z-index: 1;
}

/* === How It Works === */
.how-it-works {
  margin: 26px 0 24px;
  padding: 20px 14px 18px;
  border: 1px solid #e3e8f1;
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.how-title {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-align: center;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.how-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.how-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.how-step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(145deg, #4f46e5 0%, #4338ca 100%);
  border: 2px solid #ffffff;
  box-shadow: 0 8px 16px rgba(79,70,229,0.25);
  color: white;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.how-step-text {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  text-align: center;
  line-height: 1.45;
  letter-spacing: 0.01em;
  max-width: 92px;
}

.how-arrow {
  width: 24px;
  height: 2px;
  background: linear-gradient(90deg, #cbd5e1 0%, #94a3b8 100%);
  flex-shrink: 0;
  margin-bottom: 24px;
  position: relative;
}

.how-arrow::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-top: 2px solid #94a3b8;
  border-right: 2px solid #94a3b8;
  transform: translateY(-50%) rotate(45deg);
}

/* === Trust Badges === */
.trust-badges {
  margin-bottom: 20px;
}

.trust-badge {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafd 100%);
  border: 1px solid #dbe4ef;
  border-left: 4px solid #0f172a;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.trust-badge-icon {
  flex-shrink: 0;
  font-size: 14px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e8eef8;
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.trust-badge-text {
  font-size: 12.5px;
  color: #475569;
  line-height: 1.62;
  letter-spacing: 0.01em;
  font-weight: 500;
}

.trust-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.trust-stat {
  flex: 1;
  text-align: center;
  padding: 16px 10px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  border-radius: var(--radius-md);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
}

.trust-stat:hover {
  transform: translateY(-1px);
  border-color: #cfd8e5;
  box-shadow: var(--shadow-md);
}

.trust-stat-number {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: #dc2626;
  letter-spacing: -0.03em;
  line-height: 1.1;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}

.trust-stat-label {
  display: block;
  font-size: 11.5px;
  color: #64748b;
  margin-top: 7px;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

.disclaimer {
  font-size: 12px;
  color: #7b8798;
  line-height: 1.7;
  padding: 18px 0 4px;
  border-top: 1px solid #e4eaf2;
  margin-top: auto;
}

/* === Responsive === */
@media (min-width: 481px) {
  .app {
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    background: #ffffff;
  }
}

@media (max-width: 360px) {
  .hero-title {
    font-size: 27px;
  }

  .how-arrow {
    width: 14px;
  }

  .how-step-num {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .how-step-text {
    font-size: 11px;
  }
}

/* Hide file input */
.file-input {
  display: none;
}

/* === Language Overlay === */
.lang-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.97);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.lang-overlay.hidden {
  display: none;
}

.lang-overlay-box {
  text-align: center;
  padding: 40px 32px;
  max-width: 360px;
  width: 100%;
}

.lang-overlay-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.lang-overlay-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  line-height: 1.4;
}

.lang-overlay-desc {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 28px;
}

.lang-overlay-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lang-choice {
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s;
}

.lang-choice:hover {
  background: var(--color-surface);
  border-color: var(--color-primary);
}

.lang-choice:active {
  transform: scale(0.98);
}
