/* ---------- 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;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar__brand {
  font-weight: 650;
  font-size: 17px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.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--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--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); }

/* ---------- 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; }
.add-form__input { flex: 1; }

.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); }
.status-form__select { min-width: 200px; font-weight: 600; }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.meta-grid__item { display: flex; flex-direction: column; gap: 3px; font-size: 14px; }
.meta-grid__label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); 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; }

.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__actions { display: flex; gap: 10px; }

.finalize {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.finalize__label { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.finalize__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@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; }
  .status-form__select { width: 100%; }
}

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