/* Role Radar. Same family as Lifts and Miles: near-white / near-black pages,
   one blue accent, a top bar and a bottom tab bar. */
:root {
  color-scheme: light;
  --page: #f8f8f6;
  --surface: #ffffff;
  --sunk: #efeeea;
  --ink: #111110;
  --muted: #74726c;
  --line: #e2e1da;
  --accent: #2a63d6;
  --accent-soft: #e8eefb;
  --accent-ink: #ffffff;
  --good: #137a3a;
  --good-soft: #e3f3e8;
  --warn: #8a5a00;
  --warn-soft: #fbf0d8;
  --crit: #c2362f;
  --band-hi: #137a3a;
  --band-mid: #2a63d6;
  --band-lo: #8b8982;
  --shadow: 0 1px 2px rgba(17, 17, 16, 0.05), 0 4px 16px rgba(17, 17, 16, 0.04);
  --radius: 14px;
  --tap: 44px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --page: #0e0e0d; --surface: #1a1a19; --sunk: #242422; --ink: #f4f4f2; --muted: #9a988f; --line: #2d2d2a;
    --accent: #6f9cf4; --accent-soft: #1d2a45; --accent-ink: #0b1430;
    --good: #5fcf8b; --good-soft: #15301f; --warn: #f0b85a; --warn-soft: #34280f; --crit: #ff7b72;
    --band-hi: #5fcf8b; --band-mid: #6f9cf4; --band-lo: #858378; --shadow: none;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --page: #0e0e0d; --surface: #1a1a19; --sunk: #242422; --ink: #f4f4f2; --muted: #9a988f; --line: #2d2d2a;
  --accent: #6f9cf4; --accent-soft: #1d2a45; --accent-ink: #0b1430;
  --good: #5fcf8b; --good-soft: #15301f; --warn: #f0b85a; --warn-soft: #34280f; --crit: #ff7b72;
  --band-hi: #5fcf8b; --band-mid: #6f9cf4; --band-lo: #858378; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font: 15px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- frame */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.topbar .spacer { flex: 1; }
.wrap {
  max-width: 880px; margin: 0 auto; display: grid; gap: 16px;
  padding-block: 18px calc(96px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 10; display: flex; justify-content: center; gap: 4px;
  padding: 6px max(16px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 0 1 160px; display: grid; justify-items: center; gap: 2px; padding: 6px 8px; border: 0; background: none;
  color: var(--muted); font-size: 12px; cursor: pointer; border-radius: 10px;
}
.tabbar svg { width: 24px; height: 24px; }
.tabbar button[aria-current='page'] { color: var(--accent); font-weight: 600; }

/* ---------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
  padding: 6px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; text-decoration: none; color: var(--ink); font-size: 14px; white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn[aria-pressed='true'] { background: var(--good-soft); border-color: var(--good); color: var(--good); font-weight: 600; }
.btn.skip[aria-pressed='true'] { background: var(--sunk); border-color: var(--muted); color: var(--muted); }
.chip {
  border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px;
  font-size: 13.5px; cursor: pointer; min-height: 34px;
}
.chip[aria-pressed='true'] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
input[type='search'], input[type='text'], input[type='number'], select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 12px; min-height: 40px;
}
textarea { width: 100%; resize: vertical; line-height: 1.45; }
.syncpill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); background: var(--sunk);
  border: 0; border-radius: 999px; padding: 4px 10px; cursor: pointer;
}
.syncpill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--band-lo); }
.syncpill[data-state='ok']::before { background: var(--good); }
.syncpill[data-state='busy']::before { background: var(--accent); }
.syncpill[data-state='err']::before { background: var(--crit); }

/* ---------- jobs */
.banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn);
}
.banner.info { background: var(--accent-soft); color: var(--ink); }
.banner p { margin: 0; flex: 1 1 260px; }
.criteria { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13.5px; }
.criteria b { color: var(--ink); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.stat { padding: 12px 14px; display: grid; gap: 2px; min-width: 0; background: var(--surface); }
.stat .v { font: 600 21px/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type='search'] { flex: 1 1 220px; min-width: 0; }
.listhead { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 13px; }
.progress { height: 4px; border-radius: 2px; background: var(--sunk); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.list { display: grid; gap: 10px; }
.job {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 14px; align-items: start;
}
.job[data-status='skip'] { opacity: 0.55; }
.job[data-status='applied'] { border-color: var(--good); }
.score { grid-row: span 2; width: 48px; display: grid; justify-items: center; gap: 4px; padding-top: 2px; }
.score .n { font: 600 21px/1 var(--mono); font-variant-numeric: tabular-nums; }
.score .bar { width: 100%; height: 4px; border-radius: 2px; background: var(--sunk); overflow: hidden; }
.score .bar i { display: block; height: 100%; background: currentColor; }
.score.hi { color: var(--band-hi); } .score.mid { color: var(--band-mid); } .score.lo { color: var(--band-lo); }
.head { min-width: 0; }
.title { font-weight: 650; font-size: 16px; color: var(--ink); text-decoration: none; line-height: 1.35; }
.title:hover { text-decoration: underline; }
.meta { color: var(--muted); font-size: 13.5px; }
.pay { text-align: right; white-space: nowrap; }
.pay .amt { font: 600 15px/1.3 var(--mono); font-variant-numeric: tabular-nums; }
.pay .how { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.pay.est .amt { color: var(--muted); font-weight: 500; }
.body { grid-column: 2 / 4; display: grid; gap: 10px; min-width: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--sunk); color: var(--muted); }
.tag.wt { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tag.flag { background: var(--warn-soft); color: var(--warn); }
ul.why { margin: 0; padding-left: 18px; font-size: 13.5px; display: grid; gap: 1px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.src { margin-left: auto; font-size: 12px; color: var(--muted); }
.src a { color: inherit; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.note { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 12px 14px; display: grid; gap: 4px; }
.note h3 { margin: 0; font-size: 14.5px; }
.note p { margin: 0; white-space: pre-wrap; font-size: 14px; }
.note .meta { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
footer.credits { color: var(--muted); font-size: 12.5px; max-width: 70ch; }
footer.credits a { color: inherit; }

/* ---------- settings */
.settings { display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 14px; }
.card > h2 { margin: 0; font-size: 16px; }
.card > p.lede { margin: -8px 0 0; color: var(--muted); font-size: 13.5px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-weight: 600; font-size: 14px; }
.field .hint { color: var(--muted); font-size: 12.5px; margin: 0; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.row5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.row5 input { width: 100%; }
.money { display: flex; align-items: center; gap: 6px; }
.money input { width: 100%; min-width: 0; }
.money span { color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch span { display: grid; }
.switch small { color: var(--muted); font-size: 12.5px; }
.switch input { width: 44px; height: 26px; accent-color: var(--accent); flex: none; }
.tagbox { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-height: 44px; }
.tagbox:focus-within { border-color: var(--accent); }
.tagbox .t { display: inline-flex; align-items: center; gap: 2px; background: var(--sunk); border-radius: 7px; padding: 3px 4px 3px 9px; font-size: 13.5px; }
.tagbox .t button { border: 0; background: none; cursor: pointer; color: var(--muted); width: 24px; height: 24px; border-radius: 6px; font-size: 16px; line-height: 1; }
.tagbox .t button:hover { background: var(--line); color: var(--ink); }
.tagbox input { flex: 1 1 140px; min-width: 100px; border: 0; background: none; padding: 4px 6px; min-height: 30px; outline: none; }
details.card > summary { cursor: pointer; font-weight: 600; font-size: 16px; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: ' ▸'; color: var(--muted); }
details.card[open] > summary::after { content: ' ▾'; }
.savebar {
  position: fixed; inset: auto 0 calc(64px + env(safe-area-inset-bottom, 0px)) 0; z-index: 9; display: flex; justify-content: center;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); pointer-events: none;
}
.savebar > div {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end;
  background: var(--ink); color: var(--page); border-radius: 14px; padding: 8px 8px 8px 16px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  max-width: 880px; width: 100%;
}
.savebar span { flex: 1; font-size: 14px; }
.savebar .btn { border-color: transparent; }
.savebar .btn.quiet { color: var(--page); }
.who { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.who .meta { font-size: 13.5px; }
.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--page); padding: 9px 16px; border-radius: 10px; font-size: 14px; z-index: 20;
  opacity: 0; pointer-events: none; transition: opacity 0.2s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; }

@media (max-width: 720px) {
  /* three tiles over two, so nothing sits alone in a row */
  .stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .stat { grid-column: span 2; }
  .stat:nth-child(n + 4) { grid-column: span 3; }
  .row5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .job { grid-template-columns: auto minmax(0, 1fr); }
  .score { grid-row: auto; }
  .pay { grid-column: 2; text-align: left; }
  .body { grid-column: 1 / -1; }
  .src { margin-left: 0; width: 100%; }
  .stat { padding: 10px 12px; }
  .stat .v { font-size: 18px; }
  .row2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
