:root {
  --bg: #121211; --surface: #1a1a18; --raise: #222220; --line: #2e2d2a; --text: #ecebe5;
  --muted: #9c9a91; --faint: #6f6d66; --accent: #e3a443; --accent-ink: #1a1306;
  --good: #8fcd86; --mid: #e3a443; --low: #85827a; --bad: #e57a6e;
  --radius: 10px; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
:root[data-theme="light"] {
  --bg: #f5f4ef; --surface: #ffffff; --raise: #f0eee8; --line: #e2e0d8; --text: #1b1b18;
  --muted: #66655e; --faint: #94928a; --accent: #a5600a; --accent-ink: #ffffff;
  --good: #2f7d32; --mid: #a5600a; --low: #8a877e; --bad: #b3372b;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 76px;
}
a { color: inherit; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* header */
.top { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.top .wrap { display: flex; align-items: center; gap: 20px; height: 54px; }
.brand { font-weight: 650; letter-spacing: -0.01em; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand i { width: 9px; height: 9px; background: var(--accent); border-radius: 2px; display: inline-block; }
.nav-desk { display: none; gap: 4px; }
.nav-desk a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 7px; }
.nav-desk a.on, .nav-desk a:hover { color: var(--text); background: var(--raise); }
.top .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.pill { font-size: 12px; color: var(--muted); text-decoration: none; border: 1px solid var(--line); border-radius: 99px; padding: 3px 9px; }
.pill.on { color: var(--text); border-color: var(--faint); }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; padding: 4px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); z-index: 5; padding-bottom: env(safe-area-inset-bottom); }
.tabs a { text-align: center; text-decoration: none; color: var(--muted); padding: 10px 0 12px; font-size: 13px; }
.tabs a b { display: block; width: 18px; height: 3px; margin: 0 auto 6px; border-radius: 2px; background: transparent; }
.tabs a.on { color: var(--text); }
.tabs a.on b { background: var(--accent); }
@media (min-width: 720px) {
  .nav-desk { display: flex; }
  .tabs { display: none; }
  body { padding-bottom: 40px; }
}

h1 { font-size: 22px; letter-spacing: -0.015em; margin: 22px 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* filter chips */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; text-decoration: none; font-size: 13px; padding: 6px 11px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--muted); }
.chip span { font-family: var(--mono); font-size: 12px; color: var(--faint); margin-left: 4px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.on span { color: var(--bg); opacity: .7; }

/* job cards */
.list { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  display: grid; grid-template-columns: 52px 1fr; gap: 0 12px; padding: 14px 14px 12px 12px; }
.score { font-family: var(--mono); font-size: 22px; font-weight: 600; line-height: 1.1; text-align: center; padding-top: 1px; }
.score small { display: block; font-size: 10px; font-weight: 400; color: var(--faint); letter-spacing: .04em; margin-top: 3px; }
.s-good { color: var(--good); } .s-mid { color: var(--mid); } .s-low { color: var(--low); }
.card h3 { margin: 0; font-size: 15.5px; line-height: 1.3; font-weight: 600; }
.card h3 a { text-decoration: none; }
.card h3 a:hover { text-decoration: underline; text-underline-offset: 3px; }
.meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.meta .dot::before { content: "·"; margin: 0 6px; color: var(--faint); }
.reason { font-size: 13.5px; color: var(--muted); margin: 8px 0 0; white-space: pre-line; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag { font-size: 11.5px; padding: 2px 7px; border-radius: 5px; border: 1px solid var(--line); color: var(--muted); }
.tag.plus { border-color: color-mix(in srgb, var(--good) 45%, transparent); color: var(--good); }
.tag.warn { border-color: color-mix(in srgb, var(--mid) 45%, transparent); color: var(--mid); }
.card .acts { grid-column: 2; display: flex; gap: 8px; margin-top: 10px; }

/* buttons & forms */
.btn { font: inherit; font-size: 14px; font-weight: 550; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--raise); color: var(--text); text-decoration: none; display: inline-flex;
  align-items: center; gap: 6px; line-height: 1.2; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { font-size: 13px; padding: 6px 11px; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .5; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], textarea, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: transparent; }
input.pin { font-family: ui-monospace, monospace; font-size: 22px; letter-spacing: .45em; text-align: center; }
.login input.pin { padding: 12px 11px; }
textarea { resize: vertical; line-height: 1.5; }
.field { margin-bottom: 14px; }
.help { font-size: 12.5px; color: var(--faint); margin-top: 4px; }
.check { display: flex; gap: 9px; align-items: center; color: var(--text); font-size: 14.5px; margin: 0; padding: 6px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.panel h2 { display: flex; align-items: center; gap: 8px; }
.notice { border-left: 3px solid var(--accent); background: var(--raise); padding: 10px 12px; border-radius: 0 8px 8px 0; font-size: 14px; margin: 0 0 14px; }
.notice.bad { border-color: var(--bad); }
.ok { color: var(--good); } .bad { color: var(--bad); }

/* job detail */
.back { display: inline-block; margin-top: 16px; font-size: 13px; color: var(--muted); text-decoration: none; }
.jobhead { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; margin: 8px 0 14px; }
.jobhead h1 { margin: 0 0 4px; font-size: 21px; line-height: 1.25; }
.bigscore { font-family: var(--mono); font-size: 30px; font-weight: 600; line-height: 1; text-align: right; }
.bigscore small { display: block; font-size: 11px; font-weight: 400; color: var(--faint); margin-top: 4px; }
.stickyacts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.desc { white-space: pre-line; font-size: 14.5px; line-height: 1.6; overflow-wrap: anywhere; }
.desc.clamp { max-height: 420px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 80%, transparent); mask-image: linear-gradient(#000 80%, transparent); }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.letter textarea { font-size: 15px; min-height: 480px; background: var(--bg); }
.spinner { display: none; }
.htmx-request .spinner, .htmx-request.spinner { display: inline-block; }
.htmx-request .idle { display: none; }
.wait { display: none; color: var(--muted); font-size: 14px; padding: 8px 0; }
.htmx-request .wait, .htmx-request.wait { display: block; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--faint); font-size: 12px; padding: 0 8px 6px 0; }
td { padding: 9px 8px 9px 0; border-top: 1px solid var(--line); vertical-align: top; }
.hist { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.hist b { color: var(--text); font-weight: 500; }
.runline { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere;
  border-top: 1px solid var(--line); padding: 8px 0; }
.status-ok { color: var(--good); } .status-off { color: var(--faint); } .status-bad { color: var(--bad); }

/* login */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.login .brand { font-size: 20px; margin-bottom: 26px; }
.empty { text-align: center; color: var(--muted); padding: 50px 10px; }
.empty b { display: block; color: var(--text); font-weight: 550; margin-bottom: 4px; }
.wide { width: 100%; justify-content: center; padding: 11px; }
.mt { margin-top: 22px; }
.hidden { display: none; }
.mt-s { margin-top: 12px; }
select.auto { width: auto; }
.mb { margin-bottom: 14px; }
input.num { width: 110px; }
input[type=file] { font-size: 13px; color: var(--muted); max-width: 100%; }

/* ask */
.thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.askitem { display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; flex-direction: column; }
.msg.me { align-items: flex-end; }
.msg.bot { align-items: flex-start; }
.bubble { max-width: 88%; padding: 10px 13px; border-radius: 12px; white-space: pre-line; overflow-wrap: anywhere;
  font-size: 14.5px; unicode-bidi: plaintext; text-align: start; }
.msg.me .bubble { background: var(--raise); border: 1px solid var(--line); border-bottom-right-radius: 4px; }
.msg.bot .bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.proposal { max-width: 88%; margin-top: 8px; padding: 10px 13px; border-radius: 10px; font-size: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); background: var(--surface); }
.proposal ul { margin: 6px 0 10px; padding-left: 18px; }
.proposal li { overflow-wrap: anywhere; }
.reqstate { font-size: 12.5px; margin: 6px 0 0; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.req-done { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.req-rejected { color: var(--bad); }
.req-working { color: var(--mid); }
.askbox { position: sticky; bottom: 70px; background: var(--bg); padding: 8px 0 6px; }
.askbox textarea { unicode-bidi: plaintext; }
@media (min-width: 720px) { .askbox { bottom: 0; } }
