:root {
  color-scheme: light;
  --ink: #251d32;
  --muted: #665e70;
  --line: #e9e4ec;
  --paper: #fcfafc;
  --white: #fff;
  --violet: #5b37a6;
  --violet-dark: #4b298f;
  --violet-pale: #f1eafb;
  --sidebar: #21192f;
  --sidebar-text: #f7f0ff;
  --sidebar-muted: #b7a9c7;
  --green: #2c775e;
  --amber: #805512;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  background: var(--paper);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .54; cursor: wait; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid #9470de; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
a { color: var(--violet-dark); }
small, .muted { color: var(--muted); }
.workspace { display: grid; grid-template-columns: 244px minmax(0, 1fr) 300px; grid-template-rows: minmax(0, 1fr); min-height: 100dvh; height: 100dvh; }
.workspace.profile-closed { grid-template-columns: 244px minmax(0, 1fr); }
.workspace.profile-closed .profile { display: none; }
.sidebar { display: flex; flex-direction: column; background: var(--sidebar); color: var(--sidebar-text); padding: 27px 17px 16px; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-size: 22px; font-weight: 720; letter-spacing: -.75px; }
.brand img { width: 33px; height: 33px; border-radius: 9px; }
.main-nav { display: grid; gap: 3px; margin-top: 38px; }
.nav-item, .person-link { display: flex; width: 100%; align-items: center; gap: 11px; background: none; color: var(--sidebar-muted); text-align: left; border: 1px solid transparent; border-radius: 9px; padding: 10px; font-size: 13px; font-weight: 590; }
.nav-item:hover, .person-link:hover { background: #2c223c; color: white; }
.nav-item.active, .person-link.active { color: white; background: #382951; border-color: #493568; }
.nav-icon { width: 20px; font-size: 17px; color: #cdb3ff; text-align: center; }
.count { margin-left: auto; border-radius: 12px; background: #534174; color: #fff; min-width: 21px; text-align: center; padding: 2px 4px; font-size: 10px; }
.nav-section { display: flex; min-height: 0; flex-direction: column; margin-top: 33px; }
.nav-heading { display: flex; justify-content: space-between; align-items: center; padding: 0 9px; margin-bottom: 8px; color: #c4b5d3; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; font-weight: 680; }
#team { overflow: auto; }
.person-link { margin-bottom: 4px; }
.person-link .presence { margin-left: auto; }
.avatar { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 9px; color: #573690; background: #ece0fa; font-size: 11px; font-weight: 790; }
.avatar.large { width: 47px; height: 47px; font-size: 15px; border-radius: 13px; }
.avatar.tone-1 { color: #23614c; background: #dcf1e6; }
.avatar.tone-2 { color: #91472c; background: #ffe9dc; }
.avatar.tone-3 { color: #385483; background: #e2edff; }
.presence { width: 7px; height: 7px; background: #a497b2; border-radius: 50%; flex: none; }
.presence.idle, .presence.working, .presence.checkpointing { background: #73bd9e; }
.presence.waiting, .presence.attention { background: #d8a55d; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 14px 6px 1px; border-top: 1px solid #42344f; font-size: 12px; }
.sidebar-footer strong, .sidebar-footer small { display: block; }
.sidebar-footer small { color: var(--sidebar-muted); margin-top: 2px; font-size: 10px; }
.sidebar-footer button { margin-left: auto; }
.owner-avatar { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid #6a577f; border-radius: 50%; color: #eee1ff; }
.icon-button { display: inline-grid; place-items: center; color: inherit; background: none; border: 0; border-radius: 7px; padding: 4px; min-width: 28px; min-height: 28px; font-size: 19px; }
.icon-button:hover { background: #ad90d42a; }
.mobile { display: none; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--white); }
.topbar { display: flex; align-items: center; gap: 13px; padding: 0 28px; height: 66px; flex: none; border-bottom: 1px solid var(--line); }
.breadcrumb { color: var(--muted); font-size: 13px; white-space: nowrap; }
.breadcrumb span { margin: 0 7px; color: #a498b1; }
.breadcrumb strong { color: var(--ink); font-weight: 650; }
.outline { color: var(--ink); background: var(--white); border: 1px solid #e5deea; border-radius: 8px; padding: 8px 11px; white-space: nowrap; font-size: 12px; font-weight: 640; }
.outline:hover { border-color: #b8a2d4; background: var(--paper); }
.push-button { margin-left: auto; }
.chat { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 20px 28px; border-bottom: 1px solid var(--line); }
.chat-title, .chat-actions { display: flex; align-items: center; gap: 11px; }
.chat-title { gap: 13px; min-width: 0; }
.chat-title h1 { font-size: 21px; letter-spacing: -.56px; font-weight: 720; overflow-wrap: anywhere; }
.chat-title .muted { margin-top: 4px; font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 650; color: #63596d; white-space: nowrap; }
.status .presence { background: currentColor; }
.status.idle, .status.working, .status.checkpointing { color: var(--green); }
.status.waiting, .status.attention { color: var(--amber); }
.conversation { flex: 1; min-height: 0; overflow: auto; padding: 25px clamp(22px, 4vw, 60px); background: linear-gradient(#fdfbfd, #fff 185px); }
.empty-chat { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; max-width: 470px; min-height: 100%; margin: 0 auto; gap: 14px; padding: 22px 0; }
.welcome-mark { display: grid; place-items: center; width: 62px; height: 62px; border: 1px solid #e8dbf7; border-radius: 19px; color: var(--violet); background: var(--violet-pale); font-size: 31px; }
.empty-chat h2 { font-size: clamp(23px, 3vw, 33px); line-height: 1.13; letter-spacing: -.045em; }
.empty-chat p { color: var(--muted); font-size: 14px; line-height: 1.65; }
#messages { display: grid; gap: 17px; max-width: 820px; margin: 0 auto; }
.message { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.message.self { flex-direction: row-reverse; }
.message-content { min-width: 0; max-width: 88%; }
.message-header { display: flex; align-items: baseline; gap: 9px; margin: 0 2px 5px; }
.message.self .message-header { justify-content: flex-end; }
.message-header strong { font-size: 12px; }
.message time { font-size: 10px; color: var(--muted); }
.message-text { white-space: pre-wrap; word-break: break-word; color: #2e243b; background: #f7f3fa; padding: 11px 14px; border-radius: 2px 12px 12px 12px; font-size: 14px; line-height: 1.6; }
.message.self .message-text { background: #eee4fc; border-radius: 12px 2px 12px 12px; }
.message-summary { padding: 7px 0; color: var(--muted); font-size: 12px; }
.message-summary summary { cursor: pointer; }
.message-summary p { white-space: pre-wrap; margin-top: 6px; line-height: 1.6; }
.message-status { color: var(--muted); font-size: 12px; text-align: center; }
.working { display: flex; align-items: center; gap: 8px; max-width: 820px; margin: 14px auto 0; color: var(--muted); font-size: 12px; }
.working > span:first-child { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #9470de; animation: pulse 1.2s alternate infinite; }
@keyframes pulse { to { opacity: .35; } }
.composer-wrap { flex: none; padding: 13px clamp(20px, 4vw, 60px) max(23px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.composer { max-width: 820px; margin: 0 auto; padding: 10px 10px 8px; border: 1px solid #e3d9ed; border-radius: 13px; box-shadow: 0 4px 12px #49306f0a; }
.composer textarea { display: block; width: 100%; resize: vertical; border: 0; outline: none; background: transparent; padding: 4px 5px; color: var(--ink); min-height: 52px; font-size: 14px; }
.composer textarea:focus-visible { outline: 0; }
.composer:focus-within { border-color: #ac8fe0; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.check input { accent-color: var(--violet); }
.primary { background: var(--violet); border: 1px solid transparent; border-radius: 8px; color: #fff; padding: 9px 13px; font-weight: 680; font-size: 13px; }
.primary:hover { background: var(--violet-dark); }
.primary span { margin-left: 9px; }
.chat-note { max-width: 820px; margin: 0 auto 8px; color: var(--amber); font-size: 12px; line-height: 1.5; }
.profile { overflow: auto; background: #fbf8fc; border-left: 1px solid var(--line); }
.profile > header { display: flex; align-items: center; justify-content: space-between; height: 66px; padding: 0 20px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 680; }
#profile-inner { padding: 20px; }
.profile-person { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.profile-person h2 { font-size: 17px; letter-spacing: -.02em; }
.profile-person .muted { font-size: 11px; margin-top: 3px; }
.profile-section { margin: 19px 0; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.profile-section h3 { font-size: 12px; margin-bottom: 7px; }
.profile-section p, .profile-section dd { color: var(--muted); font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.profile-section dl { display: grid; grid-template-columns: auto minmax(0, 1fr); margin: 0; gap: 6px 12px; }
.profile-section dt { font-size: 12px; font-weight: 640; }
.profile-section dd { margin: 0; text-align: right; }
.profile-actions { display: grid; gap: 8px; }
.profile-actions .outline { text-align: left; }
.collection { flex: 1; min-height: 0; overflow: auto; padding: 30px clamp(22px, 4vw, 59px); }
.collection-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 23px; }
.collection h1 { font-size: 30px; letter-spacing: -.038em; }
.collection h2 { font-size: 16px; margin: 20px 0 10px; }
.card { display: grid; gap: 8px; border: 1px solid var(--line); padding: 15px; border-radius: 11px; margin-bottom: 10px; }
.card h3 { font-size: 15px; overflow-wrap: anywhere; }
.card p, .card small { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.card-actions, .row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.card-actions { margin-top: 4px; }
.tree { list-style: none; padding: 0; }
.tree ul { list-style: none; border-left: 1px solid #ded2e9; margin: 0 0 0 18px; padding-left: 15px; }
.tree-row { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.tree-row .row { flex-wrap: nowrap; min-width: 0; }
.tree-row span { overflow-wrap: anywhere; }
dialog { padding: 20px; border: 1px solid var(--line); border-radius: 16px; width: min(560px, calc(100% - 28px)); max-height: calc(100dvh - 32px); box-shadow: 0 18px 65px #21192f38; color: var(--ink); }
dialog::backdrop { background: #251d3280; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 13px; margin-bottom: 16px; }
.dialog-heading h2 { font-size: 20px; letter-spacing: -.03em; }
.form { display: grid; gap: 12px; }
.form label, .login label { display: grid; align-content: start; gap: 5px; font-size: 12px; font-weight: 670; }
.form .check { display: flex; }
.field, .login input { display: block; width: 100%; min-width: 0; padding: 9px 10px; background: white; border: 1px solid #dcd2e6; border-radius: 7px; color: var(--ink); }
.form textarea { resize: vertical; min-height: 88px; }
.form .primary { justify-self: start; }
.field-group { display: grid; gap: 5px; }
.form small { font-weight: 450; line-height: 1.5; }
.form-error, #login-error { color: #9b243d; font-size: 12px; }
.text-block { white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.6; }
#toast { position: fixed; z-index: 5; bottom: 16px; right: 16px; padding: 11px 14px; max-width: min(420px, calc(100% - 32px)); background: #332445; color: white; border-radius: 9px; font-size: 13px; }
.login { display: grid; place-items: center; min-height: 100dvh; padding: 20px; background: radial-gradient(ellipse at 50% 16%, #f0e5ff, #fbf8fc 58%); }
.login-card { width: min(100%, 410px); background: #fff; padding: 33px; border: 1px solid #e7deef; border-radius: 17px; box-shadow: 0 14px 52px #3c1b6d14; }
.login-brand { padding: 0; }
.login h1 { margin: 23px 0 17px; font-size: 26px; letter-spacing: -.04em; }
.login form { display: grid; gap: 10px; }
.login .primary { justify-self: start; margin-top: 3px; }
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 205px minmax(0, 1fr) 245px; }
  .workspace.profile-closed { grid-template-columns: 205px minmax(0, 1fr); }
  .topbar, .chat-header { padding-left: 20px; padding-right: 20px; }
  .chat-actions { gap: 6px; }
}
@media (max-width: 850px) {
  .workspace, .workspace.profile-closed { grid-template-columns: 190px minmax(0, 1fr); }
  .profile { display: none; position: fixed; right: 0; top: 0; bottom: 0; width: min(300px, 90vw); z-index: 3; box-shadow: -8px 0 35px #251d3226; }
  .workspace.profile-open .profile { display: block; }
}
@media (max-width: 620px) {
  .workspace, .workspace.profile-closed { grid-template-columns: minmax(0, 1fr); }
  .mobile { display: inline-grid; }
  .sidebar { display: none; position: fixed; inset: 0 auto 0 0; width: min(260px, 87vw); z-index: 4; box-shadow: 8px 0 35px #251d324d; }
  .workspace.menu-open .sidebar { display: flex; }
  #close-menu { margin-left: auto; }
  .sidebar-footer { margin-top: auto; }
  .topbar { height: 55px; padding: 0 11px; gap: 5px; }
  .chat-header { padding: 13px; align-items: flex-start; }
  .chat-title h1 { font-size: 17px; }
  #chat-avatar { width: 37px; height: 37px; border-radius: 9px; }
  .chat-actions { flex-wrap: wrap; justify-content: flex-end; }
  .chat-actions .status { order: 3; width: 100%; justify-content: flex-end; }
  .composer-wrap { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0s !important; } }

.device-code { font: 700 2rem var(--mono, monospace); letter-spacing: .12em; overflow-wrap: anywhere; user-select: all; }

.markdown { white-space: normal; overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown pre { overflow-x: auto; padding: 10px; border-radius: 6px; background: #eee9f6; color: #241b31; }
.markdown blockquote { margin-inline: 0; padding-inline-start: 12px; border-inline-start: 3px solid #a79bb9; }
.markdown table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.markdown th, .markdown td { border: 1px solid #c8bed8; padding: 4px 8px; }
