/* EverBuddy 2026-10 “晨光客厅里的陪伴伙伴”正式界面。
   业务 DOM id 仍由原有 controller / spaces shell 驱动，本文件只负责层级与视觉。 */
:root {
  --companion-line: rgba(53, 70, 61, .15);
  --companion-red: #a94f42;
  --companion-shadow: 0 18px 48px rgba(58, 48, 35, .14);
  --companion-song: STSong, "Songti SC", serif;
  --companion-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

html, body { min-width: 320px; min-height: 100%; background: var(--paper); }
body { color: var(--ink); font: 17px/1.5 var(--companion-sans); overflow-x: hidden; overflow-y: auto; }
button, input, select, textarea { font: inherit; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(196, 138, 74, .62); outline-offset: 3px;
}

.background-container { background-image: url('../images/everbuddy-living-room.png'); filter: saturate(.84) brightness(1.08); }
.background-overlay { background: linear-gradient(180deg, rgba(247,243,234,.72), rgba(247,243,234,.90)); }
.container { width: 100%; min-height: 100dvh; height: auto; padding: 0 0 104px; display: block; }

/* 顶栏：品牌、真实会话状态与用户入口。 */
.companion-topbar {
  position: relative; z-index: 1200; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 76px; padding: 8px max(32px, calc((100vw - 1360px) / 2));
  border-bottom: 1px solid var(--companion-line); background: rgba(255,253,246,.94); backdrop-filter: blur(16px);
}
.companion-brand { display: inline-flex; align-items: center; gap: 12px; width: max-content; min-height: 48px; color: var(--ink); text-decoration: none; }
.brand-seal { position: relative; flex: 0 0 46px; width: 46px; height: 46px; overflow: hidden; border-radius: 12px; background: #f8fbf5; }
/* Keep the official asset intact; its transparent margins sit outside the frame. */
.brand-seal img { position: absolute; width: 110px; height: 110px; max-width: none; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.topbar-language { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 8px 13px; border: 1px solid var(--companion-line); border-radius: 999px; color: var(--ink); background: var(--paper-card); font: inherit; font-size: 15px; white-space: nowrap; cursor: pointer; }
.topbar-language:hover { background: var(--green-mist); }
.topbar-language:disabled { opacity: .55; cursor: wait; }
.topbar-language .language-btn-symbol { display: none; }
.topbar-language .btn-text { display: inline; color: inherit; font: inherit; }
.companion-brand b, .companion-brand small { display: block; }
.companion-brand b { font-size: 18px; }
.companion-brand small { color: var(--ink-soft); font-size: 15px; }
.top-companion-status { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; padding: 0 17px; border: 1px solid var(--companion-line); border-radius: 999px; background: rgba(255,253,246,.9); font-size: 15px; font-weight: 700; }
.top-companion-status .status-dot { width: 10px; height: 10px; animation: none; }
.profile-shortcut { justify-self: end; display: inline-flex; align-items: center; gap: 10px; min-width: 48px; min-height: 48px; padding: 4px 8px; border: 0; border-radius: 999px; color: var(--ink); background: transparent; cursor: pointer; }
.profile-initial { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: #80572b; background: var(--gold-soft); font: 19px/1 var(--companion-song); }
.profile-shortcut b { font-size: 16px; }

/* 首页框架：真实角色舞台 + 安静操作席。 */
.companion-space {
  display: grid; grid-template-columns: minmax(520px, 1.15fr) minmax(400px, .85fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-areas: "stage action" "stage topics" "stage chat" "stage tools";
  gap: 0 42px; width: min(1240px, calc(100vw - 64px)); min-height: 0; height: min(686px, calc(100dvh - 180px));
  margin: 28px auto 0;
}
.companion-stage-surface, #live2d-stage, .connection-status-top, .model-container,
.familiarity-chip { grid-area: stage; }
.companion-stage-surface {
  position: relative; z-index: 1; min-width: 0; min-height: 0; overflow: hidden; border-radius: 28px;
  background: linear-gradient(rgba(255,246,229,.05), rgba(111,72,39,.10)), url('../images/everbuddy-living-room.png') center/cover no-repeat;
  box-shadow: var(--companion-shadow); isolation: isolate;
}
.companion-stage-surface::after { content: ""; position: absolute; inset: auto 0 0; height: 28%; background: linear-gradient(transparent, rgba(58,39,24,.16)); }
.companion-halo { position: absolute; z-index: 2; left: 50%; top: 51%; border-radius: 49% 51% 46% 54%; transform: translate(-50%, -50%) rotate(-2deg); pointer-events: none; }
.halo-outer { width: min(70%, 490px); aspect-ratio: 1; border: 3px solid rgba(196,138,74,.60); box-shadow: 0 0 0 13px rgba(255,224,166,.08), 0 0 70px rgba(196,138,74,.24); }
.halo-inner { width: min(59%, 415px); aspect-ratio: 1; border: 1.5px solid rgba(255,253,246,.80); transform: translate(-50%, -50%) rotate(3deg); }
#live2dPoster { position: absolute; z-index: 3; left: 50%; top: 54%; transform: translate(-50%, -50%); width: min(82%, 440px); max-height: 84%; height: auto; object-fit: contain; pointer-events: none; }
body[data-avatar-state="ready"] #live2dPoster { visibility: hidden; }

/* PIXI may retain inline pixel dimensions while its model is still loading. */
#live2d-stage { position: relative; z-index: 5; align-self: stretch; justify-self: stretch; width: 100%; height: 100%; max-width: 100%; max-height: 100%; min-width: 0; min-height: 0; display: block; pointer-events: auto; }
.connection-status-top { position: relative; z-index: 20; align-self: start; justify-self: start; margin: 22px; pointer-events: none; }
.connection-status-top .status-indicator { position: static; transform: none; display: flex; align-items: center; gap: 12px; max-width: calc(100% - 10px); padding: 11px 16px; border: 1px solid rgba(255,255,255,.78); border-radius: 16px; color: var(--ink); background: rgba(255,253,246,.91); box-shadow: 0 9px 24px rgba(46,58,52,.14); backdrop-filter: blur(15px); }
.status-symbol { display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; color: var(--ink-soft); background: #e9ece7; font-size: 25px; line-height: 1; }
.status-indicator > span:last-child { display: grid; }
.status-indicator b { font-size: 17px; }
.status-indicator small { color: var(--ink-soft); font-size: 15px; font-weight: 400; }

.model-container { position: relative; z-index: 30; inset: auto; width: 100%; height: 100%; transform: none; pointer-events: none; }
.model-container .model-loading { background: transparent; height: auto; top: auto; bottom: 18px; }
.live2d-fallback { position: absolute; inset: auto 12px 12px; z-index: 40; display: grid; place-items: end center; pointer-events: none; }
.live2d-fallback-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; justify-items: stretch; text-align: left; gap: 4px 10px; width: 100%; max-width: none; min-height: 0; padding: 10px 14px; border: 1px solid rgba(255,255,255,.82); border-radius: 16px; background: rgba(255,253,246,.94); backdrop-filter: blur(16px); }
.live2d-fallback-avatar { display: none; }
.live2d-fallback-card h2 { margin: 0; color: var(--ink); font-size: 14px; }
.live2d-fallback-card p { margin: 0; color: var(--ink-soft); font-size: 12px; }
.live2d-fallback-card .live2d-retry { grid-column: 2; grid-row: 1 / span 2; align-self: center; margin: 0; padding: 0 10px; font-size: 13px; }

.familiarity-chip { position: relative; z-index: 22; align-self: end; justify-self: start; left: auto; top: auto; margin: 0 0 22px 22px; padding: 7px 15px 7px 7px; border: 1px solid rgba(255,255,255,.75); border-radius: 999px; background: rgba(255,253,246,.92); box-shadow: 0 8px 22px rgba(46,58,52,.14); }
.familiarity-heart { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: #a65e3c; background: var(--gold-soft); font-size: 18px; }
.familiarity-info { gap: 0; }
.familiarity-info b { font-size: 16px; }
.familiarity-info small { color: var(--ink-soft); font-size: 15px; }
.familiarity-bar { display: none; }

.chat-container {
  grid-area: chat; position: relative; z-index: 24; align-self: stretch; justify-self: stretch;
  display: flex; flex-direction: column; justify-content: flex-end; left: auto; right: auto; bottom: auto;
  width: 100%; min-width: 0; min-height: 0; margin: 0; padding: 12px 36px 16px;
  overflow: hidden; pointer-events: auto; background: rgba(255,253,246,.96);
}
.chat-heading { flex: 0 0 auto; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
.chat-heading h2 { margin: 0; font-size: 19px; color: var(--green-deep); }
.chat-heading > span { color: var(--ink-soft); font-size: 13px; }
.chat-session-details { flex: 0 0 auto; max-height: 120px; margin-bottom: 10px; overflow-y: auto; border-bottom: 1px solid var(--companion-line); }
.chat-session-details summary { min-height: 40px; padding: 8px 0; color: var(--ink-soft); font-size: 14px; cursor: pointer; }
.chat-session-details .voiceprint-status { margin: 0 0 8px; }
.chat-stream {
  flex: 1 1 auto; width: 100%; min-height: 0; max-height: none; margin: 0; padding: 2px 2px 10px;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; overflow-anchor: none;
  scrollbar-color: rgba(53,90,78,.42) transparent; pointer-events: auto;
}
.chat-message { display: flex; flex: 0 0 auto; width: 100%; }
.chat-latest { flex: 0 0 auto; align-self: center; min-height: 44px; margin: 4px 0; padding: 7px 18px; border: 1px solid var(--companion-line); border-radius: 999px; color: var(--green-deep); background: var(--green-mist); cursor: pointer; font-size: 14px; }
.chat-latest[hidden] { display: none; }
.chat-message.ai { justify-content: flex-start; }
.chat-message.user { justify-content: flex-end; }
.chat-message.system { justify-content: center; }
.chat-message .message-bubble, .chat-message.ai .message-bubble, .chat-message.user .message-bubble {
  width: fit-content; max-width: 88%; padding: 11px 15px; border: 1px solid rgba(53,70,61,.10); border-radius: 16px;
  color: var(--ink); background: #f3eee3; box-shadow: 0 5px 14px rgba(46,58,52,.08);
  font-size: 17px; line-height: 1.5; overflow-wrap: anywhere; text-shadow: none;
}
.chat-message.user .message-bubble {
  color: #fffdf6; background: rgba(39,66,58,.94); border-color: transparent;
  box-shadow: 0 7px 18px rgba(39,66,58,.16);
}
.chat-message.system .message-bubble { color: var(--ink-soft); background: transparent; box-shadow: none; }
.chat-message.has-reply-feedback { flex-direction: column; align-items: flex-start; }
.chat-message.has-reply-feedback .message-bubble { align-self: flex-start; }
.reply-feedback { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; max-width: 100%; padding: 3px 0 0 5px; }
.reply-feedback-button { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 36px; height: 36px; padding: 7px; border: 1px solid transparent; border-radius: 9px; color: var(--ink-soft); background: transparent; cursor: pointer; }
.reply-feedback-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.reply-feedback-button:hover, .reply-feedback-button[aria-pressed="true"] { color: var(--green-deep); background: var(--green-mist); }
.reply-feedback-button[aria-pressed="true"] { border-color: var(--companion-line); }
.reply-feedback-button[aria-pressed="true"] svg { fill: currentColor; fill-opacity: .16; }
.reply-feedback-button:focus-visible, .reply-feedback-retry:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.reply-feedback-button:disabled { cursor: wait; opacity: .5; }
.reply-feedback-status { min-width: 0; max-width: 100%; color: var(--ink-soft); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.reply-feedback-retry { min-height: 32px; padding: 3px 7px; border: 0; border-radius: 6px; color: var(--green-deep); background: var(--green-mist); cursor: pointer; font-size: 12px; }
.reply-feedback-retry[hidden] { display: none; }
@media (max-width: 600px) { .reply-feedback-button { width: 44px; height: 44px; } }
.transcript-pending { align-items: flex-end; gap: 7px; }
.transcript-status { flex: 0 0 auto; margin-bottom: 4px; color: var(--ink-soft); text-shadow: none; }
.chat-transcript-preview { flex: 0 0 auto; min-width: 0; margin: 4px 0 8px; padding: 10px 14px; border: 1px solid var(--companion-line); border-radius: 14px; color: var(--ink); background: var(--green-mist); }
.chat-transcript-preview[hidden] { display: none; }
.chat-transcript-preview b { display: block; margin-bottom: 3px; color: var(--ink-soft); font-size: 13px; }
.chat-transcript-preview span { display: block; max-height: 72px; overflow-y: auto; overflow-wrap: anywhere; font-size: 16px; line-height: 1.5; }
.chat-ipt { flex: 0 0 auto; pointer-events: auto; }
.chat-ipt input { min-height: 50px; font-size: 16px; }
.chat-quick-actions { display: none; }

.companion-welcome { grid-area: action; position: relative; z-index: 20; left: auto; top: auto; transform: none; display: block; width: 100%; padding: 34px 36px 22px; border: 0; border-radius: 28px 28px 0 0; background: rgba(255,253,246,.96); box-shadow: var(--companion-shadow); animation: none; }
.greeting-copy .eyebrow { color: #a36a31; font-size: 15px; letter-spacing: .03em; }
.companion-welcome h2 { margin: 7px 0 6px; color: var(--green-deep); font: 44px/1.04 var(--companion-song); letter-spacing: -.035em; }
.companion-welcome p:last-child { margin: 0; color: var(--ink-soft); font-size: 17px; }
.companion-welcome-cta { display: flex; align-items: center; justify-content: center; gap: 14px; width: 100%; min-height: 76px; margin-top: 28px; padding: 10px 20px; border-radius: 19px; background: var(--green-deep); box-shadow: 0 14px 28px rgba(39,66,58,.22); text-align: left; }
.companion-welcome-cta > span:last-child { display: grid; }
.companion-welcome-cta b { font-size: 21px; }
.companion-welcome-cta small { color: rgba(255,255,255,.78); font-size: 15px; }
.primary-icon { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.45); border-radius: 50%; font-size: 24px; }
.voiceprint-status { flex: 0 0 auto; padding: 9px 12px; margin-bottom: 8px; border-radius: 12px; background: var(--green-mist); color: var(--green-deep); overflow-wrap: anywhere; }
.voiceprint-status:not([hidden]) { display: grid; gap: 3px; }
.voiceprint-status[hidden] { display: none; }
.voiceprint-status strong { font-size: 14px; }
.voiceprint-status small { font-size: 12px; line-height: 1.5; color: var(--ink-soft); }
.call-note { align-items: center; gap: 14px; margin-top: 10px; padding: 14px 16px; border-radius: 16px; background: var(--green-mist); }
.call-note:not([hidden]) { display: flex; }
.call-note > span:last-child { display: grid; flex: 1; }
.call-note b { color: var(--green-deep); font-size: 18px; }
.call-note small { color: var(--ink-soft); font-size: 15px; }
.voice-bars { display: flex; align-items: center; gap: 4px; height: 32px; }
.voice-bars i { width: 4px; height: 9px; border-radius: 99px; background: var(--green); animation: companion-bars 1.2s ease-in-out infinite; }
.voice-bars i:nth-child(2), .voice-bars i:nth-child(4) { animation-delay: -.35s; }
.voice-bars i:nth-child(3) { animation-delay: -.7s; }

.immersive-entry { grid-area: topics; position: relative; z-index: 20; left: auto; bottom: auto; transform: none; width: 100%; padding: 0 36px 20px; border-radius: 0; background: rgba(255,253,246,.96); }
.immersive-entry[hidden] { display: none; }
.topic-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.topic-heading b { font-size: 17px; }
.topic-heading span { color: var(--ink-soft); font-size: 15px; }
.quick-topics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 0; }
.topic-btn { display: flex; justify-content: flex-start; gap: 10px; min-width: 0; min-height: 52px; padding: 6px 12px; border-radius: 14px; background: #fbf7ed; box-shadow: none; }
.topic-btn span { display: grid; place-items: center; width: 31px; height: 31px; flex: 0 0 auto; border-radius: 50%; color: #8a5c2c; background: var(--gold-soft); font-size: 16px; }
.topic-btn b { min-width: 0; font: 700 16px/1.2 var(--companion-sans); white-space: nowrap; }

.control-bar { grid-area: tools; position: relative; z-index: 20; left: auto; bottom: auto; transform: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: 100%; padding: 16px 36px 28px; border: 0; border-top: 1px solid var(--companion-line); border-radius: 0 0 28px 28px; background: rgba(255,253,246,.96); box-shadow: var(--companion-shadow); backdrop-filter: none; }
body:not([data-call-active="true"]) .control-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.control-btn { width: 100%; min-width: 0; height: 52px; min-height: 52px; flex-direction: row; gap: 8px; border: 1px solid var(--companion-line); border-radius: 14px; color: var(--green-deep); background: transparent; }
.control-btn .btn-icon { width: 20px; height: 20px; margin: 0; }
.control-btn .btn-text { display: inline; color: inherit; font-size: 15px; }
.language-btn-symbol { width: 25px; height: 25px; margin: 0; background: transparent; font-size: 17px; }
.control-btn.dial-btn { display: none; }
.control-btn.recording { color: #fff; background: var(--green); animation: none; }
.control-btn:disabled { opacity: .48; }

/* 真实会话状态驱动同一个光环和主操作，不单独依赖颜色。 */
body[data-voice-state="connecting"] .halo-outer { animation: companion-connect 2.2s ease-in-out infinite; }
body[data-voice-state="listening"] .halo-outer,
body[data-voice-state="ready"] .halo-outer { border-color: rgba(53,90,78,.76); box-shadow: 0 0 0 13px rgba(53,90,78,.10), 0 0 65px rgba(53,90,78,.28); animation: companion-breathe 2.5s ease-in-out infinite; }
body[data-voice-state="thinking"] .halo-outer { border-color: rgba(196,138,74,.82); animation: companion-think 2.4s ease-in-out infinite; }
body[data-voice-state="speaking"] .halo-outer { border-color: rgba(196,138,74,.92); box-shadow: 0 0 0 14px rgba(255,215,143,.14), 0 0 72px rgba(224,167,91,.40); animation: companion-speak 1.7s ease-in-out infinite; }
body[data-voice-state="connecting"] .status-symbol,
body[data-voice-state="thinking"] .status-symbol { color: #795023; background: var(--gold-soft); }
body[data-voice-state="ready"] .status-symbol,
body[data-voice-state="listening"] .status-symbol { color: var(--green-deep); background: var(--green-mist); }
body[data-voice-state="speaking"] .status-symbol { color: #795023; background: var(--gold-soft); }
body[data-call-active="true"] .companion-welcome-cta { background: var(--companion-red); }
body[data-call-active="true"] .companion-welcome { padding-top: 20px; padding-bottom: 12px; }
body[data-call-active="true"] .companion-welcome-cta { min-height: 64px; margin-top: 0; }
body[data-call-active="true"] .call-note { padding: 10px 14px; }
body[data-call-active="true"] .immersive-entry { display: none; }
body[data-call-active="true"] .call-note { display: flex; }
body[data-call-active="true"] .familiarity-chip { display: none; }
body[data-call-active="true"] .greeting-copy { display: none; }
body:not([data-call-active="true"]) #cameraBtn { order: 2; }
body:not([data-call-active="true"]) #settingsBtn { order: 3; }
body[data-call-active="true"] #recordBtn { order: 2; }
body[data-call-active="true"] #cameraBtn { order: 3; }
body[data-call-active="true"] #settingsBtn { order: 4; }
body:not([data-call-active="true"]) .call-note { display: none; }
body:not([data-call-active="true"]) #recordBtn { display: none; }

@keyframes companion-connect { 0%,100% { transform: translate(-50%,-50%) rotate(-2deg) scale(1.03); opacity: .55; } 50% { transform: translate(-50%,-50%) rotate(-2deg) scale(.96); opacity: 1; } }
@keyframes companion-breathe { 0%,100% { transform: translate(-50%,-50%) rotate(-2deg) scale(.98); opacity: .72; } 50% { transform: translate(-50%,-50%) rotate(-2deg) scale(1.04); opacity: 1; } }
@keyframes companion-think { 0%,100% { filter: drop-shadow(-12px 0 12px rgba(196,138,74,.14)); } 50% { filter: drop-shadow(14px 0 18px rgba(196,138,74,.42)); } }
@keyframes companion-speak { 0%,100% { transform: translate(-50%,-50%) rotate(-2deg) scale(.985); } 50% { transform: translate(-50%,-50%) rotate(-2deg) scale(1.055); } }
@keyframes companion-bars { 0%,100% { height: 9px; opacity: .5; } 50% { height: 27px; opacity: 1; } }

/* 底部空间导航：手机与桌面均只保留五个空间。 */
.space-dock { position: fixed; z-index: 1400; left: 0; right: 0; bottom: 0; width: 100%; transform: none; }
.space-dock-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 128px)); justify-content: center; gap: 12px; width: 100%; padding: 8px 22px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--companion-line); border-radius: 0; background: rgba(255,253,246,.96); box-shadow: none; }
.dock-item { display: flex; min-width: 0; min-height: 56px; padding: 5px 12px; border-radius: 15px; gap: 8px; }
.dock-item span { font-size: 21px; }
.dock-item b { font-size: 16px; }
.dock-item.is-active { color: var(--green-deep); background: var(--green-mist); box-shadow: none; }
.dock-me { margin: 0; border: 0; border-radius: 15px; }
.me-popover { right: max(18px, calc((100vw - 680px) / 2)); bottom: calc(80px + env(safe-area-inset-bottom)); }

/* 今日页保留真实摘要与活动数据，不把原型日程样例伪装成用户日程。 */
#space-today, #space-family { width: 100%; max-width: none; min-height: calc(100dvh - 180px); margin: 0; background: rgba(247,243,234,.94); }
#space-today .space-content, #space-family .space-content { width: min(1080px, calc(100% - 32px)); padding: 32px 0 60px; }
#space-today .space-content::before, #space-family .space-content::before { display: none; }
#space-today .space-heading { padding: 0 2px 18px; }
#space-today .space-heading .eyebrow { display: none; }
#space-today .space-heading h2 { color: var(--green-deep); font-family: var(--companion-song); font-size: 38px; }
#space-today .today-date { color: #946029 !important; font-size: 16px; }
#space-today .today-greeting { font-size: 18px; }
#space-today .space-grid.two-col { grid-template-columns: 1.08fr .92fr; }
#space-today .morning-card { grid-row: span 2; display: block; }
#space-today .paper-card { border: 1px solid var(--companion-line); border-radius: 20px; background: var(--paper-card); box-shadow: 0 10px 26px rgba(58,48,35,.08); }
#space-today .space-subhead { margin-top: 20px; }

/* 设置层：Prompt / 模型能力优先展示，日常偏好紧随其后。 */
#settingsModal { background: rgba(39,49,44,.48); }
.settings-modal { width: min(620px, calc(100% - 32px)); max-width: 620px; max-height: min(800px, calc(100dvh - 32px)); border-radius: 26px; color: var(--ink); background: var(--paper-card); box-shadow: 0 26px 80px rgba(36,32,27,.28); }
.settings-modal .modal-header { align-items: flex-start; padding: 26px 28px 16px; border-color: var(--companion-line); background: transparent; }
.settings-modal .modal-header h2 { margin: 3px 0 0; color: var(--ink); font-family: var(--companion-song); font-size: 34px; }
.settings-modal .modal-header .eyebrow { margin: 0; color: #9a632e; font-size: 15px; letter-spacing: .02em; }
.settings-modal .close-btn { width: 48px; height: 48px; flex: 0 0 auto; border: 2px solid #9a632e; border-radius: 50%; color: var(--ink); background: transparent; font-size: 30px; }
.settings-modal .modal-body { display: flex; flex-direction: column; max-height: calc(100dvh - 140px); padding: 0 28px 28px; }
.friendly-settings-list { order: 2; display: grid; gap: 9px; margin-top: 14px; }
.friendly-setting-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 11px; min-height: 68px; padding: 9px 10px; border: 1px solid var(--companion-line); border-radius: 16px; cursor: pointer; }
.friendly-setting-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--green-deep); background: var(--green-mist); font-weight: 800; }
.friendly-setting-row b, .friendly-setting-row small { display: block; }
.friendly-setting-row b { font-size: 17px; }
.friendly-setting-row small { color: var(--ink-soft); font-size: 15px; }
.friendly-setting-row select { min-height: 48px; max-width: 154px; padding: 6px 34px 6px 12px; border: 1px solid rgba(53,70,61,.24); border-radius: 12px; color: var(--ink); background: #fffdf6; font-size: 16px; }
.switch-setting input { appearance: none; width: 54px; height: 32px; border: 1px solid rgba(53,70,61,.25); border-radius: 999px; background: #d9ddd9; cursor: pointer; }
.switch-setting input::after { content: ""; display: block; width: 26px; height: 26px; margin: 2px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,.16); transition: transform .18s ease; }
.switch-setting input:checked { background: var(--green); }
.switch-setting input:checked::after { transform: translateX(22px); }
.advanced-settings { order: 1; margin-top: 0; border: 1px solid var(--companion-line); border-radius: 16px; }
.advanced-settings > summary { display: flex; align-items: center; min-height: 66px; padding: 10px 14px; list-style: none; cursor: pointer; }
.advanced-settings > summary::-webkit-details-marker { display: none; }
.advanced-settings > summary span { min-width: 0; }
.advanced-settings > summary b, .advanced-settings > summary small { display: block; }
.advanced-settings > summary b { font-size: 16px; }
.advanced-settings > summary small { color: var(--ink-soft); font-size: 15px; }
.advanced-settings > summary i { margin-left: auto; font-size: 24px; font-style: normal; }
.advanced-settings[open] > summary i { transform: rotate(180deg); }
.advanced-settings-body { padding: 0 12px 12px; }
.advanced-settings .settings-tabs { overflow-x: auto; }
.advanced-settings .tab-btn { min-height: 48px; padding: 8px 12px; color: var(--ink-soft); white-space: nowrap; }
.advanced-settings .tab-btn.active { color: var(--green-deep); border-color: var(--green); }
.advanced-settings .config-panel, .advanced-settings .mcp-tools-container { background: var(--paper); }
.advanced-settings .config-item label, .advanced-settings .input-group label { color: var(--ink-soft); }
.engine-settings-row { padding-bottom: 4px; border-bottom: 1px dashed var(--companion-line); }
.save-friendly-settings { order: 3; width: 100%; min-height: 56px; margin-top: 18px; border: 0; border-radius: 16px; color: white; background: var(--green-deep); font-size: 18px; font-weight: 800; cursor: pointer; }

@media (max-width: 1000px) {
  .companion-topbar { min-height: 64px; padding: 6px 16px; }
  .top-companion-status { display: none; }
  .companion-topbar { grid-template-columns: 1fr auto; }
  .companion-space { grid-template-columns: minmax(0, 1fr); grid-template-rows: 360px auto auto auto auto; grid-template-areas: "stage" "chat" "action" "topics" "tools"; width: min(720px, calc(100vw - 24px)); height: auto; margin-top: 10px; gap: 0; }
  .companion-space > * { min-width: 0; }
  .companion-stage-surface, #live2d-stage, .connection-status-top, .model-container, .familiarity-chip { grid-row: 1; grid-column: 1; }
  .chat-container { align-self: stretch; width: 100%; max-height: 260px; padding: 10px 16px 0; background: transparent; }
  .chat-stream { flex: 1 1 auto; max-height: 190px; }
  .companion-welcome, .immersive-entry, .control-bar { box-shadow: 0 9px 25px rgba(58,48,35,.10); }
  .companion-welcome { margin-top: 10px; border-radius: 22px 22px 0 0; }
  .control-bar { border-radius: 0 0 22px 22px; }
  #space-today .space-grid.two-col { grid-template-columns: 1fr; }
  #space-today .morning-card { grid-row: auto; }
}

@media (max-width: 600px) {
  .container { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .companion-topbar { min-height: 60px; padding: 5px 14px; }
  .brand-seal { flex-basis: 36px; width: 36px; height: 36px; border-radius: 9px; }
  .brand-seal img { width: 86px; height: 86px; }
  .companion-brand { gap: 9px; }
  .companion-brand b { font-size: 16px; }
  .companion-brand small { font-size: 15px; line-height: 1.2; }
  .topbar-language { gap: 5px; padding-inline: 10px; font-size: 14px; }
  .profile-shortcut { padding: 4px; }
  .profile-shortcut b { display: none; }
  .profile-initial { width: 38px; height: 38px; }
  .companion-space { grid-template-rows: 318px auto auto auto auto; width: calc(100vw - 24px); margin-top: 10px; }
  .companion-stage-surface { border-radius: 22px; }
  .connection-status-top { margin: 10px; }
  .connection-status-top .status-indicator { padding: 8px 11px; border-radius: 14px; }
  .status-symbol { width: 31px; height: 31px; }
  .status-indicator b { font-size: 16px; }
  .status-indicator small { font-size: 15px; }
  .halo-outer { width: min(72%, 260px); }
  .halo-inner { width: min(61%, 222px); }
  .familiarity-chip { justify-self: center; margin: 0 0 10px; }
  .familiarity-info b { font-size: 15px; }
  .familiarity-info small { font-size: 15px; }
  .chat-container { width: 100%; max-height: 240px; margin: 0; padding: 10px 16px 0; }
  .chat-stream { max-height: 170px; }
  .chat-message .message-bubble, .chat-message.ai .message-bubble, .chat-message.user .message-bubble { padding: 11px 13px; font-size: 16px; }
  .companion-welcome { padding: 16px 16px 14px; }
  .greeting-copy .eyebrow { font-size: 15px; }
  .companion-welcome h2 { margin: 4px 0 3px; font-size: 29px; line-height: 1.18; }
  .companion-welcome p:last-child { font-size: 17px; }
  .companion-welcome-cta { min-height: 72px; margin-top: 11px; border-radius: 17px; }
  .companion-welcome-cta b { font-size: 19px; }
  .immersive-entry { padding: 0 16px 13px; }
  .topic-heading { margin-bottom: 8px; }
  .quick-topics { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .topic-btn { flex-direction: column; justify-content: center; gap: 2px; min-height: 60px; padding: 5px 2px; }
  .topic-btn span { width: 26px; height: 26px; font-size: 14px; }
  .topic-btn b { width: 100%; font-size: 15px; letter-spacing: -.04em; text-align: center; }
  .control-bar { gap: 6px; padding: 9px 16px 14px; }
  .control-btn { min-height: 48px; height: 48px; gap: 5px; padding: 4px; }
  .control-btn .btn-text { display: inline; font-size: 15px; }
  .control-btn .btn-icon { width: 18px; height: 18px; }
  .space-dock-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; padding: 4px 5px calc(4px + env(safe-area-inset-bottom)); }
  .dock-item { flex-direction: column; gap: 0; min-height: 60px; padding: 3px 1px; border-radius: 12px; }
  .dock-item span { font-size: 20px; }
  .dock-item b { font-size: 15px; }
  #space-today .space-content, #space-family .space-content { width: calc(100% - 24px); padding: 18px 0 30px; }
  #space-today .space-heading { padding-bottom: 12px; }
  #space-today .space-heading h2 { font-size: 30px; }
  #space-today .paper-card { padding: 16px; border-radius: 17px; }
  #space-today .space-grid { gap: 10px; }
  .settings-modal { width: 100%; max-width: none; max-height: calc(100dvh - 16px); margin: auto 0 0; border-radius: 24px 24px 0 0; }
  .settings-modal .modal-header { padding: 20px 16px 12px; }
  .settings-modal .modal-header h2 { font-size: 29px; }
  .settings-modal .modal-body { max-height: calc(100dvh - 104px); padding: 0 16px calc(18px + env(safe-area-inset-bottom)); }
  .friendly-setting-row { grid-template-columns: 40px 1fr auto; gap: 9px; min-height: 66px; padding: 8px 9px; }
  .friendly-setting-row b { font-size: 16px; }
  .friendly-setting-row small { font-size: 15px; }
  .friendly-setting-row select { max-width: 114px; font-size: 15px; }
}

@media (max-width: 370px) {
  .companion-space { grid-template-rows: 300px auto auto auto auto; width: calc(100vw - 16px); }
  .companion-welcome { padding-inline: 13px; }
  .companion-welcome h2 { font-size: 27px; }
  .immersive-entry, .control-bar { padding-inline: 13px; }
  .control-btn { gap: 3px; }
  .control-btn .btn-text { font-size: 15px; }
}

@media (orientation: landscape) and (min-width: 780px) and (max-height: 620px) {
  .companion-space { grid-template-columns: minmax(360px, 1.05fr) minmax(350px, .95fr); grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-areas: "stage action" "stage topics" "stage chat" "stage tools"; width: calc(100vw - 24px); height: auto; min-height: 500px; }
  .companion-stage-surface, #live2d-stage, .connection-status-top, .model-container, .familiarity-chip { grid-row: 1 / span 4; grid-column: 1; }
  .chat-container { grid-row: 3; grid-column: 2; padding: 0 36px 12px; background: rgba(255,253,246,.96); }
  .companion-welcome { grid-row: 1; grid-column: 2; }
  .immersive-entry { grid-row: 2; grid-column: 2; }
  .control-bar { grid-row: 4; grid-column: 2; }
  .companion-welcome h2 { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .companion-halo, .voice-bars i { animation: none !important; }
}

/* Trial diagnostics stay beside the conversation, without covering the avatar. */
.companion-space {
  grid-template-columns: minmax(240px, 290px) minmax(280px, 1fr) minmax(340px, 1fr);
  grid-template-areas: "diagnostic stage action" "diagnostic stage topics" "diagnostic stage chat" "diagnostic stage tools";
  width: min(1600px, calc(100vw - 40px)); gap: 0 20px;
  height: clamp(800px, calc(100dvh - 180px), 1040px);
}
.pipeline-panel {
  grid-area: diagnostic; position: relative; z-index: 24; min-width: 0; min-height: 0;
  padding: 20px 16px; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--companion-line); border-radius: 24px;
  color: var(--ink); background: rgba(255,253,246,.97); box-shadow: var(--companion-shadow);
  font-size: 14px; line-height: 1.55; overflow-wrap: anywhere;
}
.pipeline-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pipeline-heading h2 { margin: 0; font-size: 18px; }
.pipeline-heading > span { padding: 2px 8px; border-radius: 20px; background: #e5eee6; color: #355a4e; font-size: 12px; }
#pipelineStatus { margin: 14px 0 4px; font-weight: 700; }
.pipeline-elapsed { margin: 0 0 14px; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.pipeline-stages { display: grid; gap: 8px; list-style: none; padding: 0; margin: 0; }
.pipeline-stages > li { padding: 8px 10px; border: 1px solid #deded3; border-radius: 10px; background: #f6f4ec; }
.pipeline-stages b, .pipeline-stages strong { display: block; font-size: 14px; }
.pipeline-stages small { display: block; color: var(--ink-soft); }
.pipeline-stages .started, .pipeline-stages .active { border-color: #a57630; background: #fff1d4; }
.pipeline-stages .failed { border-color: #b65646; background: #fff0eb; }
.pipeline-stages .succeeded, .pipeline-stages .complete { border-color: #91af9c; background: #edf4ed; }
.pipeline-history { border-top: 1px solid var(--companion-line); margin-top: 16px; padding-top: 12px; }
.pipeline-history summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
#pipelineHistory { margin-top: 8px; }
#pipelineHistory > * { padding: 8px 0; border-bottom: 1px solid var(--companion-line); }
#pipelineHistory strong, #pipelineHistory small { display: block; }
.pipeline-details { width: 100%; min-height: 42px; margin-top: 14px; border: 1px solid #a7b9aa; border-radius: 10px; background: #eef2e8; color: var(--green-deep); cursor: pointer; }
.pipeline-details:focus-visible, .pipeline-history summary:focus-visible { outline: 3px solid #a57630; outline-offset: 3px; }
.latency-close { display: block; position: sticky; top: 0; z-index: 2; margin: 0 0 12px auto; min-height: 40px; padding: 8px 16px; border: 1px solid #788b91; border-radius: 9px; color: #fff; background: #344347; cursor: pointer; }
.local-config-save-notice { position: fixed; z-index: 11000; right: 20px; bottom: 20px; width: min(520px, calc(100vw - 40px)); max-height: 50dvh; overflow-y: auto; padding: 16px; box-sizing: border-box; background: #fffdf6; color: #253c33; border: 1px solid #91a899; border-radius: 14px; box-shadow: 0 8px 30px #183c3526; }
.local-config-save-notice[hidden], .local-config-version-status[hidden] { display: none; }
.local-config-save-notice p { margin: 0 0 10px; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.local-config-save-notice button { min-height: 40px; padding: 8px 16px; border: 1px solid #718c7d; border-radius: 8px; background: #edf3e9; color: #253c33; cursor: pointer; }
.local-config-save-notice button:focus-visible { outline: 3px solid #a57630; outline-offset: 3px; }
.local-config-version-status { margin: 12px 0 0; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; color: inherit; }
@media (max-width: 1100px) {
  .companion-space { grid-template-columns: minmax(0, 1fr); grid-template-rows: 320px auto auto auto auto auto;
    grid-template-areas: "stage" "action" "topics" "chat" "tools" "diagnostic";
    width: min(720px, calc(100vw - 24px)); height: auto; gap: 12px 0; }
  .companion-stage-surface, #live2d-stage, .connection-status-top, .model-container, .familiarity-chip { grid-row: 1; grid-column: 1; }
  .chat-container { grid-area: chat; height: clamp(560px, 72dvh, 760px); max-height: none; padding: 16px; border-radius: 22px; background: rgba(255,253,246,.96); }
  .chat-stream { max-height: none; }
  .companion-welcome { grid-area: action; }
  .immersive-entry { grid-area: topics; }
  .control-bar { grid-area: tools; }
  .pipeline-panel { max-height: 430px; }
  .pipeline-stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .companion-topbar { grid-template-columns: 1fr; gap: 5px; padding: 8px 14px; }
  .companion-topbar .topbar-actions { justify-self: stretch; justify-content: space-between; }
  .pipeline-panel { padding: 16px 12px; }
  .pipeline-stages { grid-template-columns: minmax(0, 1fr); }
}
