/* 产品工作区：导航、模块布局与操作流程；基础控件与颜色位于 styles.css。 */
[hidden] { display: none !important; }
.icon { flex: 0 0 auto; vertical-align: middle; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: .875rem; font-weight: 550; }
.button { min-height: 42px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--panel); text-decoration: none; }
.button:hover { background: var(--surface); }
.button.primary { background: var(--brand); border-color: var(--brand); color: var(--inverse); }
.button.primary:hover { background: var(--brand-hover); }
.icon-button { display: inline-flex; align-items: center; justify-content: center; padding: 9px; min-width: 38px; min-height: 38px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted); text-decoration: none; }
.icon-button:hover { background: var(--surface); color: var(--ink); }
.text-button { border: 0; color: var(--brand); background: transparent; padding: 6px 0; min-height: 36px; }
.center { justify-content: center; }
.skip-link { position: fixed; top: -70px; left: 20px; z-index: 200; padding: 12px; background: var(--panel); }
.skip-link:focus { top: 10px; }
.app-shell { min-height: 100dvh; }
.app-sidebar { position: fixed; inset: 0 auto 0 0; width: 232px; padding: 30px 18px 18px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 30; }
.app-brand { display: flex; align-items: center; gap: 12px; color: var(--ink); font-size: 1.125rem; font-weight: 650; line-height: 1.4; text-decoration: none; margin: 0 8px 42px; }
.app-brand small { display: block; margin-top: 5px; font-size: .75rem; font-weight: 400; color: var(--muted); }
.brand-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--brand); color: white; }
.nav-caption { font-size: .75rem; color: var(--muted); margin: 0 14px 12px; }
.app-nav { display: grid; gap: 7px; }
.app-nav a { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 11px 14px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: .9375rem; line-height: 1.5; }
.app-nav a:hover { background: var(--surface); color: var(--ink); }
.app-nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-short { display: none; }
.sidebar-bottom { margin-top: auto; padding-top: 40px; }
.workspace-identity { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 20px 4px 0; margin-top: 22px; }
.workspace-identity strong { font-size: .8125rem; font-weight: 550; display: block; }
.workspace-identity div > span { font-size: .75rem; color: var(--muted); display: block; margin-top: 4px; }
.workspace-identity .icon-button { margin-left: auto; }
.user-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface); font-size: .875rem; flex-shrink: 0; }
.app-workspace { margin-left: 232px; min-width: 0; }
.app-topbar { display: flex; justify-content: space-between; align-items: center; min-height: 72px; padding: 0 40px; border-bottom: 1px solid var(--line); background: var(--panel); }
.breadcrumb { display: flex; align-items: center; gap: 12px; font-size: .8125rem; color: var(--muted); }
.breadcrumb strong { font-weight: 550; color: var(--ink); }
.breadcrumb-divider { color: var(--control-line); }
.private-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .8125rem; }
.mobile-settings { display: none; }
.app-content { max-width: 1440px; margin: 0 auto; padding: 36px 40px 64px; min-width: 0; outline: none; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.page-heading h1 { font-size: 1.75rem; font-weight: 650; letter-spacing: -.035em; margin: 0; line-height: 1.5; }
.page-heading p { color: var(--muted); font-size: .9375rem; line-height: 1.6; margin: 7px 0 0; }
.eyebrow { color: var(--brand); font-size: .75rem; letter-spacing: .08em; font-weight: 600; margin-bottom: 8px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex-shrink: 0; }
.page-loading { padding: 90px 24px; display: flex; gap: 12px; align-items: center; justify-content: center; color: var(--muted); font-size: .9375rem; }
.loading-dot { height: 18px; width: 18px; border: 2px solid var(--brand-line); border-top-color: var(--brand); border-radius: 50%; animation: rotate .8s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 54px 24px; max-width: 560px; margin: 0 auto; }
.empty-icon { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 20px; color: var(--brand); background: var(--brand-soft); }
.empty-state h2 { font-size: 1.125rem; margin: 0 0 9px; }
.empty-state p { color: var(--muted); margin-bottom: 22px; font-size: .9375rem; }
.empty-state .actions { justify-content: center; }
.login-card .app-brand { margin: 0 0 34px; }
.login-help { margin-top: 26px; color: var(--muted); font-size: .8125rem; }
.login-help summary { cursor: pointer; }
.login-help p { margin: 12px 0 0; }
@media (max-width: 1100px) {
  .app-sidebar { width: 208px; padding-inline: 12px; }
  .app-workspace { margin-left: 208px; }
  .app-content { padding: 28px 26px 52px; }
  .app-topbar { padding-inline: 26px; }
}
@media (max-width: 760px) {
  .app-sidebar { inset: auto 0 0; width: 100%; padding: 0 5px env(safe-area-inset-bottom); border-right: 0; border-top: 1px solid var(--line); box-shadow: 0 -3px 18px rgb(35 44 60 / 3%); }
  .app-sidebar > .app-brand, .app-sidebar > .nav-caption, .sidebar-bottom, .nav-full { display: none; }
  .nav-short { display: block; }
  .app-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; padding: 7px 0; }
  .app-nav a { flex-direction: column; gap: 5px; min-height: 55px; padding: 6px 2px; font-size: .75rem; border-radius: 10px; }
  .app-nav a.active { background: var(--brand-soft); }
  .app-workspace { margin-left: 0; }
  .app-topbar { min-height: 60px; padding: 0 18px; }
  .mobile-settings { display: inline-flex; }
  .private-label { display: none; }
  .app-content { padding: 26px 18px calc(110px + env(safe-area-inset-bottom)); }
  .page-heading { gap: 16px; align-items: flex-start; margin-bottom: 24px; }
  .page-heading h1 { font-size: 1.5rem; }
  .page-heading p { font-size: .875rem; }
  .page-actions { gap: 6px; }
  .page-actions button, .page-actions .button { padding: 9px 12px; }
  #toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
  .empty-state { padding: 40px 12px; }
}

/* 设备：状态与操作在前，连接细节按需展开。 */
.device-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; font-size: .875rem; color: var(--muted); }
.device-toolbar > span { display: flex; align-items: center; gap: 8px; }
.device-toolbar strong { font-weight: 550; color: var(--ink); }
.device-toolbar a, .list-caption a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-size: .8125rem; }
.toolbar-separator { height: 12px; width: 1px; background: var(--line); margin: 0 8px; }
.device-list { display: grid; gap: 24px; }
.device-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-card); min-width: 0; }
.device-body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(270px, 1fr); }
.device-main { padding: 28px 30px 24px; min-width: 0; }
.device-topline, .companion-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.device-topline .eyebrow { margin: 0; color: var(--muted); letter-spacing: .02em; }
.device-overview { display: flex; align-items: center; gap: 20px; margin: 26px 0 20px; }
.device-symbol { width: 76px; height: 84px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); border-radius: 20px; flex-shrink: 0; }
.device-overview h2 { font-size: 1.5rem; line-height: 1.45; font-weight: 650; margin: 0 0 7px; overflow-wrap: anywhere; }
.device-overview p { font-size: .875rem; margin: 0; color: var(--muted); }
.device-quickfacts { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin: 22px 0; color: var(--muted); font-size: .8125rem; }
.device-quickfacts span { display: inline-flex; align-items: center; gap: 7px; }
.device-quickfacts strong { color: var(--ink); font-weight: 550; }
.device-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.device-actions > .icon-button { margin-left: auto; border-color: var(--line); }
.device-actions .primary { padding-inline: 20px; }
.device-live-state { margin-top: 17px; display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.device-state-text { color: var(--muted); font-size: .8125rem; line-height: 1.65; }
.device-state-text.bad { color: var(--danger); }
.device-state-text.warn { color: var(--warning); }
.device-companion { margin: 28px 26px 26px 0; padding: 0 0 0 26px; border-left: 1px solid var(--line); min-width: 0; }
.companion-heading > span { font-size: .8125rem; color: var(--muted); }
.companion-identity { display: flex; align-items: center; gap: 13px; margin-top: 18px; }
.companion-identity h3 { font-size: 1.125rem; margin: 0 0 5px; }
.companion-identity div > span { color: var(--muted); font-size: .8125rem; }
.companion-description { color: var(--muted); font-size: .875rem; line-height: 1.7; margin: 16px 0 20px; }
.companion-memory { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--canvas); border-radius: 12px; padding: 14px; }
.companion-memory div { min-width: 0; }
.companion-memory span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .75rem; }
.companion-memory strong { display: block; font-size: .8125rem; font-weight: 500; margin-top: 7px; overflow-wrap: anywhere; }
.device-card-footer { border-top: 1px solid var(--line); padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.device-apply { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .75rem; color: var(--muted); }
.device-apply .status { font-size: .75rem; }
.device-links { display: flex; align-items: center; gap: 20px; }
.device-links a { display: flex; align-items: center; gap: 6px; font-size: .8125rem; text-decoration: none; color: var(--muted); }
.device-links a:hover { color: var(--brand); }
.device-diagnostics { border-top: 1px solid var(--line); padding: 0 28px; }
.device-diagnostics > summary { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; cursor: pointer; font-size: .75rem; color: var(--muted); }
.device-diagnostics > summary span { color: var(--brand); }
.device-diagnostics[open] { padding-bottom: 20px; }
.diagnostics-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding: 10px 0 20px; }
.diagnostics-grid span { display: block; color: var(--muted); font-size: .75rem; margin-bottom: 6px; }
.diagnostics-grid strong { font-size: .8125rem; font-weight: 500; overflow-wrap: anywhere; }
.full { grid-column: 1 / -1; }
.setup-callout { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 22px 24px; border: 1px solid var(--brand-line); border-radius: 14px; margin-bottom: 22px; background: var(--brand-soft); }
.setup-callout strong { display: block; font-size: 1rem; color: var(--brand-hover); }
.setup-callout p { margin: 7px 0 0; font-size: .875rem; color: var(--muted); }

/* 角色与列表工具。 */
.library-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.segmented-control { display: inline-flex; background: #e9edf5; padding: 4px; border-radius: 11px; gap: 3px; }
.segmented-control button { border: 0; color: var(--muted); background: transparent; min-height: 38px; padding: 8px 17px; border-radius: 8px; }
.segmented-control button.active { color: var(--ink); background: var(--panel); box-shadow: 0 1px 4px rgb(35 44 60 / 8%); }
.segmented-control button span { font-size: .75rem; color: var(--muted); }
.search-box { position: relative; display: flex; align-items: center; gap: 9px; color: var(--muted); min-width: 0; width: 280px; }
.search-box > .icon { position: absolute; left: 13px; pointer-events: none; }
.search-box input { padding-left: 40px; min-height: 44px; width: 100%; font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.category-chips { margin-bottom: 20px; gap: 7px; }
.category-chips button { padding: 6px 13px; min-height: 36px; font-size: .8125rem; border-color: transparent; background: transparent; }
.category-chips [aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand); }
.list-caption { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin: 0 0 18px; color: var(--muted); font-size: .8125rem; }
.list-caption p { margin: 0; }
.role-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.role-grid > .empty-state { grid-column: 1 / -1; }
.role-card { padding: 24px; gap: 0; border-radius: 16px; }
.role-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 24px; }
.role-card-top .tag { font-size: .75rem; background: transparent; padding: 0; }
.role-card h2 { font-size: 1.125rem; margin-bottom: 10px; }
.role-card .role-description { font-size: .9375rem; margin-bottom: 20px; min-height: 3.3em; }
.role-voice { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .8125rem; margin-top: auto; }
.role-usage { font-size: .75rem; line-height: 1.6; color: var(--muted); margin-top: 12px; }
.role-card-actions { display: flex; align-items: center; gap: 8px; margin-top: 20px; border-top: 1px solid var(--line); padding-top: 18px; }
.role-card-actions > .primary { flex: 1; }
.row-menu { position: relative; }
.row-menu > summary { display: grid; place-items: center; min-width: 38px; min-height: 38px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; color: var(--muted); list-style: none; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu[open] > summary { color: var(--brand); background: var(--brand-soft); }
.menu-panel { position: absolute; right: 0; top: calc(100% + 7px); z-index: 25; min-width: 148px; padding: 6px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-raised); border-radius: 11px; display: grid; gap: 3px; }
.menu-panel button { justify-content: flex-start; border: 0; padding: 9px 12px; min-height: 38px; white-space: nowrap; }

/* 长表单以任务分组，标题与保存区保持可见。 */
.product-dialog { padding: 0; width: min(660px, calc(100vw - 32px)); max-height: 90dvh; overflow: hidden; }
.product-dialog > form { display: flex; flex-direction: column; max-height: calc(90dvh - 2px); overflow: hidden; }
.product-dialog .dialog-head { flex-shrink: 0; padding: 22px 26px; margin: 0; border-bottom: 1px solid var(--line); }
.product-dialog .dialog-head h2 { font-size: 1.125rem; line-height: 1.5; }
.product-dialog .dialog-head .icon-button { font-size: 1.35rem; font-weight: 400; }
.product-dialog .dialog-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.product-dialog .dialog-scroll > fieldset { padding: 26px; margin: 0; border: 0; min-width: 0; }
.product-dialog .dialog-actions { flex-shrink: 0; padding: 16px 26px; margin: 0; border-top: 1px solid var(--line); background: var(--panel); align-items: center; }
.save-hint { margin-right: auto; color: var(--muted); font-size: .75rem; }
.product-dialog > form > .inline-error { padding: 12px 26px; background: var(--danger-soft); }
.product-dialog > form > .inline-error:empty { display: none; }
.discard-warning { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 26px; background: var(--warning-soft); font-size: .8125rem; }
.discard-warning span { margin-right: auto; }
.discard-warning button { min-height: 34px; font-size: .8125rem; padding: 7px 10px; }
.grouped-dialog { width: min(840px, calc(100vw - 32px)); }
.form-sections { display: grid; grid-template-columns: 144px minmax(0, 1fr); gap: 28px; min-width: 0; }
.form-section-tabs { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; align-self: start; }
.form-section-tabs button { justify-content: flex-start; border: 0; background: transparent; color: var(--muted); min-height: 42px; padding: 11px 14px; }
.form-section-tabs button[aria-selected="true"] { color: var(--brand); background: var(--brand-soft); }
.form-section-content { min-width: 0; }
.section-intro { margin-bottom: 24px; }
.section-intro h3 { font-size: 1.0625rem; margin: 0 0 7px; }
.section-intro p { margin: 0; font-size: .8125rem; color: var(--muted); }
.form-section .form-grid { gap: 22px 18px; }
.form-note { color: var(--muted); font-size: .875rem; }
.range-value { font-size: .875rem; font-weight: 600; color: var(--brand); text-align: right; }
input[type="range"] { border: 0; }
.help-layout { display: grid; grid-template-columns: minmax(280px, .85fr) minmax(0, 1.15fr); gap: 24px; align-items: start; }
.section-icon { color: var(--brand); display: inline-flex; background: var(--brand-soft); padding: 12px; border-radius: 13px; margin-bottom: 20px; }
.help-start .guide-steps { padding-left: 22px; }
.help-start .guide-steps li { padding: 8px 0; font-size: .9375rem; }
.help-start .guide-steps p { font-size: .875rem; }
.help-footer { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; font-size: .8125rem; color: var(--muted); margin-top: 28px; }
.help-footer a { margin-left: 10px; }
@media (max-width: 1200px) {
  .role-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .device-main { padding: 24px; }
  .device-body { grid-template-columns: minmax(0, 1fr) minmax(250px, .85fr); }
  .device-overview h2 { font-size: 1.3rem; }
  .device-symbol { width: 62px; height: 74px; }
}
@media (max-width: 960px) {
  .device-body { grid-template-columns: 1fr; }
  .device-companion { margin: 0 24px 22px; padding: 20px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .companion-description { margin-bottom: 16px; }
  .help-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .library-header { flex-wrap: wrap; gap: 16px; }
  .search-box { width: 100%; }
  .role-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .device-overview { gap: 16px; margin-top: 22px; }
  .device-main { padding: 21px; }
  .device-card-footer { padding: 14px 20px; flex-wrap: wrap; gap: 12px; }
  .device-links { gap: 18px; }
  .device-quickfacts { gap: 15px; }
  .device-companion { margin-inline: 21px; }
  .device-actions { gap: 8px; }
  .device-actions .primary { padding-inline: 14px; }
  .device-diagnostics { padding-inline: 21px; }
  .diagnostics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setup-callout { flex-direction: column; align-items: flex-start; padding: 20px; gap: 16px; }
  .product-dialog .dialog-head { padding: 18px 20px; }
  .product-dialog .dialog-scroll > fieldset { padding: 20px; }
  .product-dialog .dialog-actions { padding: 14px 20px; gap: 8px; }
  .product-dialog > form > .inline-error, .discard-warning { padding: 12px 20px; }
  .form-sections { grid-template-columns: 1fr; gap: 22px; }
  .form-section-tabs { position: static; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .form-section-tabs button { white-space: nowrap; padding-inline: 12px; font-size: .8125rem; }
  .section-intro { margin-bottom: 20px; }
  .save-hint { max-width: 90px; line-height: 1.5; }
}
@media (max-width: 520px) {
  .role-grid { grid-template-columns: 1fr; }
  .role-card { padding: 22px; }
  .role-card .role-description { min-height: auto; }
  .role-card-top { margin-bottom: 18px; }
  .page-heading:has(.page-actions) { flex-wrap: wrap; }
}

/* 对话采用列表与阅读区，记忆按空间组织。 */
.filter-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.filter-select { width: 190px; }
.filter-select select { font-size: .875rem; }
.filter-bar .search-box { width: 320px; }
.filter-reset { font-size: .8125rem; margin-left: 6px; }
.history-workspace { display: grid; grid-template-columns: 280px minmax(0, 1fr); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; min-height: 560px; }
.history-list { min-width: 0; background: #fbfdff; border-right: 1px solid var(--line); border-radius: 16px 0 0 16px; }
.panel-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .75rem; padding: 20px; }
.panel-label span { background: var(--surface); padding: 2px 7px; border-radius: 5px; }
#session-list { display: grid; gap: 3px; padding: 0 9px 14px; max-height: 660px; overflow-y: auto; }
.session-item { display: flex; flex-direction: column; align-items: stretch; gap: 8px; text-align: left; padding: 16px 13px; border: 1px solid transparent; background: transparent; font-weight: 400; min-width: 0; }
.session-item.active { border-color: var(--brand-line); background: var(--brand-soft); }
.session-title { font-size: .9375rem; color: var(--ink); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-preview { color: var(--muted); font-size: .8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item time { color: var(--muted); font-size: .75rem; }
.history-detail { min-width: 0; display: flex; flex-direction: column; }
.conversation-head { display: flex; align-items: center; gap: 12px; padding: 22px 26px; border-bottom: 1px solid var(--line); }
.conversation-head h2 { font-size: 1.0625rem; margin: 0 0 5px; }
.conversation-head p { font-size: .8125rem; color: var(--muted); margin: 0; }
.mobile-back { display: none; }
.conversation-messages { flex: 1; padding: 22px 26px 34px; background: var(--canvas); border-radius: 0 0 16px; }
.conversation-notice { font-size: .75rem; color: var(--muted); text-align: center; margin-bottom: 28px; }
.message { display: flex; align-items: flex-start; gap: 12px; margin-top: 26px; }
.message.from-user { flex-direction: row-reverse; }
.message-avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); flex-shrink: 0; font-size: .8125rem; }
.from-user .message-avatar { color: var(--muted); background: var(--panel); }
.message-body { flex: 0 1 auto; display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: min(78%, 640px); }
.from-user .message-body { align-items: flex-end; }
.message-author { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: .8125rem; font-weight: 550; margin: 4px 0 8px; }
.from-user .message-author { justify-content: flex-end; }
.message-author time { color: var(--muted); font-size: .75rem; font-weight: 400; }
.message-text { max-width: 100%; padding: 12px 16px; border: 1px solid var(--line); border-radius: 4px 16px 16px; background: var(--panel); color: var(--ink); font-size: 1rem; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.from-user .message-text { background: var(--brand); border-color: var(--brand); color: var(--inverse); border-radius: 16px 4px 16px 16px; }
.message-meta { display: flex; justify-content: space-between; align-self: stretch; gap: 8px; align-items: center; font-size: .75rem; line-height: 1.5; color: var(--muted); margin-top: 6px; }
.message-meta .row-menu summary { min-height: 28px; min-width: 30px; border: 0; }
mark { background: var(--warning-soft); color: var(--ink); border-radius: 3px; }
.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-top: 20px; color: var(--muted); font-size: .8125rem; }
.pagination .button { padding: 7px 12px; min-height: 36px; font-size: .8125rem; }
.disabled-link { opacity: .45; pointer-events: none; }
.memory-workspace { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 26px; align-items: start; }
.space-sidebar { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); min-width: 0; }
.space-nav { display: grid; gap: 4px; padding: 0 9px 12px; }
.space-item { display: flex; align-items: flex-start; gap: 10px; padding: 13px 11px; border-radius: 10px; text-decoration: none; color: var(--muted); }
.space-item:hover { background: var(--canvas); }
.space-item.active { background: var(--brand-soft); color: var(--brand); }
.space-item > span:last-child { min-width: 0; }
.space-item strong { display: block; font-size: .875rem; line-height: 1.55; font-weight: 550; overflow-wrap: anywhere; }
.space-item small { display: block; font-size: .75rem; margin-top: 5px; }
.space-symbol { padding-top: 2px; }
.space-sidebar-note { padding: 16px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; line-height: 1.75; }
.memory-content { min-width: 0; }
.memory-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 24px; }
.memory-heading h2 { font-size: 1.25rem; margin: 12px 0 6px; overflow-wrap: anywhere; }
.memory-heading .tag { display: inline-flex; background: var(--panel); border: 1px solid var(--line); font-size: .75rem; }
.memory-heading p { color: var(--muted); font-size: .8125rem; margin: 0; }
.memory-tools { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 20px; }
.memory-tools .search-box { flex: 1; max-width: 340px; }
.memory-tools > button { flex-shrink: 0; }
.memory-list { display: grid; gap: 14px; }
.memory-item { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; }
.memory-item.is-disabled { background: var(--canvas); }
.memory-item-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.memory-item-top .status { font-size: .75rem; }
.memory-item-top .row-menu summary { min-height: 28px; min-width: 30px; border: 0; }
.memory-item p { font-size: 1rem; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 16px; }
.memory-source { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: .75rem; line-height: 1.6; color: var(--muted); }
.memory-source time { margin-left: auto; }
.context-note { color: var(--muted); font-size: .8125rem; line-height: 1.75; margin: 24px 0 0; }
.context-note a { margin-inline: 4px; }
.filter-summary { font-size: .8125rem; color: var(--muted); }
.filter-summary a { margin-left: 10px; }
.mobile-space-picker { display: none; }
.memory-destination { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-hover); font-size: .875rem; }

/* 服务配置以连接状态为入口，每份表单独立保存。 */
.settings-workspace { display: grid; grid-template-columns: 176px minmax(0, 800px); gap: 34px; align-items: start; }
.settings-nav { display: grid; gap: 8px; position: sticky; top: 24px; }
.settings-nav button, .settings-nav a { display: flex; justify-content: flex-start; align-items: center; gap: 10px; min-height: 44px; padding: 12px 14px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; text-decoration: none; font-size: .875rem; }
.settings-nav button.active { background: var(--brand-soft); color: var(--brand); }
.settings-content { min-width: 0; }
.section-heading { margin-bottom: 22px; }
.section-heading h2 { font-size: 1.25rem; margin: 0 0 7px; }
.section-heading p { margin: 0; font-size: .875rem; line-height: 1.7; color: var(--muted); }
.service-card { background: var(--panel); border: 1px solid var(--line); border-radius: 15px; padding: 24px; margin-bottom: 18px; }
.service-card > header { display: flex; gap: 13px; align-items: center; }
.service-card > header > span:last-child { margin-left: auto; }
.service-icon { background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0; }
.service-card h3 { margin: 0 0 5px; font-size: 1rem; }
.service-card > header p { margin: 0; font-size: .75rem; color: var(--muted); }
.service-card .status { font-size: .75rem; }
.service-description { margin: 18px 0 20px; color: var(--muted); font-size: .875rem; }
.service-state { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; background: var(--canvas); border-radius: 10px; margin-bottom: 20px; }
.service-state > span { font-size: .8125rem; line-height: 1.6; }
.service-state button { flex-shrink: 0; min-height: 36px; padding: 7px 12px; font-size: .8125rem; }
.service-component-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: -8px 0 18px; color: var(--muted); font-size: .75rem; }
.service-component-status > span { display: inline-flex; align-items: center; gap: 5px; }
.service-config { border-top: 1px solid var(--line); padding-top: 16px; }
.service-config summary { color: var(--brand); font-size: .875rem; cursor: pointer; }
.service-config form { margin-top: 22px; }
.service-config fieldset, .preference-card fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
.form-save-row { display: flex; align-items: center; gap: 16px; justify-content: space-between; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-save-row > span { color: var(--muted); font-size: .8125rem; line-height: 1.65; }
.form-save-row > button { flex-shrink: 0; margin-left: auto; }
.form-save-row .save-success { color: var(--success); }
.form-save-row .inline-error { color: var(--danger); }
.service-links { display: flex; flex-wrap: wrap; gap: 18px; font-size: .8125rem; margin-top: 16px; }
.preference-card { padding: 28px; }
.preference-card h3 { font-size: 1rem; margin-bottom: 22px; }
.preference-section { border-top: 1px solid var(--line); padding-top: 22px; margin-top: 8px; }
.preference-section .check-row { padding: 8px 0; }
.preference-section .help { color: var(--muted); font-size: .8125rem; line-height: 1.7; }
.preference-section summary { cursor: pointer; font-weight: 550; font-size: .875rem; }
.account-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 4px; }
.account-card strong { font-size: .9375rem; }
.account-card p { margin: 6px 0 0; color: var(--muted); font-size: .8125rem; }
.voice-process { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 22px 26px; gap: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 15px; }
.voice-process > div { position: relative; padding-left: 44px; }
.voice-process span { position: absolute; top: 0; left: 0; color: var(--brand); background: var(--brand-soft); border-radius: 9px; padding: 8px; font-size: .75rem; }
.voice-process strong { display: block; font-size: .9375rem; margin-top: 1px; }
.voice-process p { color: var(--muted); font-size: .8125rem; margin: 7px 0 0; }
.voice-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 6px; }
.voice-card-actions .primary { margin-left: auto; }
.clone-workspace .clone-settings, .clone-workspace .clone-register { padding: 20px 24px; }
.clone-settings summary { font-size: .875rem; color: var(--muted); }
.clone-register summary { color: var(--brand); font-size: .875rem; }
.clone-settings .help, .clone-register .help, .clone-training .help { color: var(--muted); font-size: .8125rem; line-height: 1.75; }
.clone-card .speaker-id { font-size: .75rem; }
.clone-card .card-header h3 { font-size: 1.125rem; }
.clone-card .help { color: var(--muted); font-size: .8125rem; line-height: 1.8; }
.clone-training summary { font-size: .875rem; }
.voice-library { margin-top: 6px; }
@media (max-width: 1120px) {
  .history-workspace { grid-template-columns: 240px minmax(0, 1fr); }
  .memory-workspace { grid-template-columns: 220px minmax(0, 1fr); gap: 20px; }
  .settings-workspace { grid-template-columns: 150px minmax(0, 1fr); gap: 22px; }
  .voice-process { padding: 20px; gap: 16px; }
}
@media (max-width: 960px) {
  .settings-workspace { grid-template-columns: 1fr; gap: 24px; }
  .settings-nav { display: flex; position: static; gap: 6px; flex-wrap: wrap; }
  .memory-workspace { grid-template-columns: 1fr; }
  .space-sidebar { display: none; }
  .mobile-space-picker { display: block; margin-bottom: 24px; }
}
@media (max-width: 760px) {
  .filter-bar { gap: 9px; }
  .filter-select { width: 100%; }
  .filter-bar .search-box { flex: 1; min-width: 170px; }
  .history-workspace { grid-template-columns: 1fr; min-height: 380px; }
  .history-list { border: 0; }
  #session-list { max-height: none; }
  .history-detail { display: none; }
  .history-workspace.has-selection .history-list { display: none; }
  .history-workspace.has-selection .history-detail { display: flex; }
  .mobile-back { display: inline-flex; }
  .conversation-head { padding: 18px 16px; }
  .conversation-messages { padding: 18px 16px 26px; border-radius: 0 0 16px 16px; }
  .message { gap: 9px; }
  .message-avatar { width: 28px; height: 28px; }
  .message-body { max-width: calc(100% - 52px); }
  .message-text { padding: 11px 14px; font-size: .9375rem; }
  .message-meta { align-items: flex-start; }
  .memory-tools { gap: 9px; }
  .memory-tools .search-box { min-width: 140px; }
  .memory-tools > button { padding-inline: 12px; }
  .memory-item { padding: 18px; }
  .memory-source time { width: 100%; margin-left: 0; padding-left: 20px; }
  .service-card { padding: 20px; }
  .service-card > header { gap: 10px; }
  .service-state { padding: 12px; gap: 10px; }
  .service-icon { width: 40px; height: 40px; }
  .preference-card { padding: 22px; }
  .form-save-row { gap: 12px; align-items: flex-start; }
  .voice-process { gap: 14px; padding: 20px; }
  .voice-process > div { padding-left: 0; }
  .voice-process span { position: static; display: inline-block; margin-bottom: 10px; }
  .voice-process strong { font-size: .875rem; }
  .voice-process p { font-size: .75rem; line-height: 1.65; }
  .clone-workspace .clone-settings, .clone-workspace .clone-register { padding: 18px 20px; }
}

#clone-list > .empty-state { grid-column: 1 / -1; }

/* 统一视觉语言：每个模块有自己的强调色，信息仍保持同一套阅读节奏。 */
#app {
  --page-accent: #514bcf;
  --page-accent-hover: #4039b5;
  --page-accent-soft: #efefff;
  --page-accent-line: #d5d2ff;
}
#app[data-page="devices"] { --page-accent: #0f766e; --page-accent-hover: #0b5e58; --page-accent-soft: #e6f8f3; --page-accent-line: #b9e7dd; }
#app[data-page="roles"] { --page-accent: #7c3aed; --page-accent-hover: #6830c9; --page-accent-soft: #f3eaff; --page-accent-line: #dfc7ff; }
#app[data-page="voices"] { --page-accent: #c24169; --page-accent-hover: #a73157; --page-accent-soft: #ffebf2; --page-accent-line: #fac9d9; }
#app[data-page="history"] { --page-accent: #a95b0a; --page-accent-hover: #8b4807; --page-accent-soft: #fff3df; --page-accent-line: #f2d2a1; }
#app[data-page="memory"] { --page-accent: #087b96; --page-accent-hover: #05677e; --page-accent-soft: #e3f6fb; --page-accent-line: #bce5ef; }
#app[data-page="settings"] { --page-accent: #514bcf; --page-accent-hover: #4039b5; --page-accent-soft: #efefff; --page-accent-line: #d5d2ff; }

.app-sidebar {
  background: linear-gradient(180deg, rgb(255 255 255 / 98%), #f9f9ff 100%);
  box-shadow: 12px 0 34px rgb(48 57 88 / 3%);
}
.brand-icon { background: linear-gradient(145deg, #5954dc, #8a4fd7); box-shadow: 0 8px 18px rgb(90 77 210 / 24%); }
.app-topbar { background: rgb(255 255 255 / 84%); backdrop-filter: blur(14px); }
.app-nav a.active {
  background: var(--page-accent-soft);
  color: var(--page-accent);
  box-shadow: inset 3px 0 var(--page-accent);
}
.app-nav a:hover { background: color-mix(in srgb, var(--page-accent-soft) 55%, white); }
.user-avatar { color: var(--page-accent); background: var(--page-accent-soft); border: 1px solid var(--page-accent-line); }
.workspace-page button.primary,
.workspace-page .button.primary {
  background: var(--page-accent);
  border-color: var(--page-accent);
}
.workspace-page button.primary:hover:not(:disabled),
.workspace-page .button.primary:hover { background: var(--page-accent-hover); border-color: var(--page-accent-hover); }
.workspace-page .text-button,
.workspace-page .eyebrow { color: var(--page-accent); }
.workspace-page .empty-icon { color: var(--page-accent); background: var(--page-accent-soft); }
.page-heading h1 { display: flex; align-items: center; gap: 11px; }
.page-heading h1::before { content: ""; width: 8px; height: 28px; flex: 0 0 auto; border-radius: 99px; background: linear-gradient(180deg, var(--page-accent), color-mix(in srgb, var(--page-accent) 60%, white)); box-shadow: 0 5px 12px color-mix(in srgb, var(--page-accent) 24%, transparent); }
.card, .device-card, .space-sidebar, .service-card, .history-workspace, .voice-process { box-shadow: var(--shadow-card); }

/* 不同角色使用含义明确的本地 SVG 与柔和色块，不再以首字作为头像。 */
.role-card[data-role-tone], .role-avatar[data-role-tone] { --role-accent: #0f766e; --role-soft: #e6f8f3; --role-line: #b9e7dd; }
.role-card[data-role-tone="life"], .role-avatar[data-role-tone="life"] { --role-accent: #0f766e; --role-soft: #e6f8f3; --role-line: #b9e7dd; }
.role-card[data-role-tone="companion"], .role-avatar[data-role-tone="companion"] { --role-accent: #c24169; --role-soft: #ffebf2; --role-line: #fac9d9; }
.role-card[data-role-tone="knowledge"], .role-avatar[data-role-tone="knowledge"] { --role-accent: #3666c8; --role-soft: #eaf1ff; --role-line: #c9dcff; }
.role-card[data-role-tone="story"], .role-avatar[data-role-tone="story"] { --role-accent: #9b5b08; --role-soft: #fff3df; --role-line: #f2d2a1; }
.role-card[data-role-tone="language"], .role-avatar[data-role-tone="language"] { --role-accent: #7c3aed; --role-soft: #f3eaff; --role-line: #dfc7ff; }
.role-card[data-role-tone="music"], .role-avatar[data-role-tone="music"] { --role-accent: #277aa0; --role-soft: #e4f5fb; --role-line: #bce5ef; }
.role-card[data-role-tone] {
  border-color: var(--role-line);
  background: linear-gradient(135deg, var(--role-soft) 0%, var(--panel) 48%);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--role-accent) 8%, transparent);
}
.role-avatar {
  width: 50px;
  height: 50px;
  border: 1px solid var(--role-line, var(--brand-line));
  border-radius: 16px;
  background: var(--role-soft, var(--brand-soft));
  color: var(--role-accent, var(--brand));
  font-size: 0;
}
.role-avatar .icon { width: 23px; height: 23px; }
.role-card-top .tag { display: inline-flex; align-items: center; color: var(--role-accent); font-weight: 600; }
.role-card .role-usage { display: flex; align-items: center; gap: 6px; }
.role-card-actions { border-top-color: color-mix(in srgb, var(--role-line) 72%, var(--line)); }

/* 卡片、空间和服务连接都有独立的视觉入口，避免页面像连续的表单。 */
.device-symbol { background: linear-gradient(145deg, var(--page-accent-soft), white); color: var(--page-accent); border: 1px solid var(--page-accent-line); box-shadow: inset 0 1px rgb(255 255 255 / 90%); }
.device-card { overflow: hidden; }
.device-card::before { content: ""; display: block; height: 3px; background: linear-gradient(90deg, var(--page-accent), transparent 72%); }
.voice-switch { color: var(--page-accent); border-color: var(--page-accent-line); background: var(--page-accent-soft); }
.voice-switch:hover:not(:disabled) { color: var(--page-accent-hover); border-color: var(--page-accent-line); background: color-mix(in srgb, var(--page-accent-soft) 80%, white); }
.space-symbol { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--page-accent-soft); color: var(--page-accent); flex: 0 0 auto; }
.space-item.active .space-symbol { background: var(--page-accent); color: var(--inverse); }
.memory-destination { background: var(--page-accent-soft); color: var(--page-accent-hover); }
.settings-nav button.active { background: var(--page-accent-soft); color: var(--page-accent); }
.settings-content [data-settings-panel="services"] .service-card:nth-of-type(1) .service-icon { color: #0f766e; background: #e6f8f3; }
.settings-content [data-settings-panel="services"] .service-card:nth-of-type(2) .service-icon { color: #9b5b08; background: #fff3df; }
.settings-content [data-settings-panel="services"] .service-card:nth-of-type(3) .service-icon { color: #7c3aed; background: #f3eaff; }
.service-config summary { display: flex; align-items: center; min-height: 40px; padding-block: 8px; }
.faq summary { display: flex; align-items: center; min-height: 42px; padding-block: 8px; }
.voice-process > div:nth-child(1) span { color: #0f766e; background: #e6f8f3; }
.voice-process > div:nth-child(2) span { color: #7c3aed; background: #f3eaff; }
.voice-process > div:nth-child(3) span { color: #c24169; background: #ffebf2; }

/* 对话列表明确区分会话、上下文和每条消息的交付状态。 */
.history-workspace { overflow: hidden; border-color: var(--page-accent-line); background: var(--panel); }
.history-list { background: linear-gradient(180deg, #fffdf9, #fbfcff); }
.panel-label { color: var(--page-accent); font-weight: 650; letter-spacing: .025em; }
.panel-label span { color: var(--page-accent); background: var(--page-accent-soft); }
#session-list { gap: 8px; padding: 0 10px 16px; }
.session-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  grid-template-areas:
    "leading copy"
    ". meta";
  align-items: start;
  column-gap: 10px;
  row-gap: 6px;
  padding: 12px;
  min-height: 84px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: rgb(255 255 255 / 66%);
  transition: transform .15s, background .15s, border-color .15s, box-shadow .15s;
}
.session-item:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--page-accent-line); background: var(--panel); box-shadow: 0 5px 14px rgb(42 50 72 / 6%); }
.session-item.active { border-color: var(--page-accent-line); background: var(--page-accent-soft); box-shadow: 0 5px 15px color-mix(in srgb, var(--page-accent) 12%, transparent); }
.session-leading { grid-area: leading; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; color: var(--page-accent); background: color-mix(in srgb, var(--page-accent-soft) 76%, white); }
.session-item.active .session-leading { color: var(--inverse); background: var(--page-accent); }
.session-copy { grid-area: copy; display: grid; gap: 5px; min-width: 0; padding-top: 1px; }
.session-title { font-size: .875rem; line-height: 1.45; }
.session-preview { font-size: .75rem; }
.session-meta { grid-area: meta; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; padding: 0; color: var(--muted); }
.session-meta time { white-space: nowrap; font-size: .6875rem; }
.session-count { flex: 0 0 auto; padding: 2px 6px; border-radius: 99px; color: var(--page-accent); background: rgb(255 255 255 / 75%); font-size: .6875rem; white-space: nowrap; }
.conversation-head { padding: 20px 26px; background: linear-gradient(90deg, color-mix(in srgb, var(--page-accent-soft) 54%, white), white 70%); }
.conversation-heading { min-width: 0; }
.conversation-kicker { display: inline-flex; align-items: center; gap: 5px; color: var(--page-accent); font-size: .6875rem; font-weight: 650; letter-spacing: .04em; }
.conversation-head h2 { margin-top: 4px; }
.conversation-head p { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.conversation-head p span { display: inline-flex; align-items: center; gap: 5px; }
.conversation-messages { background: linear-gradient(180deg, #fafbfe, #f5f7fb); }
.conversation-notice { display: flex; align-items: center; justify-content: center; gap: 6px; width: fit-content; max-width: 100%; margin-inline: auto; padding: 7px 11px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.message { margin-top: 25px; }
.message-avatar { border: 1px solid var(--brand-line); background: var(--brand-soft); color: var(--brand); box-shadow: 0 3px 8px rgb(53 65 98 / 7%); }
.from-user .message-avatar { color: var(--inverse); border-color: #5651d7; background: linear-gradient(145deg, #6863e8, #4943c5); }
.message-text { box-shadow: 0 4px 12px rgb(39 50 75 / 5%); }
.from-user .message-text { background: linear-gradient(135deg, #625ce0, #4943c9); border-color: #5650d4; box-shadow: 0 6px 14px rgb(73 67 201 / 17%); }
.message-status { display: inline-flex; align-items: center; gap: 5px; }
.message-status.good { color: var(--success); }
.message-status.warn { color: var(--warning); }
.message-status.bad { color: var(--danger); }

/* 小屏优先保证每个控件都有充足宽度；需要保留的次级操作进入更多菜单。 */
@media (max-width: 760px) {
  .app-nav a.active { box-shadow: inset 0 3px var(--page-accent); }
  .page-heading { align-items: center; }
  .page-heading > div:first-child { min-width: 0; }
  .page-actions button, .page-actions .button { min-height: 40px; white-space: nowrap; }
  button:not(.icon-button):not(.text-button), .button { min-height: 40px; padding: 8px 11px; font-size: .8125rem; }
  input, textarea, select { min-height: 42px; }
  .device-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 8px; }
  .device-actions > button { width: 100%; min-width: 0; padding-inline: 9px; white-space: nowrap; }
  .device-actions > .icon-button { width: 40px; min-width: 40px; min-height: 40px; margin-left: 0; padding: 8px; }
  .device-actions .voice-switch { grid-column: 1 / -1; justify-content: flex-start; }
  .device-card-footer { align-items: flex-start; }
  .segmented-control { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
  .segmented-control button { flex: 0 0 auto; padding-inline: 12px; white-space: nowrap; }
  .category-chips { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; padding-bottom: 5px; margin-inline: -2px; }
  .category-chips button { flex: 0 0 auto; white-space: nowrap; }
  .role-card-actions .primary { min-width: 0; }
  .product-dialog .dialog-actions { flex-wrap: wrap; }
  .product-dialog .dialog-actions .save-hint { flex: 1 1 100%; max-width: none; }
  .product-dialog .dialog-actions > button { flex: 1 1 0; }
  .form-save-row { flex-wrap: wrap; }
  .form-save-row > span { flex: 1 1 100%; }
  .form-save-row > button { margin-left: 0; min-width: min(100%, 132px); }
  .history-page.conversation-open > .page-heading,
  .history-page.conversation-open > .filter-bar,
  .history-page.conversation-open > .pagination { display: none; }
  .history-page.conversation-open .history-workspace { border: 0; border-radius: 0; box-shadow: none; margin-inline: -2px; }
  .history-page.conversation-open .conversation-messages { border-radius: 0; padding-bottom: 34px; }
  .history-list { border-radius: 16px; }
  .session-item { grid-template-columns: 32px minmax(0, 1fr); padding: 12px; }
  .session-meta { gap: 8px; }
  .conversation-head { padding: 16px; }
  .conversation-head p { gap: 7px 10px; }
  .conversation-messages { padding: 18px 14px 28px; }
  .conversation-notice { border-radius: 12px; text-align: center; line-height: 1.55; }
  .message-body { max-width: calc(100% - 46px); }
  .message-text { line-height: 1.75; }
  .filter-bar .search-box { width: auto; min-width: 0; flex: 1 1 170px; }
  .filter-bar > button { flex: 0 0 auto; }
  .memory-tools { flex-wrap: wrap; }
  .memory-tools .search-box { flex: 1 1 180px; max-width: none; }
  .service-state { flex-wrap: wrap; }
  .service-state > span { flex: 1 1 180px; }
}
@media (max-width: 620px) {
  .role-grid { grid-template-columns: 1fr; }
  .voice-process { grid-template-columns: 1fr; }
  .voice-process > div { min-height: 40px; }
  .memory-heading { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .app-content { padding-inline: 15px; }
  .page-heading { gap: 12px; }
  .page-heading h1 { font-size: 1.38rem; gap: 8px; }
  .page-heading h1::before { height: 23px; width: 6px; }
  .page-actions { margin-left: auto; }
  .page-actions button, .page-actions .button { padding-inline: 10px; }
  .device-card-footer { flex-direction: column; }
  .device-links { width: 100%; justify-content: space-between; gap: 10px; }
  .device-links a { min-width: 0; white-space: nowrap; }
  .device-quickfacts { gap: 10px 14px; }
  .filter-bar .search-box { width: auto; min-width: 0; flex: 1 1 0; }
  .filter-bar > button { min-width: 72px; }
  .pagination { align-items: flex-start; }
  .pagination .actions { width: 100%; }
  .pagination .actions .button { flex: 1 1 0; }
  .memory-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; }
  .memory-tools .search-box { width: 100%; min-width: 0; }
  .memory-tools > button { width: auto; }
  .service-state > button { flex: 0 0 auto; }
  .settings-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .settings-nav a { grid-column: 1 / -1; }
}

/* 视觉收口：保留原本的中性画布，强调色只用于导航和状态。 */
#app[data-page="history"] { --page-accent: #2868b6; --page-accent-hover: #1f559a; --page-accent-soft: #eaf4ff; --page-accent-line: #c9ddf6; }
.app-workspace { min-height: 100dvh; background: transparent; }
.app-sidebar { background: linear-gradient(180deg, rgb(255 255 255 / 98%), #f9f9ff 100%); }
.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  max-width: none;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}
.segmented-control button {
  width: 100%;
  min-width: 0;
  padding-inline: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.segmented-control button span { margin-left: 2px; white-space: nowrap; }
.library-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  align-items: center;
}
.library-header .search-box { width: 100%; }
.workspace-page .card,
.workspace-page .device-card,
.workspace-page .space-sidebar,
.workspace-page .service-card,
.workspace-page .history-workspace,
.workspace-page .voice-process,
.workspace-page .memory-item,
.workspace-page .clone-settings,
.workspace-page .clone-register {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
}
.workspace-page .role-card[data-role-tone] {
  position: relative;
  background: linear-gradient(135deg, var(--role-soft) 0%, var(--panel) 48%);
  border-color: var(--role-line);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--role-accent) 8%, transparent);
}
.workspace-page .role-card[data-role-tone]::before { display: none; }
.workspace-page .role-card-actions { border-top-color: var(--line); }
.workspace-page .memory-item.is-disabled { background: var(--canvas); }

/* 对话记录采用清爽蓝色和两个独立阅读区，长列表不再拖动整页。 */
.history-page .history-list { background: linear-gradient(180deg, #fbfdff, #eef7ff); }
.history-page .filter-bar {
  display: grid;
  grid-template-columns: minmax(140px, 190px) minmax(0, 1fr) auto;
  align-items: center;
}
.history-page .filter-bar:has(.filter-reset) { grid-template-columns: minmax(140px, 190px) minmax(0, 1fr) auto auto; }
.history-page .filter-bar .filter-select,
.history-page .filter-bar .search-box { width: auto; min-width: 0; }
.history-page .panel-label {
  color: var(--page-accent);
  border-bottom: 1px solid #d9e8f8;
  background: linear-gradient(90deg, #f3f9ff, #ffffff);
}
.history-page .conversation-head { background: linear-gradient(90deg, #eaf4ff, #ffffff 76%); }
.history-page .conversation-messages { background: linear-gradient(180deg, #f7fbff, #eef7ff); }
.history-page .conversation-notice { border-color: #d7e7f8; background: rgb(255 255 255 / 88%); }
.history-page .session-item { background: rgb(255 255 255 / 78%); }
.history-page .session-item:hover:not(:disabled) { border-color: #c9ddf6; background: #ffffff; box-shadow: 0 6px 16px rgb(40 104 182 / 8%); }
.history-page .session-item.active { background: #eaf4ff; border-color: #b9d5f3; box-shadow: 0 6px 16px rgb(40 104 182 / 12%); }
.history-page .from-assistant .message-avatar { color: var(--page-accent); border-color: #c9ddf6; background: #ffffff; }
.history-page .from-assistant .message-text { border-color: #d7e6f7; background: #ffffff; box-shadow: 0 4px 12px rgb(40 104 182 / 6%); }
.history-page .from-user .message-avatar { border-color: #2a66b1; background: linear-gradient(145deg, #3e7fc9, #245ca7); }
.history-page .from-user .message-text { border-color: #2a66b1; background: linear-gradient(135deg, #3a7bc6, #245ca7); box-shadow: 0 7px 16px rgb(36 92 167 / 19%); }
#session-list,
.conversation-messages {
  scrollbar-width: thin;
  scrollbar-color: #b8d3f1 transparent;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
#session-list::-webkit-scrollbar,
.conversation-messages::-webkit-scrollbar { width: 9px; height: 9px; }
#session-list::-webkit-scrollbar-thumb,
.conversation-messages::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 99px; background: #b8d3f1; background-clip: padding-box; }
#session-list:focus-visible,
.conversation-messages:focus-visible { outline: 2px solid var(--page-accent); outline-offset: -2px; }
@media (min-width: 761px) {
  .history-page .history-workspace {
    height: clamp(480px, calc(100dvh - 360px), 640px);
    min-height: 0;
  }
  .history-page .history-list,
  .history-page .history-detail { min-height: 0; }
  .history-page .history-list { display: flex; flex-direction: column; }
  .history-page #session-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }
  .history-page .conversation-messages {
    min-height: 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }
}
@media (max-width: 760px) {
  .library-header { grid-template-columns: 1fr; gap: 14px; }
  .library-header .search-box { width: 100%; }
  .segmented-control { overflow: hidden; }
  .segmented-control button { flex: 1 1 0; }
  .history-page .filter-bar { grid-template-columns: minmax(0, 1fr) auto; }
  .history-page .filter-bar:has(.filter-reset) { grid-template-columns: minmax(0, 1fr) auto; }
  .history-page .filter-bar .filter-select,
  .history-page .filter-bar .filter-reset { grid-column: 1 / -1; width: 100%; margin-left: 0; }
  .history-page .filter-bar .search-box { width: 100%; }
  .history-page:not(.conversation-open) .history-workspace { min-height: 0; }
  .history-page:not(.conversation-open) .history-list {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 330px);
    min-height: 0;
  }
  .history-page:not(.conversation-open) #session-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
  }
  .history-page.conversation-open .history-workspace {
    display: flex;
    height: calc(100dvh - 168px);
    min-height: 360px;
  }
  .history-page.conversation-open .history-detail { flex: 1 1 auto; min-height: 0; }
  .history-page.conversation-open .conversation-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }
}

/* 表单控件保持原生语义，但以统一的层次、状态和选择面板承载交互。 */
.field > .form-control,
.login-card .field > input {
  border-color: color-mix(in srgb, var(--control-line) 58%, var(--line));
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #fbfcff);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 92%);
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.field:focus-within > label { color: var(--page-accent, var(--brand)); }
.field:focus-within > .form-control:not(.ui-select-native),
.login-card .field:focus-within > input {
  border-color: var(--page-accent, var(--brand));
  background: var(--panel);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--page-accent, var(--brand)) 12%, transparent);
  outline: 0;
}
.field > .help { padding-inline: 2px; }
.check-row {
  align-items: flex-start;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  line-height: 1.55;
  transition: background .16s, border-color .16s;
}
.check-row:has(input:checked) {
  border-color: var(--page-accent-line, var(--brand-line));
  background: var(--page-accent-soft, var(--brand-soft));
}
.check-row input[type="checkbox"] { margin-top: 2px; flex: 0 0 auto; }

.ui-select { position: relative; width: 100%; min-width: 0; }
.ui-select-native {
  position: absolute !important;
  inline-size: 1px !important;
  block-size: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  clip-path: inset(50%) !important;
}
.ui-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  border-color: color-mix(in srgb, var(--control-line) 58%, var(--line));
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #fbfcff);
  color: var(--ink);
  text-align: left;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 92%);
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.ui-select-trigger:hover:not(:disabled),
.ui-select.is-open .ui-select-trigger {
  border-color: var(--page-accent, var(--brand));
  background: var(--panel);
}
.ui-select.is-open .ui-select-trigger {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--page-accent, var(--brand)) 12%, transparent);
}
.ui-select-trigger:focus-visible { outline: 0; }
.ui-select-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-select-trigger .icon,
.ui-select-trigger svg { flex: 0 0 auto; width: 16px; height: 16px; color: var(--muted); transition: transform .16s; }
.ui-select.is-open .ui-select-trigger svg { transform: rotate(180deg); color: var(--page-accent, var(--brand)); }
.ui-select-menu {
  position: absolute;
  inset: calc(100% + 7px) 0 auto;
  z-index: 70;
  display: grid;
  gap: 3px;
  max-height: min(280px, calc(100dvh - 160px));
  overflow-y: auto;
  padding: 7px;
  border: 1px solid var(--page-accent-line, var(--brand-line));
  border-radius: 13px;
  background: var(--panel);
  box-shadow: var(--shadow-raised);
  scrollbar-width: thin;
}
.ui-select-option {
  justify-content: flex-start;
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}
.ui-select-option:hover:not(:disabled),
.ui-select-option:focus-visible { background: var(--page-accent-soft, var(--brand-soft)); color: var(--page-accent, var(--brand)); outline: 0; }
.ui-select-option.is-selected { background: var(--page-accent-soft, var(--brand-soft)); color: var(--page-accent, var(--brand)); font-weight: 600; }
.filter-select .ui-select-trigger { min-height: 42px; font-size: .875rem; }
.mobile-space-picker .ui-select { display: block; }

/* 设置页用“主链路、扩展能力、默认偏好”组织功能，避免同级堆叠。 */
.section-kicker { display: inline-block; margin-bottom: 7px; color: var(--page-accent, var(--brand)); font-size: .75rem; font-weight: 650; letter-spacing: .08em; }
.service-overview {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.45fr);
  gap: 24px;
  align-items: center;
  margin-bottom: 22px;
  padding: 22px 24px;
  border: 1px solid var(--page-accent-line, var(--brand-line));
  border-radius: 16px;
  background: linear-gradient(120deg, var(--page-accent-soft, var(--brand-soft)), #ffffff 62%);
  box-shadow: var(--shadow-card);
}
.service-overview-copy h3,
.service-group-heading h3,
.preference-overview h3 { margin: 0 0 7px; font-size: 1.05rem; }
.service-overview-copy p,
.service-group-heading p,
.preference-overview p { margin: 0; color: var(--muted); font-size: .8125rem; line-height: 1.7; }
.service-summary-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.service-summary-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 74px;
  padding: 10px;
  border-color: color-mix(in srgb, var(--page-accent-line, var(--brand-line)) 72%, var(--line));
  border-radius: 12px;
  background: rgb(255 255 255 / 76%);
  text-align: left;
}
.service-summary-item:hover:not(:disabled) { border-color: var(--page-accent-line, var(--brand-line)); background: var(--panel); }
.service-summary-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: var(--page-accent, var(--brand)); background: var(--page-accent-soft, var(--brand-soft)); }
.service-summary-item > span:nth-child(2) { min-width: 0; }
.service-summary-item strong,
.service-summary-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-summary-item strong { font-size: .8125rem; }
.service-summary-item small { margin-top: 3px; color: var(--muted); font-size: .6875rem; }
.service-summary-item.needs-attention .service-summary-icon { color: var(--warning); background: var(--warning-soft); }
.service-summary-item > .icon { color: var(--muted); }
.service-card-primary { position: relative; margin-top: 0; border-color: var(--page-accent-line, var(--brand-line)); overflow: hidden; }
.service-card-primary::before { content: "主链路"; position: absolute; top: 0; right: 20px; padding: 5px 9px; border-radius: 0 0 8px 8px; background: var(--page-accent, var(--brand)); color: var(--inverse); font-size: .6875rem; font-weight: 650; letter-spacing: .04em; }
.service-group { margin-top: 34px; }
.service-group-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 13px; }
.service-group-heading .section-kicker { margin-bottom: 5px; }
.service-stack { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.service-stack .service-card { min-width: 0; margin: 0; padding: 20px; }
.service-card-secondary > header { align-items: flex-start; }
.service-card-secondary .service-description { min-height: 3.4em; margin: 16px 0; }
.service-card[data-service="realtime"] .service-icon { color: #0f766e; background: #e6f8f3; }
.service-card[data-service="search"] .service-icon { color: #9b5b08; background: #fff3df; }
.service-card[data-service="creation"] .service-icon { color: #7c3aed; background: #f3eaff; }
.service-config > summary,
.preference-section > summary {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--page-accent, var(--brand));
  font-weight: 600;
  list-style: none;
}
.service-config > summary::-webkit-details-marker,
.preference-section > summary::-webkit-details-marker { display: none; }
.service-config > summary::after,
.preference-section > summary::after { content: ""; width: 7px; height: 7px; margin-left: auto; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .16s; }
.service-config[open] > summary,
.preference-section[open] > summary { background: var(--page-accent-soft, var(--brand-soft)); }
.service-config[open] > summary::after,
.preference-section[open] > summary::after { transform: rotate(225deg) translateY(-2px); }
.service-config form { margin-top: 18px; }
.preference-overview { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 21px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.preference-overview .section-kicker { margin-bottom: 5px; }
.preference-overview a { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; font-size: .8125rem; text-decoration: none; }

@media (max-width: 760px) {
  .service-overview { grid-template-columns: 1fr; gap: 18px; padding: 19px; }
  .service-summary-list { grid-template-columns: 1fr; }
  .service-summary-item { min-height: 58px; }
  .service-stack { grid-template-columns: 1fr; }
  .service-card-secondary .service-description { min-height: auto; }
  .preference-overview { align-items: flex-start; flex-direction: column; }
  .ui-select-menu { max-height: min(260px, calc(100dvh - 130px)); }
}
