:root {
  color-scheme: light;
  --canvas: #f6f7f5;
  --paper: #fff;
  --ink: #202a24;
  --muted: #56635c;
  --line: #e1e5e0;
  --accent: #294c40;
  --tint: #eaf1eb;
  --danger: #8a3627;
  --width: 760px;
  --header-height: 54px;
  --mono: "SF Mono", ui-monospace, Consolas, monospace;
  font: 14px/1.5 system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.control, .text-button {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  font-weight: 600;
  font-size: 12px;
}
.control {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  text-decoration: none;
}
.text-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.control:hover, .session:hover, .file:hover { background: var(--tint); }
.loading { margin: 36px auto; color: var(--muted); }

.app {
  --nav-width: 198px;
  --detail-width: 284px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}
.app.sidebar-open { grid-template-columns: var(--nav-width) minmax(0, 1fr); }
.app.details-open { grid-template-columns: minmax(0, 1fr) var(--detail-width); }
.app.sidebar-open.details-open { grid-template-columns: var(--nav-width) minmax(0, 1fr) var(--detail-width); }
.sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  padding: 0 10px 8px;
  border-right: 1px solid var(--line);
  background: #f0f2ee;
}
.sidebar-header, .account, .task-heading, .participants, .profile-card {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-header {
  min-height: var(--header-height);
  padding-inline: 4px 0;
  font-size: 15px;
  font-weight: 750;
  letter-spacing: -.02em;
}
.tray-close { margin-left: auto; color: var(--muted); }
.brand-mark {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
}
.new-chat, .sidebar-item, .icon-control {
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
}
.new-chat, .sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  min-height: 33px;
  min-width: 0;
  text-align: left;
}
.new-chat { border-color: var(--line); background: var(--paper); font-weight: 650; }
.new-chat span { font-size: 18px; line-height: 1; }
.sidebar-item {
  width: 100%;
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.chat-item { display: block; }
.sidebar-item > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.sidebar-item[aria-current] {
  background: #dfe9df;
  color: var(--accent);
  font-weight: 650;
}
.sidebar-item:hover, .icon-control:hover { background: #e4ebe3; }
.new-chat:hover { background: var(--tint); }
.sidebar-content { min-height: 0; flex: 1; overflow: auto; padding: 3px; }
.sidebar h2 { margin: 0 0 4px; padding-inline: 6px; color: var(--muted); font-size: 11px; }
.sidebar nav + h2 { margin-top: 18px; }
.account { flex: none; padding-top: 8px; border-top: 1px solid var(--line); }
.icon-control { min-width: 34px; min-height: 34px; padding: 0 5px; font-size: 17px; }
.avatar {
  display: grid;
  flex: none;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: #dfebdf;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
}
.participant {
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}
.participant:hover .avatar { background: #cfe1d0; }
.participants { gap: 4px; margin-right: 4px; }
.workspace {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}
.task-header {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 12px;
  min-height: var(--header-height);
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
}
.task-heading { min-width: 0; }
.task-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 5px;
}
#show-details[aria-expanded="true"] {
  background: var(--tint);
  border-color: transparent;
  color: var(--accent);
}
.recording {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
}
h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}
.verification {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--tint);
  color: var(--accent);
  font-size: 11px;
}
.verification.failed { background: #faeee3; color: #80491b; }

.chat {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-header {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 3px 12px;
  border-bottom: 1px solid var(--line);
}
#sessions {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-width: 0;
  max-height: 96px;
  padding: 3px;
  overflow: auto;
}
.session {
  min-height: 32px;
  padding: 3px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  overflow-wrap: anywhere;
}
.session[aria-current="true"] {
  background: var(--tint);
  color: var(--accent);
  font-weight: 700;
}
.chat-context {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}
.chat-context #back { flex: none; }
#chat-model {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px max(20px, calc((100% - var(--width)) / 2)) 20px;
  scrollbar-gutter: stable;
}
.hide-timestamps .thread time { display: none; }
.thread:focus-visible, pre:focus-visible { outline-offset: -3px; }
.turn { scroll-margin-top: 12px; }
.turn-label, .finish {
  margin: 10px 0;
  color: var(--muted);
  font-size: 11px;
}
.turn-label { display: flex; align-items: center; gap: 10px; }
.turn-label::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.message {
  max-width: 68ch;
  margin: 14px 0 18px;
}
.message.user {
  width: fit-content;
  max-width: min(85%, 64ch);
}
.user .bubble {
  padding: 9px 13px;
  border-radius: 4px 13px 13px;
  background: #eff2f5;
}
.initiating-speaker { margin-left: auto; }
.initiating-speaker .bubble {
  border-radius: 13px 4px 13px 13px;
  background: #eaf1e8;
}
.message-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}
.initiating-speaker .message-meta { justify-content: end; }
.message-meta strong, .review-link { color: var(--ink); font-weight: 700; }
.message-body, .long-text {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message-body code, .long-text code {
  padding: 1px 3px;
  border-radius: 3px;
  background: #202a240c;
  font-family: var(--mono);
  font-size: .88em;
}
.message.review {
  padding: 4px 0 3px 12px;
  border-left: 2px solid #8eaa99;
}
.review-link {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.review .evidence { margin-top: 2px; }
.text-limit { margin-top: 3px; }
.text-limit summary { color: var(--accent); font-size: 11px; padding: 3px 0; }
.text-limit .long-text { max-height: 310px; overflow: auto; margin-top: 4px; }

.notice, .child-link {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 11px;
}
.notice time, .child-link time { margin-left: auto; white-space: nowrap; }
.child-link .jump, .notice button, .evidence {
  min-height: 24px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 11px;
  overflow-wrap: anywhere;
}
.child-link .jump { font-weight: 670; }
.activity {
  margin: 8px 0;
  border-block: 1px solid var(--line);
}
.activity summary, .tool summary {
  padding: 7px 5px;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.activity > summary { color: var(--muted); }
.activity > summary::marker { color: var(--accent); }
.activity > summary time { margin-left: 8px; font-size: 10px; white-space: nowrap; }
.activity > summary:hover { color: var(--accent); }
.activity-body { padding: 0 5px 4px 12px; }
.tool + .tool { border-top: 1px solid var(--line); }
.tool-content { padding: 2px 8px 9px; }
.tool-state { margin-left: 8px; color: var(--muted); font-size: 10px; font-weight: 450; }
.tool-state.error { color: var(--danger); }
.tool pre {
  max-height: 190px;
  overflow: auto;
  margin: 3px 0 8px;
  padding: 7px 8px;
  background: var(--canvas);
}
pre {
  font: 12px/1.55 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.part-label, .evidence { font-size: 11px; }
.part-label { font-weight: 650; color: var(--muted); }
.evidence { margin-right: 9px; }
mark { background: #fce6a6; color: #382d11; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 5px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.search > span:first-child { font-size: 20px; line-height: 1; }
.search input {
  flex: 1;
  min-width: 0;
  min-height: 29px;
  padding: 4px;
  border: 0;
  background: transparent;
  font-size: 12px;
  outline-offset: 0;
}
#matches { font-size: 11px; white-space: nowrap; }
.empty { color: var(--muted); font-size: 13px; }
.composer {
  flex: none;
  padding: 8px max(14px, calc((100% - var(--width)) / 2)) 14px;
  background: var(--paper);
}
.live-actions {
  flex: none;
  max-height: 24dvh;
  overflow: auto;
  padding: 0 max(14px, calc((100% - var(--width)) / 2));
  font-size: 12px;
}
.live-action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--canvas);
}
.action-buttons { display: flex; gap: 5px; margin-left: auto; }
.live-action + .live-action { margin-top: 4px; }
.compose-box {
  border: 1px solid #ccd8ce;
  border-radius: 12px;
  background: var(--paper);
}
.compose-box:focus-within { border-color: var(--accent); }
.compose-box textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  max-height: min(30vh, 180px);
  padding: 9px 12px 0;
  resize: vertical;
  border: 0;
  border-radius: 12px;
  outline: none;
  background: transparent;
}
.compose-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 7px 7px 12px;
  color: var(--muted);
  font-size: 11px;
}
#delivery {
  max-width: 45%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  font-size: 12px;
}
#compose-status { flex: 1; }
#send-message {
  flex: none;
  min-height: 33px;
  padding: 4px 10px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-weight: 670;
  font-size: 12px;
}
#send-message:disabled { background: var(--tint); color: var(--muted); cursor: default; }
.profile-card, .preferences { padding: 12px 16px; }
.profile-role { color: var(--muted); font-size: 12px; }
.preferences { display: grid; justify-items: start; gap: 8px; }
.preferences label { display: flex; align-items: center; gap: 6px; }
.preferences :is(input:not([type="checkbox"]), select, textarea) {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
}
.preferences p[role="alert"] { margin: 0; color: var(--danger); }
.preferences p[role="alert"]:empty { display: none; }
#add-agent { margin-top: 7px; }

dialog {
  width: min(570px, calc(100% - 24px));
  max-height: 85dvh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
}
dialog::backdrop { background: #202a2460; }
.dialog-header {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.dialog-header h2 { margin: 0; font-size: 16px; }
.dialog-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}
.dialog-header p:empty { display: none; }
dialog pre {
  max-height: 65dvh;
  overflow: auto;
  margin: 0;
  padding: 14px 16px;
  background: var(--canvas);
}
.details {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--canvas);
}
.details-header {
  display: flex;
  flex: none;
  align-items: center;
  min-height: var(--header-height);
  padding: 0 10px 0 15px;
  border-bottom: 1px solid var(--line);
}
.details-header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 680;
}
.details-body {
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 15px 15px;
}
.details-body section {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.details-body h3 { margin: 0 0 6px; font-size: 12px; }
.details-body .message-body, .details-body .long-text { font-size: 13px; }
.details-body #archive, #export-session { margin-top: 13px; }
.results-heading { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.check-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.check-tabs button {
  min-height: 32px;
  padding: 3px 6px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-size: 11px;
}
.check-tabs button[aria-pressed="true"] {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}
.metric-table { width: 100%; border-collapse: collapse; font-size: 11px; line-height: 1.35; }
.metric-table th, .metric-table td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.metric-table th:first-child { text-align: left; }
.metric-table thead th { color: var(--muted); font-weight: 620; }
.metric-table tbody th { font-weight: 530; }
.metric-table td.different { color: var(--danger); font-weight: 700; }
#files { display: flex; flex-wrap: wrap; gap: 6px; }
.file {
  min-height: 30px;
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  font: 11px var(--mono);
  overflow-wrap: anywhere;
}

.tray-scrim {
  position: absolute;
  z-index: 1;
  inset: 0;
  background: #1e2b2540;
}

@media (max-width: 960px) {
  .app.details-open { grid-template-columns: minmax(0, 1fr); }
  .app.sidebar-open.details-open { grid-template-columns: var(--nav-width) minmax(0, 1fr); }
  .details {
    position: absolute;
    z-index: 2;
    inset: 0 0 0 auto;
    width: min(320px, calc(100% - 32px));
  }
}

@media (max-width: 680px) {
  .app.sidebar-open, .app.sidebar-open.details-open { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: absolute;
    z-index: 2;
    inset: 0 auto 0 0;
    width: min(260px, calc(100% - 32px));
  }
  .task-header { padding-inline: 8px; }
  .task-actions { flex-wrap: wrap; justify-content: end; }
  .chat-header { flex-wrap: wrap; gap: 0 8px; padding: 3px 6px; }
  .chat-context { padding: 0 4px; }
  .message.user { max-width: 94%; }
}

@media (max-height: 440px) {
  .compose-box textarea { min-height: 32px; }
  .composer { padding-block: 4px; }
}
