/* Light, neutral theme */
:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --card: #ffffff;
  --ink: #23272b;
  --muted: #6b7178;
  --line: #e4e4e0;
  --soft: #f0f0ed;
  --accent: #46689b;       /* muted slate blue, used sparingly */
  --accent-soft: #eaf0f8;
  --star: #c4932a;
  --focus: #6d95cf;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; width: 100%; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* Header */
.top { background: var(--card); border-bottom: 1px solid var(--line); padding: calc(14px + env(safe-area-inset-top)) 0 14px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.brandnav { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.brand { margin: 0; font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.navlink { font-size: 15px; font-weight: 600; color: var(--accent); text-decoration: none; }
.brand:hover span, .navlink:hover { text-decoration: underline; }
.brand span { font-weight: 500; color: var(--muted); }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Standard / AI switch */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; position: relative; margin-right: 4px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track { width: 38px; height: 22px; border-radius: 999px; background: #cfd2d4; position: relative; transition: background .15s; flex: none; }
.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:checked ~ .switch-label:last-child { color: var(--ink); font-weight: 600; }
.switch input:not(:checked) ~ .switch-label:first-child { color: var(--ink); font-weight: 600; }
.switch input:focus-visible + .track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }

/* Search box */
.search { display: grid; gap: 8px; background: var(--soft); border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.field { display: grid; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px 6px; }
.field:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.field span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input { border: 0; padding: 2px 0; background: transparent; font-size: 17px; outline: none; }
.field { position: relative; }

/* Type-ahead suggestions */
.ac { position: absolute; left: -1px; right: -1px; top: calc(100% + 4px); z-index: 30; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 4px; max-height: 320px; overflow-y: auto; }
.ac span { font-size: inherit; font-weight: inherit; color: inherit; }
.ac .opt { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 7px; font-size: 15px; color: var(--ink); cursor: pointer; }
.ac .opt[aria-selected="true"], .ac .opt:hover { background: var(--soft); }
.ac .opt .tx { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac .opt .ic { color: var(--muted); width: 16px; flex: none; text-align: center; }
.ac .opt .sub { color: var(--muted); font-size: 13px; margin-left: auto; padding-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac .head { font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 10px 2px; }
input, select { width: 100%; font: inherit; color: var(--ink); }
select {
  font-size: 15px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--card); color: var(--ink);
}
select:focus, button:focus-visible, .job:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button {
  font: inherit; font-weight: 600; font-size: 16px;
  padding: 11px 18px; min-height: 46px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; cursor: pointer;
}
button[disabled] { opacity: .6; cursor: progress; }
button.ghost {
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  font-size: 14px; font-weight: 600; min-height: 38px; padding: 7px 12px;
}
button.ghost:hover { background: var(--soft); }
button.ghost span { color: var(--muted); margin-left: 3px; }
button.ghost[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

/* Filters and chips */
.filters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; }
.filters label { display: grid; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.chips-label { font-size: 13px; color: var(--muted); }
.chip {
  font-size: 13px; font-weight: 500; min-height: 30px; padding: 4px 12px; border-radius: 999px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: #c9d6ea; color: var(--accent); font-weight: 600; display: inline-flex; align-items: center; }

@media (min-width: 640px) {
  .search { grid-template-columns: 1.6fr 1fr auto; align-items: stretch; }
  .filters { grid-template-columns: repeat(4, minmax(0, 210px)); }
}

/* Results */
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin: -2px 0 14px; }
.suggest .chip { min-height: 38px; padding: 7px 14px; font-weight: 600; color: var(--accent); }
.status { color: var(--muted); margin: 16px 0 10px; font-size: 15px; }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; align-content: start; }
.job { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; }
.job:hover { border-color: #cfd3d6; }
.job.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.job h2 { font-size: 16px; margin: 0; line-height: 1.3; font-weight: 650; }
.co { margin: 1px 0 0; color: var(--muted); font-size: 14px; }
.lines { margin-top: 4px; }
.line { margin: 0; font-size: 14px; color: var(--muted); }
.line.pay { color: var(--ink); font-weight: 600; }
.cardfoot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 13px; color: var(--muted); }
.star { background: transparent; color: var(--star); border: 0; min-height: 34px; min-width: 34px; padding: 0; font-size: 20px; line-height: 1; flex: none; }

.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; font-size: 13px; align-items: center; }
.meta > span { background: var(--soft); border: 1px solid var(--line); border-radius: 7px; padding: 2px 8px; }
.meta > .pay { font-weight: 600; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; background: #efefec; color: #555b61; border: 0 !important; }
.tag[data-source="Reed"]      { background: #fbecef; color: #a3354f; }
.tag[data-source="Adzuna"]    { background: #eaf1fb; color: #3a5f99; }
.tag[data-source="Jooble"]    { background: #ebf5ee; color: #3c7a52; }
.tag[data-source="Careerjet"] { background: #fbf0e6; color: #9a5a26; }
.tag[data-source="Arbeitnow"] { background: #f1edf9; color: #6a4fa3; }
.tag[data-source="Remotive"], .tag[data-source="Remote OK"] { background: #e9f4f5; color: #3b7580; }
.tag[data-source="DWP"]       { background: #f8f3df; color: #7c6420; }

.details { display: none; margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.job[aria-expanded="true"] .details { display: block; }
.details p { margin: 0 0 12px; font-size: 15px; }
.apply { display: inline-block; text-decoration: none; background: var(--accent); color: #fff; font-weight: 600; padding: 10px 16px; border-radius: 10px; }

.pane { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; }
.pane h2 { font-size: 22px; margin: 0; line-height: 1.25; }
.pane .co { font-size: 15px; }
.pane .summary { margin: 18px 0 20px; padding-top: 16px; border-top: 1px solid var(--line); line-height: 1.6; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions .apply { flex: 1; text-align: center; min-width: 200px; }
.actions .mark[disabled] { opacity: 1; color: #2f6b45; border-color: #bfe0c9; background: #eef8f1; cursor: default; }
.pane .note { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

/* Show more / Load more jobs */
.results .more { list-style: none; display: flex; justify-content: center; padding: 6px 0 10px; }
.more-btn { min-width: 220px; min-height: 44px; font-size: 15px; }

/* Applicant notice: one quiet line */
.notice { margin: 0 0 14px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.notice strong { color: #8a6514; font-weight: 600; }

/* Viewed / Applied / New tags */
.tag-viewed, .tag-applied, .tag-new { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.tag-viewed  { background: #efefec; color: #6b7178; }
.tag-applied { background: #eef8f1; color: #2f6b45; }
.tag-new     { background: #eaf0f8; color: var(--accent); }
.job.seen h2 { color: #4d535a; }
.line.nopay { color: var(--muted); font-style: italic; }

/* Centred apply button, small "I applied" link beneath */
.actions { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.actions .apply { min-width: 240px; text-align: center; }
.linkish { background: none; border: 0; min-height: 32px; padding: 4px 8px; color: var(--accent); font-size: 14px; font-weight: 600; text-decoration: underline; }
.linkish[disabled] { color: #2f6b45; text-decoration: none; opacity: 1; cursor: default; }

/* New-jobs button: pulses gently until tapped */
.newbtn {
  font-size: 14px; font-weight: 700; min-height: 38px; padding: 7px 14px;
  background: var(--accent); color: #fff; border-radius: 999px;
  animation: newPulse 1.6s ease-in-out infinite;
}
@keyframes newPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(70,104,155,.45); }
  50% { box-shadow: 0 0 0 7px rgba(70,104,155,0); }
}
@media (prefers-reduced-motion: reduce) { .newbtn { animation: none; } }

/* Filters fold behind a button on phones */
.filters-btn { display: none; margin-top: 10px; }
@media (max-width: 639px) {
  .filters-btn { display: inline-block; }
  .filters { display: none; }
  .filters.open { display: grid; }
}

/* Desktop: scrollable list on the left, sticky detail pane on the right */
@media (min-width: 900px) {
  .split { display: grid; grid-template-columns: minmax(0, 36%) minmax(0, 1fr); gap: 16px; align-items: start; }
  .results { max-height: calc(100vh - 40px); overflow: auto; padding: 2px 4px 2px 2px; position: sticky; top: 16px; }
  .details { display: none !important; }
  .pane { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
}

.skeleton { height: 104px; border-radius: var(--radius); background: #ebebe7; animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .skeleton, .track, .track::after { animation: none; transition: none; } }

.foot { border-top: 1px solid var(--line); margin-top: 32px; padding: 14px 0 calc(18px + env(safe-area-inset-bottom)); background: var(--card); }
.foot p { margin: 0; color: #9ca3af; font-size: 13px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 10;
  max-width: min(560px, calc(100% - 32px)); display: flex; gap: 12px; align-items: center;
  background: #2b3036; color: #fff; padding: 12px 14px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.18); font-size: 14px;
}
.toast .ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); flex: none; }
.foot .credit { font-size: 12px; margin-top: 4px; }
.linkish.cvhelp { color: var(--muted); font-weight: 500; font-size: 13px; }
