/* 职责：成熟AI应用式任务界面；可读性和单一主操作优先，说明按需展开。按页面顺序组织，样式只来自下方令牌。 */
:root {
  --canvas: #f5f5f7;
  --paper: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #e8e8ed;
  --control-line: #d2d2d7;
  --soft: #f0f0f2;
  --hover: rgb(0 0 0 / 0.045);
  --aside: #fbfbfd;
  --accent: #1d1d1f;
  --accent-hover: #3a3a3c;
  --danger: #a52b32;
  --success: #236a4a;
  --radius-card: 24px;
  --radius-control: 10px;
  /* 投影只有三档：常驻卡片、悬停或聚焦、浮层。 */
  --card: 2px 4px 12px rgb(0 0 0 / 0.08);
  --card-raised: 2px 4px 16px rgb(0 0 0 / 0.14);
  --float: 0 0 0 0.5px rgb(0 0 0 / 0.1), 0 18px 48px -16px rgb(0 0 0 / 0.3);
  --serif: "PACE Han Serif SC", "Noto Serif SC", "Songti SC", STSong, serif;
  --sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --sidebar: 224px;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--canvas);
  font-size: 100%;
  font-synthesis: none;
}

/* ---------- 基础 ---------- */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  line-height: 1.65;
}
[hidden] {
  display: none !important;
}
/* 登录状态确定前两类都不显示；确定后访客只看到登录空态。 */
body:not(.signed-in) .member-only,
body:not(.signed-out) .guest-only {
  display: none !important;
}
::selection {
  background: #dbe7ed;
  color: var(--ink);
}
:focus-visible {
  outline: 2px solid #585858;
  outline-offset: 4px;
}
input:not([type="checkbox"]):focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline-offset: 1px;
  border-color: #8a8a8a;
}
button,
a,
summary,
input,
textarea,
select {
  transition:
    background-color 0.15s,
    border-color 0.15s,
    color 0.15s,
    box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
input,
textarea {
  caret-color: var(--ink);
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button,
select,
summary {
  cursor: pointer;
}
button {
  border: 0;
  background: transparent;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
a {
  color: inherit;
  text-underline-offset: 4px;
}
p,
h1,
h2,
h3 {
  margin: 0;
}
h1,
h2,
.brand {
  font-family: var(--serif);
}
h1 {
  font-size: 2.25rem;
  line-height: 1.4;
  font-weight: 400;
  text-wrap: balance;
}
h2 {
  font-size: 1.25rem;
  line-height: 1.5;
  font-weight: 600;
}
h3 {
  font-size: 1rem;
  line-height: 1.6;
  font-weight: 600;
}
p {
  text-wrap: pretty;
}
small {
  font-size: 0.875rem;
}
svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.sprite {
  display: none;
}
.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: 20;
  top: -80px;
  left: 24px;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 8px;
}
.skip:focus {
  top: 12px;
}
.muted,
.count-label,
.source-tag,
.conversation-state {
  color: var(--muted);
}
.count-label,
.source-tag,
.conversation-state,
.unknowns {
  font-size: 0.875rem;
  line-height: 1.6;
}
.danger {
  color: var(--danger);
}
.reception-online {
  color: var(--success);
}
pre {
  background: var(--canvas);
  padding: 18px;
  border-radius: var(--radius-control);
  overflow-x: auto;
  font:
    14px/1.8 ui-monospace,
    "Cascadia Code",
    monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 18px 0;
}
code {
  font-size: 0.875rem;
}

/* ---------- 控件 ---------- */
.primary,
.secondary,
.quiet,
.text-link,
.browse-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.5;
  min-height: 44px;
}
.primary {
  border-radius: 24px;
  padding: 10px 20px;
  color: var(--paper);
  background: var(--accent);
  border: 1px solid var(--accent);
}
.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.secondary {
  border-radius: 24px;
  padding: 9px 18px;
  background: var(--paper);
  border: 1px solid var(--control-line);
}
.secondary:hover {
  background: var(--soft);
}
.quiet {
  padding: 8px 10px;
  border-radius: 8px;
}
.quiet:hover {
  background: var(--soft);
}
.text-link,
.browse-link {
  color: var(--muted);
}
.text-link:hover,
.browse-link:hover {
  color: var(--ink);
  text-decoration: underline;
}
.text-link svg {
  width: 18px;
  height: 18px;
}
input:not([type="checkbox"]),
textarea,
select {
  min-width: 0;
  border: 1px solid var(--control-line);
  background: var(--paper);
  border-radius: var(--radius-control);
  padding: 12px 14px;
}
input:not([type="checkbox"]),
textarea {
  width: 100%;
}
textarea {
  resize: vertical;
  line-height: 1.75;
}
input::placeholder,
textarea::placeholder {
  color: #707070;
  opacity: 1;
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--ink);
  margin: 0;
  flex-shrink: 0;
}
label {
  display: block;
  font-weight: 500;
  margin-bottom: 10px;
}
details > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  font-weight: 500;
  min-height: 44px;
  list-style: none;
}
details > summary::-webkit-details-marker {
  display: none;
}
details > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  margin-left: 5px;
  transition: transform 0.15s;
}
details[open] > summary::after {
  transform: rotate(225deg) translate(-2px, -1px);
}
details > p {
  color: var(--muted);
  max-width: 65ch;
  margin: 10px 0 16px;
}

/* ---------- 外框：侧栏与主区 ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  padding: 30px 16px 20px;
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.375rem;
  line-height: 1.4;
  font-weight: 600;
  text-decoration: none;
  padding: 4px 12px;
}
.brand img {
  object-fit: contain;
  mix-blend-mode: multiply;
  /* 原图底色为 #fdfdfd，提亮到纯白后在灰色侧栏上不留方块。 */
  filter: brightness(1.02);
  width: 40px;
  height: 40px;
  margin: -5px -6px;
}
.icon-button {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
#nav-toggle {
  display: none;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar nav a,
.sidebar-bottom > a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  width: 100%;
  border-radius: 9px;
  padding: 10px 14px;
  text-decoration: none;
  font-size: 1rem;
  text-align: left;
}
.sidebar nav a:hover,
.sidebar-bottom > a:hover,
.account-button:hover {
  background: var(--hover);
}
.sidebar [aria-current="page"],
.sidebar [aria-current="page"]:hover {
  background: var(--paper);
  box-shadow: var(--card);
  font-weight: 500;
}
.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink);
  margin-left: auto;
}
.sidebar-bottom {
  margin-top: auto;
}
.legal {
  display: flex;
  gap: 18px;
  padding: 12px 14px 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.legal a {
  text-decoration: none;
}
.account-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-top: 16px;
  border-top: 1px solid rgb(0 0 0 / 0.08);
}
.account-button {
  text-align: left;
  padding: 8px 12px;
  min-height: 44px;
  border-radius: 9px;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
main {
  margin-left: var(--sidebar);
  padding: 56px 5vw 64px;
}
.page {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
}

/* ---------- 共用组件 ---------- */
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 0 36px;
}
.page-heading p {
  margin-top: 10px;
  color: var(--muted);
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 22px 0 16px;
}
/* 内容卡：白底、24px 圆角、柔和投影，取代外框。 */
.composer,
.result-card,
.supplier,
.history-list:not(:empty),
.ontology-editor,
.profile-editor,
.save-bar,
.inbox-layout,
.list-card,
.status-card,
.host-item,
.guide-body,
.empty {
  background: var(--paper);
  border-radius: var(--radius-card);
  box-shadow: var(--card);
}
/* 空态：标题 + 一句话 + 一个操作；放进已有卡片时不再成卡。 */
.empty {
  color: var(--muted);
  padding: 56px 40px;
  text-align: center;
}
.empty h2 {
  color: var(--ink);
  margin-bottom: 8px;
}
.empty p {
  max-width: 44ch;
  margin: 0 auto 24px;
}
.empty p:last-child {
  margin-bottom: 0;
}
:is(.inbox-layout, .list-card, .guide-body, dialog) .empty {
  background: none;
  box-shadow: none;
  border-radius: 0;
}
.status {
  font-size: 1rem;
  color: var(--muted);
  margin: 18px 0;
  overflow-wrap: anywhere;
}
.status:empty {
  margin: 0;
}
.is-loading {
  display: flex;
  gap: 10px;
  align-items: center;
}
.is-loading::before {
  content: "";
  display: inline-block;
  height: 14px;
  width: 14px;
  border: 2px solid #bbb;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--soft);
  font-family: var(--serif);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 14px 0;
  overflow-wrap: anywhere;
  font-size: 1rem;
}
.contacts:empty {
  display: none;
}
.contacts a,
.contacts span {
  max-width: 100%;
}
/* 低频和破坏性操作收进浮层菜单，点击外部或选择后关闭。 */
.action-menu {
  position: relative;
}
.action-menu > summary {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
}
.action-menu > summary:hover,
.action-menu[open] > summary {
  background: var(--soft);
  color: var(--ink);
}
.action-menu .menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  right: 0;
  display: flex;
  flex-direction: column;
  min-width: 148px;
  padding: 6px;
  background: var(--paper);
  border-radius: 12px;
  box-shadow: var(--float);
}
.action-menu .menu button {
  justify-content: flex-start;
  width: 100%;
  white-space: nowrap;
}
.toast {
  position: fixed;
  z-index: 30;
  top: 24px;
  left: calc(50% + var(--sidebar) / 2);
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 40px));
  border-radius: 12px;
  padding: 14px 20px;
  background: var(--paper);
  box-shadow: var(--card-raised);
  font-size: 1rem;
  /* 只提示，不拦截下面的点击。 */
  pointer-events: none;
}
dialog {
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: var(--radius-card);
  width: min(680px, calc(100% - 32px));
  max-height: 88vh;
  padding: 36px;
  box-shadow: var(--float);
}
dialog::backdrop {
  background: rgb(0 0 0 / 0.32);
}
.dialog-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
}
.dialog-close:hover {
  background: var(--soft);
}

/* ---------- Connect ---------- */
.connect-main {
  max-width: 760px;
  margin: 0 auto;
}
.connect-start {
  padding-top: clamp(70px, 18vh, 180px);
  text-align: center;
  transition: padding-top 0.25s;
}
/* 有结果后收起留白，让结果回到首屏。 */
.connect-main:has(#connection-result:not(:empty)) .connect-start {
  padding-top: 8px;
}
.connect-start h1 {
  font-size: 2.75rem;
  margin-bottom: 36px;
}
.composer {
  padding: 8px;
  text-align: left;
}
.composer:focus-within {
  box-shadow: var(--card-raised);
}
.composer textarea {
  border: 0;
  border-radius: 18px;
  background: transparent;
  min-height: 116px;
  padding: 15px 17px 8px;
  resize: none;
}
.composer textarea:focus-visible {
  outline: none;
}
.composer-bottom {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  padding: 4px 8px 8px;
}
.browse-link {
  margin-top: 18px;
}
.result-card {
  margin-top: 30px;
  padding: 32px;
  scroll-margin-top: 24px;
}
.result-person {
  display: flex;
  align-items: center;
  gap: 14px;
}
.result-person > div {
  min-width: 0;
}
.result-person h2 {
  overflow-wrap: anywhere;
}
.profile-text {
  margin: 22px 0 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.match-reason {
  margin: 10px 0;
}
.match-reason p {
  white-space: pre-wrap;
}
.unknowns {
  color: var(--muted);
  margin-top: 12px;
}
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}
.history-section {
  position: relative;
  margin-top: 60px;
}
.history-tools {
  position: absolute;
  top: -6px;
  right: 0;
  margin: 0;
}
.history-list:not(:empty) {
  padding: 0 24px;
  margin-top: 8px;
}
.history-item {
  padding: 20px 0;
}
.history-item + .history-item {
  border-top: 1px solid var(--line);
}
.history-item > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
}
.history-item strong {
  font-weight: 500;
  overflow-wrap: anywhere;
}
.history-item small,
.history-item p {
  color: var(--muted);
}
.history-item p {
  margin-top: 8px;
}
#more-history,
#more-supply {
  margin-top: 20px;
}

/* ---------- Discover ---------- */
.searchbar {
  display: flex;
  gap: 12px;
}
.searchbar input {
  flex: 1;
}
.searchbar button {
  flex-shrink: 0;
  white-space: nowrap;
}
#member-search-result:not(:empty) {
  margin-bottom: 8px;
}
.discover-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 24px;
  margin: 12px 0 20px;
}
.source-note {
  color: var(--muted);
  font-size: 0.875rem;
}
.source-note > p {
  font-size: 1rem;
  margin-bottom: 4px;
}
.pace-id-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
.pace-id-row:has(#my-pace-id:empty) {
  display: none;
}
#my-pace-id {
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}
.supply-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 20px;
}
.supplier {
  display: flex;
  flex-direction: column;
  padding: 28px;
  min-width: 0;
}
.supplier:hover {
  box-shadow: var(--card-raised);
}
.supplier > p {
  margin: 18px 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* 操作贴底，同一行卡片的按钮对齐。 */
.supplier > .quiet {
  margin-top: auto;
  align-self: flex-start;
  padding-left: 0;
}

/* ---------- Identity ---------- */
.identity-jump {
  display: none;
  gap: 8px;
  margin-bottom: 20px;
}
.identity-jump svg,
.visibility-tag svg {
  width: 16px;
  height: 16px;
}
.identity-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: start;
  gap: 28px;
}
.ontology-editor,
.profile-editor {
  padding: 36px;
  min-width: 0;
  scroll-margin-top: 24px;
}
.editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 28px;
}
.visibility-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.875rem;
}
.field-group {
  margin-bottom: 24px;
}
.field-group label {
  margin-bottom: 6px;
}
.field-hint {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 10px;
}
/* 输入框随内容增高；不支持的浏览器保留固定高度和手动拖动。 */
.identity-layout textarea {
  min-height: 110px;
}
@supports (field-sizing: content) {
  .identity-layout textarea {
    field-sizing: content;
    min-height: 88px;
    max-height: 420px;
  }
}
.field-facts {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}
.field-facts li {
  color: var(--muted);
  font-size: 0.875rem;
  padding: 2px 0 2px 12px;
  border-left: 2px solid var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.field-facts li + li {
  margin-top: 6px;
}
#identity-sources:not(:empty) {
  margin-top: 8px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
#identity-sources h3 {
  margin-bottom: 8px;
}
#identity-sources ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
#identity-sources li {
  padding: 12px 0;
}
#identity-sources li + li {
  border-top: 1px solid var(--line);
}
#identity-sources small {
  display: block;
  color: var(--muted);
}
#identity-sources p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.contact-editor {
  border: 0;
  padding: 0;
  margin: 8px 0 24px;
  min-width: 0;
}
.contact-editor legend {
  padding: 0;
  font-weight: 500;
  margin-bottom: 6px;
}
.contact-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  grid-template-areas: "kind value remove";
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.contact-row select {
  grid-area: kind;
}
.contact-row input {
  grid-area: value;
}
.contact-row button {
  grid-area: remove;
  min-height: 44px;
  padding: 6px;
  color: var(--muted);
}
.contact-row select,
.contact-row input {
  padding: 12px 10px;
}
#add-contact {
  margin-top: 8px;
  padding-inline: 0;
  color: var(--muted);
}
#add-contact:hover {
  background: none;
  color: var(--ink);
  text-decoration: underline;
}
/* 一个保存条服务两张卡，滚到哪里都能看到状态。 */
.save-bar {
  position: sticky;
  z-index: 4;
  bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
  padding: 10px 10px 10px 24px;
  box-shadow: var(--card-raised);
}
#save-status {
  color: var(--muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}
#save-status.is-error {
  color: var(--danger);
}
@media (max-width: 1180px) {
  .identity-jump {
    display: flex;
  }
  .identity-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Inbox ---------- */
#inbox-back {
  display: none;
  padding-left: 4px;
}
/* 页面高度等于视口；列表与消息各自滚动，输入框始终在底部。 */
.inbox-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: max(520px, calc(100dvh - 210px));
  overflow: clip;
}
.inbox-layout > aside {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  background: var(--aside);
  border-right: 1px solid var(--line);
  padding: 12px;
}
.channel-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border-radius: 12px;
  padding: 10px 12px;
}
.channel-choice + .channel-choice {
  margin-top: 4px;
}
.channel-choice:hover {
  background: var(--hover);
}
.channel-choice.active,
.channel-choice.active:hover {
  background: var(--paper);
  box-shadow: var(--card);
}
.channel-choice .avatar {
  width: 40px;
  height: 40px;
}
.channel-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.channel-text strong {
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.channel-text small {
  color: var(--muted);
}
#more-channels {
  align-self: flex-start;
}
.inbox-toolbar {
  margin-top: auto;
  padding: 12px 4px 0;
  border-top: 1px solid var(--line);
}
.inbox-toolbar > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}
.inbox-toolbar > p {
  font-size: 0.875rem;
  margin: 0 0 8px;
}
.conversation {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 24px 28px;
}
.conversation > .empty {
  margin: auto;
}
.conversation > header {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.conversation-title {
  min-width: 0;
}
.conversation-title h2 {
  overflow-wrap: anywhere;
}
.conversation-tools {
  display: flex;
  gap: 4px;
}
/* 菜单相对整个对话头定位，窄屏也不会伸出卡片。 */
.conversation-tools .action-menu {
  position: static;
}
.peer-menu {
  gap: 4px;
  width: min(380px, 100%);
  padding: 16px 18px !important;
}
.peer-menu p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.conversation-messages {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.conversation-message {
  max-width: 90%;
}
.conversation-message.mine {
  align-self: flex-end;
  background: var(--soft);
  border-radius: 18px;
  padding: 14px 18px;
}
.conversation-message small {
  color: var(--muted);
}
.conversation-message p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-top: 6px;
}
.turn-state {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.conversation-composer {
  flex: none;
}
.conversation-composer > .conversation-state {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
#message-form {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-top: 8px;
}
#message-form textarea {
  min-height: 72px;
  max-height: 200px;
  border-radius: 16px;
  resize: none;
}
@supports (field-sizing: content) {
  #message-form textarea {
    field-sizing: content;
  }
}
#message-form button {
  flex-shrink: 0;
}
.agent-composer {
  margin-top: 4px;
}
.agent-composer label {
  margin-top: 8px;
}
.agent-composer textarea {
  margin: 0 0 12px;
}

/* ---------- Contacts ---------- */
.contact-group + .contact-group {
  margin-top: 32px;
}
.group-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 1.125rem;
  margin: 0 0 12px 4px;
}
.group-title span {
  font-family: var(--sans);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 400;
}
.list-card {
  padding: 0 32px;
}
.contact-item {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  padding: 24px 0;
}
.contact-item + .contact-item {
  border-top: 1px solid var(--line);
}
.contact-info {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.contact-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}
.contact-name h3 {
  font-size: 1.125rem;
}
.contact-name > span {
  font-size: 0.875rem;
}
.contact-presence {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.contact-presence::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.contact-summary {
  color: var(--muted);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.contact-card {
  margin-top: 4px;
}
.contact-card > summary {
  color: var(--muted);
  font-size: 0.875rem;
}
.contact-card p {
  white-space: pre-wrap;
  color: var(--ink);
}
.contact-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
#more-contacts {
  margin-top: 16px;
}
.network-history {
  margin-top: 32px;
}
#friend-candidates:not(:empty) {
  margin-top: 8px;
  padding: 0 32px;
  background: var(--paper);
  border-radius: var(--radius-card);
  box-shadow: var(--card);
}
#friend-candidates > .muted {
  padding: 20px 0;
}
.friend-candidate {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 16px 0;
  overflow-wrap: anywhere;
}
.friend-candidate + .friend-candidate {
  border-top: 1px solid var(--line);
}
#more-friend-candidates {
  margin-top: 12px;
}
#contact-friend-form {
  display: grid;
  gap: 18px;
}
#contact-friend-form h2 {
  padding-right: 40px;
}

/* ---------- Host ---------- */
/* 顶部总览：是否在接待、由谁接待。online 表示长期接待配置，不表示本人在场。 */
.status-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 18px 28px;
  margin-bottom: 24px;
}
#hosts-status {
  font-weight: 500;
  overflow-wrap: anywhere;
}
.host-item {
  padding: 24px 32px 8px;
}
.host-item + .host-item {
  margin-top: 16px;
}
.host-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 4px;
}
.host-heading h2 {
  overflow-wrap: anywhere;
}
.host-logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  flex: none;
}
.host-logo svg {
  width: 24px;
  height: 24px;
}
.host-logo.brand-mark svg {
  fill: currentColor;
  stroke: none;
}
.host-item > .text-link {
  margin-bottom: 16px;
}
.host-endpoint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 18px 0;
}
.host-endpoint + .host-endpoint {
  border-top: 1px solid var(--line);
}
.host-endpoint-info {
  min-width: 0;
  overflow-wrap: anywhere;
}
.host-endpoint-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}
.host-state {
  color: var(--muted);
  font-size: 0.875rem;
}
.host-state.is-primary {
  color: var(--ink);
  background: var(--soft);
  border-radius: 6px;
  padding: 2px 8px;
}
.host-state.is-expired {
  color: var(--danger);
}
.probe-result {
  margin-top: 4px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.host-endpoint-info > small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}
.host-endpoint details {
  margin-top: 6px;
}
.host-endpoint details > summary {
  color: var(--muted);
  font-size: 0.875rem;
}
.host-endpoint details p {
  color: var(--muted);
}
.host-endpoint .contact-actions {
  flex: none;
}

/* ---------- Guide ---------- */
.guide-layout {
  display: grid;
  grid-template-columns: 184px minmax(0, 760px);
  gap: 40px;
  align-items: start;
  max-width: 984px;
}
.guide-nav {
  position: sticky;
  top: 32px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.guide-nav a {
  text-decoration: none;
  min-height: 40px;
  padding: 8px 0 8px 14px;
  border-left: 2px solid transparent;
  color: var(--muted);
}
.guide-nav a:hover {
  color: var(--ink);
}
.guide-nav a[aria-current] {
  color: var(--ink);
  font-weight: 500;
  border-left-color: var(--ink);
}
.guide-body {
  padding: 44px 48px 12px;
  line-height: 1.8;
  min-width: 0;
}
.guide-body section {
  padding: 0 0 32px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 32px;
}
.guide-body section:last-child {
  border-bottom: 0;
}
.guide-body h2 {
  font-size: 1.5rem;
  margin-bottom: 18px;
}
.guide-body h3 {
  font-size: 1.0625rem;
  margin: 28px 0 12px;
}
.guide-body details {
  padding: 6px 0;
}
.guide-body details > :not(summary) {
  margin-top: 12px;
}
.guide-body p,
.guide-body li {
  margin-bottom: 16px;
}
.guide-body ol,
.guide-body ul {
  padding-left: 24px;
}
.guide-body [data-copy] {
  margin-bottom: 20px;
}
.guide-body dt {
  margin-top: 24px;
  font-weight: 600;
}
.guide-body dd {
  margin: 8px 0 0;
  color: var(--muted);
}

/* ---------- 对话框 ---------- */
#login-dialog {
  max-width: 440px;
}
#login-dialog h2,
.detail-header h2 {
  padding-right: 40px;
}
#login-dialog h2 {
  font-size: 1.5rem;
  margin-bottom: 12px;
}
#login-dialog p {
  margin-bottom: 24px;
  color: var(--muted);
}
#login-dialog > a {
  width: 100%;
}
.detail-header h2 {
  font-size: 1.5rem;
  margin-bottom: 10px;
}
.detail-header p {
  margin-top: 12px;
}
.detail-services > h3 {
  font-size: 1.25rem;
  margin: 32px 0 12px;
}
.service-row {
  border-top: 1px solid var(--line);
  padding: 20px 0;
}
.service-row h3 a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.service-row h3 svg {
  width: 16px;
  height: 16px;
}
.service-row p {
  margin-top: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
}
.service-row small {
  display: block;
  margin-top: 12px;
}
.detail-services + p {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ---------- 法律文档 ---------- */
.legal-document main {
  margin: 0 auto;
  max-width: 800px;
  padding: 60px 24px;
}
.legal-document h1 {
  margin: 38px 0 24px;
}
.legal-document h2 {
  margin: 32px 0 12px;
}
.legal-document p {
  margin-bottom: 20px;
  line-height: 1.95;
}

/* ---------- 窄屏 ---------- */
@media (max-width: 1100px) {
  main {
    padding-inline: 32px;
  }
  .ontology-editor,
  .profile-editor {
    padding: 28px;
  }
  .inbox-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .guide-layout {
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 30px;
  }
  .guide-body {
    padding: 36px 32px 8px;
  }
}
@media (max-width: 900px) {
  :root {
    --sidebar: 200px;
  }
  /* 目录吸顶成一行，横向滚动，不再占满一屏。 */
  .guide-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
  .guide-nav {
    top: 0;
    z-index: 6;
    flex-direction: row;
    gap: 20px;
    margin: 0 -32px;
    padding: 0 32px;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--canvas);
    border-bottom: 1px solid var(--line);
  }
  .guide-nav::-webkit-scrollbar {
    display: none;
  }
  .guide-nav a {
    flex: none;
    white-space: nowrap;
    min-height: 44px;
    padding: 10px 0;
    border-left: 0;
    border-bottom: 2px solid transparent;
  }
  .guide-nav a[aria-current] {
    border-bottom-color: var(--ink);
  }
  .guide-body section {
    scroll-margin-top: 72px;
  }
}
@media (max-width: 768px) {
  .sidebar {
    position: sticky;
    inset: 0 0 auto;
    z-index: 10;
    width: 100%;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 8px;
    background: rgb(245 245 247 / 0.92);
    backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid rgb(0 0 0 / 0.06);
  }
  .brand-row {
    gap: 2px;
  }
  .brand {
    padding: 0;
    gap: 7px;
    font-size: 1.25rem;
  }
  .brand img {
    width: 34px;
    height: 34px;
    margin: -4px -5px;
  }
  #nav-toggle {
    display: inline-flex;
  }
  .sidebar #main-nav,
  .sidebar-bottom {
    display: none;
  }
  .sidebar.is-open #main-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-column: 1/-1;
    padding-top: 20px;
    gap: 4px 12px;
  }
  .sidebar.is-open .sidebar-bottom {
    display: block;
    grid-column: 1/-1;
    padding-top: 8px;
  }
  .sidebar-bottom .legal {
    padding-bottom: 12px;
  }
  .account-row {
    padding: 0;
    border: 0;
    grid-column: 2;
    grid-row: 1;
    gap: 0;
    max-width: 132px;
  }
  .account-button {
    max-width: 90px;
    padding: 8px;
    flex: initial;
  }
  #logout {
    padding-inline: 4px;
    font-size: 0.875rem;
  }
  main {
    margin: 0;
    padding: 32px 20px 48px;
  }
  h1 {
    font-size: 1.875rem;
  }
  .page-heading {
    gap: 12px;
    margin-bottom: 28px;
    align-items: baseline;
    flex-wrap: wrap;
  }
  .empty {
    padding: 40px 24px;
  }
  .toast {
    left: 50%;
    top: 80px;
  }
  dialog {
    padding: 28px 22px;
  }

  .connect-start {
    padding-top: 16vh;
  }
  .connect-start h1 {
    font-size: 2rem;
    margin-bottom: 26px;
  }
  .composer textarea {
    padding: 12px;
    min-height: 130px;
  }
  .composer-bottom {
    padding: 4px 4px 7px;
    gap: 8px;
  }
  .composer-bottom .primary {
    padding-inline: 14px;
  }
  .composer-bottom .primary svg {
    width: 18px;
  }
  .result-card,
  .supplier {
    padding: 22px;
  }
  .history-section {
    margin-top: 42px;
  }
  .history-list:not(:empty) {
    padding: 0 18px;
  }
  .history-item > div {
    flex-wrap: wrap;
    gap: 8px;
  }

  .searchbar {
    gap: 8px;
  }
  .searchbar button {
    padding-inline: 18px;
  }
  .supply-grid {
    gap: 16px;
  }

  .ontology-editor,
  .profile-editor {
    padding: 22px 18px;
  }
  .save-bar {
    bottom: 12px;
    padding-left: 18px;
  }

  /* Inbox 单栏：列表和对话互相切换，对话卡占满视口，页面不再二次滚动。 */
  main:has(> #page-channels.in-conversation:not([hidden])) {
    padding-block: 16px;
  }
  #page-channels.in-conversation .page-heading {
    align-items: center;
    margin-bottom: 12px;
  }
  #page-channels.in-conversation #inbox-back {
    display: inline-flex;
  }
  #page-channels.in-conversation h1,
  #page-channels.in-conversation .inbox-layout > aside,
  #page-channels:not(.in-conversation) .conversation {
    display: none;
  }
  .inbox-layout {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }
  /* 顶栏 69 + 上下留白 32 + 返回行 44 + 间距 12，余 4px 防止取整后出现滚动。 */
  #page-channels.in-conversation .inbox-layout {
    height: calc(100dvh - 161px);
  }
  .inbox-layout > aside {
    background: var(--paper);
    border-right: 0;
    overflow: visible;
  }
  .inbox-toolbar {
    margin-top: 12px;
  }
  .conversation {
    padding: 16px 18px;
  }
  .conversation > header {
    padding-bottom: 10px;
  }
  .conversation-messages {
    padding: 16px 0;
    gap: 16px;
  }
  #message-form {
    gap: 8px;
  }
  #message-form textarea {
    min-height: 56px;
    max-height: 140px;
  }
  #message-form button {
    padding-inline: 14px;
  }

  .list-card,
  #friend-candidates:not(:empty) {
    padding: 0 18px;
  }
  .contact-item {
    flex-wrap: wrap;
    gap: 14px;
  }
  .contact-item .contact-actions {
    width: 100%;
  }
  .contact-actions .action-menu .menu {
    left: 0;
    right: auto;
  }
  .status-card {
    padding: 16px 20px;
  }
  .host-item {
    padding: 20px 18px 4px;
  }
  .host-endpoint {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .guide-nav {
    top: 69px;
    margin-inline: -20px;
    padding-inline: 20px;
  }
  .guide-body {
    padding: 24px 20px 4px;
  }
  .guide-body section {
    scroll-margin-top: 140px;
  }
  .legal-document main {
    padding-top: 32px;
  }
}
@media (max-width: 480px) {
  /* 联系方式两行：类型与移除一行，输入框独占一行。 */
  .contact-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "kind remove"
      "value value";
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
  }
  .contact-row select {
    width: 128px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 生命周期本体：固定目录与正文分栏；名片保留独立公开范围。 */
#page-identity .identity-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.knowledge-toolbar { display: flex; gap: 12px; margin: 20px 0; }
.knowledge-toolbar input { flex: 1; min-width: 0; }
.knowledge-workspace { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 28px; min-height: 400px; }
#knowledge-tree { border-right: 1px solid var(--line, #e7e7e7); padding-right: 18px; }
#knowledge-tree h3 { font-size: 14px; color: var(--muted); margin: 24px 10px 8px; }
#knowledge-tree h3:first-child { margin-top: 0; }
#knowledge-tree button { display: block; text-align: left; width: 100%; padding: 10px 12px; background: transparent; border: 0; border-radius: 10px; min-height: 44px; }
#knowledge-tree button[aria-current="page"] { background: var(--soft, #f0f0f0); font-weight: 600; }
.knowledge-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.knowledge-heading h3 { font-size: 18px; margin: 0; }
.knowledge-note { padding: 20px 0; border-bottom: 1px solid var(--line, #e7e7e7); }
.knowledge-note:last-child { border: 0; }
.note-top { display: flex; align-items: center; gap: 12px; }
.note-top input { font-weight: 600; border-color: transparent; padding-left: 0; min-width: 0; flex: 1; }
.note-top span { font-size: 14px; white-space: nowrap; color: var(--muted); }
.knowledge-note textarea { margin: 8px 0; min-height: 100px; width: 100%; }
.knowledge-note details { color: var(--muted); font-size: 14px; }
.note-dates { display: flex; flex-wrap: wrap; gap: 12px; }
.note-dates label { flex: 1; min-width: 150px; }
.note-dates input { width: 100%; font-size: 14px; }
.knowledge-empty { padding: 64px 16px; text-align: center; color: var(--muted); }
.knowledge-empty p { color: var(--ink); font-size: 18px; }
#identity-sources { color: var(--muted); font-size: 14px; margin-top: 20px; }
.identity-notice { background: #f3f0e9; border-radius: 16px; padding: 16px 22px; margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.identity-notice[hidden] { display: none; }
.identity-preview { max-width: 660px; margin: 24px auto; }
.identity-preview h3 { font-size: 28px; }
.identity-preview h4 { margin: 24px 0 6px; font-size: 16px; }
.identity-preview p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
#profile-template-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.profile-edit summary { margin-bottom: 20px; }
.nightly-toggle { display: inline-flex; align-items: center; gap: 6px; margin-left: 18px; font-size: 14px; }
#nightly-status { display: block; color: var(--muted); font-size: 14px; margin-top: 6px; }
@media (max-width: 768px) {
  .knowledge-workspace { grid-template-columns: 1fr; gap: 16px; }
  #knowledge-tree { display: flex; overflow-x: auto; gap: 8px; border-right: 0; padding: 0 0 10px; }
  #knowledge-tree h3 { display: none; }
  #knowledge-tree button { flex: 0 0 auto; width: auto; white-space: nowrap; }
  #profile-template-fields { grid-template-columns: 1fr; }
  .knowledge-heading { flex-wrap: wrap; }
  .identity-notice { align-items: start; flex-direction: column; }
  .nightly-toggle { display: flex; margin: 8px 0 0; }
}
#page-identity .identity-jump { display: flex; margin-bottom: 24px; gap: 12px; }
.identity-jump button[aria-pressed="true"] { background: var(--ink, #252525); color: white; border-color: transparent; }
#page-identity .identity-layout > [hidden] { display: none; }
#knowledge-tree details { margin-bottom: 8px; }
#knowledge-tree summary { font-size: 15px; font-weight: 600; min-height: 44px; }
#knowledge-tree details button { padding-left: 20px; }
@media (max-width:768px) {
  #knowledge-tree details { flex: 0 0 auto; }
  #knowledge-tree details[open] { display: flex; }
  #knowledge-tree details button { padding-left: 12px; }
}
