:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --text: rgba(10, 10, 10, 0.92);
  --text-muted: rgba(10, 10, 10, 0.55);
  --text-subtle: rgba(10, 10, 10, 0.32);
  --border: rgba(10, 10, 10, 0.07);
  --border-strong: rgba(10, 10, 10, 0.14);
  --accent: #059669;
  --accent-warm: #d97706;
  --accent-cool: #2563eb;

  --s1: #ea580c;
  --s2: #7c3aed;
  --s3: #0d9488;
  --s4: #db2777;

  --font: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  --pad: 28px;
  --radius: 12px;
}

@supports (font-variation-settings: normal) {
  :root { --font: "Inter var", -apple-system, system-ui, sans-serif; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  overflow: hidden;
}

a { color: inherit; }

.label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.grid {
  display: grid;
  height: 100vh;
  width: 100vw;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto auto;
  grid-template-areas:
    "status"
    "artifact"
    "chat"
    "transcript";
}

/* Status bar */
.status {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px var(--pad);
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-subtle);
  transition: background 0.2s, box-shadow 0.2s;
}
.status .dot.idle    { background: var(--text-subtle); }
.status .dot.live    { background: var(--accent); box-shadow: 0 0 0 4px rgba(5,150,105,0.14); }
.status .dot.running { background: var(--accent-warm); animation: pulse 1.4s ease-in-out infinite; }
.status .dot.done    { background: var(--accent-cool); }
.status .state {
  font-weight: 500;
  color: var(--text);
}
.status .sep { color: var(--text-subtle); }
.status .detail {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 13px;
}
.status .spacer { flex: 1; }
.status .session {
  color: var(--text-subtle);
  font-family: var(--mono);
  font-size: 13px;
  margin-right: 16px;
}

.mic-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.mic-toggle:hover { background: var(--surface-2); }
.mic-toggle .mic-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-subtle);
}
.mic-toggle.on {
  color: var(--text);
  border-color: var(--accent);
}
.mic-toggle.on .mic-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(5,150,105,0.14);
  animation: pulse 1.4s ease-in-out infinite;
}
.mic-toggle.connecting .mic-dot { background: var(--accent-warm); animation: pulse 1.4s ease-in-out infinite; }
.mic-toggle.error { border-color: #b91c1c; color: #b91c1c; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Artifact pane */
.artifact {
  grid-area: artifact;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: var(--pad);
  gap: 20px;
  overflow: hidden;
  min-height: 0;
}
.artifact .primary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  min-height: 0;
}
.primary .type {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 14px;
}
.primary .name {
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.022em;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 18px;
}
.primary .url {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 13px;
  text-decoration: none;
  word-break: break-all;
}
.primary .url:hover { color: var(--text); }
.primary .body {
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.55;
  max-height: 100%;
  overflow: hidden;
}
.mermaid-container {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.mermaid-container svg {
  max-width: 100%;
  max-height: 100%;
  height: auto;
  width: auto;
}
.mermaid-error {
  color: #b91c1c;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
}
.placeholder {
  color: var(--text-subtle);
  font-size: 16px;
  text-align: center;
}

.strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 2px;
}
.strip::-webkit-scrollbar { height: 6px; }
.strip::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.card {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  min-width: 140px;
  max-width: 240px;
}
.card .type {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 4px;
}
.card .name {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Collapsible panels (chat + transcript) */
.panel {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  overflow: hidden;
  min-height: 0;
  background: var(--bg);
}
.panel.chat { grid-area: chat; }
.panel.transcript { grid-area: transcript; }
.panel.expanded { height: 32vh; }

.panel-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px var(--pad);
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: background 0.15s;
}
.panel-toggle:hover { background: var(--surface-2); }
.panel-toggle .chev {
  font-size: 14px;
  color: var(--text-subtle);
  width: 12px;
  text-align: center;
  transition: transform 0.18s ease;
  user-select: none;
}
.panel.expanded .panel-toggle .chev { transform: rotate(90deg); }
.panel-toggle .panel-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-subtle);
  flex-shrink: 0;
}
.panel-toggle .panel-preview {
  flex: 1;
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid var(--border);
}
.panel.collapsed .panel-body { display: none; }

/* Chat content inside panel body */
.chat .log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: var(--pad);
  scrollbar-width: thin;
}
.chat .log::-webkit-scrollbar { width: 6px; }
.chat .log::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.msg { display: flex; flex-direction: column; gap: 4px; }
.msg .meta {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-subtle);
  font-family: var(--mono);
}
.msg .body {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}
.msg.tool .body {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
}
.msg.tool .meta { color: var(--accent-warm); }
.msg.intercept .meta { color: var(--accent); }
.msg.intercept .body {
  color: var(--accent);
  border-left: 2px solid var(--accent);
  padding-left: 12px;
}

.chat .input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px var(--pad);
  border-top: 1px solid var(--border);
}
.chat .input .prompt {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}
.chat .input input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  caret-color: var(--accent);
}
.chat .input input::placeholder { color: var(--text-subtle); }

/* Transcript content inside panel body */
.transcript .lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 22px var(--pad);
  scrollbar-width: none;
}
.transcript .lines::-webkit-scrollbar { display: none; }

.t-line {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 20px;
  align-items: baseline;
  font-size: 22px;
  letter-spacing: -0.012em;
  line-height: 1.4;
  opacity: 0;
  animation: fadein 0.4s ease forwards;
}
.t-line .speaker {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  text-align: right;
  padding-top: 6px;
}
.t-line .text { color: var(--text); }
.t-line.partial .text { color: var(--text-muted); font-style: italic; }
.t-line.s0 .speaker { color: var(--s1); }
.t-line.s1 .speaker { color: var(--s2); }
.t-line.s2 .speaker { color: var(--s3); }
.t-line.s3 .speaker { color: var(--s4); }

@keyframes fadein {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
