/* Impulse ATS v1.0 — Claude-desktop-inspired calm palette.
   Contract: ats/docs/API_CONTRACT.md "Frontend contract". index.html DOM is
   authoritative; classes marked "js:" are generated at runtime by app.js /
   chat.js (documented next to each block). Both themes are complete:
   prefers-color-scheme is the default, [data-theme] on <html> wins both ways. */

/* ---------- design tokens ---------- */
:root {
  color-scheme: light;
  --bg: #F2F0E9;          /* window */
  --panel: #FAF9F5;       /* cards, composer, drawer */
  --panel-2: #EFEDE4;     /* sidebar, wells */
  --ink: #2B2A26;
  --ink-soft: #57544C;
  --muted: #8A867B;
  --line: #E2DFD4;
  --line-strong: #CFCBBC;
  --accent: #D97757;      /* terracotta */
  --accent-soft: #F4E3DC;
  --good: #7BA05B;
  --bad: #C65B4E;
  --warn: #B08C2A;
  --scrim: rgba(43, 42, 38, .32);
  --skel-sheen: rgba(255, 255, 255, .55);
  --shadow-1: 0 1px 2px rgba(43,42,38,.04), 0 6px 18px rgba(43,42,38,.06);
  --shadow-2: 0 4px 10px rgba(43,42,38,.06), 0 24px 60px rgba(43,42,38,.14);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Hiragino Mincho ProN", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1F1E1B;
  --panel: #2A2925;
  --panel-2: #252420;
  --ink: #EDEAE2;
  --ink-soft: #C9C5BA;
  --muted: #8F8B80;
  --line: #3A3833;
  --line-strong: #4A4840;
  --accent: #D97757;
  --accent-soft: #453029;
  --good: #92B573;
  --bad: #D3766A;
  --warn: #D3B15C;
  --scrim: rgba(0, 0, 0, .5);
  --skel-sheen: rgba(255, 255, 255, .06);
  --shadow-1: 0 1px 2px rgba(0,0,0,.2), 0 6px 18px rgba(0,0,0,.22);
  --shadow-2: 0 4px 10px rgba(0,0,0,.28), 0 24px 60px rgba(0,0,0,.45);
}
/* OS dark is only the default — an explicit data-theme (either value) wins. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    color-scheme: dark;
    --bg: #1F1E1B;
    --panel: #2A2925;
    --panel-2: #252420;
    --ink: #EDEAE2;
    --ink-soft: #C9C5BA;
    --muted: #8F8B80;
    --line: #3A3833;
    --line-strong: #4A4840;
    --accent: #D97757;
    --accent-soft: #453029;
    --good: #92B573;
    --bad: #D3766A;
    --warn: #D3B15C;
    --scrim: rgba(0, 0, 0, .5);
    --skel-sheen: rgba(255, 255, 255, .06);
    --shadow-1: 0 1px 2px rgba(0,0,0,.2), 0 6px 18px rgba(0,0,0,.22);
    --shadow-2: 0 4px 10px rgba(0,0,0,.28), 0 24px 60px rgba(0,0,0,.45);
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  height: 100vh; height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button {
  font: inherit; cursor: pointer; border: none; background: none; color: inherit;
  transition: background .2s ease, color .2s ease, border-color .2s ease,
              box-shadow .2s ease, opacity .2s ease, transform .2s ease;
}
a { color: var(--accent); }
::selection { background: var(--accent-soft); }

/* text-ish fields: soft accent ring on focus instead of a hard outline */
input[type="text"], input[type="password"], input[type="search"], textarea, select {
  font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* buttons & links keep a crisp visible ring for keyboard users */
button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }

/* thin, calm scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 6px;
  border: 3px solid transparent; background-clip: content-box;
}

/* shared button variants */
.primary {
  background: var(--accent); color: #fff; font-weight: 600; font-size: 13.5px;
  padding: 9px 16px; border-radius: 10px; box-shadow: var(--shadow-1);
}
.primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.primary:active { transform: none; }
.primary:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }
.ghost { color: var(--muted); font-size: 16px; padding: 4px 9px; border-radius: 8px; }
.ghost:hover { background: var(--panel); color: var(--ink-soft); }
.sidebar .ghost:hover, .drawer .ghost:hover { background: var(--panel-2); }

/* ---------- login ---------- */
.login {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 40px 44px; width: min(340px, calc(100vw - 32px)); text-align: center;
  box-shadow: var(--shadow-2);
}
.login-card .brand-mark { font-size: 26px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 6px 0 24px; }
.login input { width: 100%; font-size: 15px; padding: 12px 14px; }
.login button {
  margin-top: 14px; width: 100%; padding: 12px; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 600;
}
.login button:hover { box-shadow: var(--shadow-1); }
.login-err { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 1em; }

/* ---------- app shell ---------- */
.app { display: flex; height: 100vh; height: 100dvh; }
.sidebar {
  width: 260px; flex: none; background: var(--panel-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px 14px;
  min-height: 0;
}
.brand { padding: 4px 10px 16px; }
.brand-mark { font-family: var(--serif); font-size: 21px; letter-spacing: .2px; white-space: nowrap; }
.brand-mark span { color: var(--accent); }

.new-chat {
  margin: 0 2px 14px; padding: 10px 12px; border-radius: 11px;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 14px; font-weight: 550;
  text-align: left; white-space: nowrap; overflow: hidden;
  box-shadow: var(--shadow-1);
}
.new-chat:hover { border-color: var(--accent); color: var(--accent); }

.views { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  text-align: left; padding: 10px 12px; border-radius: 10px; font-size: 14.5px;
  color: var(--ink-soft); display: flex; align-items: center; gap: 8px;
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--panel); }
.nav-item.active { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1); }
.count { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 400; }

.convs-head {
  margin: 18px 12px 6px; font-size: 11px; font-weight: 600;
  letter-spacing: .6px; text-transform: uppercase; color: var(--muted);
}
.convs { flex: 1; min-height: 0; overflow-y: auto; padding: 0 2px 8px; }
/* js(chat.js): conversation rows — .conv(.active) > .conv-title + .conv-time + .conv-del.
   Structural child selectors keep any row markup presentable. */
.convs > * {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: 10px; font-size: 13.5px;
  color: var(--ink-soft); cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.convs > *:hover { background: var(--panel); }
.convs > .active, .convs > *.active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-1); }
.conv-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { flex: none; font-size: 11px; color: var(--muted); }
.conv-del {
  flex: none; opacity: 0; color: var(--muted); font-size: 13px;
  padding: 2px 6px; border-radius: 6px;
}
.convs > *:hover .conv-del, .conv-del:focus-visible { opacity: 1; }
.conv-del:hover { color: var(--bad); background: var(--accent-soft); }

.side-foot {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px 0; border-top: 1px solid var(--line);
}
.statuses { display: flex; align-items: center; gap: 6px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted);
  display: inline-block; transition: background .2s ease;
}
.dot.on { background: var(--good); }
.dot.off { background: var(--bad); }
.status-label { font-size: 11px; color: var(--muted); margin-left: 4px; }
.foot-actions { display: flex; align-items: center; gap: 2px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ---------- chat ---------- */
.chat-scroll { flex: 1; overflow-y: auto; padding: 40px 0 20px; }
.chat-empty { max-width: 640px; margin: 12vh auto 0; text-align: center; padding: 0 24px; }
.chat-empty h1 { font-family: var(--serif); font-weight: 500; font-size: 32px; line-height: 1.25; }
.chat-empty p { color: var(--muted); margin: 12px 0 28px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 8px 16px; font-size: 13.5px; color: var(--ink-soft);
}
.chip:hover { border-color: var(--accent); color: var(--ink); box-shadow: var(--shadow-1); }

#messages { max-width: 760px; margin: 0 auto; padding: 0 24px; }
/* js(chat.js): .msg.user / .msg.assistant(.streaming|.error) > .bubble */
.msg { margin: 18px 0; line-height: 1.6; font-size: 15px; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--accent-soft); border-radius: 16px 16px 4px 16px;
  padding: 10px 16px; max-width: 78%;
}
.msg.assistant .bubble { padding: 2px 2px; }
.msg.assistant .bubble > *:first-child { margin-top: 0; }
.bubble { overflow-wrap: break-word; }
.bubble p { margin: 10px 0; }
.bubble ul, .bubble ol { margin: 10px 0 10px 22px; }
.bubble li { margin: 4px 0; }
.bubble h1, .bubble h2, .bubble h3 {
  font-family: var(--serif); font-weight: 600; margin: 16px 0 8px; font-size: 17px;
}
.bubble code {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; font-size: 13px;
}
.bubble pre {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; overflow-x: auto; margin: 10px 0;
}
.bubble pre code { background: none; border: none; padding: 0; }
.bubble strong { font-weight: 650; }
.msg.error .bubble { color: var(--bad); }
/* streaming caret while deltas arrive */
.msg.streaming .bubble::after {
  content: "▍"; margin-left: 2px; color: var(--accent);
  animation: blink 1.1s infinite;
}
/* js(chat.js): <span class="caret"> waiting/streaming indicator in the bubble */
.bubble .caret::after {
  content: "▍"; margin-left: 2px; color: var(--accent);
  animation: blink 1.1s infinite;
}

/* js(chat.js): hover actions under an assistant message (copy button) */
.msg-actions { display: flex; gap: 6px; margin-top: 4px; opacity: 0; transition: opacity .2s ease; }
.msg:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-actions button, .msg .copy, .copy-btn {
  font-size: 12px; color: var(--muted); padding: 3px 9px; border-radius: 7px;
  border: 1px solid transparent;
}
.msg-actions button:hover, .msg .copy:hover, .copy-btn:hover {
  background: var(--panel); border-color: var(--line); color: var(--ink-soft);
}

/* js(chat.js): typing indicator while waiting for the first delta */
.typing { display: inline-flex; gap: 5px; padding: 8px 2px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.composer-wrap { padding: 8px 24px 18px; }
.composer {
  max-width: 760px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 10px 10px 10px 18px;
  box-shadow: var(--shadow-1);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-1); }
.composer textarea {
  flex: 1; resize: none; border: none; outline: none; background: none;
  color: var(--ink); font: inherit; font-size: 15px; line-height: 1.5;
  max-height: 180px; padding: 6px 0; border-radius: 0; box-shadow: none;
}
.composer textarea:focus { border: none; box-shadow: none; }
.composer button {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 700;
}
.composer button:hover { box-shadow: var(--shadow-1); }
.composer button:disabled { opacity: .4; cursor: default; box-shadow: none; }
.composer .stop {
  background: var(--panel-2); color: var(--bad);
  border: 1px solid var(--line); font-size: 13px;
}
.composer .stop:hover { border-color: var(--bad); }
.composer-note {
  max-width: 760px; margin: 8px auto 0; text-align: center;
  font-size: 11.5px; color: var(--muted);
}

/* ---------- list views (candidates / orders) ---------- */
.view-head { padding: 34px 40px 10px; }
.view-head h2 { font-family: var(--serif); font-weight: 550; font-size: 26px; }
.view-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.view-head-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.search {
  width: min(360px, 100%); padding: 9px 16px; border-radius: 999px;
  background: var(--panel); font-size: 13.5px;
}
.search::placeholder { color: var(--muted); }
.pills { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* .pill doubles as a static tag (cards) and a clickable filter (#stagePills) */
.pill {
  font-size: 11.5px; padding: 3px 11px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-soft);
}
.pill.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.pills .pill { background: var(--panel); padding: 5px 13px; font-size: 12px; }
.pills .pill:hover { border-color: var(--accent); color: var(--ink); }
.pills .pill.active, .pills .pill.on {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}

.cards {
  overflow-y: auto; padding: 10px 40px 40px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px; align-content: start;
}
/* js(app.js): .card > .card-top(.card-name/.pill/.card-meta) + .card-body */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
#candList .card { cursor: pointer; }
#candList .card:hover {
  border-color: var(--line-strong); box-shadow: var(--shadow-1); transform: translateY(-1px);
}
.card-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.card-name { font-weight: 650; font-size: 15.5px; }
.card-name a { color: inherit; text-decoration: none; }
.card-name a:hover { color: var(--accent); }
.card-meta { margin-left: auto; color: var(--muted); font-size: 12px; }
.card-body { color: var(--ink-soft); font-size: 13.5px; margin-top: 8px; line-height: 1.55; }
.card-body.clamp {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; cursor: pointer;
}
.empty-note { color: var(--muted); padding: 30px 40px; grid-column: 1 / -1; }

/* ---------- candidate detail drawer ---------- */
/* Show/hide is done by toggling .hidden (index.html default). These override
   the global display:none so the slide/fade actually animates both ways. */
.drawer-back {
  position: fixed; inset: 0; z-index: 60;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 1; visibility: visible;
  transition: opacity .2s ease, visibility 0s linear 0s;
}
.drawer-back.hidden {
  display: block !important;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .2s ease, visibility 0s linear .2s;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(480px, 100vw);
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  display: flex; flex-direction: column;
  transform: translateX(0); visibility: visible;
  transition: transform .28s cubic-bezier(.2, .7, .2, 1), visibility 0s linear 0s;
}
.drawer.hidden {
  display: flex !important;
  transform: translateX(105%); visibility: hidden; pointer-events: none;
  box-shadow: none;
  transition: transform .28s cubic-bezier(.2, .7, .2, 1), visibility 0s linear .28s;
}
.drawer-head {
  flex: none; display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 22px 24px 16px; border-bottom: 1px solid var(--line);
}
.drawer-head h3 { font-family: var(--serif); font-weight: 600; font-size: 21px; line-height: 1.3; }
.drawer-link { font-size: 12.5px; text-decoration: none; }
.drawer-link:hover { text-decoration: underline; }
.drawer-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 20px 24px 28px; display: flex; flex-direction: column; gap: 22px;
}
.drawer-row { display: flex; flex-direction: column; gap: 6px; }
.drawer-row label, .drawer-sec h4, .dialog-label {
  font-size: 11px; font-weight: 600; letter-spacing: .6px;
  text-transform: uppercase; color: var(--muted);
}
.drawer-row select {
  width: 100%; appearance: none; -webkit-appearance: none;
  background-color: var(--panel-2); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238A867B' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 34px;
}

/* js(app.js): .fields grid cells — .field > label + value. Generic children
   selectors keep it presentable whatever the cell markup. */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.fields > * { min-width: 0; }
.fields label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: .6px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 3px;
}
.fields .field, .fields > div { font-size: 14px; color: var(--ink); overflow-wrap: break-word; }
.fields a { text-decoration: none; }
.fields a:hover { text-decoration: underline; }

.drawer-sec { display: flex; flex-direction: column; gap: 8px; }
.reasoning {
  font-size: 13.5px; line-height: 1.6; color: var(--ink-soft);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; white-space: pre-wrap; overflow-wrap: break-word;
}
.files { list-style: none; padding: 0; }
.files li { border-bottom: 1px solid var(--line); }
.files li:last-child { border-bottom: none; }
.files a {
  display: flex; align-items: baseline; gap: 8px;
  padding: 9px 2px; font-size: 13.5px; color: var(--ink); text-decoration: none;
  border-radius: 6px;
}
.files a:hover { color: var(--accent); }
.files small, .files .file-size { margin-left: auto; color: var(--muted); font-size: 11.5px; }

.note-form { display: flex; flex-direction: column; gap: 8px; }
.note-form textarea { width: 100%; resize: vertical; min-height: 56px; font-size: 13.5px; background: var(--bg); }
.note-form button { align-self: flex-end; }

/* js(app.js): timeline entries — .tl-item > .tl-head(.tl-title) + .tl-body.
   Generic children get the rail + dot whatever the item class is. */
.timeline { display: flex; flex-direction: column; gap: 14px; }
.timeline > * { position: relative; padding-left: 18px; }
.timeline > *::before {
  content: ""; position: absolute; left: 0; top: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); opacity: .75;
}
.timeline > *::after {
  content: ""; position: absolute; left: 3px; top: 18px; bottom: -14px;
  width: 1px; background: var(--line);
}
.timeline > *:last-child::after { display: none; }
.tl-head { display: flex; align-items: baseline; gap: 8px; font-size: 11.5px; color: var(--muted); }
.tl-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.tl-body {
  font-size: 13px; color: var(--ink-soft); line-height: 1.55; margin-top: 3px;
  white-space: pre-wrap; overflow-wrap: break-word;
}

/* ---------- upload dialog ---------- */
.dialog {
  position: fixed; top: 50%; left: 50%; z-index: 62;
  width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 26px 28px; box-shadow: var(--shadow-2);
  transform: translate(-50%, -50%); opacity: 1; visibility: visible;
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear 0s;
}
.dialog.hidden {
  display: block !important;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translate(-50%, -48%) scale(.97);
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}
.dialog h3 { font-family: var(--serif); font-weight: 600; font-size: 20px; }
.dialog-sub { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 6px 0 18px; }
.dialog-label { display: block; margin: 14px 0 6px; }
.dialog input[type="text"] { width: 100%; font-size: 14px; }
.dialog input[type="file"] { width: 100%; font-size: 13px; color: var(--ink-soft); padding: 9px 10px; }
.dialog input[type="file"]::file-selector-button {
  font: inherit; font-size: 12.5px; cursor: pointer; margin-right: 10px;
  background: var(--panel-2); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 12px;
  transition: border-color .2s ease, color .2s ease;
}
.dialog input[type="file"]::file-selector-button:hover { border-color: var(--accent); color: var(--ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.dialog-actions .ghost { font-size: 13.5px; padding: 8px 14px; }
.dialog-actions .ghost:hover { background: var(--panel-2); }

/* ---------- toasts (bottom-right, slide-in) ---------- */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 90;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: none;
}
/* js(app.js ATS.toast): children are toasts; kind class on the child.
   Generic child selector so any element/tag the JS emits is styled. */
.toasts > * {
  pointer-events: auto; max-width: 340px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-left: 3px solid var(--muted);
  border-radius: 12px; padding: 10px 14px;
  font-size: 13.5px; line-height: 1.45;
  box-shadow: var(--shadow-2);
  animation: toast-in .24s ease;
}
.toasts > .ok, .toasts > .good, .toasts > .success { border-left-color: var(--good); }
.toasts > .err, .toasts > .bad, .toasts > .error { border-left-color: var(--bad); }
.toasts > .warn { border-left-color: var(--warn); }
.toasts > .out { animation: toast-out .2s ease forwards; }
@keyframes toast-in { from { transform: translateX(16px); opacity: 0; } }
@keyframes toast-out { to { transform: translateX(16px); opacity: 0; } }

/* ---------- skeleton shimmer ---------- */
.skel {
  position: relative; overflow: hidden;
  background: var(--panel-2); border-radius: 8px;
  color: transparent !important; user-select: none; pointer-events: none;
  min-height: 1em;
}
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--skel-sheen), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- mobile (sidebar → icon rail, drawer → full width) ---------- */
@media (max-width: 860px) {
  .sidebar { width: 60px; padding: 14px 6px 12px; }
  .brand { padding: 2px 0 12px; text-align: center; }
  .brand-mark { display: none; }
  .brand::before { content: "🦩"; font-size: 20px; }
  .login-card .brand-mark { display: inline; }         /* login keeps wordmark */
  .new-chat { margin: 0 0 12px; padding: 9px 0 9px 15px; text-align: left; }
  .nav-item { padding: 10px 0 10px 13px; gap: 12px; }  /* clips to leading icon */
  .count, .convs-head, .convs, .status-label { display: none; }
  .side-foot { flex-direction: column-reverse; gap: 10px; padding: 10px 0 0; }
  .statuses { display: grid; grid-template-columns: repeat(2, 8px); gap: 7px; justify-content: center; }
  .foot-actions { flex-direction: column; gap: 4px; }

  .drawer, .drawer.hidden { width: 100vw; border-left: none; }
  .view-head { padding: 22px 18px 8px; }
  .cards { padding: 8px 18px 28px; grid-template-columns: 1fr; }
  .empty-note { padding: 24px 18px; }
  .chat-scroll { padding: 24px 0 14px; }
  .chat-empty { margin-top: 7vh; }
  .chat-empty h1 { font-size: 26px; }
  #messages { padding: 0 16px; }
  .composer-wrap { padding: 6px 12px 12px; }
  .drawer-head, .drawer-body { padding-left: 18px; padding-right: 18px; }
  .fields { grid-template-columns: 1fr 1fr; gap: 12px 14px; }
  .toasts { right: 12px; bottom: 12px; left: 12px; align-items: stretch; }
  .toasts > * { max-width: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .msg.streaming .bubble::after, .bubble .caret::after { animation: none; opacity: .7; }
  .typing i { animation: none; opacity: .5; }
  .skel::after { animation: none; }
}

/* ============================================================================
   ATS v2 (board.js + drawer tabs) — kanban, handover queue, top bar, work chip.
   Reuses the v1 tokens/aesthetic (calm panels, terracotta accent, both themes).
   ========================================================================== */

/* ---------- top bar: agent metrics strip + work-session chip ---------- */
.topbar {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; border-bottom: 1px solid var(--line);
  background: var(--panel-2); min-height: 46px;
}
.topbar-spacer { flex: 1; }
.agent-strip { display: flex; align-items: center; gap: 6px; overflow-x: auto; }
.strip-chip {
  display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap;
  padding: 4px 11px; border-radius: 999px; font-size: 12px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-soft);
}
.strip-chip:hover { border-color: var(--accent); color: var(--ink); }
.strip-chip .strip-n { font-weight: 700; font-size: 13.5px; }
.strip-chip .strip-k { color: var(--muted); }
.strip-chip.strip-zero { opacity: .55; }
.strip-chip.strip-needs_human .strip-n { color: var(--warn); }
.strip-chip.strip-failed .strip-n { color: var(--bad); }
.strip-chip.strip-done .strip-n { color: var(--good); }
.strip-chip.strip-failed.strip-zero .strip-n { color: var(--muted); }
.nav-en { margin-left: 4px; font-size: 11px; color: var(--muted); font-weight: 400; }
.count.count-alert { color: var(--bad); font-weight: 700; }

.work-chip { flex: none; }
.wchip {
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-soft);
}
.wchip:hover { border-color: var(--accent); color: var(--ink); }
.wchip-on {
  background: var(--accent-soft); border-color: transparent; color: var(--accent);
  font-weight: 600; font-variant-numeric: tabular-nums;
}

/* ---------- kanban board ---------- */
.board-controls { display: flex; align-items: center; gap: 8px; }
.board-pick {
  min-width: 200px; max-width: min(60vw, 360px); font-size: 13px;
  background: var(--panel); cursor: pointer;
}
.board-meta { color: var(--ink-soft); }
.board-wrap {
  flex: 1; min-height: 0; display: flex; gap: 12px; align-items: flex-start;
  overflow-x: auto; overflow-y: hidden; padding: 12px 40px 28px;
}
.kcol {
  flex: 0 0 clamp(240px, 78vw, 288px); align-self: stretch;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.kcol-head {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  position: sticky; top: 0; background: var(--panel-2); z-index: 1;
}
.kcol-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcol-fx { margin-left: 4px; font-size: 11px; }
.kcol-n {
  flex: none; font-size: 11px; color: var(--muted); font-weight: 600;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 8px;
}
.kcol-cards {
  flex: 1; min-height: 40px; overflow-y: auto;
  padding: 10px; display: flex; flex-direction: column; gap: 9px;
}
.kcard {
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid transparent; border-radius: 11px;
  padding: 10px 12px; cursor: pointer; box-shadow: var(--shadow-1);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.kcard:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.kcard-name { font-weight: 650; font-size: 14px; overflow-wrap: anywhere; }
.kcard-kana { font-weight: 400; font-size: 11.5px; color: var(--muted); margin-left: 4px; }
.kcard-order {
  display: inline-block; margin-top: 5px; font-size: 11px; color: var(--accent);
  background: var(--accent-soft); border-radius: 6px; padding: 1px 7px;
}
.kcard-foot {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  font-size: 11px; color: var(--muted);
}
.kcard-days { font-variant-numeric: tabular-nums; }
.kcard-src { margin-left: auto; text-transform: uppercase; letter-spacing: .3px; font-size: 10px; }
.kcard-fx { color: var(--accent); }
.fit { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.fit-green { background: var(--good); }
.fit-yellow { background: var(--warn); }
.fit-gray { background: var(--muted); }

/* days-in-stage decay escalation: none → gold → terracotta → red */
.kcard.decay-warm  { border-left-color: var(--warn); }
.kcard.decay-warn  { border-left-color: var(--accent); }
.kcard.decay-stale { border-left-color: var(--bad); }
.decay-warn  .kcard-days { color: var(--accent); font-weight: 600; }
.decay-stale .kcard-days { color: var(--bad); font-weight: 700; }

/* drag states (SortableJS) */
.kcard-ghost { opacity: .4; }
.kcard-chosen { box-shadow: var(--shadow-2); }
.kcard-dragging { cursor: grabbing; }
.kcard-fallback { opacity: .92; box-shadow: var(--shadow-2); cursor: grabbing; }
.kcard-busy { opacity: .55; pointer-events: none; }

/* UNDO toast with a live countdown button */
.toasts > .toast-undo { display: flex; align-items: center; gap: 12px; }
.toast-undo-btn {
  flex: none; font-size: 12.5px; font-weight: 600; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 8px; padding: 4px 10px;
  font-variant-numeric: tabular-nums;
}
.toast-undo-btn:hover { background: var(--accent-soft); }
.toast-undo-btn:disabled { opacity: .5; cursor: default; }

/* ---------- handover queue ---------- */
.handover-list { display: block; }
.handover-list .empty-note { padding: 30px 0; }
.hcard {
  display: block; background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px;
}
.hcard.status-needs_human { border-left-color: var(--warn); }
.hcard.status-proposed { border-left-color: var(--accent); }
.hcard.status-done, .hcard.status-approved { border-left-color: var(--good); }
.hcard.hcard-failed { border-left-color: var(--bad); background: color-mix(in srgb, var(--bad) 5%, var(--panel)); }
.hcard-top { display: flex; align-items: center; gap: 8px; font-size: 11.5px; }
.hcard-agent { font-weight: 600; color: var(--ink-soft); }
.hstatus {
  font-size: 11px; font-weight: 600; padding: 1px 9px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-soft);
}
.hstatus.status-needs_human { color: var(--warn); }
.hstatus.status-failed { color: var(--bad); }
.hstatus.status-done, .hstatus.status-approved { color: var(--good); }
.hcard-when { margin-left: auto; color: var(--muted); }
.hcard-label { font-weight: 650; font-size: 14.5px; margin-top: 6px; }
.hcard-ctx { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.hcard-draft { margin-top: 10px; }
.hcard-draft summary {
  cursor: pointer; font-size: 12.5px; color: var(--accent); user-select: none;
}
.hcard-draft pre {
  margin-top: 8px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; font-size: 12.5px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: break-word; max-height: 340px; overflow-y: auto;
  font-family: var(--sans);
}
.hcard-err {
  margin-top: 10px; color: var(--bad); font-size: 12.5px;
  background: color-mix(in srgb, var(--bad) 8%, var(--panel));
  border-radius: 8px; padding: 8px 10px;
}
.hcard-decided { margin-top: 8px; font-size: 12px; color: var(--good); }
.hcard-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.hbtn { font-size: 13px; padding: 7px 14px; border-radius: 9px; }
.ghost.hbtn { border: 1px solid var(--line); color: var(--ink-soft); }
.ghost.hbtn:hover { border-color: var(--accent); color: var(--ink); background: var(--panel-2); }
.hbtn-dismiss:hover { border-color: var(--bad); color: var(--bad); }
.pill-n { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.pill.active .pill-n { color: #fff; }
.pill.pill-alert { border-color: var(--bad); color: var(--bad); }
.pill.pill-alert.active { background: var(--bad); border-color: var(--bad); color: #fff; }

/* ADHD "next action" single-card step-through (reuses .dialog) */
.na-dlg { width: min(560px, calc(100vw - 32px)); padding: 20px 22px; }
.na-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.na-head h3 { font-family: var(--serif); font-weight: 600; font-size: 19px; }
.na-prog { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.na-body .hcard { margin-bottom: 0; }
.na-foot { display: flex; justify-content: flex-end; margin-top: 14px; }
.na-done { text-align: center; padding: 28px 0; }

/* ---------- candidate drawer: tabs (timeline / apps / similar) ---------- */
.drawer-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.dtab {
  padding: 8px 12px; font-size: 13px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.dtab:hover { color: var(--ink-soft); }
.dtab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.tabn { font-size: 11px; color: var(--muted); }
.dtab-panel { padding-top: 14px; }
.apps-lens { display: flex; flex-direction: column; gap: 10px; }
.app-row {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px;
}
.app-row.clickable { cursor: pointer; }
.app-row.clickable:hover { border-color: var(--accent); }
.app-row-top { display: flex; align-items: center; gap: 8px; }
.app-role { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; }
.app-row-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.similar-lens { padding: 4px 0; }

/* agent_action rows in the merged timeline feed */
.tl-item.tl-failed .tl-title { color: var(--bad); }
.tl-item.tl-failed .tl-body { color: var(--bad); }
.tl-item.tl-agent_action::before { background: var(--warn); }

/* ---------- Stage-4 ML: fit badge, similar-lens, shortlist modal (js:) ---------- */
.fit-shadow {
  font-size: 10.5px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 7px; white-space: nowrap;
}
.fit-shadow:empty { display: none; }
.fit-shadow-scored { color: var(--accent); border-color: var(--accent-soft); }

.sim-row {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; margin-bottom: 8px;
}
.sim-row.clickable { cursor: pointer; }
.sim-row.clickable:hover { border-color: var(--accent); }
.sim-top { display: flex; align-items: baseline; gap: 8px; }
.sim-name { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; }
.sim-score { color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; }
.sim-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.sim-flag { border-radius: 999px; padding: 0 7px; font-size: 10.5px; color: #fff; }
.sim-flag-rejected { background: var(--bad); }
.sim-flag-placed { background: var(--good); }

.sl-dlg { width: min(720px, calc(100vw - 32px)); max-height: 88vh; padding: 20px 22px;
  display: flex; flex-direction: column; }
.sl-body { overflow-y: auto; margin-top: 6px; }
.sl-order { font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.sl-row {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px;
}
.sl-row.sl-flagged { opacity: .72; }
.sl-top { display: flex; align-items: baseline; gap: 8px; }
.sl-name { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; }
.sl-score { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.sl-fit {
  font-size: 11px; border-radius: 999px; padding: 1px 8px;
  background: var(--accent-soft); color: var(--accent);
}
.sl-verd-strong_match { background: var(--good); color: #fff; }
.sl-verd-no_match { background: var(--panel); color: var(--muted); border: 1px solid var(--line); }
.sl-meta { color: var(--muted); font-size: 12px; margin: 3px 0; display: flex;
  align-items: center; gap: 6px; flex-wrap: wrap; }
.sl-reason { font-size: 12.5px; color: var(--ink-soft); line-height: 1.45; margin-top: 4px; }
.sl-acts { display: flex; gap: 8px; margin-top: 8px; }
.sl-filtered-head, .sl-order + .sl-filtered-head { font-size: 12px; color: var(--muted);
  margin: 14px 0 8px; padding-top: 10px; border-top: 1px dashed var(--line-strong); }

/* ---------- S3 rubrics: score chips + drawer Evidence tab (js: app.js/board.js) ---------- */
.card-score, .kcard-score {
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--ink-soft); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 0 7px;
  flex: none;
}
.card-top .fit { align-self: center; }
.evidence-lens { display: flex; flex-direction: column; }
.ev-head {
  display: flex; align-items: center; gap: 8px; margin: 12px 0 6px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.ev-head:first-child { margin-top: 0; }
.ev-order { font-weight: 600; font-size: 13.5px; }
.ev-head-meta { color: var(--muted); font-size: 12px; margin-left: auto; }
.ev-row {
  display: flex; gap: 9px; padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.ev-row:last-child { border-bottom: 0; }
.ev-glyph { flex: none; width: 1.5em; text-align: center; font-size: 14px; line-height: 1.4; }
.ev-met .ev-glyph { color: var(--good); }
.ev-partial .ev-glyph { color: var(--warn); }
.ev-not_met .ev-glyph { color: var(--bad); }
.ev-unknown .ev-glyph { color: var(--muted); font-weight: 700; }
.ev-disqualifying { background: color-mix(in srgb, var(--bad) 7%, transparent); border-radius: 8px; }
.ev-pending .ev-glyph { color: var(--muted); }
.ev-main { min-width: 0; flex: 1; }
.ev-text { font-size: 13px; line-height: 1.45; }
.ev-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.ev-tag {
  font-size: 10px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 6px; margin-left: 4px; white-space: nowrap;
  vertical-align: 1px;
}
.ev-tag-disq { color: var(--bad); border-color: var(--bad); }
.ev-quote {
  font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; padding-left: 8px;
  border-left: 2px solid var(--accent); white-space: pre-wrap; word-break: break-word;
}
.ev-reason { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.45; }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .topbar { padding: 6px 12px; gap: 8px; }
  .board-wrap { padding: 10px 14px 22px; gap: 10px; }
  .kcol { flex-basis: 82vw; }
  .board-pick { min-width: 140px; }
  .handover-list { padding-left: 0; padding-right: 0; }
  .nav-en { display: none; }
}

/* ---------- S2 unmatched email review queue (board.js unmatchedCard) ---------- */
.uq-reason { color: var(--muted); font-size: 12px; }
.uq-preview {
  color: var(--ink-soft); font-size: 12.5px; line-height: 1.45; margin-top: 4px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.uq-assign { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.uq-assign select { flex: 1; min-width: 0; }
