:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e3e6ea;
  --text: #1d2330;
  --muted: #667085;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --ok: #15803d;
  --ok-soft: #e8f6ee;
  --agent: #7c3aed;
  --radius: 8px;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, textarea, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 5px 10px; cursor: pointer;
}
button:hover { border-color: #c7ccd4; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #1d4ed8; }
button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
textarea {
  width: 100%; min-height: 64px; resize: vertical; border: 1px solid var(--line); border-radius: 6px; padding: 8px;
}
textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.shell { display: grid; grid-template-rows: 52px 1fr; height: 100vh; }
.bar {
  display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .02em; color: var(--accent); text-decoration: none; }
.title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.latest { background: var(--ok-soft); color: var(--ok); border-color: #bfe3cc; }
.chip.old { background: var(--warn-soft); color: var(--warn); border-color: #f5d7a8; }
.chip.agent { background: #f3ecff; color: var(--agent); border-color: #ddd0fb; }
.spacer { flex: 1; }
.bar select { border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; background: var(--panel); }

.main { display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
.stage { position: relative; min-height: 0; padding: 12px; }
.stage iframe {
  width: 100%; height: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
}
.stage.picking iframe { outline: 3px solid var(--accent); outline-offset: -1px; }
.pickhint {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}

.side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-left: 1px solid var(--line); }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; border: 0; border-radius: 0; padding: 12px; background: transparent; color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.count { margin-left: 6px; background: var(--bg); border-radius: 999px; padding: 0 7px; font-size: 12px; }
.panel { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.toolbar { display: flex; gap: 8px; align-items: center; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }

.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--panel); }
.card.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 4px #fde68a; } to { box-shadow: 0 0 0 0 transparent; } }
.card.resolved { opacity: .65; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.anchor {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--accent);
  background: var(--accent-soft); border: 0; padding: 1px 6px; border-radius: 4px; cursor: pointer;
}
.quote { color: var(--muted); border-left: 3px solid var(--line); padding-left: 8px; margin: 6px 0; font-size: 13px; }
.body { margin: 6px 0 0; white-space: pre-wrap; word-wrap: break-word; }
.reply { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.actions { display: flex; gap: 6px; margin-top: 8px; }
.composer { border: 1px solid var(--accent); border-radius: var(--radius); padding: 10px; background: var(--accent-soft); }
.composer .meta { margin-bottom: 6px; }

.question { font-weight: 600; margin-bottom: 8px; }
.option {
  display: flex; gap: 8px; align-items: flex-start; padding: 8px; border: 1px solid var(--line); border-radius: 6px;
  margin-bottom: 6px; cursor: pointer;
}
.option.picked { border-color: var(--ok); background: var(--ok-soft); }
.option.mine { border-color: var(--accent); }
.option .label { font-weight: 500; }
.option .desc { color: var(--muted); font-size: 13px; }
.option .tally { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.status-open { color: var(--accent); }
.status-closed { color: var(--ok); }
.note { margin-top: 6px; }
.note input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }

.home { max-width: 1040px; margin: 32px auto; padding: 0 16px; }
.home h1 { font-size: 22px; margin: 0; }
.homebar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.home .toolbar { margin-bottom: 12px; flex-wrap: wrap; }
.search { width: 260px; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; background: var(--panel); }
.search:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.filter { border-radius: 999px; }
table.artifacts {
  width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.artifacts th, .artifacts td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.artifacts tbody tr:last-child td { border-bottom: 0; }
.artifacts tbody tr:hover { background: var(--bg); }
.artifacts th { background: var(--bg); font-weight: 600; font-size: 12px; color: var(--muted); }
.artifacts .num { text-align: right; font-variant-numeric: tabular-nums; }
.artifacts a { color: inherit; text-decoration: none; }
.artifacts a:hover strong { color: var(--accent); }
button.sort { border: 0; background: none; padding: 0; color: inherit; font-weight: inherit; }
.rowactions { text-align: right; white-space: nowrap; }
.home .more { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 12px; }
.rowactions button { padding: 3px 8px; font-size: 12px; }
.rowactions button + button { margin-left: 6px; }
button.danger { color: #b91c1c; }
button.danger:hover { border-color: #b91c1c; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff;
  padding: 8px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.toast.error { background: #b91c1c; }
.marker {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600;
}
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-size: 12px; }
button.link:hover { text-decoration: underline; }
