/* Nothing on this page is a scroll container except the page itself. The list
   rail and the job flow down together and the window scrolls once, which is
   the whole point of the layout. */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2230;
  --line: #2a3140;
  --text: #e6edf3;
  --muted: #8b95a5;
  --accent: #4c8dff;
  --accent-ink: #fff;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --top: #a371f7;
  --nav-h: 56px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa;
    --surface: #fff;
    --surface-2: #eef1f6;
    --line: #dde2ea;
    --text: #10151d;
    --muted: #5c6675;
    --accent: #1f6feb;
    --good: #1a7f37;
    --warn: #9a6700;
    --bad: #cf222e;
    --top: #8250df;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); min-height: 1.2em; margin: 0; font-size: 14px; }

/* ------------------------------------------------------------------- login */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }

.login-card {
  width: min(340px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 22px;
  display: grid;
  gap: 14px;
}

.login-card h1 { font-size: 22px; }

/* --------------------------------------------------------------------- top */

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 650; font-size: 15px; }
.sync { margin-left: auto; font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; align-items: center; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); display: inline-block; margin-right: 5px; }
.dot.stale { background: var(--warn); }
.dot.cold { background: var(--bad); }

.tag {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
}

.icon-btn {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 17px;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 8px;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

.nav { display: flex; gap: 4px; }

.nav-item {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.nav-item:hover { color: var(--text); }
.nav-item.active { color: var(--text); background: var(--surface-2); }

/* ------------------------------------------------------------------- shell */

.shell { padding: 20px; display: grid; gap: 28px; }

@media (min-width: 900px) {
  /* The rail flows with the page rather than scrolling inside itself, so it
     simply ends where its last card does. */
  .shell { grid-template-columns: 290px minmax(0, 1fr); align-items: start; padding: 22px 24px 60px; gap: 32px; }
}

/* On a phone there is only room for one of them, so they take turns. */
@media (max-width: 899px) {
  .shell.picked .rail { display: none; }
  .shell:not(.picked) .content { display: none; }
}

/* -------------------------------------------------------------------- rail */

.rail { display: grid; gap: 10px; align-content: start; }

.dates { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.dates::-webkit-scrollbar { display: none; }

.date {
  flex: 0 0 auto;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 5px 11px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.date.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }

.chip {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.clear { color: var(--muted); border-style: dashed; }

.job-card {
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
}
.job-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.job-card.top { border-left-color: var(--top); }
.job-card.on { border-color: var(--accent); border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }

.job-card b { font-weight: 600; font-size: 14px; line-height: 1.35; }
.job-card span { color: var(--muted); font-size: 12.5px; }
.job-card i { font-style: normal; color: var(--good); font-size: 12px; font-weight: 600; }

/* ----------------------------------------------------------------- content */

.content { min-width: 0; }

.blank { color: var(--muted); padding: 60px 0; text-align: center; font-size: 14px; }

.back {
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 550;
  padding: 0 0 12px;
  cursor: pointer;
}
@media (min-width: 900px) { .back { display: none; } }

.job h1 { font-size: 23px; line-height: 1.25; }
.main-col { min-width: 0; }
.job .sub { color: var(--muted); margin: 5px 0 0; font-size: 14px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }

.state {
  margin: 12px 0 0;
  font-size: 13.5px;
  color: var(--muted);
  border-left: 2px solid var(--line);
  padding-left: 10px;
}
.state.done { border-left-color: var(--good); }
.state.wait { border-left-color: var(--warn); }

.job h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 34px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.prose { max-width: 72ch; overflow-wrap: anywhere; }
.prose h1 { font-size: 18px; margin: 18px 0 8px; }
.prose h2 { font-size: 16px; margin: 18px 0 8px; text-transform: none; letter-spacing: 0; color: var(--text); border: 0; padding: 0; }
.prose h3 { font-size: 15px; margin: 14px 0 6px; color: var(--muted); }
.prose p { margin: 9px 0; }
.prose ul { margin: 9px 0; padding-left: 20px; }
.prose li { margin: 4px 0; }
.prose pre { background: var(--surface-2); padding: 11px; border-radius: 9px; overflow-x: auto; font-size: 13px; white-space: pre-wrap; }
.prose > :first-child { margin-top: 0; }

/* The posting and the documents side by side, so the right half of a wide
   screen carries the CV instead of nothing. Single column until there is
   genuinely room for two readable ones. */
.job-grid { display: grid; gap: 30px; }

@media (min-width: 1180px) {
  .job-grid { grid-template-columns: minmax(0, 1fr) minmax(420px, 0.95fr); align-items: start; }

  /* Pinned, not scrollable: the page still scrolls as one, the column just
     stops travelling so a requirement can be checked against the CV without
     scrolling back up. */
  .docs-col { position: sticky; top: 16px; }

  /* Starts level with the job title. The 4px is optical - a 13px uppercase
     label sitting flush against a 23px heading reads as too high. */
  .docs-col > h2:first-child { margin-top: 4px; }
}

.pdf {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  /* Stacked on a phone, so give it the shape of the page itself. */
  aspect-ratio: 1 / 1.414;
}

/* Pinned, it has to fit the window instead — otherwise the bottom of the
   document is permanently below the fold and pinning buys nothing. */
@media (min-width: 1180px) {
  .pdf { aspect-ratio: auto; height: min(calc(100vh - 150px), 940px); }
}

.doc-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; }
.doc-links { display: flex; gap: 12px; font-size: 13px; }

.switch { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 3px; }
.switch button {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 560;
  padding: 6px 13px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.switch button.on { background: var(--surface); color: var(--text); }

.ats { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.ats a { margin-left: 10px; }

details.more { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 12px; }
details.more > summary {
  cursor: pointer;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 650;
}
details.more > summary:hover { color: var(--text); }
details.more[open] > summary { margin-bottom: 14px; }
.more-body { display: grid; gap: 12px; max-width: 640px; }

/* --------------------------------------------------------------- form bits */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 560;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:active { opacity: 0.8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.on { border-color: var(--good); color: var(--good); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.wide { width: 100%; justify-content: center; }

label { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 550; }

input, select, textarea {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: -1px;
}
textarea { resize: vertical; line-height: 1.5; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }

.warn-box {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--warn);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 13px;
}

/* -------------------------------------------------------- applied and add */

.wide-view { max-width: 900px; display: grid; gap: 12px; }

.row-item {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
}
.row-item b { font-weight: 600; font-size: 14px; }
.row-item span { color: var(--muted); font-size: 12.5px; }
.row-item .when { flex: 0 0 auto; font-size: 12.5px; color: var(--muted); text-align: right; }
.row-item .when em { font-style: normal; color: var(--good); }

/* ------------------------------------------------------------------- phone */

@media (max-width: 899px) {
  .top { padding: 10px 16px calc(10px + env(safe-area-inset-top)); }
  .brand { display: none; }
  .shell { padding: 16px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 30px); }

  /* The three views move to a thumb-reachable bar. */
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .nav-item { border-radius: 0; padding: 12px 0; text-align: center; }
  .nav-item.active { background: none; color: var(--accent); }

  .job h1 { font-size: 20px; }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ------------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  transform: translate(-50%, 12px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 550;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 60;
  max-width: min(90vw, 400px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 900px) { .toast { bottom: 22px; } }
