/* ---------- design tokens ---------- */
:root {
  --bg:           #FAFAF7;
  --bg-elev:      #FFFFFF;
  --bg-renderer:  #F4F5F2;
  --bg-renderer-2:#FAFAF7;
  --ink:          #0B1220;
  --ink-2:        #1F2A3D;
  --muted:        #6B7488;
  --muted-2:      #98A0B0;
  --line:         #E6E5DF;
  --line-2:       #EFEEE8;
  --line-strong:  #D4D2C8;
  --brand:        #2A6FDB;
  --brand-deep:   #1F4FB0;
  --brand-soft:   #EAF1FB;
  --brand-faint:  #F4F8FD;
  --gold:         #B68A2E;
  --gold-soft:    #F7F0DC;
  --success:      #1F8A5B;
  --success-soft: #E2F2EA;
  --slate-bubble: #F1F0EA;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px;
  --font-ui: "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-display: "Source Serif 4", "Inter", serif;
  --shadow-card: 0 1px 0 rgba(11,18,32,0.04), 0 4px 14px rgba(11,18,32,0.04);
  --shadow-elev: 0 1px 0 rgba(11,18,32,0.06), 0 8px 24px rgba(11,18,32,0.07);
  --shadow-soft: 0 1px 2px rgba(11,18,32,0.04);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
input, button { font: inherit; color: inherit; }
button { border: none; background: transparent; padding: 0; }

/* ---------- app shell ----------
   .app fills whatever its parent gives it. On the demo page the
   parent is body (100vh). When this gets embedded as a panel on the
   front page, the parent panel controls the height. */
.app {
  display: grid;
  grid-template-columns: 38fr 62fr;
  height: 100%;
  width: 100%;
  background: var(--bg);
  min-height: 0;
}
.app__pane--chat {
  border-right: 1px solid var(--line);
  background: var(--bg-elev);
  min-width: 0;
  min-height: 0;                       /* lets the flex child overflow correctly */
}
.app__pane--renderer {
  background: var(--bg-renderer);
  min-width: 0;
  min-height: 0;
}

/* Audit trail sidebar is hidden until SOR Phase 0 ships — keep the renderer
   main column visible. To bring the audit sidebar back, remove these rules.
   !important needed because a later .audit-trail rule sets display: flex. */
.audit-trail { display: none !important; }
.renderer-panel__body { grid-template-columns: 1fr !important; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 220px 1fr; }
  .app__pane--chat { order: 2; border-right: none; border-top: 1px solid var(--line); }
  .app__pane--renderer { order: 1; overflow: hidden; }
}

/* ---------- chat panel ---------- */
.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--bg-elev);
  width: 100%;
}
.chat-panel__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.chat-panel__identity { display: flex; align-items: center; gap: 12px; }
.chat-panel__id-text { line-height: 1.2; }
.chat-panel__name {
  font-size: 15px; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.chat-panel__tagline { font-size: 12px; color: var(--muted); margin-top: 2px; letter-spacing: 0.01em; }
.chat-panel__replay {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.chat-panel__replay:hover { background: var(--line-2); color: var(--ink); }

.godo-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); display: inline-block; position: relative; }
.godo-status-dot::after {
  content: ""; position: absolute; inset: -3px;
  border-radius: 50%; border: 1.5px solid var(--success);
  opacity: 0; animation: pulse 2s ease-out infinite;
}
@keyframes pulse { 0% { opacity: 0.6; transform: scale(0.6); } 100% { opacity: 0; transform: scale(1.6); } }

.godo-avatar { flex-shrink: 0; border-radius: 9px; overflow: hidden; display: grid; place-items: center; }

/* messages */
.chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  min-height: 0;                       /* without this, flex item refuses to shrink and pushes the input below the fold */
  padding: 22px 22px 16px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
}
.msg { display: flex; gap: 9px; max-width: 100%; animation: msgIn 0.32s cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.msg--user { justify-content: flex-end; }
.msg--godo { justify-content: flex-start; }
.msg__bubble {
  padding: 10px 14px; border-radius: 14px;
  max-width: 85%; font-size: 14px; line-height: 1.5;
  word-wrap: break-word; white-space: pre-wrap;
}
.msg__bubble--user { background: var(--brand); color: white; border-bottom-right-radius: 4px; }
.msg__bubble--godo { background: var(--slate-bubble); color: var(--ink); border-bottom-left-radius: 4px; }

.msg--typing .msg__bubble { padding: 12px 14px; display: inline-flex; gap: 4px; }
.typing-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: typingBounce 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* booking card */
.booking-card {
  margin-top: 6px;
  background: linear-gradient(180deg, var(--brand-faint), var(--bg-elev));
  border: 1px solid var(--brand-soft);
  border-radius: 14px;
  padding: 16px;
  animation: cardSlide 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
  box-shadow: var(--shadow-soft);
}
@keyframes cardSlide { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.booking-card--confirmed { background: linear-gradient(180deg, var(--success-soft), var(--bg-elev)); border-color: var(--success); }
.booking-card__header { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.booking-card__icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.booking-card--confirmed .booking-card__icon { background: var(--success); }
.booking-card__title { font-weight: 600; color: var(--ink); font-size: 14px; }
.booking-card__subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
.booking-card__row { margin-bottom: 12px; }
.booking-card__label {
  display: block; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 5px; font-weight: 500;
}
.booking-card__input {
  width: 100%; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; font-size: 13px;
  outline: none; transition: border-color 0.15s;
}
.booking-card__input:focus { border-color: var(--brand); }
.booking-card__actions { display: flex; gap: 8px; }
.btn { padding: 9px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; transition: all 0.15s; }
.btn--primary { background: var(--brand); color: white; flex: 1; }
.btn--primary:hover:not(:disabled) { background: var(--brand-deep); }
.btn--primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--ghost:hover { color: var(--ink); }
.booking-card__confirmation { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.confirmation-row { display: grid; grid-template-columns: 70px 1fr; align-items: baseline; gap: 10px; font-size: 13px; }
.confirmation-key { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 500; }
.confirmation-val { color: var(--ink); }

/* footer */
.chat-panel__footer { border-top: 1px solid var(--line); padding: 12px 22px 16px; background: var(--bg-elev); }
.chat-panel__input-row {
  display: flex; gap: 8px; align-items: center;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 4px 4px 4px 14px;
  transition: border-color 0.15s;
}
.chat-panel__input-row:focus-within { border-color: var(--brand); }
.chat-panel__input { flex: 1; background: transparent; border: none; outline: none; padding: 8px 0; font-size: 14px; }
.chat-panel__input::placeholder { color: var(--muted-2); }
.chat-panel__send {
  width: 30px; height: 30px;
  background: var(--brand); color: white;
  border-radius: 7px;
  display: grid; place-items: center;
  transition: background 0.15s;
}
.chat-panel__send:hover:not(:disabled) { background: var(--brand-deep); }
.chat-panel__send:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-panel__audit-footnote {
  display: flex; align-items: center; gap: 5px;
  margin-top: 10px; font-size: 11px; color: var(--muted); letter-spacing: 0.01em;
}
.chat-panel__error {
  margin-top: 8px;
  font-size: 12px; color: #b91c1c;
  background: #fef2f2; border: 1px solid #fecaca;
  padding: 8px 10px; border-radius: 8px;
  display: none;
}
.chat-panel__error.visible { display: block; }

/* ---------- renderer panel ---------- */
.renderer-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--bg-renderer); position: relative; }
.renderer-panel__header { border-bottom: 1px solid var(--line); background: var(--bg-renderer-2); padding: 16px 28px 0; flex-shrink: 0; }
.renderer-panel__title-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.godo-mark { flex-shrink: 0; }
.renderer-panel__title { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; line-height: 1.2; }
.renderer-panel__subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.renderer-panel__status { margin-left: auto; }

.status-stamp {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.status-stamp--building { background: var(--brand-faint); color: var(--brand-deep); border: 1px solid var(--brand-soft); }
.status-stamp__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); animation: blink 1.4s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.status-stamp--saved {
  background: var(--success-soft); color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 25%, transparent);
}

.renderer-panel__progress { height: 2px; background: var(--line-2); border-radius: 2px; overflow: hidden; margin-bottom: -1px; }
.renderer-panel__progress-bar { height: 100%; background: var(--brand); transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); width: 0%; }

.renderer-panel__body { flex: 1; display: grid; grid-template-columns: 1fr 280px; min-height: 0; }
.renderer-panel__main { overflow-y: auto; min-height: 0; padding: 24px 28px 40px; display: flex; flex-direction: column; gap: 14px; }

/* empty state */
.empty-hint { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 20px; color: var(--muted); gap: 24px; }
.empty-hint__skeleton { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; opacity: 0.5; }
.skel-section { background: var(--bg-elev); border: 1px dashed var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.skel-line { height: 8px; border-radius: 4px; background: var(--line-2); width: 100%; }
.skel-line--short { width: 55%; }
.empty-hint__text { font-size: 13px; max-width: 320px; }

/* sections */
.wf-section { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; transition: border-color 0.4s, box-shadow 0.4s; }
.wf-section--empty { background: var(--bg-renderer-2); border-style: dashed; opacity: 0.65; }
.wf-section--fresh { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); animation: sectionPop 1.6s ease-out; }
@keyframes sectionPop { 0% { box-shadow: 0 0 0 0 var(--brand-soft); } 20% { box-shadow: 0 0 0 5px var(--brand-soft); } 100% { box-shadow: 0 0 0 3px var(--brand-soft); } }
.wf-section__header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); background: var(--bg-renderer-2); }
.wf-section--empty .wf-section__header { border-bottom: none; }
.wf-section__icon { color: var(--muted); display: grid; place-items: center; }
.wf-section__title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.wf-section__count { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--bg); padding: 2px 8px; border-radius: 8px; border: 1px solid var(--line); }
.wf-section__pending { margin-left: auto; font-size: 10px; color: var(--muted-2); font-style: italic; letter-spacing: 0.02em; }
.wf-section__body { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.wf-section__placeholder { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.placeholder-line { height: 6px; border-radius: 3px; background: var(--line-2); width: 100%; }
.placeholder-line--short { width: 50%; }

.field-cell { display: grid; grid-template-columns: 140px 1fr; gap: 16px; align-items: baseline; padding: 6px 0; position: relative; transition: background 0.4s; }
.field-cell--fresh { animation: cellGlow 1.6s ease-out; }
@keyframes cellGlow { 0% { background: var(--brand-soft); } 100% { background: transparent; } }
.field-cell__label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 500; }
.field-cell__value { font-size: 13px; color: var(--ink); line-height: 1.45; }

.chip-row { display: flex; align-items: baseline; gap: 10px; padding: 7px 10px; background: var(--bg-renderer-2); border: 1px solid var(--line-2); border-radius: 7px; font-size: 13px; color: var(--ink-2); transition: all 0.4s; }
.chip-row--fresh { animation: cellGlow 1.6s ease-out; border-color: var(--brand-soft); }
.chip-row__num { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.chip-row__text { flex: 1; }

/* steps */
.step-row { display: flex; gap: 12px; padding: 6px 0; position: relative; transition: background 0.4s; }
.step-row--fresh { animation: cellGlow 1.6s ease-out; }
.step-row__connector { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; width: 22px; }
.step-row__bullet { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: white; font-size: 11px; font-weight: 600; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.step-row:not(:last-child) .step-row__connector::after { content: ""; width: 1px; flex: 1; background: var(--line); margin-top: 2px; min-height: 14px; }
.step-row__body { flex: 1; padding: 1px 0 14px; }
.step-row:last-child .step-row__body { padding-bottom: 0; }
.step-row__title { font-size: 13px; color: var(--ink); font-weight: 500; margin-bottom: 4px; }
.step-row__meta { display: flex; gap: 6px; flex-wrap: wrap; }
.step-row__chip { font-size: 10.5px; padding: 2px 7px; border-radius: 5px; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.step-row__chip--actor { background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); }
.step-row__chip--sla { background: var(--gold-soft); color: var(--gold); font-family: var(--font-mono); }

/* audit trail */
.audit-trail { border-left: 1px solid var(--line); background: var(--bg-renderer-2); display: flex; flex-direction: column; min-height: 0; }
.audit-trail__header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 9px; background: linear-gradient(180deg, var(--bg-elev), var(--bg-renderer-2)); }
.audit-trail__lock { width: 26px; height: 26px; border-radius: 7px; background: var(--gold-soft); color: var(--gold); display: grid; place-items: center; }
.audit-trail__title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink); }
.audit-trail__chain { margin-left: auto; }
.chain-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; background: var(--success-soft); color: var(--success); border-radius: 999px; font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.chain-pill__dot { width: 5px; height: 5px; border-radius: 50%; background: var(--success); }

.audit-trail__body { flex: 1; overflow-y: auto; padding: 12px 16px 20px; scroll-behavior: smooth; }
.audit-entry { display: flex; gap: 10px; padding: 6px 0; animation: auditIn 0.4s cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes auditIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: translateX(0); } }
.audit-entry__rail { flex-shrink: 0; width: 9px; position: relative; display: flex; flex-direction: column; align-items: center; padding-top: 5px; }
.audit-entry__node { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); border: 2px solid var(--bg-renderer-2); box-shadow: 0 0 0 1px var(--brand); flex-shrink: 0; }
.audit-entry[data-actor="prospect"] .audit-entry__node { background: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.audit-entry[data-actor="system"] .audit-entry__node { background: var(--success); box-shadow: 0 0 0 1px var(--success); }
.audit-entry:not(:last-child) .audit-entry__rail::after { content: ""; position: absolute; top: 14px; bottom: -6px; left: 50%; width: 1px; background: var(--line); transform: translateX(-0.5px); }
.audit-entry__body { flex: 1; display: flex; flex-direction: column; gap: 2px; padding-bottom: 4px; min-width: 0; }
.audit-entry__row1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.audit-entry__time { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.audit-entry__action { font-family: var(--font-mono); font-size: 11px; color: var(--ink); font-weight: 500; }
.audit-entry__row2 { font-size: 11.5px; color: var(--ink-2); display: flex; gap: 5px; align-items: baseline; flex-wrap: wrap; }
.audit-entry__actor { color: var(--brand-deep); font-family: var(--font-mono); font-size: 11px; }
.audit-entry[data-actor="prospect"] .audit-entry__actor { color: var(--gold); }
.audit-entry[data-actor="system"] .audit-entry__actor { color: var(--success); }
.audit-entry__sep { color: var(--muted-2); }
.audit-entry__detail { color: var(--ink-2); font-size: 11.5px; flex: 1; min-width: 0; }
.audit-entry__row3 { display: flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 10px; color: var(--muted); margin-top: 1px; }
.audit-entry__hash { letter-spacing: -0.01em; }

.audit-trail__footer { border-top: 1px solid var(--line); padding: 10px 16px; background: var(--bg-elev); display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.audit-trail__footer-row { display: flex; justify-content: space-between; font-size: 10.5px; }
.audit-trail__footer-key { color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.audit-trail__footer-val { color: var(--ink-2); font-family: var(--font-mono); }

/* scrollbar polish */
.chat-panel__messages::-webkit-scrollbar, .renderer-panel__main::-webkit-scrollbar, .audit-trail__body::-webkit-scrollbar { width: 8px; }
.chat-panel__messages::-webkit-scrollbar-thumb, .renderer-panel__main::-webkit-scrollbar-thumb, .audit-trail__body::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
.chat-panel__messages::-webkit-scrollbar-track, .renderer-panel__main::-webkit-scrollbar-track, .audit-trail__body::-webkit-scrollbar-track { background: transparent; }

/* mobile */
@media (max-width: 900px) {
  .renderer-panel__body { grid-template-columns: 1fr; }
  .audit-trail { display: none; }
  .renderer-panel__main { padding: 12px 16px; }
  .wf-section__body { padding: 8px 12px; }
}
