:root {
  color-scheme: dark;
  --bg: #0d1117; --card: #161b22; --line: #30363d; --raise: #21262d;
  --text: #e6edf3; --muted: #8b949e;
  --blue: #58a6ff; --green: #3fb950; --orange: #d29922; --red: #f85149; --purple: #bc8cff;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body { padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
a { color: var(--blue); text-decoration: none; }
code { font-family: var(--mono); font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 5px; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.top {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: rgba(13, 17, 23, .92); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.titles { min-width: 0; }
.logo { width: 34px; height: 34px; border-radius: 8px; flex: none; }
h1 { font-size: 17px; margin: 0; }
#sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; align-items: center; gap: 6px; flex: none; }

button {
  font: inherit; color: var(--text); background: var(--raise);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer;
}
button.icon { width: 38px; height: 38px; padding: 0; font-size: 18px; line-height: 1; }
button.primary { background: #238636; border-color: #2ea043; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pill {
  font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line);
  white-space: nowrap; max-width: 34vw; overflow: hidden; text-overflow: ellipsis;
}
.pill:empty { display: none; }
.pill.ok { color: var(--green); border-color: rgba(63, 185, 80, .5); }
.pill.busy { color: var(--blue); border-color: rgba(88, 166, 255, .5); }
.pill.warn { color: var(--orange); border-color: rgba(210, 153, 34, .6); }

main { padding: 12px; max-width: 1200px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 900px) { .grid { grid-template-columns: 1fr 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; min-width: 0; }
.card h2 { font-size: 13px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.card h3 { font-size: 13px; margin: 16px 0 6px; color: var(--muted); font-weight: 600; }

.kv { display: flex; gap: 10px; padding: 3px 0; }
.kv .k { flex: 0 0 58px; color: var(--muted); }
.kv .v { min-width: 0; overflow-wrap: anywhere; }

.bar { height: 6px; background: var(--raise); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.fill { height: 100%; background: var(--blue); border-radius: 99px; }
.fill.hot { background: var(--orange); }
.meter { margin: 8px 0; font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 520px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-width: 0; }
.big { font-size: 22px; font-weight: 650; }
.allowance { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.allowance > div + div { margin-top: 3px; }
.leftrow { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.leftrow .big { font-size: 26px; }
.leftusd { font-size: 22px; font-weight: 650; color: var(--green); }
.warn { color: var(--orange); }

.chart { display: flex; align-items: flex-end; gap: 4px; height: 130px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.colbar { width: 100%; background: linear-gradient(180deg, var(--green), #238636); border-radius: 4px 4px 0 0; }
.colbar.zero { background: var(--raise); }
.colval { font-size: 9.5px; color: var(--muted); white-space: nowrap; min-height: 13px; }
.collab { margin-top: 3px; font-size: 11px; color: var(--muted); }
.collab.today { color: var(--text); font-weight: 600; }

.role { margin: 7px 0; }
.rowhead { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }

.badge { font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--raise); border: 1px solid var(--line); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; padding: 3px 9px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); }
.s-ready, .s-approved, .s-verified { color: var(--green); border-color: rgba(63, 185, 80, .5); }
.s-solving, .s-computing, .s-running, .s-partial { color: var(--blue); border-color: rgba(88, 166, 255, .5); }
.s-claimed, .s-verifying, .s-formalizing, .s-writing, .s-refereeing, .s-recheck { color: var(--purple); border-color: rgba(188, 140, 255, .5); }
.s-hold, .s-waiting { color: var(--orange); border-color: rgba(210, 153, 34, .6); }
.s-failed, .s-dead { color: var(--red); border-color: rgba(248, 81, 73, .5); }

.item, .job, .event { border-top: 1px solid var(--line); padding: 8px 0; overflow-wrap: anywhere; }
.item.ready { border-left: 3px solid var(--green); padding-left: 8px; }
.item.hold { border-left: 3px solid var(--orange); padding-left: 8px; }
.event { font-size: 13px; }
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; cursor: pointer; }
.item.clamp, .event.clamp { padding-bottom: 0; margin-bottom: 8px; }
button.more { display: block; width: 100%; margin-top: 8px; font-size: 13px; color: var(--blue); }
button.mini { margin-top: 6px; padding: 3px 10px; font-size: 12.5px; }
.rush { color: var(--orange); font-size: 12.5px; white-space: nowrap; }
.wanted { color: var(--blue); font-size: 12.5px; white-space: nowrap; }
.expandable { cursor: pointer; }
.chev::before { content: "▸ "; color: var(--muted); }
.expanded .chev::before { content: "▾ "; }
.stages { display: none; margin: 8px 0 2px; padding: 6px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; cursor: default; }
.expanded > .stages { display: block; }
.item.expanded.clamp, .item.expanded .clamp { display: block; -webkit-line-clamp: unset; line-clamp: unset; overflow: visible; }
.stage { padding: 5px 0; }
.stage + .stage { border-top: 1px solid var(--line); }
.stage .icon { display: inline-block; width: 1.1em; text-align: center; }
.stage.done .icon { color: var(--green); }
.stage.now .icon { color: var(--blue); }
.stage.hold .icon { color: var(--orange); }
.stage.left { color: var(--muted); }
.stage .facts { padding-left: 1.4em; }
.toast {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 5;
  max-width: calc(100% - 32px); width: max-content; padding: 9px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--raise); color: var(--text); font-size: 13.5px; box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
  opacity: 0; transform: translate(-50%, 12px); transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.kind { font-family: var(--mono); font-size: 12px; color: var(--purple); }
.notes { padding-left: 18px; margin: 10px 0 0; }

.banner {
  background: rgba(210, 153, 34, .12); border: 1px solid rgba(210, 153, 34, .5); color: #e3b341;
  border-radius: 10px; padding: 10px 12px; margin-bottom: 12px;
}
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty button { margin-top: 14px; }

dialog {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 14px; width: min(520px, 94vw); padding: 16px;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0 0 8px; font-size: 17px; }
label { display: block; margin: 10px 0; font-size: 13px; color: var(--muted); }
input {
  display: block; width: 100%; margin-top: 4px; font-family: inherit; font-size: 16px;
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
}
details { margin: 8px 0; font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
