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

/* ── Dark theme (default) ── */
:root {
  --bg:           #0e0e0f;
  --surface:      #161618;
  --border:       #2a2a2e;
  --accent:       #4f8ef7;
  --success:      #3ecf8e;
  --error:        #f87171;
  --warning:      #f59e0b;
  --text:         #e8e8ea;
  --muted:        #6b6b7a;
  --sans:         'DM Sans', sans-serif;
  --mono:         'DM Mono', monospace;
  /* Derived tokens — keep in sync with accent/surface colors above */
  --accent-ring:  rgba(79,142,247,0.15);
  --accent-muted: rgba(79,142,247,0.04);
  --shadow-card:  0 0 60px rgba(79,142,247,0.06), 0 24px 48px rgba(0,0,0,0.4);
  --shadow-tab:   0 1px 3px rgba(0,0,0,0.3);
  --shadow-panel: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
}

/* ── Light theme ── */
[data-theme="light"] {
  --bg:           #f3f4f6;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --accent:       #2563eb;
  --success:      #059669;
  --error:        #dc2626;
  --warning:      #d97706;
  --text:         #0f172a;
  --muted:        #64748b;
  --accent-ring:  rgba(37,99,235,0.15);
  --accent-muted: rgba(37,99,235,0.05);
  --shadow-card:  0 0 40px rgba(37,99,235,0.04), 0 8px 24px rgba(0,0,0,0.08);
  --shadow-tab:   0 1px 3px rgba(0,0,0,0.08);
  --shadow-panel: 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
}

/* ── Smooth theme transition — applied briefly during switch ── */
.theme-changing,
.theme-changing *,
.theme-changing *::before,
.theme-changing *::after {
  transition:
    background     0.25s ease,
    background-color 0.25s ease,
    color          0.2s  ease,
    border-color   0.2s  ease,
    box-shadow     0.2s  ease !important;
}

html, body {
  height: 100%; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: ''; position: fixed; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px; opacity: 0.35;
  pointer-events: none; z-index: 0;
}

.wrap {
  position: relative; z-index: 1; min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px;
}

.card {
  width: 100%; max-width: 520px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 40px;
  box-shadow: var(--shadow-card);
}

.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.logo-icon {
  width: 34px; height: 34px; background: var(--accent); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.logo-text { font-size: 17px; font-weight: 600; }
.logo-text span { color: var(--accent); }

h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; margin-bottom: 6px; }
.subtitle { color: var(--muted); font-size: 13.5px; margin-bottom: 28px; }

label {
  display: block; font-size: 11px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px;
}
.field { margin-bottom: 14px; }

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 13px 15px; font-family: var(--sans);
  font-size: 14px; color: var(--text); outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
input.input-error { border-color: var(--error); }
input::placeholder { color: var(--muted); }

.field-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field-hint.error { color: var(--error); }

.strength-bar {
  height: 3px; border-radius: 2px; margin-top: 6px;
  background: var(--border); overflow: hidden;
}
.strength-fill {
  height: 100%; border-radius: 2px; width: 0%;
  transition: width 0.3s, background 0.3s;
}
.strength-label { font-size: 11px; margin-top: 4px; color: var(--muted); }

.drop-zone {
  width: 100%; border: 2px dashed var(--border); border-radius: 10px;
  padding: 32px 20px; text-align: center; cursor: pointer;
  transition: border-color 0.2s, background 0.2s; background: var(--bg);
  margin-bottom: 12px;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent); background: var(--accent-muted);
}
.drop-zone input[type="file"] { display: none; }
.drop-zone-icon { font-size: 28px; margin-bottom: 8px; }
.drop-zone-label { font-size: 13px; color: var(--muted); }
.drop-zone-label span { color: var(--accent); font-weight: 500; }
.drop-zone-file { font-size: 13px; color: var(--success); margin-top: 8px; font-family: var(--mono); }

.btn {
  width: 100%; padding: 13px; border: none; border-radius: 10px;
  font-family: var(--sans); font-size: 15px; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity 0.2s, transform 0.15s;
}
.btn:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost   { background: transparent; color: var(--muted); border: 1px solid var(--border); margin-top: 10px; }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--text); }

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

.msg {
  padding: 11px 14px; border-radius: 8px; font-size: 13px;
  margin-top: 16px; display: none; line-height: 1.5;
}
.msg.error   { background: rgba(248,113,113,0.12); color: var(--error);   border: 1px solid rgba(248,113,113,0.2); }
.msg.success { background: rgba(62,207,142,0.12);  color: var(--success); border: 1px solid rgba(62,207,142,0.2); }
.msg.info    { background: rgba(79,142,247,0.10);  color: var(--accent);  border: 1px solid rgba(79,142,247,0.2); }

.link-btn {
  background: none; border: none; color: var(--accent); font-size: 13px;
  cursor: pointer; padding: 0; font-family: var(--sans); text-decoration: underline;
}
.link-btn:hover { opacity: 0.8; }

.forgot-row { text-align: right; margin-top: -6px; margin-bottom: 14px; }

.tab-row {
  display: flex; gap: 4px; margin-bottom: 24px;
  background: var(--bg); border-radius: 8px; padding: 4px; border: 1px solid var(--border);
}
.tab {
  flex: 1; padding: 8px; border-radius: 6px; border: none;
  background: transparent; color: var(--muted);
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-tab); }

.steps { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }
.step { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); transition: color 0.3s; }
.step.active { color: var(--text); }
.step.done   { color: var(--success); }
.step-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex-shrink: 0; transition: background 0.3s; }
.step.active .step-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.step.done .step-dot   { background: var(--success); }

.user-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 14px; margin-bottom: 24px; font-size: 13px;
}
.user-bar .email { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; }
.user-bar .logout { color: var(--error); cursor: pointer; font-size: 12px; flex-shrink: 0; }
.user-bar .logout:hover { text-decoration: underline; }

.resume-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 4px 10px; border-radius: 20px; margin-bottom: 20px;
}
.resume-badge.saved   { background: rgba(62,207,142,0.12); color: var(--success); }
.resume-badge.missing { background: rgba(245,158,11,0.12);  color: var(--warning); }

.download-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
  padding: 10px 18px; background: var(--success); color: var(--bg);
  border-radius: 8px; font-size: 13px; font-weight: 600;
  text-decoration: none; cursor: pointer; border: none;
  font-family: var(--sans); transition: opacity 0.2s;
}
[data-theme="light"] .download-btn { color: #fff; }
.download-btn:hover { opacity: 0.85; }

.screen { display: none; }
.screen.active { display: block; }

.history-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.history-url {
  color: var(--accent); font-size: 13px; font-family: var(--mono);
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-url:hover { text-decoration: underline; }
.history-date { color: var(--muted); font-size: 11.5px; }
.history-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.history-dl { margin-top: 0; padding: 7px 12px; font-size: 12px; }
.history-expired { color: var(--muted); font-size: 12px; }
.history-delete {
  background: none; border: none; color: var(--muted); font-size: 13px;
  cursor: pointer; padding: 5px 7px; border-radius: 6px; line-height: 1;
  transition: color 0.2s, background 0.2s;
}
.history-delete:hover { color: var(--error); background: rgba(248,113,113,0.1); }
.history-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 28px 0; line-height: 1.7; }
.load-more-btn { margin-top: 12px; }

.checkbox-row {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--text); cursor: pointer;
  margin-bottom: 14px; user-select: none;
}
.checkbox-row input[type="checkbox"] {
  width: 15px; height: 15px; accent-color: var(--accent);
  cursor: pointer; flex-shrink: 0;
}
.checkbox-note { color: var(--muted); font-size: 11.5px; }

.resend-row {
  margin-top: 10px; font-size: 12.5px; color: var(--muted); text-align: center;
}
.resend-row .link-btn { font-size: 12.5px; }

.footer { margin-top: 28px; font-size: 12px; color: var(--muted); text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); }

/* ── Builder ── */
.builder-section-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); margin: 22px 0 12px; padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
}

.optional-label {
  color: var(--muted); font-size: 10px; font-weight: 400;
  text-transform: none; letter-spacing: 0;
}

.builder-back-row {
  display: flex; align-items: center; gap: 14px; margin-bottom: 20px;
}
.builder-view-title { font-size: 15px; font-weight: 600; color: var(--text); }

.b-select {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 13px 15px; font-family: var(--sans);
  font-size: 14px; color: var(--text); outline: none;
  transition: border-color 0.2s, box-shadow 0.2s; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.b-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.b-textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 13px 15px; font-family: var(--sans);
  font-size: 14px; color: var(--text); outline: none; resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s; min-height: 80px; line-height: 1.5;
}
.b-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.b-textarea::placeholder { color: var(--muted); }

.b-preview-area { min-height: 340px; font-family: var(--mono); font-size: 12px; line-height: 1.6; }

.entry-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; margin-bottom: 12px;
}
.entry-card-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.entry-card-title {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.entry-remove {
  background: none; border: none; color: var(--muted); font-size: 12px;
  cursor: pointer; padding: 3px 7px; border-radius: 5px;
  font-family: var(--sans); transition: color 0.2s, background 0.2s;
}
.entry-remove:hover { color: var(--error); background: rgba(248,113,113,0.1); }

.entry-date-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px;
}
.entry-date-row .field { margin-bottom: 0; }

/* ── Light mode: re-key msg backgrounds to light-theme status colors ── */
[data-theme="light"] .msg.error   { background: rgba(220, 38,  38, 0.08); border-color: rgba(220, 38,  38, 0.2); }
[data-theme="light"] .msg.success { background: rgba(  5,150, 105, 0.08); border-color: rgba(  5,150, 105, 0.2); }
[data-theme="light"] .msg.info    { background: rgba( 37, 99, 235, 0.08); border-color: rgba( 37, 99, 235, 0.2); }

/* ── Settings ── */
.settings-wrap { margin-left: auto; position: relative; }

.settings-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 17px; line-height: 1;
  padding: 3px 5px; border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.settings-btn:hover { color: var(--text); background: var(--border); }

.settings-panel {
  display: none; position: absolute; right: 0; top: calc(100% + 10px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px; width: 188px; z-index: 200;
  box-shadow: var(--shadow-panel);
}
.settings-panel.open { display: block; }

.settings-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
}

.theme-options { display: flex; gap: 6px; }

.theme-opt {
  flex: 1; padding: 7px 6px; border-radius: 7px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); font-family: var(--sans);
  font-size: 12.5px; font-weight: 500; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.theme-opt:hover { border-color: var(--accent); color: var(--accent); }
.theme-opt.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Chip input ── */
.chip-input-container {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  cursor: text; min-height: 50px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chip-input-container:focus-within {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px 4px 10px; border-radius: 6px;
  font-size: 12.5px; font-family: var(--mono);
  background: var(--border); color: var(--text);
  border: 1px solid transparent; max-width: 230px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  user-select: none;
}
.chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-remove {
  background: none; border: none; color: var(--muted);
  font-size: 15px; line-height: 1; cursor: pointer; padding: 0; flex-shrink: 0;
  transition: color 0.15s;
}
.chip-remove:hover { color: var(--text); }

.chip.queued   { background: rgba(107,107,122,0.14); color: var(--muted); border-color: var(--border); }
.chip.generating {
  background: rgba(79,142,247,0.12); color: var(--accent);
  border-color: rgba(79,142,247,0.3);
  animation: chip-pulse 1.4s ease-in-out infinite;
}
.chip.completed { background: rgba(62,207,142,0.12); color: var(--success); border-color: rgba(62,207,142,0.3); }
.chip.failed    { background: rgba(248,113,113,0.12); color: var(--error);   border-color: rgba(248,113,113,0.3); }
@keyframes chip-pulse { 0%,100% { opacity:1; } 50% { opacity:0.6; } }

.chip-input {
  border: none; background: transparent; outline: none;
  font-family: var(--sans); font-size: 13.5px; color: var(--text);
  flex: 1; min-width: 160px; padding: 4px 2px;
}
.chip-input::placeholder { color: var(--muted); }
.chip-input:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Batch progress ── */
.batch-progress {
  margin-top: 16px; padding: 12px 14px; border-radius: 8px;
  background: rgba(79,142,247,0.06); border: 1px solid rgba(79,142,247,0.15);
}
.batch-progress-label { font-size: 13px; font-weight: 500; color: var(--accent); }
.batch-note { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ── Batch results ── */
.batch-results { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.batch-result-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
}
.batch-result-name {
  font-size: 12.5px; font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1;
}
.batch-result-name.success { color: var(--success); }
.batch-result-name.error   { color: var(--error); }
.batch-result-dl { flex-shrink: 0; margin-top: 0; padding: 6px 11px; font-size: 12px; }

/* ── Saved resume info card (My Resume tab) ── */
.saved-resume-info {
  margin-bottom: 14px; padding: 10px 14px; border-radius: 8px;
  background: rgba(62,207,142,0.07); border: 1px solid rgba(62,207,142,0.25);
}
.saved-resume-name {
  font-size: 13.5px; font-weight: 500; color: var(--success);
  word-break: break-all;
}
.saved-resume-date { font-size: 12px; color: var(--muted); margin-top: 2px; }
.saved-resume-hint { font-size: 12px; color: var(--muted); margin-top: 6px; margin-bottom: 0; }
