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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  line-height: 1.6;
}

.container { max-width: 900px; margin: 0 auto; padding: 24px 20px 60px; }

header { text-align: center; padding: 40px 0 32px; }
header h1 { font-size: 32px; font-weight: 700; }
.subtitle { color: #86868b; margin-top: 8px; font-size: 16px; }

/* API Key */
.api-key-section { text-align: right; margin-bottom: 16px; }
.btn-text { background: none; border: none; color: #86868b; cursor: pointer; font-size: 14px; padding: 4px 8px; }
.btn-text:hover { color: #1d1d1f; }
#apiKeyPanel {
  background: white; border-radius: 12px; padding: 16px; margin-top: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#apiKeyPanel.hidden { display: none; }
.api-info {
  background: #f0f7ff; border-radius: 8px; padding: 12px 16px; margin-bottom: 12px;
  font-size: 13px; color: #515154; line-height: 1.7;
}
.api-info a { color: #0071e3; }
.api-input-row {
  display: flex; align-items: center; gap: 10px;
}
.api-input-row label { font-size: 14px; color: #86868b; white-space: nowrap; }
.api-input-row input { flex: 1; padding: 8px 12px; border: 1px solid #d2d2d7; border-radius: 8px; font-size: 14px; }
#apiStatus { font-size: 13px; color: #34c759; }

/* Input Sections */
.input-section {
  background: white; border-radius: 16px; padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.section-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px; flex-wrap: wrap; gap: 8px;
}
.section-header h2 { font-size: 17px; font-weight: 600; }
.section-hint { font-size: 13px; color: #86868b; }

/* Upload Area */
.upload-area {
  border: 2px dashed #d2d2d7; border-radius: 12px; padding: 28px 24px;
  text-align: center; cursor: pointer; transition: all 0.2s;
  margin-bottom: 12px;
}
.upload-area:hover, .upload-area.dragover {
  border-color: #0071e3; background: #f0f7ff;
}
.upload-icon { margin-bottom: 8px; }
.upload-text { font-size: 14px; color: #1d1d1f; margin-bottom: 4px; }
.upload-link { color: #0071e3; font-weight: 500; }
.upload-hint { font-size: 12px; color: #86868b; }
.upload-status { font-size: 13px; color: #34c759; margin-top: 8px; }

/* Version Bar */
.version-bar {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  padding: 8px 0; flex-wrap: wrap;
}
.version-bar.hidden { display: none; }
.version-bar-label { font-size: 12px; color: #86868b; white-space: nowrap; }
.version-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.version-tag {
  padding: 3px 10px; border-radius: 14px; font-size: 12px;
  background: #f0f7ff; color: #0071e3; cursor: pointer; border: 1px solid transparent;
  transition: all 0.2s;
}
.version-tag:hover { border-color: #0071e3; }
.version-tag.active { background: #0071e3; color: white; }
.btn-text-sm {
  background: none; border: none; color: #0071e3; font-size: 12px;
  cursor: pointer; white-space: nowrap;
}

textarea {
  width: 100%; min-height: 200px; padding: 16px;
  border: 1px solid #d2d2d7; border-radius: 12px;
  font-size: 15px; font-family: inherit; resize: vertical; line-height: 1.6;
}
textarea:focus { outline: none; border-color: #0071e3; box-shadow: 0 0 0 3px rgba(0,113,227,0.1); }

.version-label { font-size: 12px; color: #0071e3; background: #f0f7ff; padding: 2px 8px; border-radius: 10px; }

.controls {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
}
.controls-left { display: flex; gap: 10px; align-items: center; flex: 1; }
.controls select {
  padding: 10px 16px; border: 1px solid #d2d2d7; border-radius: 10px;
  font-size: 15px; background: white; cursor: pointer;
}
.target-input {
  padding: 10px 14px; border: 1px solid #d2d2d7; border-radius: 10px;
  font-size: 14px; flex: 1; max-width: 220px;
}
.target-input:focus { outline: none; border-color: #0071e3; box-shadow: 0 0 0 3px rgba(0,113,227,0.1); }

/* Buttons */
.btn-primary {
  background: #0071e3; color: white; border: none; border-radius: 10px;
  padding: 10px 24px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.btn-primary:hover { background: #0077ed; }
.btn-primary:disabled { background: #a1c9f5; cursor: not-allowed; }
.btn-sm { padding: 6px 16px; font-size: 13px; }
.btn-outline {
  background: white; color: #0071e3; border: 2px solid #0071e3; border-radius: 10px;
  padding: 10px 24px; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.btn-outline:hover { background: #0071e3; color: white; }

/* Loading */
#loading { text-align: center; padding: 40px; color: #86868b; }
#loading.hidden { display: none; }
.loading-detail { font-size: 13px; color: #a1a1a6; margin-top: 4px; }

.spinner {
  width: 32px; height: 32px; border: 3px solid #e8e8ed; border-top-color: #0071e3;
  border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

#error { background: #fff2f0; border: 1px solid #ffccc7; color: #cf1322; border-radius: 12px; padding: 16px; margin-top: 16px; }
#error.hidden { display: none; }

/* JD Match Card (Jobscan style) */
.jd-match-card { margin-bottom: 20px; }
.jd-match-card.hidden { display: none; }
.match-main { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.match-circle { position: relative; width: 100px; height: 100px; flex-shrink: 0; }
.match-circle svg { width: 100%; height: 100%; }
.match-pct {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 24px; font-weight: 700; color: #0071e3;
}
.match-details { flex: 1; min-width: 200px; }
.match-details p { font-size: 14px; color: #515154; margin-bottom: 6px; }
.match-details .match-stat { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; font-size: 13px; }
.match-stat .dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.green { background: #34c759; }
.dot.yellow { background: #ffcc02; }
.dot.red { background: #ff3b30; }

.keyword-gap { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.keyword-col h4 { font-size: 14px; margin-bottom: 8px; }
.keyword-col .kw-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.kw-tag { padding: 4px 12px; border-radius: 16px; font-size: 13px; }
.kw-tag.matched { background: #e8f5e9; color: #2e7d32; }
.kw-tag.missing { background: #fff2f0; color: #cf1322; }

/* Result Tabs */
#result { margin-top: 24px; }
#result.hidden { display: none; }
.result-tabs {
  display: flex; gap: 4px; background: #e8e8ed; border-radius: 10px; padding: 4px; margin-bottom: 20px;
}
.tab {
  flex: 1; padding: 10px; border: none; background: none; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer; color: #86868b; transition: all 0.2s;
}
.tab.active { background: white; color: #1d1d1f; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.card {
  background: white; border-radius: 12px; padding: 24px; margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.card h3 { font-size: 18px; margin-bottom: 12px; color: #1d1d1f; }
.card p { color: #515154; margin-bottom: 8px; }

/* Score */
.score-circle {
  width: 100px; height: 100px; border-radius: 50%; background: #f5f5f7;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 700; margin: 0 auto 16px;
}
.score-circle.high { background: #e8f5e9; color: #2e7d32; }
.score-circle.mid { background: #fff8e1; color: #f57f17; }
.score-circle.low { background: #fff2f0; color: #cf1322; }

.score-dimensions {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-top: 16px;
}
.score-dim {
  text-align: center; padding: 12px 6px; border-radius: 10px; background: #f5f5f7;
}
.score-dim .dim-value { font-size: 20px; font-weight: 700; color: #0071e3; }
.score-dim .dim-label { font-size: 11px; color: #86868b; margin-top: 2px; }

/* Change Items */
.change-item {
  padding: 16px; border-bottom: 1px solid #f0f0f5; background: white;
  border-radius: 12px; margin-bottom: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.change-item:last-child { border: none; margin-bottom: 0; }
.change-item .change-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.change-item .change-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; background: #0071e3; color: white;
  border-radius: 50%; font-size: 12px; font-weight: 600;
}
.change-item .original { color: #cf1322; text-decoration: line-through; font-size: 14px; margin-bottom: 6px; padding: 8px 12px; background: #fff2f0; border-radius: 8px; }
.change-item .improved { color: #2e7d32; font-weight: 500; margin-bottom: 6px; padding: 8px 12px; background: #f0fdf4; border-radius: 8px; }
.change-item .reason { color: #86868b; font-size: 13px; margin-top: 4px; padding-left: 4px; }

#finalResume {
  background: #1d1d1f; color: #f5f5f7; padding: 24px; border-radius: 12px;
  font-size: 14px; line-height: 1.8; white-space: pre-wrap;
  font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
}

.strengths p { color: #2e7d32; }
.weaknesses p { color: #cf1322; }

@media (max-width: 768px) {
  .controls { flex-direction: column; }
  .controls-left { flex-direction: column; width: 100%; }
  .target-input { max-width: 100%; width: 100%; }
  .score-dimensions { grid-template-columns: repeat(2, 1fr); }
  .keyword-gap { grid-template-columns: 1fr; }
  .match-main { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 600px) {
  .container { padding: 12px; }
  header { padding: 20px 0; }
  header h1 { font-size: 24px; }
}
