:root {
  --bg: #f4efe6;
  --bg-deep: #ebe4d7;
  --surface: #fffdf8;
  --ink: #1c1915;
  --muted: #6b6458;
  --line: #d9d0c0;
  --accent: #0f6e56;
  --accent-soft: #d8efe6;
  --warn: #9a5b12;
  --danger: #9b2c2c;
  --shadow: 0 18px 50px rgba(28, 25, 21, 0.08);
  --radius: 18px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Instrument Serif", Georgia, serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 110, 86, 0.08), transparent 35%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow: hidden;
  z-index: 20;
}

.main {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 36px 42px 60px;
  max-width: 1100px;
  scroll-behavior: smooth;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--surface);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-name {
  font-family: var(--display);
  font-size: 1.35rem;
  line-height: 1;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 4px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-step {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(28, 25, 21, 0.08);
  color: var(--muted);
  flex-shrink: 0;
}

.nav-item.active .nav-step {
  background: var(--accent);
  color: white;
}

.nav-item:hover { background: rgba(28, 25, 21, 0.04); color: var(--ink); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.nav-bottom {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.sidebar-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.account-panel {
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.account-panel .btn { margin-top: 8px; align-self: flex-start; }
.account-name { font-size: 0.85rem; font-weight: 700; overflow-wrap: anywhere; }
.account-email { color: var(--muted); font-size: 0.72rem; overflow-wrap: anywhere; }

.auth-page {
  min-height: 100%;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 28px 18px;
}

.auth-shell { width: min(100%, 460px); }
.auth-brand { justify-content: center; margin-bottom: 22px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 30px;
}
.auth-card h1 { font-family: var(--display); font-size: 2.25rem; font-weight: 400; }
.auth-intro { color: var(--muted); line-height: 1.5; margin-top: 6px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.auth-form .btn { margin-top: 4px; }
.auth-error { min-height: 1.2em; color: var(--danger); font-size: 0.82rem; }

.mini-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}

.mini-stat span {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
}

.mini-stat label {
  color: var(--muted);
  font-size: 0.75rem;
}

.view { display: none; animation: fadeIn 0.25s ease; }
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.view-header {
  margin-bottom: 28px;
}

.view-header.row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.view-header h1 {
  font-family: var(--display);
  font-size: 2.6rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.view-header p {
  color: var(--muted);
  max-width: 52ch;
  line-height: 1.5;
}

.search-form,
.job-card,
.empty-state,
.search-progress {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search-form {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.pasted-job-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.pasted-job-form textarea { width: 100%; min-height: 260px; resize: vertical; }

.pasted-job-form-status {
  min-height: 1.25em;
  color: var(--muted);
  font-size: 0.86rem;
}

.pasted-job-form-status.pending { color: var(--accent); }
.pasted-job-form-status.error { color: var(--danger); }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.7fr;
  gap: 14px;
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

input, select, textarea {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="checkbox"] {
  width: auto;
  padding: 0;
  margin-right: 6px;
  vertical-align: middle;
  accent-color: var(--accent);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 110, 86, 0.12);
}

textarea.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
}

.hint {
  color: var(--muted);
  font-size: 0.75rem;
}

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

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn-outline {
  background: white;
  border: 1px solid var(--line);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn-danger {
  background: #f8e8e8;
  color: var(--danger);
}

.search-progress {
  margin-top: 18px;
  padding: 18px 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.search-progress .progress-body { flex: 1; min-width: 0; }

.search-progress.is-error {
  border-color: #e8c4c4;
  background: #fff8f8;
}

.search-progress.is-done {
  border-color: #b9dfd2;
  background: #f3fbf7;
}

.search-progress.is-error .progress-pulse,
.search-progress.is-done .progress-pulse {
  animation: none;
}

.search-progress.is-error .progress-pulse { background: var(--danger); }
.search-progress.is-done .progress-pulse { background: var(--accent); }

.progress-steps {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 0;
}

.progress-steps li {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.progress-steps li.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.progress-steps li.is-complete {
  color: var(--ink);
  background: #e8f5ef;
  border-color: transparent;
}

.progress-steps li.is-failed {
  color: var(--danger);
  background: #f8e8e8;
  border-color: transparent;
}

.form-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.import-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 28px;
}

#resume-upload-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.import-status {
  display: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.import-status.processing {
  display: block;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(15, 110, 86, 0.18);
}

.import-status.error {
  display: block;
  background: #fcecec;
  color: var(--danger);
  border: 1px solid rgba(184, 55, 55, 0.2);
  font-weight: 600;
}

.resume-import-success {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 4px;
}

.success-mark {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.35rem;
  font-weight: 800;
}

.success-copy h2 {
  font-size: 1.15rem;
  margin: 1px 0 5px;
}

.success-copy p {
  color: var(--muted);
  margin-bottom: 14px;
}

.section-label {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 400;
  margin: 8px 0 16px;
}

.search-progress.hidden,
.empty-state.hidden,
.hidden {
  display: none !important;
}

.progress-pulse {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.55; }
  50% { transform: scale(1.15); opacity: 1; }
}

.progress-title { font-weight: 650; }
.progress-detail { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }

.empty-state.hidden { display: none; }


.empty-state h2 {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 400;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--muted);
  margin-bottom: 18px;
}

.empty-state { padding: 28px; }
.empty-state.compact { padding: 22px; }

.pasted-job-history { margin-top: 34px; }

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading h2 {
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 5px;
}

.section-heading p { color: var(--muted); line-height: 1.45; }

.pasted-job-list {
  display: grid;
  gap: 14px;
}

.pasted-job-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
}

.pasted-job-main { min-width: 0; }
.pasted-job-main h3 { font-size: 1.15rem; line-height: 1.3; }
.pasted-job-meta { color: var(--accent); font-size: 0.82rem; font-weight: 600; margin-top: 5px; }
.pasted-job-preview { color: var(--muted); font-size: 0.92rem; line-height: 1.5; margin-top: 12px; }

.jobs-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

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

.resume-instructions-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 18px;
}

.resume-instructions-panel .field { margin: 0; }
.resume-instructions-panel textarea { width: 100%; }

.jobs-tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}

.jobs-tab {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}

.jobs-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.jobs-search-field {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  margin: 0;
}

.jobs-search-field input {
  width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.chip.status-applied {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.chip.status-skipped {
  background: #f3eee4;
  color: var(--muted);
}

.job-card {
  padding: 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
}

.job-main h3 {
  font-size: 1.15rem;
  line-height: 1.3;
  margin-bottom: 4px;
}

.job-company {
  color: var(--accent);
  font-weight: 600;
}

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
}

.chip.score {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
  font-weight: 650;
}

.job-reason {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.job-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 170px;
}

.job-actions .btn { width: 100%; text-align: center; text-decoration: none; }

.resume-status {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.resume-status.ready { color: var(--accent); font-weight: 600; }
.resume-status.error { color: var(--danger); }

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.saved-hint {
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 600;
}

.saved-hint.hidden,
#btn-save-profile.hidden,
#btn-refresh-jobs.hidden {
  display: none;
}

.profile-actions {
  align-items: center;
}

.toast {
  background: var(--ink);
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: fadeIn 0.2s ease;
  max-width: 340px;
}

@media (max-width: 900px) {
  html, body { overflow: auto; height: auto; }
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    z-index: 30;
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-bottom { margin-top: 0; gap: 14px; }
  .nav-bottom { padding-top: 0; border-top: 0; }
  .sidebar-stats { display: none; }
  .main {
    height: auto;
    overflow: visible;
    padding: 24px 18px 40px;
    max-width: none;
  }
  .field-row, .profile-grid, .job-card, .pasted-job-card { grid-template-columns: 1fr; }
  .job-actions { min-width: 0; }
  .section-heading { flex-direction: column; }
}
