:root {
  --bg: #0c0f14;
  --panel: rgba(19, 23, 31, 0.96);
  --panel-2: #181d27;
  --panel-3: #212735;
  --border: #2c3444;
  --text: #eef2f7;
  --muted: #8f9bad;
  --accent: #78a3ff;
  --accent-strong: #5b8def;
  --danger: #ff6b73;
  --success: #54d49a;
  --warning: #f6c85f;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 92px 1fr 340px;
  grid-template-rows: 68px 1fr 34px;
  grid-template-areas:
    "top top top"
    "tools stage inspector"
    "status status status";
  background: var(--bg);
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: #11151d;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(145deg, #7eafff, #506ee9);
  color: white;
  box-shadow: 0 8px 24px rgba(71, 100, 220, 0.24);
}
.brand strong { display: block; font-size: 14px; }
.brand span { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

.topbar-stats { display: flex; gap: 24px; }
.stat { text-align: right; min-width: 54px; }
.stat span { display: block; font-weight: 750; font-size: 16px; }
.stat small { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }

.toolbar {
  grid-area: tools;
  padding: 12px 9px;
  background: #11151d;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 4;
}

.tool-button {
  min-height: 66px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: .15s ease;
  font-size: 10px;
}
.tool-button:hover { background: var(--panel-2); color: var(--text); }
.tool-button.active { border-color: rgba(120, 163, 255, .48); background: rgba(91, 141, 239, .13); color: var(--accent); }
.tool-button .icon { font-size: 20px; font-weight: 500; line-height: 1; }
.toolbar-spacer { flex: 1; }

.office-stage { grid-area: stage; position: relative; overflow: hidden; min-width: 0; }
#officeCanvas { display: block; width: 100%; height: 100%; outline: none; touch-action: none; opacity: 1; transition: opacity .22s ease; }
#officeCanvas.scene-loading { opacity: 0; }

.mode-banner,
.loading-card {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  border: 1px solid var(--border);
  background: rgba(17, 21, 29, .94);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 35px rgba(0,0,0,.28);
}
.mode-banner {
  top: 18px;
  border-radius: 10px;
  padding: 9px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}
.mode-banner span { color: var(--muted); }
.loading-card {
  top: 45%;
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #384153;
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.inspector {
  grid-area: inspector;
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  z-index: 4;
}
.empty-inspector {
  min-height: 100%;
  padding: 34px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.empty-icon { width: 58px; height: 58px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 16px; color: var(--accent); font-size: 26px; margin-bottom: 12px; }
.empty-inspector h2 { margin: 0 0 8px; font-size: 18px; }
.empty-inspector p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; max-width: 240px; }

.desk-inspector { padding: 20px; }
.inspector-heading,
.modal-heading,
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.inspector-heading { margin-bottom: 8px; }
.inspector-heading small,
.section-heading small,
.modal-heading small { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.inspector-heading h2,
.modal-heading h2 { margin: 3px 0 0; font-size: 20px; }
.section-heading h3 { margin: 3px 0 0; font-size: 15px; }

.section { padding: 18px 0; border-top: 1px solid var(--border); }
.section:first-of-type { border-top: 0; }
.section h3 { margin: 0; }
label { display: block; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .04em; margin: 12px 0 6px; }
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #10141b;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}
input:focus,
select:focus,
textarea:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(91,141,239,.12); }
textarea { resize: vertical; min-height: 82px; }
.field-hint { display: block; margin: -1px 0 7px; color: var(--muted); font-size: 10px; line-height: 1.4; }

.primary,
.secondary,
.danger,
.text-danger,
.icon-button {
  border: 0;
  border-radius: 9px;
  padding: 10px 12px;
}
.primary { width: 100%; margin-top: 14px; background: var(--accent-strong); color: white; font-weight: 700; }
.primary:hover { filter: brightness(1.08); }
.secondary { background: var(--panel-3); color: var(--text); border: 1px solid var(--border); }
.secondary:hover { background: #293141; }
.danger { width: 100%; margin-top: 8px; background: rgba(255,107,115,.12); color: var(--danger); border: 1px solid rgba(255,107,115,.22); }
.text-danger { padding: 0; background: transparent; color: var(--danger); }
.icon-button { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; color: var(--muted); background: var(--panel-3); font-size: 18px; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.danger-zone { text-align: center; }

.status-pill { padding: 5px 8px; border-radius: 999px; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; background: #2b3240; color: var(--muted); }
.status-pill[data-status="working"] { background: rgba(84,212,154,.12); color: var(--success); }
.status-pill[data-status="meeting"], .status-pill[data-status="waiting"] { background: rgba(246,200,95,.12); color: var(--warning); }
.status-pill[data-status="error"] { background: rgba(255,107,115,.12); color: var(--danger); }
.status-pill[data-status="offline"] { background: #232834; color: #6f7888; }

.statusbar {
  grid-area: status;
  background: #0d1117;
  border-top: 1px solid var(--border);
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
  z-index: 5;
}
.statusbar .hint { opacity: .7; }

.modal {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}
.modal[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  overflow: auto;
}
.modal::backdrop { background: rgba(4,7,11,.66); backdrop-filter: blur(3px); }
.modal-card { width: min(420px, calc(100vw - 32px)); background: #151a23; border: 1px solid var(--border); border-radius: 16px; padding: 20px; box-shadow: 0 24px 70px rgba(0,0,0,.42); }
.modal-heading { margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-actions .primary { width: auto; margin: 0; }

.hidden { display: none !important; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 74px 1fr; grid-template-rows: 60px 1fr 34px; grid-template-areas: "top top" "tools stage" "status status"; }
  .inspector { position: fixed; right: 0; top: 60px; bottom: 34px; width: min(340px, 90vw); box-shadow: -16px 0 50px rgba(0,0,0,.35); }
  .topbar-stats { display: none; }
}


/* Agent runtime */
.ai-run-button:disabled { opacity: .62; cursor: wait; filter: none; }
.agent-save-button { width: 100%; margin-top: 8px; }
.agent-work,
.agent-activity {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #10141b;
  padding: 11px;
}
.work-heading { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.work-heading strong { font-size: 11px; }
.work-heading span { color: var(--muted); font-size: 9px; text-align: right; }
#agentResult { white-space: pre-wrap; word-break: break-word; margin: 0; max-height: 260px; overflow: auto; font: inherit; font-size: 11px; line-height: 1.55; color: var(--text); }
.agent-activity small { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.agent-activity .muted { color: var(--muted); font-size: 10px; margin: 8px 0 0; }
.activity-list { margin-top: 8px; display: grid; gap: 7px; }
.activity-row { display: grid; grid-template-columns: 42px 1fr; gap: 8px; font-size: 10px; line-height: 1.4; }
.activity-row time { color: var(--muted); font-variant-numeric: tabular-nums; }
.activity-row span { color: var(--text); overflow-wrap: anywhere; }
.activity-task_failed span { color: var(--danger); }

/* Asset catalog + decoration inspector */
.asset-modal-card {
  width: min(760px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
}

.asset-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
  min-height: 160px;
}

.asset-card {
  min-height: 78px;
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #10141b;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  font-size: 10px;
  line-height: 1.25;
}

.asset-card:hover {
  border-color: rgba(120, 163, 255, .55);
  background: #1b2230;
}

.asset-cube {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(120, 163, 255, .1);
  color: var(--accent);
  font-size: 17px;
}

.asset-empty,
.decoration-inspector .muted {
  color: var(--muted);
  font-size: 10px;
}

#decorationScale { padding: 0; accent-color: var(--accent-strong); }

@media (max-width: 700px) {
  .asset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.tool-button.gizmo-on {
  border-color: rgba(120, 163, 255, .48);
  background: rgba(91, 141, 239, .13);
  color: var(--accent);
}

.asset-card {
  min-height: 156px;
  align-items: stretch;
  justify-content: flex-start;
  overflow: hidden;
}

.asset-thumb-wrap {
  height: 88px;
  border-radius: 8px;
  background: linear-gradient(180deg, #f6f8fc 0%, #d8e0ee 100%);
  border: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.asset-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-thumb-placeholder {
  color: #4d5d7b;
  font-size: 23px;
}

.asset-label {
  padding: 0 2px 4px;
  font-size: 10px;
  line-height: 1.3;
}

.asset-file {
  color: var(--muted);
  font-size: 9px;
}

.agent-collaboration {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #10141b;
  padding: 11px;
}

.agent-collaboration > small {
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
}

.agent-collaboration .muted {
  color: var(--muted);
  font-size: 10px;
  margin: 8px 0 0;
}

.collaboration-list {
  margin-top: 9px;
  display: grid;
  gap: 8px;
}

.collaboration-row {
  border-radius: 8px;
  padding: 8px 9px;
  background: #151b25;
  border: 1px solid #273142;
}

.collaboration-row.outgoing {
  border-left: 2px solid var(--accent-strong);
}

.collaboration-row.incoming {
  border-left: 2px solid var(--success);
}

.collaboration-meta {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  margin-bottom: 4px;
}

.collaboration-message {
  color: var(--text);
  font-size: 10px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 86px;
  overflow-y: auto;
}

/* Shared agent workspace */
.workspace-modal-card {
  width: min(920px, calc(100vw - 32px));
  height: min(680px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workspace-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.workspace-heading h2 { margin-bottom: 4px; }
.workspace-heading .muted { margin: 0; color: var(--muted); font-size: 10px; }

.workspace-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.workspace-actions button { width: auto; margin: 0; }

.workspace-browser {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) minmax(0, 2.2fr);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #0e131a;
}

.workspace-files {
  min-width: 0;
  border-right: 1px solid var(--border);
  background: #111720;
  display: flex;
  flex-direction: column;
}

.workspace-path {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.workspace-file-list {
  min-height: 0;
  overflow-y: auto;
  padding: 7px;
}

.workspace-file-list > .muted { margin: 8px; color: var(--muted); font-size: 10px; line-height: 1.5; }

.workspace-file-button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 8px 9px;
  margin: 0 0 3px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  font: 10px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.workspace-file-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-file-button small { color: var(--muted); flex: 0 0 auto; }
.workspace-file-button:hover { background: #1a2230; }
.workspace-file-button.selected { background: rgba(91, 141, 239, .14); color: var(--accent); }

.workspace-preview {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.workspace-preview-heading {
  min-height: 42px;
  padding: 9px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.workspace-preview-heading strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.workspace-preview-heading span { color: var(--muted); font-size: 9px; text-align: right; }

#workspacePreviewContent {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 14px;
  white-space: pre;
  tab-size: 2;
  color: #dce5f4;
  background: #0c1117;
  font: 10px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 700px) {
  .workspace-browser { grid-template-columns: 1fr; grid-template-rows: 190px 1fr; }
  .workspace-files { border-right: 0; border-bottom: 1px solid var(--border); }
}
.activity-workspace span { color: #b9d2ff; }
.activity-workspace_error span { color: var(--danger); }

/* Projects v1 */
.projects-modal-card {
  width: min(980px, calc(100vw - 32px));
  height: min(720px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.projects-layout {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #0f141c;
}

.projects-sidebar {
  min-width: 0;
  border-right: 1px solid var(--border);
  background: #111720;
  overflow-y: auto;
  padding: 8px;
}

.project-list { display: grid; gap: 6px; }
.project-list > .muted { margin: 8px; font-size: 10px; line-height: 1.5; }

.project-card {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  padding: 10px;
  text-align: left;
  display: grid;
  gap: 4px;
}
.project-card:hover { background: #1a2230; }
.project-card.selected {
  border-color: rgba(120,163,255,.34);
  background: rgba(91,141,239,.12);
}
.project-card-title { font-size: 11px; font-weight: 750; }
.project-card-meta { color: var(--muted); font-size: 9px; }

.project-detail {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
}
.project-empty {
  min-height: 260px;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}
.project-empty h3 { margin: 0 0 8px; color: var(--text); }
.project-empty p { max-width: 360px; margin: 0; font-size: 11px; line-height: 1.55; }

.project-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}
.project-stats span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 9px;
  background: #111720;
}

.project-activity { margin-top: 18px; }
.project-activity > small {
  display: block;
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .11em;
  margin-bottom: 8px;
}
.project-event {
  display: grid;
  grid-template-columns: 100px minmax(0,1fr);
  gap: 9px;
  padding: 7px 0;
  border-top: 1px solid rgba(44,52,68,.72);
  font-size: 10px;
}
.project-event strong { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.project-event span { color: var(--muted); line-height: 1.45; }

.project-create-form {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  background: #11151d;
  padding: 14px 16px 16px;
}
.project-create-form .section-heading span { color: var(--muted); font-size: 9px; }
.project-create-form textarea { min-height: 64px; }
.project-create-form .primary { max-width: 180px; }

@media (max-width: 760px) {
  .projects-layout { grid-template-columns: 1fr; overflow-y: auto; }
  .projects-sidebar { border-right: 0; border-bottom: 1px solid var(--border); max-height: 180px; }
  .project-create-form { grid-column: auto; }
}

.project-task-row {
  display: grid;
  grid-template-columns: 70px 90px minmax(0,1fr);
  gap: 8px;
  align-items: start;
  padding: 7px 0;
  border-top: 1px solid rgba(44,52,68,.72);
  font-size: 10px;
}
.project-task-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-task-row > span:last-child { color: var(--muted); line-height: 1.45; }
.project-task-status {
  width: max-content;
  border-radius: 999px;
  padding: 3px 6px;
  text-transform: uppercase;
  font-size: 8px;
  letter-spacing: .06em;
  background: #242c39;
  color: var(--muted);
}
.project-task-status.status-completed { color: var(--success); background: rgba(84,212,154,.1); }
.project-task-status.status-working { color: var(--warning); background: rgba(246,200,95,.1); }
.project-task-status.status-failed { color: var(--danger); background: rgba(255,107,115,.1); }
.project-activity-second-heading { margin-top: 18px; }

/* Memory v1 */
.agent-memory {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #10141b;
  padding: 11px;
}
.agent-memory > small {
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
}
.agent-memory .muted { color: var(--muted); font-size: 10px; margin: 8px 0 0; }
.agent-memory-list { display: grid; gap: 7px; margin-top: 8px; }
.agent-memory-row {
  border: 1px solid #273142;
  border-left: 2px solid #77859b;
  border-radius: 8px;
  padding: 8px;
  background: #151b25;
}
.agent-memory-row.scope-company { border-left-color: #d2ad72; }
.agent-memory-row.scope-project { border-left-color: var(--accent-strong); }
.agent-memory-row.scope-agent { border-left-color: var(--success); }
.agent-memory-meta { color: var(--muted); font-size: 8px; font-weight: 700; margin-bottom: 4px; }
.agent-memory-content { color: var(--text); font-size: 10px; line-height: 1.45; overflow-wrap: anywhere; }
.activity-memory_stored span { color: #d9c59d; }
.activity-memory_recalled span { color: #b9d2ff; }
.activity-memory_error span { color: var(--danger); }

.memory-modal-card {
  width: min(900px, calc(100vw - 32px));
  height: min(720px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.memory-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 9px;
  align-items: end;
  margin-bottom: 12px;
}
.memory-toolbar label { margin: 0; }
.memory-toolbar label > span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.memory-toolbar .secondary { margin: 0; min-height: 34px; }
.memory-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}
.memory-stats span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 9px;
  background: #111720;
}
.memory-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding-right: 4px;
}
.memory-card {
  border: 1px solid var(--border);
  border-left: 3px solid #77859b;
  border-radius: 10px;
  padding: 11px 12px;
  background: #10151d;
}
.memory-card.scope-company { border-left-color: #d2ad72; }
.memory-card.scope-project { border-left-color: var(--accent-strong); }
.memory-card.scope-agent { border-left-color: var(--success); }
.memory-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.memory-card-head > div { min-width: 0; display: grid; gap: 3px; }
.memory-card-head strong { color: var(--text); font-size: 11px; }
.memory-card-head span { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .05em; }
.memory-card-content { color: var(--text); font-size: 10px; line-height: 1.55; margin: 9px 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.memory-card-foot { color: var(--muted); font-size: 8px; line-height: 1.4; }
.memory-delete-button {
  border: 1px solid rgba(255,107,115,.3);
  background: rgba(255,107,115,.07);
  color: var(--danger);
  border-radius: 7px;
  padding: 5px 7px;
  font-size: 8px;
  cursor: pointer;
}
.memory-delete-button:hover { background: rgba(255,107,115,.13); }
.project-memory-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 9px;
  padding: 7px 0;
  border-top: 1px solid rgba(44,52,68,.72);
  font-size: 10px;
}
.project-memory-row strong { color: #d9c59d; overflow: hidden; text-overflow: ellipsis; }
.project-memory-row span { color: var(--muted); line-height: 1.45; }

@media (max-width: 760px) {
  .memory-toolbar { grid-template-columns: 1fr 1fr; }
  .memory-toolbar .secondary { width: 100%; }
}

/* Background Worker v1 */
.runtime-modal-card {
  width: min(760px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.runtime-summary {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 1.5fr);
  gap: 12px;
  margin-bottom: 12px;
}
.runtime-health,
.runtime-counts {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #10151d;
}
.runtime-health {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 13px;
}
.runtime-health > div { min-width: 0; display: grid; gap: 3px; }
.runtime-health strong { font-size: 12px; }
.runtime-health small { color: var(--muted); font-size: 9px; line-height: 1.4; }
.runtime-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255,107,115,.08);
}
.runtime-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(84,212,154,.09);
}
.runtime-counts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
}
.runtime-count {
  display: grid;
  place-content: center;
  min-height: 64px;
  text-align: center;
  border-left: 1px solid var(--border);
}
.runtime-count:first-child { border-left: 0; }
.runtime-count strong { font-size: 15px; }
.runtime-count span { color: var(--muted); font-size: 8px; margin-top: 3px; }
.runtime-actions { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.runtime-list-heading {
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .11em;
  margin-bottom: 7px;
}
.runtime-job-list {
  min-height: 0;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
.runtime-job-row {
  display: grid;
  grid-template-columns: 64px 120px minmax(0,1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 9px 2px;
  border-bottom: 1px solid rgba(44,52,68,.72);
  font-size: 9px;
}
.runtime-job-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runtime-job-row .runtime-job-project { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runtime-job-state {
  width: max-content;
  border-radius: 999px;
  padding: 3px 6px;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: #242c39;
  color: var(--muted);
  font-size: 8px;
}
.runtime-job-state.status-running { color: var(--warning); background: rgba(246,200,95,.1); }
.runtime-job-state.status-completed { color: var(--success); background: rgba(84,212,154,.1); }
.runtime-job-state.status-failed { color: var(--danger); background: rgba(255,107,115,.1); }
.runtime-job-state.status-queued { color: var(--accent); background: rgba(120,163,255,.1); }
.runtime-job-attempts { color: var(--muted); white-space: nowrap; }
.activity-task_queued span { color: #b9d2ff; }

@media (max-width: 760px) {
  .runtime-summary { grid-template-columns: 1fr; }
  .runtime-counts { grid-template-columns: repeat(2, 1fr); }
  .runtime-count:nth-child(3) { border-left: 0; border-top: 1px solid var(--border); }
  .runtime-count:nth-child(4) { border-top: 1px solid var(--border); }
  .runtime-job-row { grid-template-columns: 58px 1fr auto; }
  .runtime-job-row .runtime-job-project { display: none; }
}



/* Agent tool access */
.agent-tools-field {
  display: grid;
  gap: 7px;
  margin: 2px 0 4px;
}
.agent-tools-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.agent-tools-heading label { margin: 0; }
.agent-tools-heading small {
  color: var(--muted);
  font-size: 8px;
}
.agent-tool-list {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #10141b;
}
.agent-tool-list > .muted {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
}
.agent-tool-group {
  display: grid;
  gap: 5px;
}
.agent-tool-group + .agent-tool-group {
  padding-top: 7px;
  border-top: 1px solid var(--border);
}
.agent-tool-category {
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.agent-tool-option {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 7px;
  align-items: start;
  padding: 7px;
  margin: 0;
  border: 1px solid #273142;
  border-radius: 8px;
  background: #151b25;
  cursor: pointer;
}
.agent-tool-option:hover { border-color: rgba(120,163,255,.38); }
.agent-tool-option input {
  margin: 2px 0 0;
  accent-color: var(--accent-strong);
}
.agent-tool-option > span {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.agent-tool-option strong {
  color: var(--text);
  font-size: 9px;
  line-height: 1.35;
}
.agent-tool-option small {
  color: var(--muted);
  font-size: 8px;
  line-height: 1.4;
}
.agent-tool-option.risk-write { border-left: 2px solid #d2ad72; }
.activity-tools_updated span { color: #c7d4ea; }
.activity-tool_used span { color: #b9d2ff; }
.activity-tool_denied span,
.activity-tool_error span { color: var(--danger); }

/* Scheduled work */
.schedules-modal-card {
  width: min(1000px, calc(100vw - 36px));
  height: min(820px, calc(100vh - 36px));
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.schedules-modal-card > .modal-heading,
.schedules-modal-card > .schedule-summary {
  flex: 0 0 auto;
}

.schedule-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.025);
}

.schedule-counts { display: flex; gap: 8px; flex-wrap: wrap; }
.schedule-counts span {
  color: var(--muted);
  font-size: 9px;
  border-left: 1px solid var(--border);
  padding-left: 10px;
}
.schedule-counts strong { color: var(--text); font-size: 12px; }

.schedule-layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.schedule-create-form,
.schedule-list-pane {
  min-height: 0;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.02);
  padding: 12px;
}

.schedule-create-form {
  overflow-y: auto;
  display: grid;
  gap: 7px;
  align-content: start;
}
.schedule-create-form .section-heading { margin-bottom: 3px; }
.schedule-create-form .section-heading span { color: var(--muted); font-size: 8px; }
.schedule-create-form textarea { min-height: 78px; }
.schedule-create-form .primary { margin-top: 4px; }
.schedule-field { display: grid; gap: 6px; }
.schedule-inline { display: grid; grid-template-columns: 90px auto; gap: 8px; align-items: center; }
.schedule-inline span { color: var(--muted); font-size: 10px; }
.schedule-timezone { color: var(--muted); font-size: 8px; line-height: 1.4; }

.schedule-list-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}
.schedule-list-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
}
.schedule-list-actions small {
  color: var(--muted);
  font-weight: 750;
  letter-spacing: .08em;
}
.schedule-list-actions .secondary { margin: 0; }

.schedule-list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
  padding-right: 3px;
  align-content: start;
}
.schedule-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-strong);
  background: #111720;
  padding: 10px;
  display: grid;
  gap: 8px;
}
.schedule-card.paused { opacity: .72; border-left-color: #6f7884; }
.schedule-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.schedule-card-head > div { display: grid; gap: 3px; min-width: 0; }
.schedule-card-head strong { color: var(--text); font-size: 11px; }
.schedule-card-head span { color: var(--muted); font-size: 9px; }
.schedule-state {
  flex: 0 0 auto;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: 7px;
  font-weight: 800;
  padding: 4px 6px;
  border: 1px solid var(--border);
}
.schedule-state.active { color: var(--success); background: rgba(84,212,154,.09); }
.schedule-state.paused { color: var(--muted); background: rgba(255,255,255,.03); }
.schedule-assignment { display: grid; gap: 4px; }
.schedule-assignment > span { color: var(--text); font-size: 9px; }
.schedule-assignment small {
  color: var(--muted);
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.schedule-card-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 8px;
}
.schedule-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.schedule-card-actions button { margin: 0; min-height: 28px; padding: 5px 8px; font-size: 8px; }
.schedule-delete-button {
  border: 1px solid rgba(255,107,115,.28);
  background: transparent;
  color: var(--danger);
  cursor: pointer;
}
.schedule-delete-button:hover { background: rgba(255,107,115,.11); }

@media (max-width: 760px) {
  .schedules-modal-card {
    height: calc(100vh - 20px);
    max-height: calc(100vh - 20px);
    overflow-y: auto;
  }
  .schedule-summary { grid-template-columns: 1fr; }
  .schedule-layout {
    flex: 0 0 auto;
    grid-template-columns: 1fr;
    overflow: visible;
  }
  .schedule-create-form,
  .schedule-list-pane { overflow: visible; }
  .schedule-list { max-height: 420px; overflow-y: auto; }
}
