:root {
  --bg: #f3ecdf;
  --bg-2: #e7dcc8;
  --ink: #1d1814;
  --muted: #5e5348;
  --line: #d4c4ae;
  --card: #fffaf3;
  --accent: #c4551a;
  --accent-ink: #fff8f4;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 8px 20px rgba(60, 36, 12, 0.06);
  --c-saved: #2f6f9f;
  --c-applied: #a56b12;
  --c-screen: #8a4e86;
  --c-interview: #c4551a;
  --c-offer: #1f7a45;
  --c-rejected: #8d4a4a;
  color-scheme: light;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161311;
    --bg-2: #221e1a;
    --ink: #f6f0e6;
    --muted: #c3b5a4;
    --line: #3d352e;
    --card: #26211c;
    --accent: #f0a05a;
    --accent-ink: #2a1608;
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
    --c-saved: #8ebfdf;
    --c-applied: #e2b15a;
    --c-screen: #e0a0d4;
    --c-interview: #f0a05a;
    --c-offer: #7dcea0;
    --c-rejected: #e0a0a0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background:
    radial-gradient(1000px 420px at 8% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 55%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  font-size: 15px;
  line-height: 1.4;
  overflow-x: clip;
}

body::before {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(90deg, var(--c-saved), var(--c-applied), var(--c-screen), var(--c-interview), var(--c-offer), var(--c-rejected));
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}

button:hover { border-color: color-mix(in srgb, var(--accent) 65%, var(--line)); }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--card);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 5;
}

.skip:focus { top: 12px; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 16px 16px 10px;
}

h1 {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-weight: 500;
  font-size: clamp(32px, 4vw, 42px);
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.stamp {
  display: block;
  margin-bottom: 4px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.lede {
  margin: 8px 0 0;
  max-width: 46ch;
  color: var(--muted);
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 4px 16px 10px;
}

.stat {
  background: color-mix(in srgb, var(--card) 78%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}

.stat b {
  display: block;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-weight: 500;
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tools {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 8px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
}

.search label { color: var(--muted); font-size: 13px; }

.search:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#q {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 8px 0;
  font-size: 16px;
}

#q:focus, #q:focus-visible { outline: none; }

.status { margin: 0 0 0 auto; color: var(--muted); font-size: 13px; }

.jumps {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 16px 8px;
}

.jumps button { padding: 6px 10px; font-size: 13px; white-space: nowrap; }

.board {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 16px 16px;
  scroll-snap-type: x mandatory;
  align-items: stretch;
}

.board-empty { display: block; }

.column {
  flex: 1 0 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 228px);
  min-height: 280px;
  scroll-snap-align: start;
  background: color-mix(in srgb, var(--card) 50%, transparent);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.column[data-stage="saved"] { --stage: var(--c-saved); }
.column[data-stage="applied"] { --stage: var(--c-applied); }
.column[data-stage="screen"] { --stage: var(--c-screen); }
.column[data-stage="interview"] { --stage: var(--c-interview); }
.column[data-stage="offer"] { --stage: var(--c-offer); }
.column[data-stage="rejected"] { --stage: var(--c-rejected); }

.col-h {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 8px;
}

.col-h::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stage);
  flex: none;
}

.col-h h2 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.count {
  margin-left: auto;
  min-width: 1.4rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--stage);
  border: 1px solid color-mix(in srgb, var(--stage) 45%, var(--line));
  border-radius: 999px;
  padding: 0 6px;
}

.cards {
  overflow: auto;
  padding: 0 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.ghost {
  margin: 8px 4px;
  color: var(--muted);
  font-size: 13px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--stage);
  border-radius: 12px;
  padding: 8px 8px 8px 10px;
  box-shadow: var(--shadow);
  cursor: grab;
}

.card:hover { border-color: color-mix(in srgb, var(--stage) 55%, var(--line)); }
.card.dragging { opacity: 0.45; }
.card.drop-before { box-shadow: 0 -2px 0 var(--accent); }
.column.drop { outline: 2px solid var(--accent); outline-offset: -2px; }

.card h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.role { margin: 2px 0 0; font-size: 13px; }

.notes {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.card a { font-size: 12px; color: var(--accent); }

.card-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  margin-top: 8px;
}

.card-actions select,
.card-actions button {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 4px 6px;
  min-height: 32px;
  font-size: 13px;
  cursor: pointer;
}

.empty {
  max-width: 520px;
  margin: 24px auto;
  padding: 40px 20px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--card) 72%, transparent);
}

.empty h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-weight: 500;
  font-size: 28px;
}

.empty p { margin: 0 0 16px; color: var(--muted); }
.empty .actions { justify-content: center; }

dialog {
  width: min(440px, calc(100vw - 24px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(20, 16, 12, 0.5); }

form { display: grid; gap: 12px; padding: 18px; }

form h2 {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-weight: 500;
}

form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

input, textarea, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 16px;
}

.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

.error { margin: 0; color: var(--c-rejected); font-size: 14px; }

.toast {
  position: fixed;
  z-index: 6;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 24px);
  padding: 8px 8px 8px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
}

.toast[hidden] { display: none; }

.toast button {
  background: transparent;
  color: inherit;
  border-color: currentColor;
  padding: 4px 10px;
}

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

noscript {
  margin: 16px;
  color: var(--muted);
}

@media (max-width: 1099px) {
  .column { flex: 0 0 260px; min-width: 260px; }
}

@media (min-width: 1100px) {
  .jumps { display: none; }
}

@media (max-width: 700px) {
  .top { flex-direction: column; align-items: stretch; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; justify-content: stretch; }
  .actions .primary { grid-column: 1 / -1; }
  .stats { grid-template-columns: 1fr 1fr; }
  .tools { flex-wrap: wrap; }
  .search { max-width: none; }
  .status { margin-left: 0; width: 100%; }
  .actions button:last-child:nth-child(even) { grid-column: 1 / -1; }
  .column { max-height: none; min-height: 70vh; }
  .toast { top: 12px; bottom: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
  .card, .column, button, .stat { border: 1px solid ButtonText; }
}
