:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1d23;
  --text2: #5f6672;
  --accent: #e8590c;
  --accent-light: #fff4ed;
  --border: #e2e4e8;
  --danger: #d92b2b;
  --danger-bg: #fde8e8;
  --warn: #e08a00;
  --warn-bg: #fef3e0;
  --safe: #0a8a3d;
  --safe-bg: #e4f5eb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

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

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 500px;
  margin: 0 auto;
  padding: 0 16px 40px;
  min-height: 100dvh;
}

/* Header */
.header {
  text-align: center;
  padding: 32px 0 20px;
}
.header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px; height: 48px;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  margin-bottom: 12px;
}
.header h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.header-sub {
  font-size: 13px;
  color: var(--text2);
  margin-top: 6px;
  line-height: 1.5;
}

/* Card */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* API */
.api-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.api-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  background: var(--bg);
  transition: border-color 0.2s;
  box-sizing: border-box;
  -webkit-appearance: none;
}
.api-row input:focus {
  outline: none;
  border-color: var(--accent);
}
.api-buttons {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.btn-icon {
  width: 44px; height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-save {
  padding: 0 14px;
  height: 44px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}
.api-saved {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--safe-bg);
  color: var(--safe);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}
.btn-change {
  padding: 6px 14px;
  background: var(--card);
  color: var(--text2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.hint {
  font-size: 11px;
  color: var(--text2);
  margin-top: 8px;
}

/* Work Type Chips */
.work-type-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.work-type-chip {
  display: flex;
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.work-type-chip input {
  display: none;
}
.work-type-chip span {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text2);
  background: var(--bg);
  transition: all 0.15s;
  white-space: nowrap;
}
.work-type-chip input:checked + span {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Upload */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s;
  position: relative;
}
.upload-zone.has-image {
  border-style: solid;
  border-color: var(--accent);
}
.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text2);
  font-size: 14px;
}
.preview-img {
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: contain;
  border-radius: 10px;
}
.file-info {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text2);
  display: flex;
  justify-content: space-between;
}

/* Analyze Button */
.btn-analyze {
  width: 100%;
  padding: 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity 0.2s, transform 0.1s;
  -webkit-appearance: none;
}
.btn-analyze:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-analyze:active:not(:disabled) {
  transform: scale(0.98);
}

/* Spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Result */
.result-card { animation: fadeUp 0.4s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.result-meta {
  font-size: 11px;
  color: var(--text2);
}

/* Checklist */
.checklist-group {
  margin-bottom: 16px;
}
.checklist-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  padding: 8px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f1f3;
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type="checkbox"] {
  width: 20px; height: 20px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}
.checklist-content {
  flex: 1;
}
.checklist-text {
  font-size: 14px;
  line-height: 1.55;
}
.checklist-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  margin-top: 4px;
}
.tag-danger { background: var(--danger-bg); color: var(--danger); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-safe { background: var(--safe-bg); color: var(--safe); }

/* Download */
.btn-download {
  width: 100%;
  padding: 14px;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  -webkit-appearance: none;
}
.btn-download:active { transform: scale(0.98); }

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%; transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  max-width: 90%;
  text-align: center;
  z-index: 999;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }

@media (max-width: 400px) {
  .header h1 { font-size: 18px; }
  .card { padding: 14px; }
  .api-row { flex-direction: column; }
  .api-row input { width: 100%; }
  .api-buttons { width: 100%; }
  .api-buttons .btn-save { flex: 1; }
}
