/* AgentForge 2.0 — 3-Pane Workspace, Editorial Warm-Cream Theme & Timeline Pills */

.ws-shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) minmax(380px, 42%);
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
  background: var(--canvas);
}

.ws-mobile-nav {
  display: none;
}

/* ---------- Sidebar ---------- */
.ws-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--canvas);
  border-right: 1px solid var(--hairline);
}
.ws-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
}
.ws-side-head h2 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.88px;
  text-transform: uppercase;
  color: var(--muted);
}
.ws-side-actions { display: flex; gap: 6px; align-items: center; }

.ws-search-wrap { padding: 0 12px 10px; }
.ws-search-wrap input {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--ink);
}
.ws-search-wrap input::placeholder { color: var(--muted-soft); }
.ws-search-wrap input:focus {
  outline: none;
  border-color: var(--ink);
}

.ws-new-form {
  margin: 0 12px 10px;
  padding: 10px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ws-new-form input,
.ws-new-form select {
  width: 100%;
  padding: 7px 9px;
  background: var(--canvas-soft);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  font-size: 12.5px;
  color: var(--ink);
}
.ws-new-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ws-new-actions { display: flex; gap: 6px; justify-content: flex-end; }

.ws-thread-list {
  list-style: none;
  margin: 0;
  padding: 0 8px 14px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ws-thread-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.ws-thread-item:hover { background: var(--canvas-soft); border-color: var(--hairline-soft); }
.ws-thread-item.is-selected {
  background: var(--surface-card);
  border-color: var(--hairline-strong);
}
.ws-thread-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.ws-thread-title-row { display: flex; align-items: center; gap: 7px; min-width: 0; }
.ws-thread-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ws-thread-meta {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ws-thread-del {
  opacity: 0;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: var(--r-sm);
  font-size: 13px;
}
.ws-thread-item:hover .ws-thread-del,
.ws-thread-item.is-selected .ws-thread-del { opacity: 1; }
.ws-thread-del:hover { color: var(--semantic-error); background: var(--error-bg); }

.sb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sb-dot.running { background: var(--semantic-success); }
.sb-dot.suspended { background: var(--timeline-done); }
.sb-dot.cold { background: var(--muted-soft); }

.ws-empty-side { padding: 18px 14px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- Center Chat Pane ---------- */
.ws-chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--canvas);
}
.ws-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--hairline);
  background: var(--canvas);
}
.ws-chat-title-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ws-chat-title-wrap h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ws-agent-meta {
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-strong);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.ws-chat-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.ws-sb-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--hairline);
  background: var(--surface-card);
  font-size: 12px;
  color: var(--body);
}

.ws-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ws-chat-empty {
  margin: auto;
  max-width: 540px;
  text-align: center;
  padding: 32px 20px;
}
.ws-chat-empty h3 {
  font-size: 26px;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.325px;
  color: var(--ink);
  margin-bottom: 8px;
}
.ws-chat-empty p { color: var(--body); font-size: 15px; margin-bottom: 20px; }
.ws-starters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ws-starter-chip {
  padding: 8px 14px;
  background: var(--surface-card);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
.ws-starter-chip:hover { border-color: var(--ink); background: var(--canvas-soft); }

.ws-msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--hairline);
}
.ws-msg.is-user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--surface-strong);
  border-color: var(--hairline-strong);
  color: var(--ink);
}
.ws-msg.is-assistant {
  background: var(--surface-card);
  border-color: var(--hairline);
  color: var(--body);
}
.ws-msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted);
}
.ws-msg-role {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.88px;
  color: var(--ink);
}
.ws-msg-body { font-size: 14px; line-height: 1.55; color: var(--body); overflow-wrap: anywhere; }
.ws-msg.is-user .ws-msg-body { color: var(--ink); }
.ws-msg-body h1 { margin: 12px 0 6px; font-size: 20px; font-weight: 400; letter-spacing: -0.11px; color: var(--ink); }
.ws-msg-body h2 { margin: 11px 0 6px; font-size: 17px; font-weight: 500; color: var(--ink); }
.ws-msg-body h3, .ws-msg-body h4, .ws-msg-body h5, .ws-msg-body h6 { margin: 10px 0 5px; font-size: 15px; font-weight: 600; color: var(--ink); }
.ws-msg-body p { margin: 0 0 8px; }
.ws-msg-body p:last-child { margin-bottom: 0; }
.ws-msg-body ul, .ws-msg-body ol { margin: 4px 0 8px 20px; padding: 0; }
.ws-msg-body li + li { margin-top: 3px; }
.ws-msg-body .md-task-item { list-style: none; margin-left: -16px; display: flex; align-items: baseline; gap: 7px; }
.ws-msg-body blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--hairline-strong);
  background: var(--canvas);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  color: var(--body);
}
.ws-msg-body hr {
  border: 0;
  border-top: 1px solid var(--hairline);
  margin: 12px 0;
}
.ws-msg-body a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.ws-msg-body del { color: var(--muted); }
.ws-msg-body .md-table-wrap {
  overflow-x: auto;
  margin: 10px 0;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface-card);
}
.ws-msg-body .md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ws-msg-body .md-table th,
.ws-msg-body .md-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--hairline-soft);
  text-align: left;
  vertical-align: top;
}
.ws-msg-body .md-table th {
  background: var(--canvas);
  font-weight: 600;
  color: var(--ink);
}
.ws-msg-body .md-table tr:last-child td { border-bottom: 0; }
.ws-msg-body .md-code {
  margin: 8px 0;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--canvas-soft);
}
.ws-msg-body .md-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline-soft);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}
.ws-msg-body .md-code-copy {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xs);
  padding: 2px 8px;
  font-size: 11px;
  color: var(--ink);
  cursor: pointer;
}
.ws-msg-body .md-code-copy:hover { border-color: var(--ink); }
.ws-msg-body .md-code pre {
  margin: 0;
  border: 0;
  border-radius: 0;
}
.ws-msg-body pre {
  margin: 8px 0;
  padding: 12px 14px;
  background: var(--canvas-soft);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
}
.ws-msg-body code {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  color: var(--ink);
  padding: 1px 5px;
  border-radius: var(--r-xs);
  font-family: var(--mono);
  font-size: 12.5px;
}
.ws-msg-body pre code { background: transparent; border: 0; padding: 0; font-size: inherit; }

/* ---------- Signature AI Timeline Pills (scoped strictly inside agent timeline) ---------- */
.thinking-card,
.tool-card {
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--canvas-soft);
  font-size: 12.5px;
}
.thinking-card summary,
.tool-card summary {
  padding: 7px 10px;
  cursor: pointer;
  color: var(--body);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  list-style: none;
}
.thinking-card summary::-webkit-details-marker,
.tool-card summary::-webkit-details-marker { display: none; }

.tl-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.88px;
  text-transform: uppercase;
  line-height: 1.4;
  flex-shrink: 0;
}
.tl-pill.tl-thinking { background: var(--timeline-thinking); color: var(--tl-ink); }
.tl-pill.tl-grep { background: var(--timeline-grep); color: var(--tl-ink); }
.tl-pill.tl-read { background: var(--timeline-read); color: var(--tl-ink); }
.tl-pill.tl-edit { background: var(--timeline-edit); color: var(--tl-ink); }
.tl-pill.tl-done { background: var(--timeline-done); color: var(--on-primary); margin-left: auto; }
.tl-pill.tl-running { background: var(--surface-strong); color: var(--ink); margin-left: auto; }
.tl-pill.tl-error { background: var(--error-pill-bg); color: var(--semantic-error); margin-left: auto; }

.tool-summary-arg {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.thinking-body,
.tool-body {
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--hairline-soft);
  background: var(--canvas);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 220px;
  overflow-y: auto;
  color: var(--body);
}

.ws-msg-error-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.ws-msg-error-row .ws-msg-error { flex: 1; }
.ws-retry-btn { flex-shrink: 0; }
.ws-msg-error {
  padding: 9px 12px;
  border-radius: var(--r-md);
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--semantic-error);
  font-size: 13px;
}

.ws-composer {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--hairline);
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ws-banner-warn {
  padding: 9px 12px;
  border-radius: var(--r-md);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  font-size: 13px;
  color: var(--ink);
}
.ws-composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.ws-composer-selects { display: flex; gap: 8px; flex-wrap: wrap; }
.ws-composer-selects select {
  padding: 6px 10px;
  background: var(--surface-card);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  font-size: 12.5px;
  color: var(--ink);
  max-width: 240px;
}
.ws-cost-hint { font-size: 12px; color: var(--muted); }

.ws-composer-input-row { display: flex; gap: 10px; align-items: flex-end; }
.ws-composer-input-row textarea {
  flex: 1;
  min-height: 62px;
  max-height: 180px;
  resize: vertical;
  padding: 10px 14px;
  background: var(--surface-card);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--ink);
}
.ws-composer-input-row textarea::placeholder { color: var(--muted-soft); }
.ws-composer-input-row textarea:focus { outline: none; border-color: var(--ink); }
.ws-composer-btns { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Right Workbench ---------- */
.ws-workbench {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--hairline);
  background: var(--surface-card);
}
.ws-wb-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--hairline);
  background: var(--canvas);
}
.ws-wb-tab {
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
}
.ws-wb-tab:hover { color: var(--ink); }
.ws-wb-tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.wb-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.wb-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--hairline-soft);
}
.wb-toolbar-left, .wb-toolbar-right, .wb-vp-group { display: flex; gap: 6px; align-items: center; }
.wb-vp-btn[aria-pressed="true"] {
  background: var(--surface-strong);
  color: var(--ink);
  border-color: var(--hairline-strong);
}
.ws-muted-small { font-size: 12px; color: var(--muted); }

.wb-new-file-form {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--hairline);
  background: var(--canvas-soft);
}
.wb-new-file-form input {
  flex: 1;
  padding: 6px 10px;
  background: var(--surface-card);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  font-size: 13px;
  font-family: var(--mono);
  color: var(--ink);
}

.wb-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(130px, 34%) minmax(0, 1fr);
}
.wb-tree {
  overflow-y: auto;
  padding: 8px 10px;
  background: var(--canvas-soft);
  border-bottom: 1px solid var(--hairline);
  font-size: 13px;
}
.tree-dir summary {
  cursor: pointer;
  padding: 3px 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12.5px;
  user-select: none;
}
.tree-children { padding-left: 14px; }
.tree-file {
  display: block;
  width: 100%;
  text-align: left;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--body);
  font-family: var(--mono);
  font-size: 12.5px;
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-file:hover { background: var(--hairline-soft); color: var(--ink); }
.tree-file.is-open { background: var(--surface-strong); color: var(--ink); font-weight: 500; }

.wb-editor-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.wb-editor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline-soft);
}
.wb-editor-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wb-editor-path { font-family: var(--mono); font-size: 12px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-editor-actions { display: flex; gap: 6px; }
.danger-text { color: var(--semantic-error); }
.wb-editor-input {
  flex: 1;
  width: 100%;
  border: 0;
  resize: none;
  padding: 14px;
  background: var(--surface-card);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  outline: none;
}

.wb-preview-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: var(--surface-strong);
  padding: 12px;
  overflow: auto;
}
.wb-preview-stage iframe {
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-lg);
  background: #ffffff;
  height: 100%;
}
.wb-preview-stage.vp-desktop iframe { width: 100%; }
.wb-preview-stage.vp-tablet iframe { width: 768px; max-width: 100%; }
.wb-preview-stage.vp-mobile iframe { width: 390px; max-width: 100%; }
.wb-preview-empty { margin: auto; max-width: 340px; text-align: center; color: var(--muted); font-size: 13px; }

.wb-runtime-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rt-card {
  padding: 12px 14px;
  background: var(--canvas-soft);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rt-card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.88px;
  text-transform: uppercase;
  color: var(--muted);
}
.rt-kv {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 5px 8px;
  font-size: 12px;
}
.rt-kv dt { color: var(--muted); }
.rt-kv dd { margin: 0; color: var(--ink); font-family: var(--mono); overflow-wrap: anywhere; }
.rt-egress-list { display: flex; flex-direction: column; gap: 6px; }
.rt-egress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  font-size: 12px;
}
.rt-egress-host { font-family: var(--mono); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Admin Providers ---------- */
.provider-form {
  padding: 16px;
  background: var(--canvas-soft);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.provider-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.provider-form-grid input,
.provider-form-grid select {
  padding: 8px 10px;
  background: var(--surface-card);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--ink);
}
.prov-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); }
.providers-list { display: flex; flex-direction: column; gap: 10px; }
.provider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--canvas-soft);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
}
.provider-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; color: var(--ink); }
.provider-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.provider-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Mobile ---------- */
@media (max-width: 960px) {
  .ws-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: calc(100vh - var(--topbar-h));
  }
  .ws-mobile-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 8px 10px;
    background: var(--canvas);
    border-bottom: 1px solid var(--hairline);
  }
  .ws-mobile-btn {
    padding: 8px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
  }
  .ws-mobile-btn[aria-selected="true"] {
    background: var(--surface-card);
    color: var(--ink);
    border-color: var(--hairline-strong);
  }
  .ws-shell[data-mobile-pane="threads"] .ws-chat,
  .ws-shell[data-mobile-pane="threads"] .ws-workbench { display: none; }
  .ws-shell[data-mobile-pane="chat"] .ws-sidebar,
  .ws-shell[data-mobile-pane="chat"] .ws-workbench { display: none; }
  .ws-shell[data-mobile-pane="workbench"] .ws-sidebar,
  .ws-shell[data-mobile-pane="workbench"] .ws-chat { display: none; }
}
