:root {
  --bg: #1a1a1a;
  --panel: #232323;
  --panel-2: #2b2b2b;
  --border: #3a3a3a;
  --text: #e8e6e3;
  --muted: #9a958f;
  --accent: #d97757;
  --user: #2d3b4d;
  --tool: #2a3326;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
header {
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}
header h1 { font-size: 15px; margin: 0; font-weight: 600; }
header h1 a { color: inherit; text-decoration: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #888; }
.dot.on { background: #4caf50; box-shadow: 0 0 6px #4caf50; }
.dot.off { background: #e05c4a; }
.meta { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.meta b { color: var(--text); font-weight: 500; }
.navlink { color: var(--accent); text-decoration: none; font-size: 12px; font-weight: 600; }
.navlink:hover { text-decoration: underline; }

#page {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 16px 40px;
}
.wrap { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.card h2 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.card .sub { color: var(--muted); font-size: 12px; margin: -6px 0 14px; }

/* intake form */
form .field { margin-bottom: 14px; }
form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
textarea, input[type=file] {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  outline: none;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
textarea:focus, input[type=file]:focus { border-color: var(--accent); }
input[type=file] { padding: 8px 10px; font-size: 13px; }
button {
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: 9px;
  padding: 0 20px;
  height: 42px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
button:disabled { opacity: .5; cursor: not-allowed; }
/* bug / feature tabs along the top edge of the card */
.tabcard { padding: 0; overflow: hidden; }
.tabcard .cardbody { padding: 16px 18px; }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab { padding: 12px 18px; cursor: pointer; font-size: 14px; color: var(--muted);
  user-select: none; border-right: 1px solid var(--border); }
.tab input { display: none; }
.tab.sel { color: var(--text); background: var(--panel-2); font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent); }
.chip.kind { font-weight: 600; }
.chip.kind.feat { color: #c3a8ff; border-color: #4a3f6a; }
/* header limit indicators */
#limits .lim-ok { color: #8fd29a; font-weight: 500; }
#limits .lim-bad { color: #e0896f; font-weight: 500; }
.form-msg { margin-top: 10px; font-size: 13px; color: var(--muted); min-height: 18px; }
.form-msg.err { color: #e0896f; }
.form-msg.ok { color: #a8c98a; }

/* history table */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
td.desc { max-width: 360px; }
td.desc .d { white-space: pre-wrap; word-break: break-word; }
.empty { color: var(--muted); font-size: 13px; padding: 10px 0; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; font-family: var(--mono); }
.badge.working { background: #3a3320; color: #e3c463; }
.badge.waiting { background: #2f2a3b; color: #c3a8ff; }
.badge.done { background: #233a26; color: #8fd29a; }
.badge.failed { background: #3a2323; color: #e0896f; }
.badge.spam { background: #36302a; color: #d6a866; }
.badge.queued { background: #2a2c30; color: #9aa3ad; }
a.dl { color: var(--accent); text-decoration: none; font-weight: 600; }
a.dl:hover { text-decoration: underline; }
.when { font-family: var(--mono); color: var(--muted); white-space: nowrap; }

/* session tiles */
#history { display: flex; flex-direction: column; gap: 12px; }
.tile { border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); padding: 12px 14px; }
.tile.active { border-color: var(--accent); }
.tile-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.chip { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: #00000033; border: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.chip.mono { font-family: var(--mono); color: var(--muted); }
.chip .k { color: var(--muted); }
.tile-top .badge { margin-left: auto; }
.tile-desc { white-space: pre-wrap; word-break: break-word; margin-bottom: 8px; }
/* auto-translated descriptions: badge + folded original */
.tr-orig { margin-top: 6px; }
.tr-orig summary {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  list-style: none; user-select: none;
}
.tr-orig summary::-webkit-details-marker { display: none; }
.tr-badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  color: #8fb8d8; border: 1px solid #3a5268; background: #24303c;
}
.tr-toggle { font-size: 11px; color: var(--muted); text-decoration: underline dotted; }
.tr-orig summary:hover .tr-toggle { color: var(--text); }
.tr-orig-text {
  margin-top: 6px; padding: 8px 10px; font-size: 13px; font-style: italic;
  color: var(--muted); border-left: 3px solid #3a5268; border-radius: 0 6px 6px 0;
  background: var(--panel);
}
.tile-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tile-foot .when { font-size: 12px; }
/* progress bar */
.prog { margin: 6px 0 8px; }
.prog-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-family: var(--mono); }
.prog-stage { color: var(--text); font-family: inherit; }
.bar { height: 8px; background: #00000040; border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
.bar.indet > i { width: 30% !important; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.bar.paused > i { background: #6a5a9a; opacity: .6; }
/* friendly one-sentence status + done "what changed" */
.note { margin-top: 7px; font-size: 13px; color: var(--text); }
.changed { margin: -2px 0 9px; font-size: 13px; color: #8fd29a; }
.changed::before { content: "✓ "; }
.pushed-note { margin: -2px 0 9px; font-size: 13px; color: #7fc3e8; }
.tile.waiting { border-color: #6a5a9a; }
/* queued: lined up behind other reports — calm, no animation */
.tile.queued { opacity: .72; }
.prog.queued-note { font-size: 13px; color: var(--muted); margin: 2px 0 4px; }
/* spam: collapsed + dimmed one-liner; brightens on hover/expand */
.tile.spam { opacity: .5; padding: 0; transition: opacity .15s ease; }
.tile.spam:hover, .tile.spam[open] { opacity: 1; }
.tile.spam > summary {
  cursor: pointer; list-style: none; user-select: none;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px;
}
.tile.spam > summary::-webkit-details-marker { display: none; }
.tile.spam > summary::before { content: "▸"; color: var(--muted); width: 1em; flex: 0 0 auto; }
.tile.spam[open] > summary::before { content: "▾"; }
.tile.spam .spam-reason { color: var(--muted); font-size: 13px; flex: 1 1 200px; }
.tile.spam > summary .badge.spam { margin-left: auto; }
.tile.spam .tile-body { padding: 0 14px 12px; }
.tile.spam .tile-top { margin-bottom: 8px; }
/* usage-limit banner */
.banner { background: #2f2a3b; border: 1px solid #4a3f6a; color: #d9ccff;
  border-radius: 10px; padding: 11px 14px; font-size: 13px; }
.banner b { color: #fff; }
/* activity collapsible */
#activityFold > summary { cursor: pointer; user-select: none; color: var(--muted); font-size: 13px; }
#activityFold[open] > summary { margin-bottom: 12px; }
#activityFold > summary b { color: var(--text); }

/* activity / claude stream */
#log {
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}
.msg {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg .role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.msg.user { background: var(--user); border-color: #34465a; }
.msg.user .role { color: #9cc3ea; }
.msg.assistant .role { color: var(--accent); }
.msg.tool {
  background: var(--tool);
  border-color: #3a4730;
  font-family: var(--mono);
  font-size: 13px;
}
.msg.tool .role { color: #a8c98a; }
.msg.result {
  background: var(--panel-2);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.msg.sys {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
  text-align: center;
}
.msg .body { font-family: inherit; }
.tool-input {
  margin-top: 6px;
  padding: 8px;
  background: #00000033;
  border-radius: 6px;
  font-size: 12px;
  white-space: pre-wrap;
  color: #c8d6b6;
}
.tool-fold > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  color: #a8c98a;
  font-size: 13px;
  font-family: var(--mono);
}
.tool-fold > summary::-webkit-details-marker { display: none; }
.tool-fold > summary::before {
  content: "▸";
  display: inline-block;
  width: 1em;
  color: var(--muted);
}
.tool-fold[open] > summary::before { content: "▾"; }
.tool-fold.err > summary { color: #e0896f; }
.tool-result-head { margin-top: 8px; font-size: 12px; color: var(--muted); }
.tool-result.err .tool-result-head { color: #e0896f; }
.msg.question { background: #2d2a3b; border-color: #463f5a; }
.msg.question .role { color: #b9a8e8; }
.q-block { margin-top: 4px; }
.q-block + .q-block { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.q-header { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.q-text { margin-bottom: 10px; }
.q-opts { display: flex; flex-direction: column; gap: 8px; }
.q-opt { text-align: left; width: 100%; height: auto; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font: inherit; cursor: pointer; display: block; }
.q-opt:hover:not(:disabled) { border-color: var(--accent); background: #34303f; }
.q-opt .q-opt-label { font-weight: 600; }
.q-opt .q-opt-desc { color: var(--muted); font-size: 12px; margin-top: 2px; }
.q-opt.sel { border-color: var(--accent); background: #3a2f33; }
.q-opt.sel .q-opt-label::before { content: "✓ "; color: var(--accent); }
.q-submit { margin-top: 10px; height: 36px; }
.q-answered { margin-top: 8px; color: #a8c98a; font-size: 12px; font-family: var(--mono); }
.cursor::after { content: "▋"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* live device connection (top section) */
#liveConnect h2 { display: flex; align-items: center; gap: 8px; }
.lc-opt { font-size: 11px; font-weight: 500; color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 8px; text-transform: uppercase; letter-spacing: .05em; }
.lc-warn { background: #3a2c20; border: 1px solid #6a4a2a; color: #f0c89a;
  border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.lc-warn.small { font-size: 12px; padding: 8px 10px; margin: 10px 0 8px; }
.lc-warn code { background: #00000033; padding: 0 4px; border-radius: 4px; }
.lc-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.lc-row input { flex: 1 1 200px; width: auto; }
.lc-row button { height: 42px; flex: 0 0 auto; }
.lc-steps { margin: 4px 0 0; padding-left: 20px; font-size: 13px; line-height: 1.7; }
.lc-steps code { background: #00000033; padding: 0 4px; border-radius: 4px; font-family: var(--mono); }
.lc-status { margin-top: 12px; font-size: 13px; color: var(--accent); }
.lc-status::before { content: "● "; animation: blink 1.2s steps(2) infinite; }
.lc-dev { font-size: 14px; margin-bottom: 4px; }
.lc-forget { background: transparent; border: 1px solid var(--border); color: var(--muted);
  height: 32px; padding: 0 14px; font-size: 12px; font-weight: 600; margin-top: 14px; }
.lc-forget:hover { border-color: var(--accent); color: var(--text); }
.lc-autolog { background: #1e2f24; border: 1px solid #3a5740; color: #a8d6b8;
  border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; }
.lc-update-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #3a2c20; border: 1px solid #6a4a2a; border-radius: 8px; padding: 10px 12px; margin-top: 10px; }
.lc-behind { color: #f0c89a; font-size: 13px; flex: 1 1 200px; }
.lc-update { height: 34px; padding: 0 16px; font-size: 13px; flex: 0 0 auto; }
.lc-update:disabled { opacity: .6; }

/* admin: git log */
#gitlog { display: flex; flex-direction: column; }
.commit { border-bottom: 1px solid var(--border); }
.commit:last-child { border-bottom: none; }
.commit > summary {
  cursor: pointer; list-style: none; user-select: none;
  padding: 9px 2px; display: flex; gap: 10px; align-items: baseline;
}
.commit > summary::-webkit-details-marker { display: none; }
.commit > summary::before { content: "▸"; color: var(--muted); width: 1em; display: inline-block; flex: 0 0 auto; }
.commit[open] > summary::before { content: "▾"; }
.commit .h { font-family: var(--mono); color: var(--accent); font-size: 12px; flex: 0 0 auto; }
.commit .subj { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.commit[open] .subj { white-space: normal; }
.commit .cmeta { color: var(--muted); font-size: 12px; font-family: var(--mono); white-space: nowrap; flex: 0 0 auto; }
.diff { margin: 2px 0 12px; background: #00000033; border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-family: var(--mono); font-size: 12px; line-height: 1.45; }
.diff .dl { display: block; white-space: pre; }
.diff .da { color: #8fd29a; }      /* added line */
.diff .dr { color: #e0896f; }      /* removed line */
.diff .dh { color: #c3a8ff; }      /* @@ hunk header */
.diff .df { color: var(--text); font-weight: 600; background: #ffffff0a; margin-top: 6px; }  /* file header */
.diff .dc { color: var(--muted); } /* context line */
.diff .loading { color: var(--muted); }

/* admin: flat report list with a re-run button (see admin.html renderReports) */
.rrow { display: flex; gap: 10px; align-items: baseline; padding: 8px 2px;
  border-bottom: 1px solid var(--border); font-size: 13px; }
.rrow:last-child { border-bottom: none; }
.rstat { font-family: var(--mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; flex: 0 0 62px; }
.rstat.s-done { color: #8fd29a; }
.rstat.s-failed { color: #e0896f; }
.rstat.s-spam, .rstat.s-waiting { color: var(--muted); }
.rstat.s-working { color: var(--accent); }
.rid { font-family: var(--mono); font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.rdesc { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rbtn { background: transparent; color: var(--accent); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
  flex: 0 0 auto; }
.rbtn:hover:enabled { border-color: var(--accent); }
.rbtn:disabled { color: var(--muted); cursor: default; }
