/* Resume Match Optimizer — light-first, professional theme.
 * Dark mode is opt-in via [data-theme="dark"] on <html>; the app sets it from
 * the saved preference or the OS setting. */
:root {
  --bg: #f5f7fb;
  --bg-grad-1: #eef2ff;
  --bg-grad-2: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f2f5fa;
  --surface-3: #eef1f7;
  --border: #e4e9f2;
  --border-strong: #d3dbe8;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f6bff;
  --accent-2: #7b5cff;
  --accent-ink: #ffffff;
  --accent-weak: #eef1ff;
  --accent-border: #cdd6ff;
  --good: #15a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --good-weak: #e8f7ee;
  --bad-weak: #fdeceb;
  --warn-weak: #fdf3e3;
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1000px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
}

[data-theme="dark"] {
  --bg: #0e1116;
  --bg-grad-1: #141a26;
  --bg-grad-2: #0e1116;
  --surface: #161b22;
  --surface-2: #1c232d;
  --surface-3: #212a35;
  --border: #2a323d;
  --border-strong: #384250;
  --text: #e6edf3;
  --muted: #9aa7b4;
  --accent: #6b83ff;
  --accent-2: #9a7dff;
  --accent-ink: #0b0f16;
  --accent-weak: #1a2340;
  --accent-border: #2c3a63;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --good-weak: rgba(63, 185, 80, 0.12);
  --bad-weak: rgba(248, 81, 73, 0.12);
  --warn-weak: rgba(210, 153, 34, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 520px at 50% -160px, var(--bg-grad-1), transparent 70%),
    var(--bg-grad-2);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Topbar ------------------------------------------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 22px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: saturate(1.4) blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 680; }
.logo { display: inline-flex; }
.logo svg { display: block; border-radius: 8px; box-shadow: var(--shadow-sm); }
.brand-name { letter-spacing: 0.2px; }
.account { display: flex; align-items: center; gap: 10px; }
.credits {
  background: var(--accent-weak);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.linkbtn {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.linkbtn:hover { border-color: var(--accent); background: var(--surface-2); }
.linkbtn:active { transform: translateY(1px); }
.iconbtn {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  width: 34px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: border-color 0.15s, background 0.15s;
}
.iconbtn:hover { border-color: var(--accent); background: var(--surface-2); }

/* Layout ------------------------------------------------------------------ */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 30px 20px 64px; }
.hero { text-align: center; margin: 8px 0 26px; }
.hero h1 {
  font-size: clamp(26px, 4.4vw, 38px);
  line-height: 1.1;
  margin: 0 0 12px;
  letter-spacing: -0.5px;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lede { color: var(--muted); font-size: 15.5px; max-width: 660px; margin: 0 auto; }

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.inputs { padding: 22px; display: flex; flex-direction: column; gap: 20px; }

.field { display: flex; flex-direction: column; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; min-height: 26px; }
.field label { font-size: 13px; font-weight: 650; color: var(--text); }

textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 13px 14px;
  font: 13.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea::placeholder, input::placeholder { color: var(--muted); opacity: 0.85; }
textarea:focus, input[type="text"]:focus, input[type="url"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.url-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 13px;
  font-size: 13.5px;
  margin-bottom: 9px;
}
.field-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}
.field-meta.split { justify-content: space-between; }
.autoclean { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 500; }
.autoclean input { accent-color: var(--accent); margin: 0; }

/* Source detection chip + clean note */
.source-detect {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-weak);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}
.source-detect .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.clean-note {
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--good);
  background: var(--good-weak);
  border: 1px solid color-mix(in srgb, var(--good) 35%, transparent);
  border-radius: 8px;
  padding: 7px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.linktext {
  background: none; border: none; padding: 0;
  color: inherit; font: inherit; font-weight: 700;
  text-decoration: underline; cursor: pointer;
}

.ghostbtn {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.ghostbtn:hover { border-color: var(--accent); color: var(--accent); }
.ghostbtn:active { transform: translateY(1px); }

.controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
  flex-wrap: wrap;
}
.role-field { display: flex; flex-direction: column; flex: 1 1 280px; }
.role-field label { font-size: 13px; font-weight: 650; margin-bottom: 7px; }
.muted { color: var(--muted); font-weight: 400; }
input[type="text"] {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}
.run { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.primary {
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  font-weight: 650;
  font-size: 15px;
  padding: 12px 26px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: filter 0.15s, transform 0.06s, box-shadow 0.15s;
}
.primary:hover { filter: brightness(1.06); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: 0.55; cursor: default; box-shadow: none; filter: grayscale(0.2); }
.cost-note { font-size: 12px; color: var(--muted); min-height: 16px; text-align: right; }

/* History ----------------------------------------------------------------- */
.history { margin-top: 20px; padding: 20px 22px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.hist-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.hist-row:hover { border-color: var(--accent); background: var(--surface-3); }
.hist-score {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  border: 2px solid var(--border-strong);
}
.hist-main { flex: 1; min-width: 0; }
.hist-role { font-weight: 650; font-size: 14px; }
.hist-verdict {
  color: var(--muted);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hist-when { flex: none; color: var(--muted); font-size: 12px; }
.hist-empty { color: var(--muted); font-size: 13.5px; }

/* Status ------------------------------------------------------------------ */
.status {
  margin-top: 22px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 11px;
}
.spinner {
  width: 17px; height: 17px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Results ----------------------------------------------------------------- */
.results { margin-top: 26px; display: flex; flex-direction: column; gap: 18px; }

.score-card {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 24px;
}
.ring {
  --pct: 0;
  --ring-color: var(--accent);
  width: 132px; height: 132px;
  border-radius: 50%;
  flex: none;
  background: conic-gradient(var(--ring-color) calc(var(--pct) * 1%), var(--surface-3) 0);
  display: grid;
  place-items: center;
  transition: background 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.ring-inner {
  width: 102px; height: 102px;
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  text-align: center;
  box-shadow: inset 0 0 0 1px var(--border);
}
.score-num { font-size: 38px; font-weight: 760; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ring-color, var(--text)); }
.score-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.4px; margin-top: 2px; }
.score-side { display: flex; flex-direction: column; gap: 11px; min-width: 0; }
.score-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.verdict { margin: 0; font-size: 16px; line-height: 1.5; }
.result-actions { display: flex; gap: 8px; margin-top: 2px; }
.badge {
  align-self: flex-start;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
}
.badge.strong_match { background: var(--good-weak); color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.badge.promising { background: var(--accent-weak); color: var(--accent); border-color: var(--accent-border); }
.badge.needs_work { background: var(--warn-weak); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.badge.not_a_fit { background: var(--bad-weak); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.badge.ats {
  text-transform: none;
  letter-spacing: 0.2px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.panel { padding: 20px 22px; }
.panel h2 { font-size: 13px; margin: 0 0 13px; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.panel-head h2 { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 550;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
}
.chip.match { color: var(--good); border-color: color-mix(in srgb, var(--good) 38%, transparent); background: var(--good-weak); }
.chip.miss { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 38%, transparent); background: var(--bad-weak); }
.chips .empty { color: var(--muted); font-size: 13px; }

.bullets { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.bullets li { font-size: 14px; }
.bullets.empty-list { list-style: none; padding-left: 0; color: var(--muted); }

.suggestions { display: flex; flex-direction: column; gap: 14px; }
.sugg {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 14px 16px;
}
.sugg.high { border-left-color: var(--bad); }
.sugg.medium { border-left-color: var(--warn); }
.sugg.low { border-left-color: var(--muted); }
.sugg-head { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.sugg-section { font-weight: 680; font-size: 13.5px; }
.pri {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--muted);
}
.pri.high { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-weak); }
.pri.medium { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-weak); }
.pri.low { color: var(--muted); }
.sugg .issue { color: var(--muted); font-size: 13.5px; margin: 2px 0 8px; }
.sugg .action { font-size: 14px; margin: 0 0 9px; }
.sugg .example-wrap { position: relative; }
.sugg .example {
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 12px;
  padding-right: 62px;
  white-space: pre-wrap;
  color: var(--text);
}
.copy-ex {
  position: absolute; top: 7px; right: 7px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--muted);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.copy-ex:hover { color: var(--accent); border-color: var(--accent); }
.tailored { margin: 0; font-size: 14.5px; line-height: 1.65; }

/* Footer ------------------------------------------------------------------ */
.foot {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12.5px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.foot a { color: var(--accent); text-decoration: none; }
.foot a:hover { text-decoration: underline; }

/* Toasts ------------------------------------------------------------------ */
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 20; }
.toast {
  padding: 12px 15px;
  border-radius: 10px;
  font-size: 13.5px;
  max-width: 340px;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast.ok { border-left: 3px solid var(--good); }
.toast.error { border-left: 3px solid var(--bad); }
.toast a { color: var(--accent); }

.hidden { display: none !important; }

/* Responsive -------------------------------------------------------------- */
@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; }
  .score-card { flex-direction: column; text-align: center; gap: 18px; }
  .score-side { align-items: center; }
  .badge { align-self: center; }
  .result-actions { justify-content: center; }
  .controls { flex-direction: column; align-items: stretch; }
  .run { align-items: stretch; }
  .primary { width: 100%; }
  .cost-note { text-align: center; }
  .brand-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ring, .toast, .primary { transition: none; animation: none; }
  .spinner { animation-duration: 1.4s; }
}
