:root {
  --bg: #ffffff;
  --surface: #f8fafc;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --text: #0f172a;
  --text-soft: #475569;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius: 14px;
}

* { box-sizing: border-box; }
[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;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

.lang-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.lang-btn.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08); }

.credits-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.credits-chip:hover { border-color: var(--border-hover); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #f59e0b; }
.dot.ok { background: var(--success); }
.chip-link { color: var(--primary); font-weight: 600; }

.btn-dark {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  background: var(--text);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 9px;
  transition: opacity 0.15s;
}
.btn-dark:hover { opacity: 0.88; }

/* Main Container */
.main { max-width: 1120px; margin: 0 auto; padding: 40px 20px 72px; }

/* Upload View (Centered Single Focus) */
.upload-view { max-width: 720px; margin: 0 auto; }

.hero { text-align: center; margin-bottom: 28px; }
.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 4.2vw, 40px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.hero p { margin: 0 auto; max-width: 560px; font-size: 15.5px; color: var(--text-soft); }

.composer {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.06);
}

.pill-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.pill-group {
  display: inline-flex;
  flex-wrap: wrap;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.choice-pill {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.choice-pill:hover { color: var(--text); }
.choice-pill.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* Dropzone */
.dropzone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  border: 2px dashed var(--border-hover);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  padding: 24px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragover, .dropzone:focus-within {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dropzone.error {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.drop-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}
.drop-cta { display: block; font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.drop-hint { font-size: 13px; color: var(--text-muted); }

.preview-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 100%; }
#previewImg { max-width: 100%; max-height: 220px; border-radius: 10px; object-fit: contain; }
.preview-meta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
}
.file-name { font-size: 12.5px; font-weight: 600; color: var(--text-soft); overflow-wrap: anywhere; }
.btn-clear-photo {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-clear-photo:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

.options-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.note-input {
  flex: 1;
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
.note-input:focus { outline: none; border-color: var(--primary); }
.visual-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  white-space: nowrap;
}

.action-bar { display: flex; gap: 10px; margin-top: 16px; }
button { font-family: inherit; cursor: pointer; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  flex: 1;
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 14.5px;
  padding: 13px 18px;
  border-radius: 11px;
  transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  padding: 13px 16px;
  border-radius: 11px;
}
.btn-secondary:hover:not(:disabled) { background: var(--surface); border-color: var(--border-hover); }

.progress-bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.progress-step { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-muted); }
.p-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-hover); }
.progress-step.active { color: var(--primary); font-weight: 600; }
.progress-step.active .p-dot { background: var(--primary); }
.progress-step.done { color: var(--success); font-weight: 600; }
.progress-step.done .p-dot { background: var(--success); }

.status-msg { margin: 12px 0 0; font-size: 13px; color: var(--text-soft); text-align: center; min-height: 20px; }
.status-msg.error { color: var(--danger); font-weight: 500; }
.status-msg.success { color: var(--success); font-weight: 500; }

.value-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 28px;
}
@media (max-width: 680px) { .value-row { grid-template-columns: 1fr; } }
.value-item {
  padding: 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.value-item strong { display: block; font-size: 13.5px; margin-bottom: 4px; }
.value-item span { font-size: 12.5px; color: var(--text-soft); }

/* Result View */
.result-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.btn-back {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 14px;
  border-radius: 9px;
}
.btn-back:hover { background: var(--surface); }

.export-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-outline {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 600;
  font-size: 12.5px;
  padding: 8px 12px;
  border-radius: 8px;
}
.btn-outline:hover { background: var(--surface); }

.notice {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 18px;
}

.result-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 880px) { .result-grid { grid-template-columns: 1fr; } }

.card-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.card-section h2 { margin: 0; font-size: 14px; font-weight: 700; color: var(--text); }
.card-head-right { display: flex; align-items: center; gap: 8px; }
.muted { font-size: 12.5px; color: var(--text-muted); margin: 0; }
.unit-note { margin-top: 8px; }

.btn-copy {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 7px;
}
.btn-copy:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }

.text-block {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.strong-text { font-weight: 600; font-size: 15px; }

.tags-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  overflow-wrap: anywhere;
}

.bullets { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; overflow-wrap: anywhere; }

.visuals-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 12px; }
@media (max-width: 720px) { .visuals-grid { grid-template-columns: 1fr; } }
.visual-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.visual-card strong { font-size: 12.5px; }
.visual-card img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 8px; }
.visual-card a { text-align: center; text-decoration: none; font-size: 12.5px; font-weight: 600; color: var(--primary); }
.prompt-box {
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-soft);
  flex: 1;
}

.score-header { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.score-badge {
  min-width: 60px;
  height: 60px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}
.score-badge span { font-size: 20px; line-height: 1; }
.score-badge small { font-size: 10px; font-weight: 600; }
.audit-text { margin: 0 0 10px; font-size: 13.5px; color: var(--text-soft); }
.fix-list { margin: 0; padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 5px; }

.faq-list { display: flex; flex-direction: column; gap: 10px; }
.obj-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.obj-card strong { display: block; margin-bottom: 4px; color: var(--text); }
.obj-card p { margin: 0; color: var(--text-soft); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.2);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--surface); color: var(--text); }
.modal-input {
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--border-hover);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.modal-input:focus { outline: none; border-color: var(--primary); }
.modal-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 40px;
}
.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.footer-brand { font-weight: 700; color: var(--text-soft); }

/* UX Polish: Compliance Pills, Score Colors, Upgrade Banner, Toast */
.compliance-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.score-badge.score-high { background: #ecfdf5; color: #15803d; }
.score-badge.score-mid { background: #fffbeb; color: #b45309; }
.score-badge.score-low { background: #fef2f2; color: #b91c1c; }

.upgrade-banner {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.upgrade-copy strong { display: block; font-size: 13.5px; color: var(--text); }
.upgrade-copy span { font-size: 12.5px; color: var(--text-soft); }
.upgrade-actions { display: flex; align-items: center; gap: 8px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
  animation: toastIn 0.18s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .header-inner { flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
  .header-actions { width: 100%; justify-content: space-between; gap: 8px; }
  .main { padding: 24px 14px 56px; }
  .composer { padding: 16px; border-radius: 16px; }
  .pill-bar { gap: 8px; }
  .choice-pill { padding: 6px 10px; font-size: 12px; }
  .note-input { min-width: 0; width: 100%; }
  .progress-bar { flex-direction: column; gap: 8px; }
}
@media (max-width: 520px) {
  .action-bar { flex-direction: column; }
  .action-bar .btn-primary, .action-bar .btn-secondary { width: 100%; }
}
