/* Job Scout UI — same design language as the alive_ai-pipeline project:
   flat neutral greys, one indigo accent, hairline borders, 12/8 px radius,
   mono for numbers and small labels. Light first, compact dark variant. */

:root, [data-theme="light"] {
  /* Upwork-inspired palette: white surfaces, one green, green-grey hairlines. */
  --bg: #f7f9f7;
  --bg2: #ffffff;
  --panel: #ffffff;
  --panel2: #f7f9f7;
  --line: #d5e0d5;
  --text: #001e00;
  --muted: #5e6d55;
  --accent: #14a800;
  --accent-hover: #108a00;
  --accent2: #108a00;
  --accent-wash: #eaf7ea;
  --accent-wash-border: #b7e0b7;
  --ok: #108a00;
  --ok-fill: #14a800;
  --ok-wash: #eaf7ea;
  --ok-border: #b7e0b7;
  --danger: #b42318;
  --danger-fill: #d92d20;
  --danger-wash: #fef3f2;
  --danger-border: #fecdca;
  --warn: #8a5a00;
  --warn-fill: #f79009;
  --warn-wash: #fffaeb;
  --radius: 12px;
  --radius-sm: 8px;
  --rowhover: #f7f9f7;
  --topbar: rgba(255, 255, 255, .95);
  --tabbar: #ffffff;
  --shadow: 0 1px 2px rgba(0, 30, 0, .06);
  --shadow-pop: 0 12px 28px rgba(0, 30, 0, .12);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0a130b;
  --bg2: #0f1a10;
  --panel: #0f1a10;
  --panel2: #142117;
  --line: #223022;
  --text: #e7f0e7;
  --muted: #9bb09b;
  --accent: #56d364;
  --accent-hover: #7ee787;
  --accent2: #56d364;
  --accent-wash: rgba(86, 211, 100, .14);
  --accent-wash-border: rgba(86, 211, 100, .38);
  --ok: #56d364;
  --ok-fill: #2ea043;
  --ok-wash: rgba(86, 211, 100, .13);
  --ok-border: rgba(86, 211, 100, .35);
  --danger: #ff9c9c;
  --danger-fill: #f04438;
  --danger-wash: rgba(255, 107, 107, .13);
  --danger-border: rgba(255, 107, 107, .35);
  --warn: #fbbf6b;
  --warn-fill: #f79009;
  --warn-wash: rgba(251, 191, 107, .13);
  --rowhover: #16241a;
  --topbar: rgba(12, 22, 13, .94);
  --tabbar: #0c160d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-pop: 0 12px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  padding-bottom: calc(58px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1 { font-size: 1.5rem; letter-spacing: -.02em; font-weight: 600; margin: 0 0 .2rem; }
h2 { font-size: 1rem; font-weight: 600; margin: 1.1rem 0 .45rem; }
p { margin: .4rem 0; }
pre { white-space: pre-wrap; word-break: break-word; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--topbar);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 650; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark {
  width: 18px; height: 18px; border-radius: 6px;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.topnav { display: none; align-items: center; gap: 1.1rem; font-size: .875rem; color: var(--muted); }
.topnav a { color: var(--muted); }
.topnav a:hover { color: var(--accent); text-decoration: none; }
.topnav a.nav-on { color: var(--text); font-weight: 600; }
.topnav .menu { margin-left: .2rem; }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: .3rem .6rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--muted); font-size: .82rem;
}
.menu-btn:hover { border-color: var(--accent); color: var(--accent); }
.menu[open] .menu-btn { border-color: var(--accent); color: var(--accent); background: var(--accent-wash); }
.caret { border: solid currentColor; border-width: 0 1.5px 1.5px 0; padding: 2.5px; transform: rotate(45deg) translateY(-1px); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 11rem; z-index: 60;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop); padding: .25rem 0;
}
.menu-panel form { margin: 0; }
.menu-item {
  display: block; width: 100%; text-align: left; padding: .5rem .9rem;
  background: none; border: 0; font: inherit; font-size: .875rem; color: var(--text);
  cursor: pointer; text-decoration: none; min-height: 0;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--accent-wash); color: var(--accent); text-decoration: none; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 16px 14px 28px; }
.wrap-auth { display: grid; place-items: center; min-height: 82vh; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--tabbar);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; padding: 6px 2px; color: var(--muted);
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .68rem; letter-spacing: .06em; text-transform: uppercase;
}
.tabbar a:hover { text-decoration: none; color: var(--text); }
.tabbar a[aria-current] { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
.tabbar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- page furniture ---------- */
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.pagehead p { font-size: .84rem; color: var(--muted); margin: .15rem 0 0; }
.headlinks { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.headlinks a {
  padding: .3rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--muted); font-size: .8rem;
}
.headlinks a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.headlinks a.on { border-color: var(--accent-wash-border); background: var(--accent-wash); color: var(--accent); }
.flash { border-radius: var(--radius-sm); padding: 9px 12px; margin: 10px 0; font-size: .875rem; border: 1px solid var(--line); background: var(--panel); }
.flash.ok { border-color: var(--ok-border); background: var(--ok-wash); color: var(--ok); }
.flash.err { border-color: var(--danger-border); background: var(--danger-wash); color: var(--danger); }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.spacer { flex: 1; }
.mono, .num { font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.num { font-size: .82rem; white-space: nowrap; }
.fineprint { color: var(--muted); font-size: .76rem; }
.domain { color: var(--accent2); }
.money { color: var(--ok); font-weight: 650; }

/* ---------- buttons ---------- */
button, .primary, .ghost, .danger, .btn, .btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: .42rem .8rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text);
  font: inherit; font-size: .84rem; line-height: 1.3; cursor: pointer; text-align: center;
}
button:hover, .ghost:hover, .btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.primary, .btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.primary:hover, .btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
[data-theme="dark"] .primary, [data-theme="dark"] .btn-primary { color: #101828; }
.danger { color: var(--danger); border-color: var(--danger-border); background: var(--danger-wash); }
button.tiny, .ghost.tiny, a.tiny, .btn.tiny { min-height: 28px; padding: .18rem .55rem; font-size: .76rem; }
.inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- form controls ---------- */
input, select, textarea {
  font: inherit; font-size: .875rem; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .42rem .6rem; min-height: 38px; max-width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
textarea { min-height: 120px; resize: vertical; width: 100%; }
select {
  appearance: none; padding-right: 1.7rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--accent); }
.stack { display: grid; gap: 12px; }
.stack label { display: grid; gap: 5px; font-size: .84rem; color: var(--muted); }
.compact { gap: 8px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0; }
legend { color: var(--muted); font-size: .78rem; padding: 0 6px; }
.radio, .check { display: flex; align-items: center; gap: 8px; min-height: 36px; color: var(--text); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

/* ---------- filter bar: msel multi-select + segmented groups ---------- */
.filterbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 4px 0 10px;
}
.filterbar .fsearch { flex: 1 1 240px; min-width: 0; min-height: 38px; }
.filterbar .fsel { min-height: 38px; }
.filterbar > button, .filterbar > .btn, .filterbar > .btn-primary { min-height: 38px; }

.msel { position: relative; }
.msel > summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .42rem .8rem; min-height: 38px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text); font-size: .84rem; user-select: none;
}
.msel > summary::-webkit-details-marker { display: none; }
.msel > summary::after { content: ""; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; padding: 2.5px; transform: rotate(45deg) translateY(-1px); margin-left: 2px; }
.msel > summary:hover { border-color: var(--accent); color: var(--accent); }
.msel > summary b {
  background: var(--accent); color: #fff; font-weight: 600; font-size: .72rem;
  border-radius: 1rem; padding: .04rem .4rem;
}
[data-theme="dark"] .msel > summary b { color: #101828; }
.msel[open] > summary { border-color: var(--accent); background: var(--accent-wash); color: var(--accent); }
.msel-panel {
  position: absolute; z-index: 50; top: calc(100% + 4px); left: 0;
  min-width: 17rem; max-width: min(26rem, 92vw); max-height: 22rem; overflow: auto;
  background: var(--panel); border: 1px solid var(--accent-wash-border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); padding: .45rem .55rem;
}
.msel-wide { min-width: 21rem; max-width: min(34rem, 94vw); }
.msel-panel input[type="search"] { width: 100%; margin: 0 0 .4rem; min-height: 32px; font-size: .84rem; }
.msel-panel ul { list-style: none; margin: 0; padding: 0; }
.msel-panel li label { display: flex; gap: .5rem; align-items: baseline; padding: .3rem .25rem; font-size: .845rem; border-radius: 6px; cursor: pointer; }
.msel-panel li:hover label { background: var(--accent-wash); }
.msel-panel li.off label { color: var(--muted); opacity: .5; cursor: default; }
.msel-panel li.off:hover label { background: none; }
.msel-n { color: var(--muted); font-size: .76rem; margin-left: auto; white-space: nowrap; font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.msel-note { margin: .1rem .25rem .35rem; font-size: .76rem; color: var(--muted); }
.msel-sep {
  margin: .45rem .25rem .2rem; padding-top: .4rem; border-top: 1px solid var(--line);
  font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: .68rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}

.segctl { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel); }
.segctl .seg {
  min-height: 38px; min-width: 40px; padding: .3rem .65rem; margin: 0;
  border: 0; border-right: 1px solid var(--line); border-radius: 0;
  background: transparent; color: var(--muted); font-size: .84rem; cursor: pointer;
}
.segctl .seg:last-child { border-right: 0; }
.segctl .seg:hover { background: var(--accent-wash); color: var(--accent); }
.segctl .seg i { font-style: normal; font-size: .7rem; color: var(--muted); margin-left: 3px; font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.segctl label.seg { display: inline-flex; align-items: center; gap: 3px; }
.segctl label.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segctl label.seg:has(input:checked) { background: var(--accent); color: #fff; }
.segctl label.seg:has(input:checked) i { color: rgba(255, 255, 255, .75); }
.segctl button.seg[aria-pressed="true"] { background: var(--accent); color: #fff; }
[data-theme="dark"] .segctl label.seg:has(input:checked),
[data-theme="dark"] .segctl button.seg[aria-pressed="true"] { color: #101828; }
[data-theme="dark"] .segctl label.seg:has(input:checked) i { color: rgba(16, 24, 40, .65); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 0; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 6px 0 10px; }
.tab {
  padding: .55rem 1rem; color: var(--muted); font-size: .875rem; font-weight: 500;
  border: 1px solid transparent; border-bottom: none; margin-bottom: -1px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab:hover { background: var(--accent-wash); color: var(--accent); text-decoration: none; }
.tab-active, .tab-active:hover { color: #fff; background: var(--accent); border-color: var(--accent); }
[data-theme="dark"] .tab-active, [data-theme="dark"] .tab-active:hover { color: #101828; }
.tab-count { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: .72rem; margin-left: .4rem; color: var(--muted); }
.tab-active .tab-count { color: rgba(255, 255, 255, .8); }
[data-theme="dark"] .tab-active .tab-count { color: rgba(16, 24, 40, .7); }
.tabs::-webkit-scrollbar { display: none; }

/* ---------- chips / tags ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: .1rem .45rem; border-radius: 4px;
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
  font-size: .72rem; white-space: nowrap;
}
.chip.hot, .okchip { color: var(--ok); border-color: var(--ok-border); background: var(--ok-wash); }
.badchip { color: var(--danger); border-color: var(--danger-border); background: var(--danger-wash); }
.reqchip { font-family: 'IBM Plex Mono', ui-monospace, monospace; letter-spacing: .02em; color: var(--accent); border-color: var(--accent-wash-border); background: var(--accent-wash); }
.st-new { color: var(--accent2); }
.st-interested, .st-outreach, .st-queued { color: var(--warn); }
.st-applied, .st-contacted { color: var(--accent); }
.st-replied { color: #5b3ce0; }
.st-won, .st-done { color: var(--ok); }
.st-failed { color: var(--danger); }
.st-running { color: var(--accent2); }
.st-dismissed, .st-cancelled, .st-rejected { color: var(--muted); }
.st-saved { color: var(--accent); border-color: var(--accent-wash-border); background: var(--accent-wash); }
.st-hidden { color: var(--muted); background: var(--panel2); }

/* ---------- board rows ---------- */
.resultline { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: .82rem; margin: 8px 2px 8px; }
.resultline b { color: var(--text); font-weight: 650; }
.rows { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.itemrow { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 4px; align-items: start; }
.itemrow > .pick { margin: 15px 0 0 2px; }
.itemrow.is-saved .rowtitle { color: var(--accent); }
.item { border-bottom: 1px solid var(--line); min-width: 0; }
.item > summary { list-style: none; cursor: pointer; }
.item > summary::-webkit-details-marker { display: none; }
.item[open] > summary.rowitem { background: var(--bg2); }
.rowitem {
  display: grid; align-items: center; gap: 10px; padding: 10px 14px 10px 4px;
  grid-template-columns: 42px 92px minmax(0, 1fr) 96px 62px 12px;
  grid-template-areas: "grade src main status time chev";
  color: var(--text);
}
.rowitem:hover { background: var(--rowhover); text-decoration: none; }
.rowscore {
  grid-area: grade; display: flex; align-items: center; justify-content: center;
  padding: .28rem 0; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel2); color: var(--muted);
  font-weight: 700; font-size: .84rem; font-variant-numeric: tabular-nums;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.rowscore.s-hi { background: var(--ok-wash); color: var(--ok); border-color: var(--ok-border); }
.rowscore.s-mid { background: var(--warn-wash); color: var(--warn); border-color: rgba(181, 71, 8, .22); }
.grade { display: inline-flex; align-items: center; justify-content: center; font-weight: 650; font-size: .78rem; padding: .1rem .45rem; border-radius: 4px; }
.gA { background: var(--ok-wash); color: var(--ok); border: 1px solid var(--ok-border); }
.gB { background: var(--warn-wash); color: var(--warn); border: 1px solid rgba(181, 71, 8, .22); }
.gC { background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.rowsrc {
  grid-area: src; font-size: .68rem; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.rowmain { grid-area: main; min-width: 0; display: block; }
.rowtitle { display: block; font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rowmeta { display: flex; flex-wrap: wrap; gap: 2px 10px; color: var(--muted); font-size: .78rem; margin-top: 3px; align-items: center; }
.rowmeta .zh { color: var(--muted); }
.rowstatus { grid-area: status; justify-self: start; }
.rowtime { grid-area: time; justify-self: end; font-size: .76rem; white-space: nowrap; font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.chev { grid-area: chev; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; padding: 3px; transform: rotate(45deg); transition: transform .15s; }
.item[open] .chev { transform: rotate(-135deg); }
.src-upwork { color: var(--ok); }
.src-google, .src-google_news { color: var(--accent); }
.src-greenhouse, .src-lever, .src-ashby { color: var(--warn); }
.src-remotive, .src-remoteok, .src-jobicy, .src-working_nomads, .src-weworkremotely, .src-himalayas { color: var(--accent2); }

.itemdetail { display: flex; flex-direction: column; gap: 14px; padding: 4px 16px 20px 16px; background: var(--bg2); }
.detailmeta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 4px 16px; font-size: .82rem; color: var(--muted); }
.detailmeta b { color: var(--text); font-weight: 600; margin-right: 5px; }
.attrib { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; font-size: .82rem; }
.summarybox { padding: .7rem .9rem; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); background: var(--panel); }
.summarybox h2 { margin: 0 0 .25rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-family: 'IBM Plex Mono', ui-monospace, monospace; font-weight: 600; }
.summarybox p { margin: .15rem 0; font-size: .88rem; }
.desc { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); font-size: .84rem; max-height: 420px; overflow: auto; }
.sectionhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sectionhead h2 { margin: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.sectionhead form { margin: 0; }
.actions { display: flex; flex-direction: column; gap: 8px; }
.actiongrid { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actiongrid select { width: auto; min-width: 120px; min-height: 32px; padding: .2rem 1.6rem .2rem .5rem; font-size: .8rem; }
.draft { width: 100%; background: var(--panel); }
.comments { display: flex; flex-direction: column; gap: 8px; }
.commentlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.commentlist li { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .75rem; background: var(--panel); }
.commentlist p { margin: .3rem 0 0; white-space: pre-wrap; font-size: .87rem; }
.commentmeta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; font-size: .78rem; }

.bulkbar {
  position: sticky; top: calc(48px + env(safe-area-inset-top)); z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--topbar); backdrop-filter: saturate(140%) blur(12px);
}
.bulkcheck { display: inline-flex; gap: 6px; align-items: center; font-size: .82rem; color: var(--muted); }
.bulkcount { font-size: .78rem; color: var(--muted); min-width: 56px; font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.bulknote { flex: 1 1 200px; min-width: 140px; min-height: 34px; }
.bulkactions { display: flex; gap: 6px; flex-wrap: wrap; }
.bulkbar button { min-height: 32px; padding: .25rem .65rem; font-size: .8rem; }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 18px 0; }
.empty { text-align: center; padding: 40px 12px; color: var(--muted); }
.empty p { font-size: .9rem; }

/* ---------- cards / panels / stats ---------- */
.card, .panel, .detail, .login-card, .rows, .feedback-list, .stat, .tablewrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.card { display: block; padding: 13px 15px; color: var(--text); box-shadow: var(--shadow); }
a.card:hover { border-color: var(--accent); text-decoration: none; }
.card h2 { margin: .35rem 0 .25rem; font-size: .98rem; }
.card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cards { display: grid; gap: 10px; }
.card .actionsrow, .job .actionsrow, .query .actionsrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.panel { padding: 14px; margin: 12px 0; }
.panel h2 { margin-top: 0; }
.detail { padding: 16px; }
.detail h1 { margin: 8px 0 12px; }
.metagrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 14px; }
.metagrid > div { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; font-size: .86rem; }
.metagrid .k { display: block; color: var(--muted); font-size: .72rem; margin-bottom: 1px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { padding: 12px 14px; }
.stat .k { display: block; font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat b { font-size: 1.5rem; letter-spacing: -.02em; font-weight: 650; }
.breakdown { margin-top: 14px; }
.barrow { display: grid; grid-template-columns: 84px 1fr 40px; align-items: center; gap: 9px; margin: 6px 0; }
.barlabel { color: var(--muted); font-size: .78rem; }
.bar { height: 8px; background: var(--bg2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar i { display: block; height: 100%; background: var(--accent); }
.barval { text-align: right; font-size: .78rem; color: var(--muted); font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.backlink { display: inline-block; color: var(--muted); font-size: .84rem; margin: 2px 0 10px; }
.snippet { color: var(--muted); font-size: .86rem; margin-top: 6px; }

/* ---------- charts ---------- */
.spark { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; align-items: end; height: 120px; padding-top: 8px; }
.sparkcol { display: grid; grid-template-rows: 1fr auto; gap: 4px; min-width: 0; }
.sparkbars { display: flex; align-items: flex-end; justify-content: center; gap: 2px; height: 100%; }
.sparkbars i, .legend i { display: block; width: 6px; border-radius: 2px 2px 0 0; min-height: 1px; }
.sparkcol > span { font-size: .58rem; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; }
.b1 { background: var(--accent); }
.b2 { background: var(--accent2); }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .74rem; }
.legend i { width: 9px; height: 9px; border-radius: 2px; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th {
  color: var(--muted); font-weight: 600; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .06em; background: var(--bg2); font-family: 'IBM Plex Mono', ui-monospace, monospace;
}
.tablegrid { width: 100%; border-collapse: collapse; font-size: .84rem; min-width: 920px; }
.tablegrid th, .tablegrid td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.tablegrid th {
  color: var(--muted); font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  background: var(--bg2); position: sticky; top: 0; z-index: 1; font-family: 'IBM Plex Mono', ui-monospace, monospace;
}
.tablegrid tbody tr:hover, table.audit tbody tr:hover, .table tbody tr:hover { background: var(--bg2); }
.tablegrid tr:last-child td { border-bottom: 0; }
.tablegrid tr.off { opacity: .55; }
.tablegrid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tablegrid .querycell { min-width: 260px; max-width: 520px; white-space: normal; }
.tablegrid .querytext { margin: 0; font-size: .87rem; font-weight: 500; }
.tablegrid .actions { white-space: nowrap; }
.tablegrid .actions form { display: inline; margin: 0 2px 0 0; }

/* Fixed layout so the requirements table fits the page instead of scrolling
   sideways; text wraps inside its own column. */
.tablegrid.fit { table-layout: fixed; min-width: 0; }
.tablegrid.fit th, .tablegrid.fit td { padding: 7px 6px; overflow-wrap: anywhere; }
.tablegrid.fit .querycell { min-width: 0; max-width: none; }
.tablegrid.fit .actions { white-space: normal; }
.tablegrid.fit .chip { font-size: .66rem; padding: 1px 4px; margin: 0 2px 2px 0; }
.tablegrid.fit .freqsel { max-width: 100%; }
.tablegrid.fit .nextrun { display: block; font-size: .68rem; margin-top: 2px; }
.tablegrid .actions button, .tablegrid .actions a { min-height: 26px; padding: 2px 7px; font-size: .74rem; }
.tablegrid .errorcell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--danger); font-size: .78rem; }
.tablegrid .snippetcell { min-width: 240px; max-width: 520px; white-space: normal; color: var(--muted); }
.tablegrid .detailcell { min-width: 240px; max-width: 520px; }
.tablegrid .detailcell summary { cursor: pointer; color: var(--accent); font-size: .8rem; }
.tablegrid .detailcell .detailbox { max-height: 260px; overflow: auto; white-space: pre-wrap; margin: 6px 0 0; }
table.audit { width: 100%; border-collapse: collapse; font-size: .86rem; min-width: 720px; }
table.audit th, table.audit td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.audit th { color: var(--muted); font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; background: var(--bg2); }
table.audit tr:last-child td { border-bottom: 0; }
.detailbox { font-size: .76rem; color: var(--muted); background: var(--bg2); padding: 8px 10px; border-radius: var(--radius-sm); margin: 8px 0 0; }
.querytext { margin: 8px 0 6px; font-size: .95rem; }
.query.off { opacity: .58; }
.query.stale { border-color: var(--danger-border); }
.run.bad { border-color: var(--danger-border); }

/* ---------- feedback ---------- */
.digest {
  margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg2); color: var(--text); font-size: .8rem; line-height: 1.45;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 480px; overflow: auto;
}
.feedback-list { overflow: hidden; box-shadow: var(--shadow); }
.feedback-head, .feedback-row {
  display: grid; grid-template-columns: 30px 150px minmax(0, 1fr) 250px 92px;
  gap: 10px; align-items: start; padding: 10px 12px;
}
.feedback-head {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  background: var(--bg2); font-family: 'IBM Plex Mono', ui-monospace, monospace;
}
.feedback-row { border-top: 1px solid var(--line); }
.feedback-row.off { opacity: .68; }
.fbcheck { padding-top: 2px; }
.fbcheck input, .fb-label input, .feedback-actions input { width: auto; min-height: 0; padding: 0; margin: 0; }
.fb-target a { font-weight: 600; }
.fb-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.fb-body p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .87rem; }
.fb-label { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: .78rem; color: var(--muted); }
.fb-label label { display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
.fb-time { font-size: .76rem; color: var(--muted); }
.feedback-actions {
  position: sticky; bottom: calc(58px + env(safe-area-inset-bottom)); z-index: 10;
  display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--topbar);
  backdrop-filter: saturate(140%) blur(12px);
}
.feedback-actions label { display: inline-flex; gap: 6px; align-items: center; font-size: .84rem; }

/* ---------- learned rules ---------- */
.learnedrow { display: flex; gap: 10px; align-items: flex-start; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.learnedrow .term { font-weight: 600; }
.learnedrow .reason { color: var(--muted); font-size: .82rem; }
.learnedrow.inactive, .learnedrow.off { opacity: .5; }

/* ---------- auth ---------- */
.login-card { width: min(420px, 92vw); padding: 22px; box-shadow: var(--shadow-pop); }
.login-brand { display: flex; align-items: center; gap: 9px; font-size: 1.25rem; font-weight: 650; margin-bottom: 4px; }
.login-card .stack { margin-top: 16px; }

/* ---------- Chinese annotations kept beside the English UI ---------- */
.zh { color: var(--muted); font-size: .85em; font-weight: 400; }
p .zh { display: block; margin-top: 2px; }

/* ---------- responsive ---------- */
@media (min-width: 720px) {
  body { padding-bottom: 28px; }
  .tabbar { display: none; }
  .topnav { display: flex; }
  .wrap { padding: 22px 20px 48px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .metagrid { grid-template-columns: repeat(3, 1fr); }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .spark { height: 150px; }
  .feedback-actions { bottom: 0; }
}
@media (max-width: 760px) {
  .row2, .row3, .row4 { grid-template-columns: 1fr; }
  .msel { position: static; }
  .msel-panel { left: 0; right: 0; min-width: 0; max-width: none; }
  .filterbar .fsearch { flex-basis: 100%; }
  .bulknote { flex-basis: 100%; }
  .itemrow { grid-template-columns: 16px minmax(0, 1fr); }
  .feedback-head { display: none; }
  .feedback-row { grid-template-columns: 28px minmax(0, 1fr); grid-template-areas: "check target" "check body" "check label" "check time"; }
  .fbcheck { grid-area: check; }
  .fb-target { grid-area: target; }
  .fb-body { grid-area: body; }
  .fb-label { grid-area: label; }
  .fb-time { grid-area: time; }
}
@media (max-width: 719px) {
  .rowitem {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    grid-template-areas: "grade main chev" "src main status";
    row-gap: 3px; padding: 10px 12px 10px 2px;
  }
  .rowsrc { align-self: start; }
  .rowstatus { justify-self: end; }
  .rowtime { display: none; }
  .chev { align-self: center; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- search: chat → panel ---------- */
.build h2 { font-size: 15px; margin: 0; }
.build-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.build textarea { margin-top: 10px; }

.se-shell {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.se-shell.filled { animation: sefill 2.4s ease-out; }
@keyframes sefill {
  0%   { box-shadow: 0 0 0 3px var(--accent-wash); border-color: var(--accent-wash-border); }
  100% { box-shadow: var(--shadow); }
}

.se-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.se-ico { color: var(--accent); font-size: 18px; line-height: 1; margin-left: 2px; }
.se-q {
  flex: 1 1 320px; min-width: 180px;
  border: 0; background: transparent; padding: 6px 2px;
  font-size: 15px; color: var(--text);
}
.se-q:focus { outline: none; }
.se-bar .se-site {
  flex: 0 1 190px; border: 0; border-left: 1px solid var(--line);
  background: transparent; padding: 6px 0 6px 10px; font-size: 13px; color: var(--muted);
}
.se-bar .se-site:focus { outline: none; }
.se-bar select {
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel);
  padding: 6px 8px; font-size: 13px; color: var(--text); max-width: 160px;
}
.se-bar select:focus-visible { outline: 2px solid var(--accent-wash-border); outline-offset: 1px; }

.se-kw { display: flex; flex-direction: column; border-bottom: 1px solid var(--line); }
.kwbox { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.kwbox:first-child { border-top: 0; }
.kwlabel {
  flex: 0 0 42px; font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 11px;
  letter-spacing: .06em; color: var(--muted); text-transform: uppercase;
}
.kwlist { display: flex; flex-wrap: wrap; gap: 6px; }
.kw {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent-wash); color: var(--accent);
  border: 1px solid var(--accent-wash-border); border-radius: 999px;
  padding: 2px 4px 2px 9px; font-size: .8rem; line-height: 1.5;
}
.kwx {
  min-height: 0; min-width: 0; height: 16px; border: 0; background: transparent;
  color: var(--accent); cursor: pointer; font-size: 14px; line-height: 1;
  padding: 0 4px; border-radius: 999px; opacity: .55;
}
.kwx:hover { opacity: 1; background: rgba(42, 63, 143, .10); }
.kwadd {
  flex: 1 1 200px; min-width: 140px; border: 0; background: transparent;
  font-size: 13px; color: var(--text); padding: 3px 2px;
}
.kwadd:focus { outline: none; }
.kwadd::placeholder { color: var(--muted); }
.kwsrc { display: none; }

.se-foot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; flex-wrap: wrap; }
.se-foot .spacer { flex: 1 1 auto; }
.se-freq .seg span { padding: 3px 9px; font-size: .78rem; }
.se-hint { font-size: .78rem; color: var(--muted); }
.se-hint.ok { color: var(--ok); }
.se-hint.warn { color: var(--warn); }
.se-hint.bad { color: var(--danger); }

.adv { border-top: 1px solid var(--line); background: var(--panel2); }
.adv > summary {
  cursor: pointer; padding: 8px 12px; font-size: .8rem; color: var(--muted);
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.adv > summary::-webkit-details-marker { display: none; }
.adv > summary::before { content: "+"; font-family: 'IBM Plex Mono', ui-monospace, monospace; color: var(--accent); }
.adv[open] > summary::before { content: "\2212"; }
.adv-body {
  padding: 4px 12px 12px; display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.adv-body .row2, .adv-body .row3 { display: contents; }
.adv-body .fineprint { grid-column: 1 / -1; margin: 0; }

.warnchip, .chip.warnchip { color: var(--warn); border-color: var(--warn-wash); background: var(--warn-wash); }
.sectionrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 0 8px; }
.sectionrow h2 { margin: 0; }

@media (max-width: 720px) {
  .se-bar { padding: 8px 10px; }
  .se-q { flex: 1 1 100%; }
  .kwbox { padding: 7px 10px; }
  .kwadd { flex: 1 1 120px; }
  .se-foot { padding: 8px 10px; }
  .segfreq { flex: 1 1 100%; justify-content: space-between; }
  .segfreq .seg { flex: 1 1 auto; justify-content: center; }
  .se-foot .btn, .se-foot .btn-primary { flex: 1 1 42%; }
  .se-hint { flex: 1 1 100%; order: 3; }
}

.oktext { color: var(--ok); font-weight: 600; }
.badtext { color: var(--danger); font-weight: 600; }

/* Upwork-style primary action: pill CTA, white label. */
.primary, .btn-primary { border-radius: 999px; }
[data-theme="dark"] .primary, [data-theme="dark"] .btn-primary { color: #06210a; }
.brand-mark { border-radius: 50%; background: linear-gradient(140deg, #14a800, #0d7a00); }
