/* ---------- Tokens ---------- */
:root {
  --bg: oklch(96% 0.006 250);
  --surface: oklch(99% 0.003 250);
  --surface-alt: oklch(93% 0.008 250);
  --border: oklch(87% 0.012 250);
  --ink: oklch(24% 0.02 250);
  --muted: oklch(42% 0.02 250);
  --accent: oklch(52% 0.16 260);
  --accent-ink: oklch(99% 0.01 260);
  --accent-hover: oklch(46% 0.17 260);

  --tone-neutral-bg: oklch(91% 0.008 250);
  --tone-neutral-ink: oklch(38% 0.02 250);
  --tone-info-bg: oklch(92% 0.05 260);
  --tone-info-ink: oklch(38% 0.13 260);
  --tone-progress-bg: oklch(93% 0.07 70);
  --tone-progress-ink: oklch(38% 0.13 55);
  --tone-success-bg: oklch(92% 0.08 150);
  --tone-success-ink: oklch(34% 0.12 150);
  --tone-danger-bg: oklch(93% 0.06 25);
  --tone-danger-ink: oklch(40% 0.16 25);
  --tone-muted-bg: oklch(91% 0.006 250);
  --tone-muted-ink: oklch(46% 0.015 250);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px oklch(20% 0.02 250 / 0.06), 0 1px 1px oklch(20% 0.02 250 / 0.04);
  --z-dropdown: 10;
  --z-sticky: 20;
  --z-modal: 30;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(19% 0.012 250);
    --surface: oklch(24% 0.014 250);
    --surface-alt: oklch(16% 0.012 250);
    --border: oklch(32% 0.018 250);
    --ink: oklch(93% 0.008 250);
    --muted: oklch(74% 0.02 250);
    --accent: oklch(70% 0.15 260);
    --accent-ink: oklch(15% 0.02 260);
    --accent-hover: oklch(76% 0.14 260);

    --tone-neutral-bg: oklch(30% 0.014 250);
    --tone-neutral-ink: oklch(84% 0.015 250);
    --tone-info-bg: oklch(30% 0.07 260);
    --tone-info-ink: oklch(86% 0.06 260);
    --tone-progress-bg: oklch(32% 0.08 65);
    --tone-progress-ink: oklch(87% 0.08 70);
    --tone-success-bg: oklch(30% 0.08 150);
    --tone-success-ink: oklch(85% 0.1 150);
    --tone-danger-bg: oklch(32% 0.09 25);
    --tone-danger-ink: oklch(87% 0.09 20);
    --tone-muted-bg: oklch(28% 0.012 250);
    --tone-muted-ink: oklch(70% 0.015 250);

    color-scheme: dark;
  }
}

/* ---------- Reset & base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2 { text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar__logout { margin-left: auto; }
.topbar__brand {
  font-weight: 650;
  font-size: 17px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.topbar__nav {
  display: flex;
  gap: 18px;
}
.topbar__nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 550;
}
.topbar__nav a:hover { color: var(--ink); }
.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 550;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 160ms ease-out, border-color 160ms ease-out, opacity 160ms ease-out;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:not(:disabled):hover { background: var(--accent-hover); }
.btn--secondary { background: var(--surface-alt); color: var(--ink); border-color: var(--border); }
.btn--secondary:not(:disabled):hover { background: var(--border); }
.btn--ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn--ghost:not(:disabled):hover { color: var(--ink); border-color: var(--muted); }
.btn--danger { background: transparent; color: var(--tone-danger-ink); border-color: var(--tone-danger-bg); }
.btn--danger:not(:disabled):hover { background: var(--tone-danger-bg); }
.btn--small { padding: 6px 12px; font-size: 13px; }
.btn--block { width: 100%; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 550; color: var(--muted); }
.field__input {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}
.field__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Login ---------- */
.login-body {
  margin: 0;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
}
.login-card {
  width: min(360px, 90vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 32px 28px;
}
.login-card__title { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.01em; }
.login-card__subtitle { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Alerts ---------- */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin: 0 0 16px;
}
.alert--danger { background: var(--tone-danger-bg); color: var(--tone-danger-ink); }
.alert--warning { background: var(--tone-progress-bg); color: var(--tone-progress-ink); }
.alert--success { background: var(--tone-success-bg); color: var(--tone-success-ink); }
.alert--neutral { background: var(--tone-neutral-bg); color: var(--tone-neutral-ink); }
.alert--row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge--neutral { background: var(--tone-neutral-bg); color: var(--tone-neutral-ink); }
.badge--info { background: var(--tone-info-bg); color: var(--tone-info-ink); }
.badge--progress { background: var(--tone-progress-bg); color: var(--tone-progress-ink); }
.badge--success { background: var(--tone-success-bg); color: var(--tone-success-ink); }
.badge--danger { background: var(--tone-danger-bg); color: var(--tone-danger-ink); }
.badge--muted { background: var(--tone-muted-bg); color: var(--tone-muted-ink); }

/* ---------- Board ---------- */
.board-header {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
}
.board-header__title { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.01em; }
.board-header__subtitle { margin: 0; color: var(--muted); font-size: 14px; }
.add-form { display: flex; gap: 8px; flex: 1 1 320px; max-width: 480px; align-items: flex-start; }
.add-form__input { flex: 1; resize: vertical; min-height: 38px; max-height: 200px; line-height: 1.4; font-family: inherit; }

.gmail-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 13.5px;
}
.gmail-bar__status { color: var(--muted); margin-right: auto; }

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
}
.empty-state__title { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.empty-state__body { color: var(--muted); margin: 0; }

.board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 12px;
}
.column {
  flex: 0 0 288px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 12px;
}
.column__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
}
.column__count { color: var(--muted); font-size: 13px; font-weight: 600; }
.column__cards { display: flex; flex-direction: column; gap: 8px; min-height: 4px; }
.column__empty { color: var(--muted); font-size: 13px; text-align: center; padding: 8px 0; margin: 0; }

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow-card);
  transition: border-color 160ms ease-out, transform 160ms ease-out;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card__company { margin: 0 0 2px; font-weight: 650; font-size: 14px; }
.card__position { margin: 0 0 8px; color: var(--muted); font-size: 13.5px; }
.card__meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); gap: 8px; }
.card__flag { color: var(--tone-progress-ink); }

/* ---------- Email matches ---------- */
.match-list { display: flex; flex-direction: column; gap: 12px; }
.match-card {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.match-card__main { min-width: 0; flex: 1; }
.match-card__vacancy { margin: 0 0 4px; font-weight: 650; font-size: 14px; }
.match-card__subject { margin: 0 0 2px; font-size: 14px; }
.match-card__from { margin: 0 0 8px; color: var(--muted); font-size: 12.5px; }
.match-card__snippet { margin: 0; color: var(--muted); font-size: 13px; max-width: 65ch; }
.match-card__side {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  text-align: right;
}
.match-card__confidence, .match-card__current { color: var(--muted); font-size: 12px; }
.match-card__actions { display: flex; gap: 8px; margin-top: 6px; }

@media (max-width: 640px) {
  .match-card { flex-direction: column; }
  .match-card__side { align-items: flex-start; text-align: left; flex-basis: auto; }
}

/* ---------- Vacancy detail ---------- */
.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
}
.back-link:hover { color: var(--ink); }

.detail-header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}
.detail-header__title { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.01em; }
.detail-header__subtitle { margin: 0; color: var(--muted); font-size: 14px; }
.detail-header__subtitle a { color: var(--muted); }
.detail-header__facts { margin: 6px 0 0; color: var(--muted); font-size: 14px; max-width: 80ch; }
.detail-header__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.status-form__select { min-width: 200px; font-weight: 600; }

.panel { margin-bottom: 24px; }
.panel__title { font-size: 15px; margin: 0 0 10px; letter-spacing: -0.01em; }
.panel__pre {
  white-space: pre-wrap;
  font-family: inherit;
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0;
  max-height: 340px;
  overflow-y: auto;
  font-size: 14px;
  max-width: 75ch;
}
.panel__hint { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.panel__hint--after { margin: 10px 0 0; }
.panel__details { margin-top: 12px; }
.panel__details summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.panel__details summary:hover { color: var(--ink); }
.panel__details .panel__pre { max-height: 22rem; overflow: auto; margin-top: 8px; }
.panel__details > .panel__hint { margin-top: 8px; }
.panel__details--section { margin: 0; padding: 12px 0; border-top: 1px solid var(--border); }
.panel__details--section > summary { color: var(--ink); font-weight: 550; }
.panel__details--section > .copy-panel { margin-top: 10px; }

.diff { max-height: 24rem; overflow: auto; font-size: 12.5px; }
.diff__add { color: var(--tone-success-ink); }
.diff__del { color: var(--tone-danger-ink); text-decoration: line-through; opacity: .85; }
.diff__ctx { color: var(--muted); }
.diff__hunk { color: var(--muted); font-style: italic; }

.draft-form { display: flex; flex-direction: column; gap: 12px; }
.draft-form__textarea {
  width: 100%;
  min-height: 420px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.6;
  resize: vertical;
}
.draft-form__textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.draft-form__textarea::placeholder { color: var(--muted); }
.draft-form__actions { display: flex; gap: 10px; align-items: center; }
.draft-form__meta { min-height: 1.2em; }
.draft-form__status { font-size: 12px; color: var(--muted); }
.draft-form__status.is-error { color: var(--tone-danger-ink); font-weight: 600; }

.copy-panel { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.copy-panel .btn { font-size: 13px; }
.copy-panel--after { margin: 10px 0 0; }

/* The review bench: the résumé that goes out next to what it is judged against. */
.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  margin-bottom: 24px;
}
.workbench--solo { grid-template-columns: minmax(0, 1fr); max-width: 900px; }
.workbench__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.workbench__head .panel__title { margin: 0; }
.draft-form__textarea--bench { height: 52vh; min-height: 320px; }
.panel__pre--bench { max-height: 52vh; max-width: none; }

.sent__row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 14px; }

.pick-list { list-style: none; margin: 8px 0 0; padding: 0; }
.pick-list__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.pick-list__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Always-visible next step. The page drops its bottom padding so the bar sits flush. */
.page:has(.action-bar) { padding-bottom: 0; }
.action-bar {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 28px -24px 0;
  padding: 12px 24px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.action-bar__spacer { flex: 1 1 0; }

.profile-form { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.profile-form__row { display: flex; flex-direction: column; gap: 4px; }
.profile-form__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profile-privacy { margin-top: 24px; }
.profile-privacy__check { display: flex; align-items: center; gap: 8px; font-weight: 550; cursor: pointer; }
.profile-token { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); max-width: 640px; }
.profile-token__value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  background: var(--surface-alt);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.card__teammates {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.applications-list { display: flex; flex-direction: column; gap: 4px; }
.applications-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.applications-row:last-child { border-bottom: none; }
.applications-row__link {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1;
  min-width: 0;
  color: inherit;
}
.applications-row__company { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.applications-row__position { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.applications-row__date { color: var(--muted); font-size: 13px; white-space: nowrap; }
.applications-row__format { color: var(--muted); font-size: 13px; }

.team-list { display: flex; flex-direction: column; gap: 4px; }
.team-list__row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.team-list__row:last-child { border-bottom: none; }
.team-list__name { flex: 1; font-weight: 550; }
.team-list__date { color: var(--muted); font-size: 13px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* ---------- Table view ---------- */
.table-wrap { overflow-x: auto; }
.vtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.vtable th, .vtable td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.vtable th { cursor: pointer; user-select: none; color: var(--muted); font-size: 13px; }
.vtable td.vtable__stack { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.bulk-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }

/* ---------- Application stats ---------- */
.stats-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.stats-chip {
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 10px 16px;
  min-width: 120px;
}
.stats-chip__value { display: block; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.stats-chip__label { display: block; color: var(--muted); font-size: 12.5px; }

/* ---------- Prompts ---------- */
.prompts-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 18px;
}
.prompts-toolbar__form { display: flex; align-items: flex-end; gap: 10px; margin: 0; }
.prompts-create {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.prompts-files { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.prompts-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .draft-form__textarea--bench { height: 50vh; }
  .panel__pre--bench { max-height: 340px; }
}
@media (max-width: 640px) {
  .page { padding: 20px 16px 48px; }
  .topbar { padding: 12px 16px; }
  .board-header { align-items: stretch; }
  .add-form { max-width: none; flex-basis: 100%; }
  .detail-header { flex-direction: column; }
  .action-bar { margin: 24px -16px 0; padding: 10px 16px; }
  .action-bar { gap: 8px; }
  .action-bar .btn { padding: 9px 10px; font-size: 13px; }
  .action-bar > a, .action-bar__spacer, .action-bar__long { display: none; }
  .action-bar__main { flex: 1 1 auto; order: -1; }
  .action-bar__main .btn { width: 100%; }
  .topbar { gap: 14px; }
  .topbar__nav { min-width: 0; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .status-form__select { width: 100%; }
  .profile-form__grid { grid-template-columns: 1fr; }
  .applications-row { flex-wrap: wrap; }
  .applications-row__link { flex-basis: 100%; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .btn { transition: none; }
}
