:root {
  --ink: #29253a;
  --muted: #766f86;
  --line: #e8e5ef;
  --paper: #fff;
  --sidebar: #f8f7fb;
  --purple: #6954c5;
  --purple-dark: #4f3ca9;
  --purple-soft: #f1edff;
  --green: #247a59;
  --green-soft: #e8f7ef;
  --amber: #9a6513;
  --amber-soft: #fff6e6;
  --red: #ae4754;
  --shadow: 0 12px 34px #2d1f5512;
  --radius: 14px;
  font:
    16px/1.55 Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Noto Sans TC",
    "PingFang TC",
    "Microsoft JhengHei",
    sans-serif;
  color: var(--ink);
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
html,
body,
#app {
  min-height: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  overflow: hidden;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  border: 0;
  cursor: pointer;
  background: none;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #b8aafd;
  outline-offset: 2px;
}
a {
  color: var(--purple);
}
.login-shell {
  height: 100dvh;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: var(--sidebar);
}
.login-card {
  width: min(100%, 460px);
  padding: clamp(24px, 5vw, 40px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.login-card .brand { margin: 0 0 24px; padding: 0; }
.login-card h1 { margin: 0 0 12px; font-size: 1.65rem; }
.login-card p { margin: 0 0 20px; }
.login-card .btn { display: inline-flex; text-decoration: none; margin-bottom: 16px; }
.login-card .muted { font-size: .875rem; }
.login-card form { display: grid; gap: 16px; }
.login-card textarea { width: 100%; resize: vertical; }
svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: fixed;
  z-index: 1000;
  top: -60px;
  left: 16px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--purple);
  border-radius: 8px;
}
.skip:focus {
  top: 16px;
}
.workspace {
  height: 100dvh;
  display: flex;
  overflow: hidden;
  background: var(--paper);
}
.sidebar {
  width: 224px;
  flex: 0 0 224px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 18px 12px 14px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 45px;
  padding: 3px 8px 15px;
  font-weight: 720;
  letter-spacing: -0.25px;
}
.brand-symbol {
  width: 31px;
  height: 31px;
  padding: 7px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(145deg, #836ee1, #5743b6);
  box-shadow: 0 4px 12px #6954c540;
}
.brand small,
.project-group > small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 39px;
  margin-bottom: 12px;
  border: 1px solid #d8d0ff;
  border-radius: 10px;
  color: var(--purple-dark);
  background: #fff;
  font-size: 14px;
  font-weight: 650;
}
.new-chat:hover {
  background: var(--purple-soft);
}
.project-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.project-group > small {
  padding: 10px 9px 5px;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
}
.chat-link {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-width: 0;
  padding: 9px;
  border-radius: 9px;
  color: #5e586c;
  text-align: left;
  font-size: 14px;
  line-height: 1.35;
}
.chat-link:hover {
  background: #eeebf5;
  color: var(--ink);
}
.chat-link.active {
  color: #4e3aa4;
  background: #eae4ff;
  font-weight: 650;
}
.chat-link > span:not(.badge) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-footer {
  margin-top: auto;
  padding: 13px 8px 2px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.main-area {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  min-height: 59px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.workspace-title {
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workspace-title small {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 35px;
  height: 35px;
  border-radius: 9px;
  color: var(--muted);
}
.icon-btn:hover {
  color: var(--purple);
  background: var(--purple-soft);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid #dfdbe8;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.btn:hover:not(:disabled),
.btn.subtle:hover:not(:disabled) {
  border-color: #cfc5ff;
  background: var(--purple-soft);
}
.btn.primary,
.send-button {
  border-color: var(--purple);
  color: #fff;
  background: var(--purple);
}
.btn.primary:hover:not(:disabled),
.send-button:hover:not(:disabled) {
  background: var(--purple-dark);
  border-color: var(--purple-dark);
}
.btn.subtle {
  color: var(--muted);
  background: transparent;
}
.btn.danger {
  color: var(--red);
  border-color: #f0cfd4;
}
.demo-strip {
  min-height: 31px;
  display: flex;
  align-items: center;
  padding: 5px 20px;
  border-bottom: 1px solid #eee9ff;
  background: #fbfaff;
  color: #675c80;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-tabs {
  display: none;
}
.workbody {
  min-height: 0;
  flex: 1;
  display: flex;
  overflow: hidden;
}
.conversations {
  min-width: 0;
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(300px, 1fr));
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.chat-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.chat-pane + .chat-pane {
  border-left: 1px solid var(--line);
}
.chat-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 17px;
  border-bottom: 1px solid var(--line);
}
.chat-header h2 {
  min-width: 0;
  flex: 1;
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: -0.15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-tag {
  padding: 3px 7px;
  border-radius: 5px;
  color: #5644aa;
  background: #f0edfd;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.agent-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--green);
  font-size: 12px;
  white-space: nowrap;
}
.agent-state:before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #54b489;
  box-shadow: 0 0 0 3px #e9f8f0;
}
.message-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px clamp(15px, 2vw, 28px) 18px;
  scroll-behavior: smooth;
}
.message {
  display: flex;
  gap: 9px;
  margin: 0 0 21px;
  align-items: flex-start;
}
.message.user {
  flex-direction: row-reverse;
}
.avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: #5e4bb0;
  background: #eeeafd;
  font-size: 12px;
  font-weight: 700;
}
.message.user .avatar {
  color: #4e745f;
  background: #e8f4ec;
}
.message.system .avatar {
  color: #93703a;
  background: #fff3dc;
}
.message-body {
  min-width: 0;
  max-width: 88%;
}
.message.user .message-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.message-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 5px;
  color: #5d566c;
  font-size: 12px;
  font-weight: 650;
}
.message-meta time,
.message-meta span {
  color: var(--muted);
  font-weight: 450;
}
.message-body > p,
.message-body > div:not(.message-meta):not(.message-actions):not(.review-card) {
  margin: 0;
  padding: 10px 12px;
  border-radius: 4px 12px 12px;
  background: #f7f6fa;
  color: #393444;
  font-size: 16px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.message.user .message-body > p {
  border-radius: 12px 4px 12px 12px;
  background: #f0edff;
}
.message.system .message-body > p {
  background: #fff9ed;
  color: #75613d;
  font-size: 14px;
}
.message-actions {
  display: flex;
  gap: 3px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.message:hover .message-actions,
.message:focus-within .message-actions {
  opacity: 1;
}
.message-actions button {
  padding: 3px 5px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 12px;
}
.message-actions button:hover {
  background: var(--purple-soft);
  color: var(--purple);
}
.review-card {
  margin: 12px 0 2px;
  border: 1px solid #e5dcbb;
  border-radius: 11px;
  background: #fffdf7;
  overflow: hidden;
}
.review-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 11px;
  border-bottom: 1px solid #f0e9d7;
  font-size: 14px;
  font-weight: 650;
}
.diff-preview {
  margin: 0;
  padding: 10px 11px;
  overflow: auto;
  border-bottom: 1px solid #f0e9d7;
  background: #fcfbf7;
  color: #625c69;
  font:
    12px/1.6 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
  white-space: pre;
}
.review-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  padding: 9px 11px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
}
.badge.running {
  color: var(--green);
  background: var(--green-soft);
}
.badge.review {
  color: var(--amber);
  background: var(--amber-soft);
}
.badge.paused {
  color: #687180;
  background: #eef0f4;
}
.composer {
  flex: 0 0 auto;
  padding: 10px 14px 13px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.composer-context {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
}
.composer textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  max-height: 122px;
  padding: 10px 11px;
  resize: vertical;
  border: 1px solid #ded9e8;
  border-radius: 10px;
  background: #fff;
  font-size: 16px;
  line-height: 1.45;
  outline: 0;
}
.composer textarea:focus {
  border-color: #a99bef;
  box-shadow: 0 0 0 3px #eeeaff;
}
.composer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
}
.composer-tools > div {
  display: flex;
  gap: 2px;
}
.composer-tools .icon-btn {
  width: 29px;
  height: 29px;
}
.send-button {
  min-height: 29px;
  padding: 5px 9px;
  border: 1px solid;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
}
.activity-rail {
  width: 278px;
  flex: 0 0 278px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fcfbfd;
  overflow: hidden;
}
.rail-header {
  min-height: 59px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 15px;
  border-bottom: 1px solid var(--line);
}
.rail-header h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.1px;
}
.rail-tabs,
.tool-tabs {
  display: flex;
  gap: 2px;
  padding: 7px 10px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.rail-tabs button,
.tool-tabs button {
  flex: 0 0 auto;
  padding: 7px 7px 8px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.rail-tabs button.active,
.tool-tabs button.active {
  border-color: var(--purple);
  color: var(--purple);
  font-weight: 700;
}
.rail-content {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  overscroll-behavior: contain;
}
.tool-card,
.memory-card {
  margin-bottom: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.tool-card h3,
.memory-card h3 {
  margin: 0 0 5px;
  font-size: 14px;
}
.tool-card p,
.memory-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.activity-item {
  position: relative;
  padding: 0 0 15px 17px;
  color: #504a5e;
  font-size: 14px;
  line-height: 1.5;
}
.activity-item:before {
  content: "";
  position: absolute;
  top: 6px;
  left: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8b7bd7;
  box-shadow: 0 0 0 3px #efecfb;
}
.activity-item small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}
.todo-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid #eeeaf2;
  font-size: 14px;
}
.todo-row:last-child {
  border: 0;
}
.field {
  display: block;
  margin: 0 0 11px;
}
.field > span {
  display: block;
  margin-bottom: 5px;
  color: #554e62;
  font-size: 14px;
  font-weight: 650;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid #ded9e8;
  border-radius: 7px;
  background: #fff;
  font-size: 14px;
}
.field textarea {
  min-height: 72px;
  resize: vertical;
}
.drawer-backdrop {
  display: none;
}
.modal {
  width: min(560px, calc(100vw - 30px));
  max-height: min(700px, 88dvh);
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 24px 70px #2d1f5530;
}
.modal::backdrop,
.drawer-backdrop {
  background: #241d3d54;
  backdrop-filter: blur(2px);
}
.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 17px;
  border-bottom: 1px solid var(--line);
}
.modal-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}
.modal-header h2 {
  margin: 0;
  font-size: 17px;
}
.modal-body {
  padding: 17px;
  overflow: auto;
}
.toast {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 10px 13px;
  border-radius: 9px;
  color: #fff;
  background: #302a42;
  box-shadow: var(--shadow);
  font-size: 14px;
}
.empty-state {
  padding: 30px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}
@media (max-width: 1199px) {
  .activity-rail {
    position: absolute;
    z-index: 30;
    top: 0;
    right: 0;
    bottom: 0;
    display: none;
    box-shadow: -12px 0 30px #34275a16;
  }
  .activity-rail.open {
    display: flex;
  }
  .drawer-backdrop {
    position: fixed;
    z-index: 29;
    inset: 0;
    display: block;
  }
  .conversations {
    border-right: 0;
  }
}
@media (max-width: 760px) {
  body {
    overflow: hidden;
  }
  .workspace {
    position: relative;
  }
  .sidebar {
    position: fixed;
    z-index: 50;
    inset: 0 auto 0 0;
    transform: translateX(-103%);
    transition: transform 0.22s ease;
    box-shadow: 10px 0 30px #34275a22;
  }
  .sidebar-open .sidebar {
    transform: translateX(0);
  }
  .sidebar-open:after {
    content: "";
    position: fixed;
    z-index: 45;
    inset: 0;
    background: #241d3d50;
  }
  .topbar {
    min-height: 53px;
    padding: 8px 12px;
  }
  .workspace-title small {
    display: none;
  }
  .demo-strip {
    min-height: 28px;
    padding: 4px 12px;
  }
  .room-tabs {
    display: flex;
    gap: 3px;
    padding: 6px 10px 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .room-tabs button {
    flex: 0 0 auto;
    padding: 6px 8px 7px;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    background: none;
    font-size: 12px;
    white-space: nowrap;
  }
  .room-tabs button.active {
    border-color: var(--purple);
    color: var(--purple);
    font-weight: 700;
  }
  .workbody {
    position: relative;
  }
  .conversations {
    display: block;
  }
  .chat-pane {
    height: 100%;
  }
  .chat-pane.mobile-hidden {
    display: none;
  }
  .chat-header {
    min-height: 60px;
    padding: 9px 13px;
  }
  .message-list {
    padding: 16px 13px;
  }
  .message-body {
    max-width: 91%;
  }
  .message-body > p,
  .composer textarea {
    font-size: 16px;
  }
  .composer {
    padding: 9px 11px 11px;
  }
  .activity-rail {
    width: min(88vw, 330px);
    flex-basis: min(88vw, 330px);
  }
  .toast {
    right: 10px;
    bottom: 10px;
    left: 10px;
    max-width: none;
  }
}
@media (max-width: 380px) {
  .top-actions .btn {
    display: none;
  }
  .project-tag {
    max-width: 84px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .agent-state {
    font-size: 0;
  }
  .agent-state:before {
    margin: 2px;
  }
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(145deg, #836ee1, #5743b6);
  box-shadow: 0 4px 12px #6954c540;
}
.brand strong > span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
.mobile-menu {
  display: none;
}
.sidebar-search {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: -3px 0 7px;
  padding: 7px 8px;
  border: 1px solid #e1ddea;
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
}
.sidebar-search input {
  width: 0;
  min-width: 0;
  flex: 1;
  border: 0;
  background: transparent;
  outline: 0;
  font-size: 12px;
}
.sidebar-search kbd,
.send-button kbd {
  padding: 1px 4px;
  border: 1px solid #ddd8e7;
  border-radius: 4px;
  background: #faf9fc;
  color: var(--muted);
  font:
    10px ui-monospace,
    monospace;
  white-space: nowrap;
}
.sidebar-rooms {
  min-height: 0;
}
.project-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 4px;
  color: #625b70;
  font-size: 12px;
  font-weight: 700;
}
.project-label .muted {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
}
.room-dot,
.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: #a9a4b2;
}
.room-dot.running,
.status-dot.running {
  background: #48a57a;
}
.room-dot.review,
.status-dot.review {
  background: #d29b3c;
}
.room-dot.paused,
.status-dot.paused {
  background: #9ba2ae;
}
.sidebar-note {
  display: grid;
  gap: 4px;
  margin-top: auto;
  padding: 11px 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-footer > div {
  min-width: 0;
  flex: 1;
}
.sidebar-footer strong {
  display: block;
  font-size: 12px;
  color: #514b5d;
}
.sidebar-footer select {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  outline: 0;
}
.avatar.human {
  color: #4e745f;
  background: #e8f4ec;
}
.chat-heading {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.chat-heading h2 {
  flex-basis: 100%;
}
.pane-label {
  color: var(--muted);
  font-size: 11px;
}
.agent-state .icon-btn {
  width: 29px;
  height: 29px;
}
.agent-state .badge {
  margin-left: 2px;
}
.conversation-start {
  margin: 0 auto 18px;
  width: max-content;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 5px;
  background: #f5f3f8;
  color: var(--muted);
  font-size: 11px;
}
.message {
  display: block;
}
.message-meta {
  align-items: center;
}
.message-meta .avatar {
  margin-right: 1px;
}
.message-body {
  max-width: none;
  margin-left: 37px;
}
.message-body > p,
.message-body > div:not(.message-meta):not(.message-actions):not(.review-card) {
  padding: 0;
  background: transparent;
}
.message.user .message-body {
  align-items: initial;
}
.message.user .message-body > p {
  background: transparent;
}
.message.system .message-body > p {
  background: transparent;
}
.message.user .message-meta,
.message.user .message-body {
  margin-left: 0;
  margin-right: 37px;
}
.message.user .message-meta {
  justify-content: flex-end;
}
.message.user .message-body {
  margin-left: 0;
  text-align: right;
}
.message.system {
  padding: 10px 12px;
  border-radius: 9px;
  background: #fff9ed;
}
.message.system .message-body {
  margin-left: 37px;
}
.message.system .message-meta {
  margin-bottom: 2px;
}
.message-actions {
  margin-left: 37px;
}
.message.user .message-actions {
  justify-content: flex-end;
  margin: 4px 37px 0 0;
}
.source-reference {
  margin: 0 0 5px 37px;
  padding: 3px 7px;
  border-left: 2px solid #b4a8ed;
  color: #71658e;
  background: #faf9ff;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.attachment-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 7px;
  padding: 5px 7px;
  border-radius: 7px;
  background: #f3f0ff;
  color: #5b489f;
  font-size: 12px;
}
.attachment-chip .icon-btn {
  width: 20px;
  height: 20px;
  margin-left: auto;
}
.composer-footnote {
  padding-top: 6px;
  color: var(--muted);
  font-size: 11px;
}
.approval-note,
.blocker-card {
  margin: 2px 0 15px;
  padding: 10px 11px;
  border: 1px solid #cce7d8;
  border-radius: 9px;
  background: #f3fbf6;
  color: #417057;
  font-size: 14px;
}
.blocker-card {
  border-color: #f0ddb8;
  background: #fffaf0;
  color: #805e26;
}
.approval-note .btn,
.blocker-card .btn {
  min-height: 24px;
  margin-left: 4px;
  padding: 3px 6px;
  font-size: 12px;
}
.review-card > p {
  margin: 0;
  padding: 10px 11px;
  color: #5c5663;
  font-size: 14px;
  line-height: 1.5;
}
.review-top > div {
  min-width: 0;
  flex: 1;
}
.review-top p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}
.review-symbol {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-soft);
  font-weight: 700;
}
.check-line {
  padding: 8px 11px;
  border-top: 1px solid #f0e9d7;
  color: var(--green);
  font-size: 12px;
}
.review-card details {
  border-top: 1px solid #f0e9d7;
}
.review-card summary {
  padding: 8px 11px;
  color: var(--purple);
  cursor: pointer;
  font-size: 12px;
}
.diff-add {
  color: var(--green);
}
.review-card > small {
  display: block;
  padding: 0 11px 10px;
  color: var(--muted);
  font-size: 11px;
}
.rail-header > div {
  min-width: 0;
}
.rail-header strong {
  display: block;
  font-size: 15px;
}
.rail-header .muted {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.tool-intro {
  margin-bottom: 13px;
}
.tool-intro h3 {
  margin: 0 0 3px;
  font-size: 14px;
}
.tool-intro p,
.rail-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.section-eyebrow {
  margin: 2px 0 7px;
  color: #625a72;
  font-size: 12px;
  font-weight: 700;
}
.section-eyebrow + .agent-stack {
  margin-bottom: 15px;
}
.agent-stack {
  display: grid;
  gap: 5px;
}
.agent-card {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px;
  border-radius: 8px;
  text-align: left;
}
.agent-card:hover {
  background: #f3f0fa;
}
.agent-card > div {
  min-width: 0;
  flex: 1;
}
.agent-card strong,
.agent-card span:not(.avatar):not(.status-dot) {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-card strong {
  font-size: 12px;
}
.agent-card span:not(.avatar):not(.status-dot) {
  color: var(--muted);
  font-size: 11px;
}
.activity-item {
  display: flex;
  width: 100%;
  gap: 8px;
  padding: 8px 0 10px 14px;
  text-align: left;
  background: transparent;
}
.activity-item:before {
  left: 1px;
}
.activity-item p {
  margin: 2px 0 0;
  color: #4e4859;
  font-size: 12px;
}
.event-project {
  color: #665b7a;
  font-size: 11px;
  font-weight: 700;
}
.event-project time {
  margin-left: 5px;
  color: var(--muted);
  font-weight: 400;
}
.checkbox-label {
  display: block;
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 12px;
}
.memory-meta {
  margin-bottom: 5px;
  color: #766b89;
  font-size: 11px;
}
.memory-meta .badge {
  float: right;
}
.memory-card h4 {
  margin: 0 0 5px;
  font-size: 14px;
}
.memory-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.memory-card .btn {
  min-height: 27px;
  margin-top: 8px;
  padding: 4px 7px;
  font-size: 12px;
}
.tool-card {
  display: block;
  width: 100%;
  text-align: left;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.tool-card:hover {
  border-color: #cfc5ff;
  background: #faf9ff;
}
.tool-card h4 {
  margin: 4px 0;
  font-size: 14px;
}
.skill-command,
.tool-use {
  display: block;
  color: #6954c5;
  font:
    11px ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
}
.tool-use {
  margin-top: 7px;
  color: var(--muted);
  font-family: inherit;
}
.rail-hint {
  margin-top: 10px;
  padding: 8px;
  border-radius: 7px;
  background: #f5f3f9;
}
dialog {
  padding: 0;
  border: 0;
  background: transparent;
}
dialog[open] {
  display: block;
}
.modal {
  padding: 0;
}
dialog form {
  margin: 0;
}
@media (max-width: 760px) {
  .mobile-menu {
    display: inline-flex;
  }
  .brand .mobile-menu {
    margin-left: auto;
  }
  .sidebar-search {
    padding: 9px;
  }
  .chat-heading {
    gap: 4px;
  }
  .agent-state > span:not(.status-dot):not(.badge) {
    display: none;
  }
  .message-body {
    margin-left: 0;
  }
  .message.user .message-meta,
  .message.user .message-body {
    margin-right: 0;
  }
  .message-actions,
  .message.user .message-actions {
    margin-left: 0;
    margin-right: 0;
  }
  .source-reference {
    margin-left: 0;
  }
  .message.system .message-body {
    margin-left: 0;
  }
  .chat-pane:not(.is-focused) {
    display: none;
  }
}

/* P2 visual refinement: narrow conversation panes retain readable hierarchy. */
.workspace-title strong {
  margin-right: 10px;
}
.workspace-title > span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.demo-strip {
  gap: 9px;
  white-space: normal;
}
.demo-strip > span:not(.demo-label) {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.demo-label {
  flex: 0 0 auto;
  padding: 2px 5px;
  border-radius: 4px;
  background: #eeeaff;
  color: #5946a9;
  font-size: 11px;
  font-weight: 700;
}
.demo-play {
  flex: 0 0 auto;
  color: #5c4aa4;
  font-size: 12px;
  font-weight: 650;
}
.conversations.single {
  grid-template-columns: minmax(0, 1fr);
}
.chat-header {
  min-height: 82px;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
  padding: 10px 17px;
}
.agent-state {
  display: flex;
  font-size: 14px;
}
.agent-state:before {
  display: none;
}
.message-body > p,
.message-body > div:not(.message-meta):not(.message-actions):not(.review-card) {
  padding: 0;
  background: transparent;
  font-size: 16px;
  line-height: 1.7;
}
.message.user .message-body > p,
.message.user
  .message-body
  > div:not(.message-meta):not(.message-actions):not(.review-card) {
  padding: 12px 16px;
  border-radius: 14px 4px 14px 14px;
  background: #f0edff;
}
.message-actions {
  opacity: 1;
}
.message-actions button {
  min-height: 24px;
}
.composer-context {
  white-space: nowrap;
  overflow: hidden;
}
.composer-context span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.composer-context .context-dot {
  flex: 0 0 7px;
}
.activity-rail.closed {
  display: none;
}
.rail-tabs button,
.tool-tabs button {
  font-size: 14px;
}
.project-label,
.section-eyebrow,
.tool-intro h3,
.memory-card h4,
.tool-card h4,
.agent-card strong {
  font-size: 14px;
}
.tool-intro p,
.rail-hint,
.activity-item p,
.todo-row,
.tool-card p,
.memory-card p {
  font-size: 14px;
}
.project-label .muted,
.agent-card span:not(.avatar):not(.status-dot),
.memory-meta,
.memory-card small,
.event-project,
.sidebar-note {
  font-size: 12px;
}
@media (max-width: 1199px) {
  .activity-rail.open,
  .activity-rail.closed.open {
    display: flex;
  }
}
@media (max-width: 760px) {
  .workspace-title > span {
    display: none;
  }
  .demo-strip {
    gap: 6px;
  }
  .demo-label {
    display: none;
  }
  .demo-strip > span:not(.demo-label) {
    font-size: 11px;
  }
  .chat-header {
    min-height: 70px;
    padding: 8px 13px;
  }
  .chat-pane:not(.is-focused) {
    display: none;
  }
}

.chat-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.chat-row .chat-link {
  flex: 1;
  min-width: 0;
}
.pin-button {
  width: 26px;
  height: 28px;
  flex: 0 0 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: #8b83a1;
  font-size: 15px;
  line-height: 1;
}
.pin-button:hover {
  color: var(--purple);
  background: #eae4ff;
}
.pin-button:focus-visible {
  color: var(--purple);
  background: #eae4ff;
}

.message-body {
  font-size: 16px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.message.user .message-body {
  display: block;
  padding: 12px 16px;
  border-radius: 14px 4px 14px 14px;
  background: #f0edff;
  text-align: left;
}
.rail-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
}
.rail-tabs button {
  min-width: 0;
  padding: 6px 2px;
  font-size: 14px;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
}
.rail-tabs button span {
  display: block;
}

.close-sidebar,
.close-tools {
  display: none;
}

/* 抽屜只在中小螢幕覆蓋內容；未開啟時不保留可見或可點擊的邊角。 */
@media (max-width: 1199px) {
  .close-tools {
    display: inline-flex;
  }
  .activity-rail,
  .activity-rail.open,
  .activity-rail.closed.open {
    position: fixed;
    z-index: 70;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(88vw, 360px);
    flex-basis: min(88vw, 360px);
    display: flex;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(100%);
    transition:
      transform 0.22s ease,
      visibility 0s linear 0.22s;
    box-shadow: -12px 0 30px #34275a26;
  }
  body.tools-open .activity-rail,
  body.tools-open .activity-rail.open {
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
    transition: transform 0.22s ease;
  }
  body.tools-open::before {
    content: "";
    position: fixed;
    z-index: 60;
    inset: 0;
    background: #241d3d50;
  }
}

@media (max-width: 900px) {
  .mobile-menu {
    display: inline-flex;
  }
  .close-sidebar {
    display: inline-flex;
    margin-left: auto;
  }
  .workspace {
    position: relative;
  }
  .sidebar {
    position: fixed;
    z-index: 80;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 320px);
    flex-basis: min(86vw, 320px);
    transform: translateX(-100%);
    visibility: hidden;
    pointer-events: none;
    transition:
      transform 0.22s ease,
      visibility 0s linear 0.22s;
    box-shadow: 10px 0 30px #34275a26;
  }
  body.sidebar-open .sidebar {
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
    transition: transform 0.22s ease;
  }
  body.sidebar-open::after {
    content: "";
    position: fixed;
    z-index: 75;
    inset: 0;
    background: #241d3d50;
  }
  .conversations {
    display: block;
  }
  .chat-pane:not(.is-focused),
  .chat-pane.mobile-hidden {
    display: none;
  }
}

@media (min-width: 1200px) {
  body.tools-open::before,
  body.sidebar-open::after {
    content: none;
  }
}

/* 治理視窗的工作量清單在小螢幕可捲動，標頭與操作列維持可見。 */
.modal {
  overflow: hidden;
}
.modal > form {
  max-height: min(700px, 88dvh);
  display: flex;
  flex-direction: column;
}
.modal-body {
  min-height: 0;
  flex: 1 1 auto;
}
.modal-footer {
  flex: 0 0 auto;
}

@media (max-width: 900px) {
  .modal > form {
    max-height: 88dvh;
  }
  .modal-body {
    padding: 14px;
  }
  .modal-footer {
    padding: 11px 14px;
  }
  .tool-card {
    overflow-wrap: anywhere;
  }
}
