:root {
  color-scheme: light;
  --ink: #20223a;
  --ink-soft: #505d78;
  --accent: #5146c8;
  --accent-light: #efedfc;
  --surface: #fff;
  --wash: #f3f5fb;
  --rule: #dce2ef;
  --danger: #a12647;
  font: 15px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--wash);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
h1, h2, p { margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid #7968e8;
  outline-offset: 3px;
}

.primary, .quiet {
  border: 0;
  border-radius: 7px;
  padding: 8px 12px;
  font-weight: 600;
  min-height: 38px;
}
.primary { background: var(--accent); color: white; }
.primary:hover:not(:disabled) { background: #4035aa; }
.quiet { background: transparent; color: var(--ink-soft); }
.quiet:hover:not(:disabled) { background: var(--accent-light); color: var(--ink); }
.error { color: var(--danger); font-size: .875rem; }
.error:empty { display: none; }
.muted { color: var(--ink-soft); }

.opening, .sign-in {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.opening { color: var(--ink-soft); }
.sign-in-panel {
  width: min(100%, 410px);
  padding: clamp(24px, 6vw, 44px);
  background: white;
  border: 1px solid var(--rule);
  border-top: 4px solid var(--accent);
  border-radius: 14px;
}
.sign-in-panel h1 { margin: 30px 0 20px; font-size: 1.65rem; line-height: 1.2; letter-spacing: -.035em; }
.sign-in-panel form, .dialog-form { display: grid; gap: 12px; }
.sign-in-panel label, .dialog-form label, .member-filters label { font-weight: 600; }
.sign-in-panel .muted { font-size: .89rem; }
.sign-in-panel button { justify-self: start; margin-top: 6px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 1.15rem; font-weight: 680; letter-spacing: -.025em; }
.brand-mark {
  width: 27px;
  height: 27px;
  position: relative;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-radius: 7px 7px 7px 2px;
  color: #a89afa;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 6px 5px 5px 6px;
  border: 2px solid currentColor;
  border-radius: 3px 3px 3px 0;
}
.sign-in-panel .brand-mark { color: var(--accent); }

.workspace {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  overflow: hidden;
}
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 23px 14px 14px;
  background: var(--ink);
  color: #f7f7ff;
}
.sidebar > .brand { padding: 0 8px; }
.rooms { margin-top: 35px; overflow-y: auto; }
.rooms h2 { margin: 0 8px 7px; font-size: .85rem; font-weight: 560; color: #b7bcd2; }
#room-nav { display: grid; gap: 4px; }
.room-link {
  width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 9px 10px;
  background: transparent;
  color: #d9dff4;
  text-align: start;
  overflow-wrap: anywhere;
}
.room-link[aria-current="page"], .room-link:hover { background: #373960; color: white; }
.account { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 12px 0 0; border-top: 1px solid #40415f; }
#account-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .88rem; }
.account .quiet { color: #d9dff4; padding: 4px 6px; margin-left: auto; white-space: nowrap; font-size: .82rem; }
.account .quiet:hover { color: white; background: #373960; }

.room-shell, .room, .conversation, .thread, .chat-layout { min-width: 0; min-height: 0; }
.room-shell { background: var(--surface); }
.room { height: 100%; display: flex; flex-direction: column; }
.room-header { flex: 0 0 auto; padding: 17px 26px 0; border-bottom: 1px solid var(--rule); }
.room-heading { display: flex; align-items: baseline; gap: 12px; }
.room-heading h1 { font-size: 1.66rem; font-weight: 680; line-height: 1.25; letter-spacing: -.035em; overflow-wrap: anywhere; }
#room-count, .connection { font-size: .82rem; color: var(--ink-soft); }
.connection { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; }
.connection::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #8d8d9c; }
.connection.connected::before { background: #287a69; }
.tabs { display: flex; gap: 19px; margin-top: 5px; overflow-x: auto; scrollbar-width: thin; }
.tabs button { flex: 0 0 auto; border: 0; border-bottom: 2px solid transparent; padding: 10px 2px 9px; background: transparent; color: var(--ink-soft); font-weight: 590; }
.tabs button[aria-current="page"] { border-bottom-color: var(--accent); color: var(--accent); }
.room-error { margin: 8px 26px; }
.room-empty { padding: 32px; }
.room-empty p { color: var(--ink-soft); margin-top: 7px; }

.chat-layout { display: flex; flex: 1; }
.conversation, .thread { display: flex; flex-direction: column; }
.conversation { flex: 1; }
.thread { flex: 0 0 clamp(295px, 34%, 412px); border-left: 1px solid var(--rule); background: #fbfcff; }
.thread-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 16px; border-bottom: 1px solid var(--rule); }
.thread-header h2, .pane-heading h2, dialog h2 { font-size: 1.14rem; line-height: 1.3; letter-spacing: -.02em; }
.thread-header h2 { overflow-wrap: anywhere; min-width: 0; }
.thread-header button { flex-shrink: 0; }
.history { flex: 1; min-height: 0; overflow: auto; padding: 17px 24px 12px; }
.older { align-self: start; margin: 5px 14px 0; font-size: .84rem; }
.thread-history { padding: 13px 13px 14px 18px; }
.empty-note { padding: 16px 4px; color: var(--ink-soft); }
.message { display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: 10px; padding: 10px 4px; }
.conversation .message { max-width: 820px; margin-inline: auto; }
.avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: #e4e9f6;
  color: #354471;
  font-weight: 700;
  font-size: .74rem;
}
.avatar.bot { background: var(--accent-light); color: #4b39a2; border: 1px solid #d6cbfb; border-radius: 6px 6px 6px 1px; }
.account-avatar { width: 27px; height: 27px; border-radius: 8px; }
.message-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 7px; }
.message-author { font-weight: 675; overflow-wrap: anywhere; }
.message-time, .identity-kind { color: var(--ink-soft); font-size: .78rem; }
.identity-kind { padding: 0 5px; border: 1px solid var(--rule); border-radius: 4px; }
.message-text { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 76ch; }
.message-mentions { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.mention-tag { display: inline-block; padding: 1px 6px; border: 0; border-radius: 4px; color: #413494; background: var(--accent-light); font-size: .81rem; overflow-wrap: anywhere; }
.thread-link { background: none; border: 0; color: var(--accent); padding: 4px 0; font-size: .82rem; font-weight: 620; }
.thread-link:hover { text-decoration: underline; }
.thread-history > .message { border-left: 2px solid #dbd3fc; padding-left: 10px; }
.thread-history > .message:first-child { border-left-color: var(--accent); padding-top: 1px; }

.composer { padding: 7px 24px 17px; max-width: 866px; margin-inline: auto; }
.thread .composer { padding-inline: 12px; }
.composer-box { position: relative; border: 1px solid #c6cfe5; border-radius: 9px; background: white; }
.composer-box:focus-within { border-color: #8174d5; }
.composer textarea { display: block; width: 100%; min-height: 54px; max-height: 150px; padding: 9px 11px 0; resize: vertical; border: 0; background: transparent; color: var(--ink); border-radius: 9px; }
.composer textarea:focus-visible { outline: 0; }
.composer-controls { display: flex; justify-content: space-between; align-items: center; padding: 5px 7px; gap: 6px; }
.composer-controls button { min-height: 33px; padding: 5px 9px; font-size: .86rem; }
.chosen-mentions { display: flex; flex-wrap: wrap; gap: 4px; padding: 7px 10px 0; }
.chosen-mentions:empty { display: none; }
.composer-error { margin-top: 5px; }
.mention-picker {
  position: absolute;
  z-index: 3;
  left: 7px;
  bottom: 41px;
  width: min(300px, calc(100% - 14px));
  padding: 7px;
  background: white;
  border: 1px solid var(--rule);
  border-radius: 9px;
  box-shadow: 0 6px 20px #20223a20;
}
input, select, dialog textarea { width: 100%; border: 1px solid #c8d0e1; border-radius: 6px; color: var(--ink); background: white; padding: 8px; }
.mention-options { max-height: 190px; overflow: auto; margin-top: 4px; }
.mention-options button { display: flex; justify-content: space-between; gap: 6px; width: 100%; background: white; border: 0; border-radius: 5px; padding: 6px; text-align: start; overflow-wrap: anywhere; }
.mention-options button:hover { background: var(--accent-light); }

.room-pane { flex: 1; min-height: 0; overflow: auto; padding: 22px 26px; }
.pane-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 850px; margin-bottom: 15px; }
.activity-list, .member-list { list-style: none; margin: 0; padding: 0; max-width: 850px; }
.activity-list li { display: flex; gap: 9px; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--rule); }
.activity-list time { flex-shrink: 0; color: var(--ink-soft); font-size: .8rem; }
.board-heading { max-width: none; }
.task-lanes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 15px; }
.task-lane { min-width: 0; padding: 10px; background: var(--wash); border: 1px solid var(--rule); border-top: 3px solid #8c9ab5; border-radius: 8px; }
.task-lane[data-status="doing"] { border-top-color: #7263d4; }
.task-lane[data-status="review"] { border-top-color: #9b7034; }
.task-lane[data-status="done"] { border-top-color: #287a69; }
.task-lane-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 3px 6px; }
.task-lane-heading h3 { margin: 0; font-size: .95rem; font-weight: 660; }
.task-count, .task-empty, .task-assignee { color: var(--ink-soft); font-size: .82rem; }
.task-cards { display: grid; gap: 7px; list-style: none; margin: 0; padding: 0; }
.task-card { padding: 9px 10px; background: var(--surface); border: 1px solid var(--rule); border-radius: 7px; }
.task-card-title { background: none; border: 0; color: var(--ink); display: block; width: 100%; padding: 0; text-align: start; font-weight: 660; overflow-wrap: anywhere; }
.task-card-title:hover { color: var(--accent); text-decoration: underline; }
.task-assignee { margin-top: 3px; overflow-wrap: anywhere; }
.task-empty { padding: 4px 3px 9px; }
.task-proposed { display: inline-block; margin-top: 6px; padding: 1px 5px; border-radius: 4px; background: var(--accent-light); color: var(--accent); font-size: .77rem; }
.task-dialog { width: min(530px, calc(100vw - 30px)); }
.task-dialog textarea { resize: vertical; max-height: 42dvh; }
.task-field { display: grid; gap: 4px; }
.task-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.task-latest-review { padding: 8px 10px; border: 1px solid var(--rule); border-radius: 6px; overflow-wrap: anywhere; }
.task-latest-review h3 { margin: 0 0 4px; font-size: .9rem; }
.task-latest-review p + p { margin-top: 4px; }
.document-options { min-width: 0; padding: 6px 9px; margin: 0; border: 1px solid var(--rule); border-radius: 6px; }
.document-options > div { max-height: 110px; overflow: auto; }
.dialog-form .document-options label, .member-actions .checked-option { display: flex; align-items: baseline; gap: 6px; overflow-wrap: anywhere; }
.document-options input, .member-actions .checked-option input { width: auto; }
.room-context, .roles, .workspace-list { max-width: 850px; }
.room-context:empty { display: none; }
.workspace-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; }
.workspace-heading h3, .roles summary { margin: 0; font-size: .95rem; font-weight: 650; }
.roles { padding-block: 8px; border-block: 1px solid var(--rule); }
.roles summary { cursor: pointer; }
.workspace-list { margin: 12px 0 0; padding: 0; list-style: none; }
.workspace-list > li { border-bottom: 1px solid var(--rule); }
.workspace-list .muted { flex-shrink: 0; font-size: .82rem; }
.workspace-item { min-width: 0; }
.workspace-fields { display: grid; gap: 10px; }
.workspace-fields textarea { resize: vertical; max-height: 48dvh; }
.doc-text { font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; max-width: 80ch; }
.room-rules { margin-block: 5px; }
.member-filters { display: grid; gap: 4px; margin-bottom: 12px; max-width: 260px; }
.member-filters label { font-size: .83rem; }
.member-line { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto auto; gap: 9px; align-items: center; min-height: 57px; padding: 7px 0; border-bottom: 1px solid var(--rule); }
.member-text { min-width: 0; margin-right: auto; overflow-wrap: anywhere; }
.member-text strong { display: block; font-size: .93rem; font-weight: 660; }
.member-text p, .member-presence, .member-tier { color: var(--ink-soft); font-size: .8rem; }
.member-presence, .member-tier { white-space: nowrap; }
.member-menu[open] { grid-column: 2 / -1; }
.member-menu summary { display: block; width: max-content; margin-inline-start: auto; cursor: pointer; padding: 5px; color: var(--accent); font-weight: 600; font-size: .84rem; border-radius: 4px; }
.member-menu summary::-webkit-details-marker { display: none; }
.member-menu[open] summary { background: var(--accent-light); }
.member-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 6px; margin-top: 6px; padding: 6px; background: white; border: 1px solid var(--rule); border-radius: 8px; }
.member-actions label { display: grid; min-width: 0; max-width: 100%; padding: 5px 7px; font-size: .8rem; }
.member-actions select { max-width: min(100%, 240px); padding: 4px; }
.member-actions button { border: 0; border-radius: 4px; background: white; padding: 6px 7px; text-align: start; font-size: .85rem; }
.member-actions button:hover { background: var(--accent-light); }

dialog { border: 1px solid var(--rule); border-radius: 11px; padding: 20px; width: min(400px, calc(100vw - 30px)); color: var(--ink); }
dialog::backdrop { background: #18193273; }
.dialog-form label { display: grid; gap: 4px; font-size: .89rem; }
.dialog-actions { display: flex; justify-content: end; gap: 7px; }

@media (max-width: 920px) {
  .workspace { grid-template-columns: 171px minmax(0, 1fr); }
  .thread { flex-basis: 290px; }
  .history, .composer { padding-inline: 15px; }
  .task-lanes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .task-lanes { grid-template-columns: minmax(0, 1fr); }
  .tabs { flex-wrap: wrap; gap: 0 clamp(8px, 2.5vw, 14px); overflow-x: visible; }
}
@media (max-width: 700px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 8px 12px 6px; }
  .sidebar > .brand { padding: 0; font-size: 1rem; }
  .sidebar .brand-mark { width: 22px; height: 22px; }
  .sidebar .brand-mark::after { inset: 4px; }
  .rooms { grid-row: 2; grid-column: 1 / -1; margin-top: 4px; }
  .rooms h2, #account-name { display: none; }
  #room-nav { display: flex; overflow: auto; }
  .room-link { flex: 0 0 auto; width: auto; max-width: 75vw; padding: 5px 8px; }
  .account { grid-row: 1; grid-column: 2; border: 0; padding: 0; }
  .account .quiet { min-height: 32px; }
  .room-header { padding: 10px 15px 0; }
  .room-heading { flex-wrap: wrap; gap: 3px 9px; }
  .room-heading h1 { font-size: 1.35rem; }
  .tabs button { padding-top: 6px; }
  .chat-layout:has(.thread:not([hidden])) .conversation { display: none; }
  .thread { flex: 1; border-left: 0; }
  .room-pane { padding: 15px; }
  .member-presence { display: none; }
  .room-error { margin-inline: 15px; }
}
