/* PM Kick-off Console (ADK). Same look as demo-ui: an app bar, the project bar, the five-stage tracker (the status
   bar), then "Now" (the run, the gate to answer, the reply) beside the stage log and the dry-run writes. */
:root {
  --bg: #f3f5f8; --paper: #ffffff; --sunk: #f7f8fa; --fg: #1b2230; --muted: #5d6676; --line: #dde2e9;
  --accent: #2f6f8f; --accent-strong: #245a75; --accent-tint: #e4eff5;
  --ok: #26734a; --ok-tint: #e2f2e8; --warn: #a35a09; --warn-tint: #fdf1e2; --bad: #b3261e; --bad-tint: #fbe8e6;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.06), 0 4px 16px rgba(20, 30, 45, 0.05);
  --on-accent: #ffffff;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c; --paper: #192029; --sunk: #141a22; --fg: #e4e8ef; --muted: #9aa3b2; --line: #2e3744;
    --accent: #6fb3d3; --accent-strong: #8cc4de; --accent-tint: #16303c;
    --ok: #6fcf97; --ok-tint: #163325; --warn: #f0a95a; --warn-tint: #33261a; --bad: #f2948a; --bad-tint: #3a1c1a;
    --shadow: none; --on-accent: #0d1a22; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11151c; --paper: #192029; --sunk: #141a22; --fg: #e4e8ef; --muted: #9aa3b2; --line: #2e3744;
  --accent: #6fb3d3; --accent-strong: #8cc4de; --accent-tint: #16303c;
  --ok: #6fcf97; --ok-tint: #163325; --warn: #f0a95a; --warn-tint: #33261a; --bad: #f2948a; --bad-tint: #3a1c1a;
  --shadow: none; --on-accent: #0d1a22; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14.5px/1.55 var(--font); }
h1, h2, h3, p { margin: 0; }
.hint { color: var(--muted); font-size: 12.5px; font-weight: 400; }
code { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* App bar */
.appbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 24px; background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 12px; align-items: center; }
.mark { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.brand-name { font-size: 16px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.brand-sub { font-size: 12.5px; color: var(--muted); }
.tag { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 2px 7px;
  border-radius: 6px; background: var(--accent-tint); color: var(--accent); }
.status-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px;
  border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-tint); border-color: transparent; }
.pill.warn { color: var(--warn); background: var(--warn-tint); border-color: transparent; }
.appbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
.account { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 3px 4px 3px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--sunk); min-width: 0; }
.account-label { color: var(--muted); font-weight: 600; }
.account-name { font-weight: 600; overflow-wrap: anywhere; }
.account-name.off { color: var(--warn); }
.account .link { padding-right: 8px; }
.btn-small { padding: 3px 10px; font-size: 12.5px; border-radius: 999px; }

/* A notice after the OneDrive sign-in */
.notice { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 8px 8px 14px;
  border-radius: 10px; font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.notice.ok { background: var(--ok-tint); color: var(--ok); }
.notice.bad { background: var(--bad-tint); color: var(--bad); }

/* Layout: the chat is the page; the evidence and the kick-off controls sit in a rail beside it */
.workspace { max-width: 1440px; margin: 0 auto; padding: 16px 24px 24px; display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: 16px; align-items: start; }
.rail { display: grid; gap: 16px; min-width: 0; }
.rail .tracker { grid-template-columns: minmax(0, 1fr); gap: 6px; }
.rail .stage { padding: 8px 10px; gap: 4px; }
.rail .stage.prd::after { display: none; }
.fold > summary { cursor: pointer; }
.fold[open] > summary { margin-bottom: 4px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 16px 18px; display: grid; gap: 12px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.panel-title { font-size: 15px; font-weight: 700; }
.sub-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }

/* Project bar */
.toolbar { grid-template-columns: minmax(220px, 320px) minmax(0, 1fr) auto; align-items: end; }
.field { display: grid; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 600; }
select, input[type="text"], textarea { font: inherit; width: 100%; min-width: 0; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--sunk); color: var(--fg); }
select { font-weight: 600; }
textarea { resize: vertical; min-height: 64px; }
.path { display: grid; gap: 6px; min-width: 0; }
.path-text { font-size: 13.5px; overflow-wrap: anywhere; }
.toolbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); }

/* Buttons */
.btn { font: inherit; font-weight: 600; font-size: 13.5px; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-secondary { background: var(--paper); color: var(--fg); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-ok { background: var(--ok); color: var(--on-accent); }
.btn-warn { background: var(--warn); color: var(--on-accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.link { font: inherit; font-size: 12.5px; border: none; background: none; color: var(--accent); padding: 0; cursor: pointer; text-decoration: underline; }
.icon-btn { font: inherit; font-size: 20px; line-height: 1; width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--paper); color: var(--muted); cursor: pointer; }

/* The tracker: five stage cards; the gate between them */
.tracker { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.stage { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; background: var(--sunk);
  display: grid; gap: 6px; align-content: start; min-width: 0; border-top: 4px solid var(--line); }
.stage-top { display: flex; gap: 8px; align-items: center; }
.stage-num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  color: var(--muted); background: var(--paper); border: 1px solid var(--line); flex: none; }
.stage-name { font-weight: 650; font-size: 13.5px; line-height: 1.3; }
.stage-gate { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.stage-status { justify-self: start; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: var(--paper); color: var(--muted); border: 1px solid var(--line); }
.stage-meta { font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.stage.current { border-color: var(--accent); background: var(--paper); box-shadow: 0 0 0 3px var(--accent-tint); }
.stage.done { border-top-color: var(--ok); }
.stage.done .stage-num { background: var(--ok); color: var(--on-accent); border-color: transparent; }
.stage.done .stage-status { background: var(--ok-tint); color: var(--ok); border-color: transparent; }
.stage.waiting { border-top-color: var(--warn); }
.stage.waiting .stage-status { background: var(--warn-tint); color: var(--warn); border-color: transparent; }
.stage.working { border-top-color: var(--accent); }
.stage.working .stage-status { background: var(--accent-tint); color: var(--accent); border-color: transparent; }
.stage.bad { border-top-color: var(--bad); }
.stage.bad .stage-status { background: var(--bad-tint); color: var(--bad); border-color: transparent; }
.stage.prd::after { content: "PRD"; position: absolute; left: -9px; top: 50%; transform: translate(-50%, -50%);
  font-size: 9.5px; font-weight: 800; color: var(--warn); background: var(--warn-tint); border-radius: 4px; padding: 1px 4px; }
@media (prefers-reduced-motion: no-preference) {
  .stage.working .stage-num { animation: pulse 1.4s ease-in-out infinite; }
}
@keyframes pulse { 50% { box-shadow: 0 0 0 5px var(--accent-tint); } }

/* Now */
.run-head { display: grid; gap: 4px; }
.run-head code { font-family: var(--font); font-weight: 650; font-size: 14px; }
.phase { display: flex; gap: 8px; align-items: center; color: var(--accent); font-weight: 600; font-size: 13.5px; }
.phase.live::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .phase.live::before { animation: blink 1.2s ease-in-out infinite; }
}
@keyframes blink { 50% { opacity: 0.25; } }
.time { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 12px; background: var(--paper); }
.card.gate { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn-tint) 45%, var(--paper)); }
.card.info { background: var(--sunk); }
.card.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: var(--bad-tint); }
.card-title { font-weight: 700; font-size: 15px; }
.card-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.choice { display: flex; gap: 10px; flex-wrap: wrap; }
.choice label { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; background: var(--paper); flex: 1 1 220px; }
.choice label:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }
.choice small { display: block; color: var(--muted); font-size: 12px; }
.form-error { color: var(--bad); font-size: 13px; font-weight: 600; }
.reply { border-top: 1px solid var(--line); padding-top: 12px; }
.steps-box summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.steps { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.steps b { color: var(--fg); font-weight: 600; }

/* Markdown from the workflow */
.md { display: grid; gap: 8px; min-width: 0; }
.md h3, .md h4, .md h5 { margin: 6px 0 0; font-size: 14px; }
.md h3 { font-size: 15px; }
.md h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.md ul, .md ol { margin: 0; padding-left: 20px; display: grid; gap: 3px; }
.md p { overflow-wrap: anywhere; }
.md .table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.md table { border-collapse: collapse; width: 100%; font-size: 13px; }
.md th, .md td { text-align: left; vertical-align: top; padding: 6px 10px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.md th { background: var(--sunk); font-size: 12px; border-top: none; }
.md pre { margin: 0; padding: 10px; background: var(--sunk); border-radius: 8px; overflow-x: auto; font-size: 12px; }

/* Side panels */
.facts { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 6px 10px; margin: 0; font-size: 13px; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.writes, .files { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; }
.writes li { padding: 6px 8px; border-radius: 8px; background: var(--sunk); overflow-wrap: anywhere; }
.files li { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.files code { font-size: 12.5px; }
.dry-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dry-table th, .dry-table td { text-align: left; padding: 5px 6px; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.dry-table th { color: var(--muted); font-size: 11.5px; border-top: none; }
.badge { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--sunk); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.warn { background: var(--warn-tint); color: var(--warn); border-color: transparent; }

/* Dialog */
.dialog { border: none; border-radius: 12px; padding: 18px; width: min(900px, calc(100% - 32px)); max-height: 85vh;
  background: var(--paper); color: var(--fg); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.dialog::backdrop { background: rgba(15, 20, 30, 0.45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.viewer-body pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px; margin: 0; }

/* The chat: the main column, as tall as the window */
.chat-main { position: sticky; top: 12px; height: calc(100dvh - 104px); min-height: 460px; display: flex;
  flex-direction: column; background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); min-width: 0; overflow: hidden; }
.chat-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-project { flex: 1 1 240px; max-width: 380px; }
.chat-head-actions { display: flex; gap: 14px; align-items: center; padding-bottom: 8px; }
.chat-main .notice { margin: 10px 16px 0; }
.chat-project-line { padding: 6px 16px 0; }
.chat-project-line:empty { display: none; }
.chat-log { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.chat-welcome { color: var(--muted); font-size: 13.5px; display: grid; gap: 8px; max-width: 640px; }
.chat-welcome strong { color: var(--fg); }
.chat-welcome ul { margin: 0; padding-left: 18px; display: grid; gap: 2px; }
.msg { max-width: min(82%, 760px); border-radius: 12px; padding: 9px 12px; font-size: 14px; overflow-wrap: anywhere; min-width: 0; }
.who { font-size: 12.5px; font-weight: 600; color: var(--muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.rail-toggle { display: none; }

/* What the agent can see: the required inputs, what it waits for, the files */
.snapshot { display: grid; gap: 10px; font-size: 13px; }
.req { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.req li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 6px; align-items: start; }
.req-mark { font-weight: 800; line-height: 1.4; }
.req li.ok .req-mark { color: var(--ok); }
.req li.missing .req-mark { color: var(--warn); }
.req-why { color: var(--muted); font-size: 12px; }
.snap-list { margin: 0; padding-left: 18px; color: var(--fg); display: grid; gap: 2px; }
.snap-files { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .chat-main { position: static; height: min(78dvh, 760px); }
  .rail-toggle { display: inline; }
  .rail.closed { display: none; }
}
@media (max-width: 760px) {
  .workspace { padding: 12px 16px 16px; }
  .appbar { padding: 12px 16px; }
  .who { display: none; }
  .msg { max-width: 92%; }
}
.msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); white-space: pre-wrap; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--sunk); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.bot.error { background: var(--bad-tint); border-color: transparent; color: var(--bad); }
.msg.typing { color: var(--muted); font-style: italic; }
.msg .md { gap: 6px; }
.msg .md h3 { font-size: 14px; }
.run-card { align-self: stretch; max-width: none; border: 1px solid var(--line); border-left: 4px solid var(--accent);
  background: var(--paper); display: grid; gap: 2px; }
.run-card.wait { border-left-color: var(--warn); }
.run-card.done { border-left-color: var(--ok); }
.run-card.bad { border-left-color: var(--bad); }
.run-card-title { font-weight: 650; font-size: 12.5px; }
.run-card-phase { color: var(--muted); font-size: 12.5px; }
.run-card.live .run-card-phase::before { content: "● "; color: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .run-card.live .run-card-phase::before { animation: blink 1.2s ease-in-out infinite; }
}
.chat-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 16px 0; }
.chip-btn { font: inherit; font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--sunk); color: var(--fg); cursor: pointer; }
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.chat-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px 16px 14px; align-items: end; }
.chat-form textarea { min-height: 44px; }
