/* The companion layout reuses the existing diary, chat and memory surfaces. */
:root {
  --text: #2a324b;
  --muted: #6f747f;
  --accent: #6877b3;
  --accent-deep: #52619d;
  --accent-soft: #eef0fa;
  --bubble-user: #f3f1eb;
  --line: #e4e8f4;
  --surface: rgba(255, 255, 255, 0.64);
}
body { background: #ffffff; color: var(--text); }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(104, 119, 179, 0.45); outline-offset: 4px; }

/* Single-column shell with top horizontal navigation */
.companion-app {
  display: block;
  height: 100dvh;
}
.companion-app > .sidebar-scrim, .companion-app .mobile-menu { display: none !important; }
.companion-app .workspace {
  position: relative;
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr);
  height: 100%;
  overflow: hidden;
  background: #ffffff;
}
.workspace-bg {
  position: absolute;
  inset: 0;
  background: url("branding/background.png") center center / cover no-repeat;
  z-index: 0;
  pointer-events: none;
  transition: opacity .35s ease, filter .35s ease;
}
.workspace-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 40%, rgba(244, 246, 252, 0.35) 100%);
  transition: background .35s ease;
}
.companion-app:not([data-view="home"]) .workspace-bg {
  opacity: 0.42;
  filter: saturate(0.85) blur(1px);
}
.companion-app:not([data-view="home"]) .workspace-bg::after {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.48) 55%, rgba(255, 255, 255, 0.56) 100%);
}
.companion-app.is-card-expanded .workspace-bg {
  opacity: 0.22;
}

.companion-app .topbar {
  position: relative;
  z-index: 15;
  height: 60px;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100%;
  box-sizing: border-box;
  padding: 0 28px;
  border-bottom: 1px solid rgba(226, 231, 244, 0.85);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  gap: 16px;
}
.companion-app .topbar-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.companion-app .topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.companion-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  padding: 4px 6px;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.companion-brand:hover { background: var(--accent-soft); }
.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
}
.brand-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.companion-brand > span:last-child { font-size: 17px; font-weight: 700; letter-spacing: .08em; }
.companion-app .topbar h2, #activeViewTitle, #agentStatus { display: none !important; }
.home-back { display: none !important; }

.top-nav {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0;
  margin: 0;
}
.top-nav::-webkit-scrollbar { display: none; }
.top-nav .nav-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 9px;
  border: 0 !important;
  box-shadow: none !important;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.top-nav .nav-item:hover {
  background: rgba(104, 119, 179, 0.08);
  color: var(--text);
}
.top-nav .nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 600;
  border: 0 !important;
  box-shadow: none !important;
}

.topbar-pet-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid #dde2f2;
  background: rgba(255, 255, 255, 0.94);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.topbar-pet-btn:hover { border-color: var(--accent); color: var(--accent-deep); }
.topbar-link {
  border: 1px solid #dde2f2;
  background: rgba(255, 255, 255, 0.94);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.companion-app .backend-state { font-size: 11px; color: var(--muted); }
.companion-app .backend-state i { width: 6px; height: 6px; }
.companion-app .view-stack {
  position: relative;
  z-index: 2;
  height: 100%;
  box-sizing: border-box;
  padding: 20px 36px 26px;
  overflow: hidden;
}
.companion-app .home-view.is-active {
  position: relative;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  height: 100%;
  padding-bottom: 14px;
}
.lark-greeting-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  z-index: 5;
}
.lark-greeting-bubble {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(460px, 84vw);
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(182, 192, 226, 0.72);
  background: rgba(244, 246, 253, 0.88);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(52, 62, 108, 0.12);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.lark-greeting-bubble:hover { transform: translateY(-2px); }
.lark-greeting-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(104, 119, 179, 0.22);
  flex-shrink: 0;
}

.home-quick-cards {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 860px;
  margin-bottom: 4px;
}
.home-quick-cards[hidden] {
  display: none !important;
}
.home-quick-card {
  flex: 0 1 186px;
  min-width: 152px;
  background: rgba(244, 246, 253, 0.86);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(190, 199, 232, 0.72);
  border-radius: 16px;
  padding: 14px 18px;
  box-shadow: 0 10px 26px rgba(48, 58, 104, 0.14);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.home-quick-card:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.96);
  border-color: var(--accent);
}
.home-quick-card .quick-arrow {
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
}

/* Home hides duplicate Live2D stage; non-home views bring Lark in on the left */
.companion-stage {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 53%;
  width: min(330px, 38vh);
  transform: translate3d(-50%, -50%, 0);
  will-change: transform, opacity;
  pointer-events: none;
  opacity: 0;
  transition: transform .4s cubic-bezier(.22,.75,.2,1), opacity .28s ease;
}
.companion-app[data-view="home"] .companion-stage {
  opacity: 0;
  pointer-events: none;
}
.companion-app:not([data-view="home"]) .companion-stage {
  transform: translate3d(calc(-50% - 32vw), -50%, 0);
  opacity: 1;
}
.character-mount { position: relative; z-index: 1; width: 100%; }
.character-art { position: relative; width: 100%; }
.character-art > img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.button-link { display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }
.character-ground {
  position: absolute;
  bottom: -4px;
  left: 14%;
  width: 72%;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(104, 119, 179, 0.20) 0%, rgba(104, 119, 179, 0) 72%);
}
.companion-app:not([data-view="home"]) .view-stack {
  padding: 18px 34px 20px 35%;
}
.companion-app[data-view="study"] .companion-stage {
  transform: translate3d(calc(-50% - 35vw), -50%, 0);
}
.companion-app[data-view="study"] .view-stack {
  padding-left: 27%;
}
.companion-app[data-view="library"] .companion-stage {
  transform: translate3d(calc(-50% - 35vw), -50%, 0);
}
.companion-app[data-view="library"] .view-stack {
  padding-left: 27%;
}

/* 展开全屏卡片状态（隐藏云雀、轮盘等组件，铺满导航栏外区域） */
.card-expand-btn .collapse-icon { display: none; }
.card-expand-btn.is-expanded .expand-icon { display: none; }
.card-expand-btn.is-expanded .collapse-icon { display: inline-block; }
.card-expand-btn.is-expanded {
  border-color: rgba(104, 119, 179, 0.48) !important;
  background: var(--accent-soft) !important;
  color: var(--accent-deep) !important;
}
.companion-app.is-card-expanded .companion-stage {
  display: none !important;
}
.companion-app.is-card-expanded .view-stack {
  padding: 18px 24px 18px 24px !important;
}
.companion-app .message-content {
  transition: max-width .28s ease;
}
.companion-app.is-card-expanded .message-content {
  max-width: min(1120px, 84%);
}
.companion-app.is-card-expanded[data-view="study"] .study-wheel-column {
  display: none !important;
}
.companion-app.is-card-expanded[data-view="study"] .study-workspace-layout {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}
.companion-app .surface {
  border-color: rgba(255, 255, 255, 0.82);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px) saturate(1.08);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  box-shadow: 0 12px 48px rgba(72, 86, 136, 0.10);
}
.companion-app .chat-header { min-height: 58px; padding: 12px 20px; border-bottom: 1px solid rgba(223, 231, 237, 0.65); }
.companion-app .chat-header-actions { gap: 8px !important; }
.companion-app .header-action { border: 1px solid rgba(216, 230, 237, 0.8); background: #ffffffc8; min-height: 34px; font-size: 12px; padding: 0 12px; border-radius: 20px; }
.companion-app .header-action svg { width: 16px; height: 16px; }
.companion-app .chat-list { padding: 24px 20px; scrollbar-width: thin; scrollbar-color: #b7c9d780 transparent; }

/* 聊聊天：对话界面与媒体界面双悬浮卡片轮换堆叠 (.chat-deck) */
.companion-app .chat-view.is-active {
  display: block;
  height: 100%;
  min-height: 0;
}
.chat-deck {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  perspective: 1200px;
}
.chat-deck .deck-card {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 12px;
  height: auto !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  transition: transform 0.35s cubic-bezier(0.22, 0.8, 0.22, 1), opacity 0.28s ease;
  overflow: hidden;
  contain: layout style;
}
.chat-deck .sent-media-panel.deck-card {
  border: 1px solid var(--line) !important;
  border-radius: 22px !important;
  background: rgba(255, 255, 255, 0.94) !important;
  box-shadow: 0 14px 40px rgba(68, 79, 128, 0.12) !important;
}
.companion-app .chat-header {
  border-bottom: 0 !important;
  background: transparent !important;
}
.companion-app .message.is-user .bubble {
  background: var(--bubble-user);
  color: #252f4a;
  border: 1px solid #d5dcf2;
}
.companion-app .message.is-agent .bubble {
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid #e6e9f4;
  color: var(--text);
}
.companion-app .send-button,
.companion-app .button-primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #ffffff !important;
}
.companion-app .send-button:hover,
.companion-app .button-primary:hover {
  background: var(--accent-deep) !important;
  border-color: var(--accent-deep) !important;
}
.chat-deck .chat-panel.deck-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.chat-deck .sent-media-panel.deck-card {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr);
}
.chat-deck .deck-card.is-front-card {
  z-index: 3;
  transform: translateY(0) scale(1);
  opacity: 1;
}
.chat-deck .deck-card.is-back-card {
  z-index: 1;
  transform: translateY(16px) scale(0.98);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.chat-deck .deck-card.is-back-card > * {
  pointer-events: none;
}
.media-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(223, 231, 237, 0.65);
  background: rgba(255, 255, 255, 0.55);
}
.media-card-header > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.media-card-header > div > span {
  font-size: 12px;
  color: var(--muted);
}
.chat-card-title-group {
  display: flex !important;
  align-items: center;
  gap: 9px;
}
.chat-card-title-group strong {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.deck-card-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #eff6ff;
  color: #2563eb;
}
.deck-card-tag.is-media {
  background: #f3e8ff;
  color: #7c3aed;
}
.companion-app .message { margin-bottom: 26px; }
.companion-app .message > .avatar { display: none; }
.companion-app .message-role { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.companion-app .message-content { min-width: 0; max-width: min(600px, 88%); }
.companion-app .bubble { position: relative; padding: 16px 22px; border: 0; border-radius: 24px; background: #ffffffeb; box-shadow: 0 8px 28px #718da012; line-height: 1.8; }
.companion-app .bubble::before { content: ""; position: absolute; left: -9px; top: 20px; width: 10px; height: 19px; background: inherit; clip-path: polygon(100% 0, 0 45%, 100% 100%); }
.companion-app .message.is-user .bubble { border-radius: 24px; background: #dfedf9ed; box-shadow: 0 8px 28px #718da00d; }
.companion-app .message.is-user .bubble::before { left: auto; right: -9px; clip-path: polygon(0 0, 100% 45%, 0 100%); }
.companion-app .composer { margin: 12px 8px 8px; padding: 12px; border: 0; border-radius: 28px; background: #ffffffc9; box-shadow: 0 8px 32px #718da014; }
.companion-app .composer:focus-within { box-shadow: 0 8px 32px #718da01c, 0 0 0 2px #a9c6df80; }
.companion-app .composer textarea { background: transparent; }
.companion-app .composer :is(.attachment-button, .voice-button) { border: 0; border-radius: 50%; background: transparent; }
.companion-app .composer .voice-button.is-recording { color: #fff; background: #d85f5f; }
.companion-app .composer .send-button { border-radius: 50%; }
.companion-app .settings-surface { padding: 28px; }
.switch input:focus-visible + span { outline: 3px solid #87b6dc; outline-offset: 4px; }
.companion-app .intro-screen, .intro-screen { position: fixed; inset: 0; z-index: 100; min-height: 0; background: #43577140; backdrop-filter: blur(12px); }
.intro-screen .auth-popover { position: static; width: 100%; margin: 0; box-shadow: none; }
.companion-toast { position: fixed; z-index: 200; bottom: 30px; left: 50%; transform: translateX(-50%); max-width: min(90vw, 500px); padding: 14px 24px; border: 1px solid var(--line); border-radius: 30px; background: #fff; box-shadow: var(--shadow); font-size: 13px; }
.desktop-dialog { width: min(420px, calc(100vw - 32px)); padding: 30px; border: 1px solid #fff; border-radius: 25px; background: #f8fbff; color: var(--text); text-align: center; box-shadow: 0 30px 90px #36527138; }
.desktop-dialog::backdrop { background: #405a7240; backdrop-filter: blur(8px); }
.desktop-dialog img { width: 130px; display: block; margin: 0 auto; }
.desktop-dialog h2 { margin: 10px 0; font-size: 21px; font-weight: 500; }
.desktop-dialog p { color: var(--muted); font-size: 13px; line-height: 1.8; }
.desktop-dialog .button { min-height: 43px; width: 100%; border-radius: 12px; }
.dialog-close { position: absolute; top: 12px; right: 12px; font-size: 22px; }
.text-button { display: block; margin: 14px auto 0; background: none; border: 0; color: var(--accent-deep); font-size: 12px; cursor: pointer; }
@media (min-width: 721px) and (max-height: 700px) {
  .companion-app[data-view="home"] .companion-stage { top: calc(84px + (100% - 84px) * .55); width: min(260px, 38vh); }
  .lark-greeting-wrap { top: 8px; }
  .lark-greeting-bubble { padding: 8px 14px; font-size: 13px; }
  .orbit-bubble { min-width: 145px; padding: 11px 15px; gap: 8px; }
  .orbit-symbol { width: 30px; height: 30px; flex-basis: 30px; }
  .orbit-symbol svg { width: 17px; height: 17px; }
  .orbit-bubble strong { font-size: 12px; }
}
@media (max-width: 1050px) {
  .companion-stage { width: min(270px, 36vh); }
  .orbit-bubble { min-width: 155px; padding: 13px 16px 13px 13px; gap: 8px; }
  .orbit-chat { right: calc(50% + 155px); top: 23%; }
  .orbit-study { right: calc(50% + 195px); top: 42%; }
  .orbit-memory { right: calc(50% + 195px); top: 61%; }
  .orbit-trajectory { right: calc(50% + 155px); top: 80%; }
  .orbit-diary { left: calc(50% + 155px); top: 23%; }
  .orbit-pet { left: calc(50% + 195px); top: 42%; }
  .orbit-profile { left: calc(50% + 195px); top: 61%; }
  .orbit-settings { left: calc(50% + 155px); top: 80%; }
  .companion-app .chat-header { padding: 16px; }
  .companion-app .chat-header-actions .header-action > span { display: none; }
  .companion-app .memory-browser { grid-template-columns: 125px 180px minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .companion-app .workspace { grid-template-rows: 58px minmax(0, 1fr); }
  .companion-app .topbar { padding: 0 12px; gap: 8px; }
  .companion-brand > span:last-child { font-size: 15px; }
  .companion-app .backend-state, .topbar-pet-btn { display: none; }
  .companion-app .view-stack { padding: 12px 14px 16px; overflow-y: auto; }
  .companion-app:not([data-view="home"]) .view-stack { padding: 12px 14px 16px; }
  .companion-app:not([data-view="home"]) .companion-stage { display: none; }
  .home-quick-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .home-quick-card { padding: 12px 14px; font-size: 13px; }
  .lark-greeting-bubble { padding: 8px 14px; font-size: 12.5px; }
  .companion-app .chat-header { min-height: 44px; padding: 4px 8px; }
  .companion-app .chat-list { padding: 16px 10px; }
  .companion-app .message-content { max-width: 92%; }
  .companion-app .bubble { padding: 12px 16px; border-radius: 22px; }
  .companion-app .composer { grid-template-columns: minmax(0, 1fr) repeat(3, 36px); gap: 4px; margin: 8px 0 0; padding: 10px; border-radius: 24px; }
  .companion-app .composer :is(.attachment-button, .voice-button, .send-button) { width: 36px; height: 36px; }
  .companion-app:not([data-view="home"]):not([data-view="chat"]) .view-stack { padding: 12px; }
  .companion-app:not([data-view="home"]):not([data-view="chat"]) .companion-stage { display: none; }
  .companion-app .settings-surface { padding: 18px; }
  .companion-app .setting-row { gap: 14px; }
  .companion-app .memory-browser { grid-template-columns: 110px minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .orbit-bubble { animation: none !important; translate: none; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* 独立学习页面 (studyView) 轮盘式列表与对话框样式 */
.study-workspace-layout {
  display: grid;
  grid-template-columns: 226px minmax(0, 1fr);
  gap: 20px;
  height: 100%;
  min-height: 0;
  align-items: stretch;
}
.study-wheel-column {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: 100%;
  min-height: 0;
  padding: 12px 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  user-select: none;
}
.study-new-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.12);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
  z-index: 6;
}
.study-new-pill-btn svg {
  width: 16px;
  height: 16px;
}
.study-new-pill-btn:hover {
  transform: translateY(-2px);
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.24);
}
.study-wheel-stage {
  position: relative;
  width: 100%;
  flex: 1;
  max-height: 440px;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.study-wheel-list {
  position: relative;
  width: 100%;
  height: 100%;
}
.study-wheel-item {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 6px 20px rgba(100, 130, 160, 0.08);
  text-align: left;
  cursor: pointer;
  transition: transform 0.38s cubic-bezier(0.22, 0.8, 0.24, 1), opacity 0.32s ease, background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.study-wheel-item:hover:not(.is-active) {
  background: rgba(255, 255, 255, 0.92);
  border-color: #bfdbfe;
}
.study-wheel-item.is-active {
  background: #ffffff;
  border-color: #60a5fa;
  box-shadow: 0 12px 32px rgba(37, 99, 235, 0.16), inset 3px 0 0 #2563eb;
  z-index: 4;
}
.study-wheel-item .wheel-item-subject {
  display: inline-block;
  align-self: flex-start;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #2563eb;
}
.study-wheel-item .wheel-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.study-wheel-item.is-active .wheel-item-title {
  color: #1e3a8a;
}

.study-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  border: 1px solid #ffffff;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 48px rgba(84, 116, 148, 0.11);
  overflow: hidden;
  contain: layout style;
}
.study-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(223, 231, 237, 0.65);
}
.study-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.study-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.study-files-drawer {
  padding: 12px 18px;
  background: rgba(248, 250, 252, 0.92);
  border-bottom: 1px solid rgba(223, 231, 237, 0.8);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
}
.study-files-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}
.study-files-drawer-btns .button {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
}
.study-files-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.study-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #dbeafe;
  font-size: 12px;
  color: var(--text);
}
.study-file-chip small {
  color: var(--muted);
  font-size: 11px;
}
.study-file-chip button {
  border: 0;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.study-file-chip button:hover {
  color: #ef4444;
}
.study-header-info strong {
  font-size: 16px;
  color: var(--text);
  font-weight: 600;
}
.study-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  background: #eff6ff;
  color: #2563eb;
  font-weight: 500;
}
.study-chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(20px, 4vh, 40px) 18px 20px;
  scrollbar-width: thin;
  scrollbar-color: #b7c9d780 transparent;
}
.study-composer {
  margin: 8px 12px 12px;
  padding: 12px;
  border: 0;
  border-radius: 28px;
  background: #ffffffd9;
  box-shadow: 0 8px 32px #718da014;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 44px;
  align-items: end;
  gap: 8px;
}
.study-composer .pending-attachments {
  grid-column: 1 / -1;
}
.study-composer textarea {
  border: 0;
  background: transparent;
  outline: none;
  resize: none;
  font-size: 14px;
  line-height: 1.6;
}

/* 设置页：主界面快捷气泡勾选网格 */
.setting-row-block {
  display: flex;
  flex-direction: column;
  align-items: stretch !important;
  gap: 14px;
}
.shortcut-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  width: 100%;
}
.shortcut-check-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  user-select: none;
  transition: all .18s ease;
}
.shortcut-check-item:hover {
  border-color: rgba(104, 119, 179, 0.55);
  background: #f6f8fd;
}
.shortcut-check-item:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
  box-shadow: 0 3px 10px rgba(80, 94, 153, 0.12);
}
.shortcut-check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* 主聊天意图联动卡片与跳转链接 */
.chat-action-card {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(239, 246, 255, 0.75);
  border: 1px solid #bfdbfe;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-action-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chat-action-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: all .2s;
}
.chat-action-btn:hover {
  background: #1d4ed8;
}
.chat-action-btn.secondary {
  border-color: #cbd5e1;
  background: #fff;
  color: #475569;
}
.study-jump-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 20px;
  background: #2563eb;
  color: #fff !important;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-top: 6px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  cursor: pointer;
}
.study-jump-link:hover {
  background: #1d4ed8;
}

/* 用户画像管理 (profileView) 样式 */
.profile-surface {
  padding: 28px;
  height: 100%;
  overflow-y: auto;
}
.profile-cards-section {
  margin: 18px 0 24px;
}
.profile-cards-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  margin-bottom: 12px;
}
.profile-cards-title span {
  font-size: 12px;
  color: var(--muted);
}
.profile-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.profile-card-item {
  position: relative;
  padding: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  background: #ffffffc9;
  cursor: pointer;
  transition: all .2s;
}
.profile-card-item:hover {
  border-color: #fed7aa;
  box-shadow: 0 6px 20px rgba(0,0,0,0.04);
}
.profile-card-item.is-active {
  border-color: #ea580c;
  background: #fffaf5;
  box-shadow: 0 6px 20px rgba(234, 88, 12, 0.1);
}
.profile-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.profile-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.active-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background: #ffedd5;
  color: #ea580c;
  font-weight: 600;
}
.profile-card-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.active-profile-card {
  padding: 20px;
  border: 1px solid #fed7aa;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 6px 24px rgba(234, 88, 12, 0.05);
}

/* 学业阶段（学历）切换与动态展开样式 */
.stage-select-section {
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fbfdff;
  margin-top: 14px;
}
.stage-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.stage-section-title span {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.stage-section-title small {
  font-size: 11px;
  color: var(--muted);
}
.stage-segmented-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stage-segment-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
  text-align: left;
  transition: all .2s ease;
}
.stage-segment-btn:hover {
  border-color: #93c5fd;
  background: #f0f7ff;
}
.stage-segment-btn.is-active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 3px 12px rgba(37, 99, 235, 0.12);
}
.stage-segment-btn .segment-icon {
  font-size: 20px;
  line-height: 1;
}
.stage-segment-btn .segment-label strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}
.stage-segment-btn.is-active .segment-label strong {
  color: #1d4ed8;
}
.stage-segment-btn .segment-label small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
@media (max-width: 640px) {
  .stage-segmented-bar {
    grid-template-columns: 1fr;
  }
}

.stage-details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #e2e8f0;
}
.stage-step-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.stage-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}
#newProfileModal .modal-card {
  width: min(680px, 100%);
  max-height: 90vh;
  overflow-y: auto;
}

/* 对话气泡 Markdown 排版样式 */
.companion-app .bubble.md-bubble {
  white-space: normal;
  line-height: 1.72;
}
.bubble.md-bubble > :first-child {
  margin-top: 0;
}
.bubble.md-bubble > :last-child {
  margin-bottom: 0;
}
.bubble.md-bubble p {
  margin: 0.55em 0;
}
.bubble.md-bubble h1,
.bubble.md-bubble h2,
.bubble.md-bubble h3,
.bubble.md-bubble h4,
.bubble.md-bubble h5,
.bubble.md-bubble h6 {
  margin: 0.85em 0 0.45em;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}
.bubble.md-bubble h1 { font-size: 1.25em; }
.bubble.md-bubble h2 { font-size: 1.15em; }
.bubble.md-bubble h3 { font-size: 1.06em; }
.bubble.md-bubble h4,
.bubble.md-bubble h5,
.bubble.md-bubble h6 { font-size: 1em; }
.bubble.md-bubble ul,
.bubble.md-bubble ol {
  margin: 0.5em 0;
  padding-left: 1.4em;
}
.bubble.md-bubble li {
  margin: 0.25em 0;
}
.bubble.md-bubble hr {
  border: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  margin: 0.85em 0;
}
.bubble.md-bubble blockquote {
  margin: 0.6em 0;
  padding: 0.35em 0.85em;
  border-left: 3px solid #60a5fa;
  background: rgba(239, 246, 255, 0.65);
  border-radius: 0 8px 8px 0;
  color: #475569;
}
.bubble.md-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
  padding: 0.12em 0.4em;
  border-radius: 5px;
  background: rgba(148, 163, 184, 0.16);
  color: #0f172a;
}
.bubble.md-bubble pre {
  margin: 0.7em 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: #1e293b;
  color: #f8fafc;
  overflow-x: auto;
  line-height: 1.55;
}
.bubble.md-bubble pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 0.86em;
}
.bubble.md-bubble a {
  color: #2563eb;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.bubble.md-bubble .md-table-wrap {
  margin: 0.65em 0;
  overflow-x: auto;
}
.bubble.md-bubble table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92em;
}
.bubble.md-bubble th,
.bubble.md-bubble td {
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 6px 10px;
  text-align: left;
}
.bubble.md-bubble th {
  background: rgba(241, 245, 249, 0.85);
  font-weight: 600;
}

/* 交互式 HTML 沙盒组件卡片 */
.companion-app .message-content.has-html-widget {
  width: min(760px, 86vw);
  max-width: min(920px, 92%);
}
.companion-app.is-card-expanded .message-content.has-html-widget {
  width: min(1040px, 90vw);
  max-width: min(1120px, 92%);
}
.md-html-widget {
  margin: 0.75em 0;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.08);
  overflow: hidden;
}
.md-widget-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(90deg, #eff6ff 0%, #f8fafc 100%);
  border-bottom: 1px solid #dbeafe;
}
.md-widget-title {
  font-size: 12px;
  font-weight: 600;
  color: #1e40af;
}
.md-widget-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.md-widget-btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.md-widget-btn:hover {
  border-color: #93c5fd;
  color: #1d4ed8;
}
.md-widget-btn.is-active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}
.md-widget-preview {
  background: #ffffff;
}
.md-widget-frame {
  display: block;
  width: 100%;
  height: 300px;
  border: 0;
  background: #ffffff;
}
.md-widget-code pre {
  margin: 0 !important;
  border-radius: 0 !important;
  max-height: 420px;
}
.md-widget-fullscreen-backdrop {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(6px);
}
.md-widget-fullscreen-dialog {
  width: min(1160px, 95vw);
  height: min(860px, 90vh);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35);
}
.md-widget-fullscreen-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #ffffff;
}


/* === Study Material Library & Grounded RAG Panels === */
.study-files-drawer-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.study-files-drawer-title strong {
  font-size: 13px;
  color: var(--ink, #1e293b);
}
.study-files-drawer-title span {
  font-size: 11.5px;
  color: var(--muted, #64748b);
}
.study-files-drawer-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.study-files-drawer-btns .header-action.is-active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.study-files-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 2px;
}
.study-files-empty {
  font-size: 12px;
  color: var(--muted, #64748b);
  padding: 6px 2px;
}
.study-library-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.25);
  transition: border-color .15s ease, background .15s ease;
}
.study-library-item.is-linked {
  border-color: rgba(37, 99, 235, 0.45);
  background: rgba(239, 246, 255, 0.72);
}
.study-lib-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 600;
  color: #475569;
}
.study-lib-check input {
  width: 15px;
  height: 15px;
  accent-color: #2563eb;
  cursor: pointer;
}
.study-library-item.is-linked .study-lib-check {
  color: #1d4ed8;
}
.study-lib-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.study-lib-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.study-type-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
}
.study-lib-name {
  font-size: 13px;
  color: var(--ink, #1e293b);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.study-lib-meta {
  font-size: 11.5px;
  color: var(--muted, #64748b);
}
.study-lib-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.study-lib-btn {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #ffffff;
  color: #334155;
  border-radius: 8px;
  padding: 3px 9px;
  font-size: 11.5px;
  cursor: pointer;
}
.study-lib-btn:hover {
  border-color: #2563eb;
  color: #1d4ed8;
}
.study-lib-btn.is-danger:hover {
  border-color: #ef4444;
  color: #dc2626;
}

/* Inline citation pill */
.cite-pill {
  display: inline-flex;
  align-items: center;
  vertical-align: baseline;
  margin: 0 2px;
  padding: 0 5px;
  border: 1px solid rgba(37, 99, 235, 0.32);
  border-radius: 6px;
  background: rgba(239, 246, 255, 0.9);
  color: #1d4ed8;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
}
.cite-pill:hover {
  background: #2563eb;
  color: #ffffff;
}

.md-bubble.is-abstained {
  border: 1px solid rgba(217, 119, 6, 0.45);
  background: rgba(255, 251, 235, 0.92);
}

/* Grounded RAG panels below study assistant bubble */
.study-rag-panel {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
}
.rag-status-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(241, 245, 249, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #475569;
  font-size: 11.5px;
}
.rag-status-strip.is-abstained {
  background: rgba(254, 243, 199, 0.72);
  border-color: rgba(217, 119, 6, 0.35);
  color: #92400e;
}
.rag-status-badge {
  font-weight: 700;
  color: #047857;
}
.rag-status-strip.is-abstained .rag-status-badge {
  color: #b45309;
}
.rag-warning {
  color: #b45309;
}

.rag-section {
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.84);
  padding: 8px 10px;
}
.rag-section > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  color: #334155;
  user-select: none;
}
.rag-card-list {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}
.rag-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: #ffffff;
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
}
.rag-card:hover {
  border-color: rgba(104, 119, 179, 0.55);
  transform: translateY(-1px);
}
.rag-rec-card {
  border-color: rgba(148, 163, 184, 0.26);
  background: #ffffff;
}
.rag-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.rag-card-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rag-card-score {
  font-size: 12.5px;
  color: var(--muted);
  flex-shrink: 0;
}
.rag-reason-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  flex-shrink: 0;
}
.rag-card-sub {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.45;
}
.rag-card-snippet {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rag-topic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.rag-topic-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 12.5px;
  font-weight: 500;
}
.rag-card-actions {
  margin-top: 4px;
  display: flex;
  gap: 6px;
}
.rag-mini-btn {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #ffffff;
  color: var(--text);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
}
.rag-mini-btn.is-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.rag-mini-btn:hover {
  opacity: 0.92;
}

/* Chunk preview modal */
.study-chunk-modal {
  margin: auto;
  width: min(740px, 92vw);
  max-height: 82vh;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}
.study-chunk-modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.study-chunk-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  background: #f8fafc;
}
.study-chunk-modal-sub {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}
.study-chunk-modal-body {
  padding: 16px 18px;
  max-height: calc(82vh - 68px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.study-chunk-fulltext {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.2);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.65;
  color: #1e293b;
}
.study-chunk-modal-actions {
  display: flex;
  justify-content: flex-end;
}
.study-chunk-list-card {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.study-chunk-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
}
.study-chunk-list-text {
  font-size: 12px;
  color: #475569;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* === Standalone Study Library Module (Compact Light-Paper Preview + Title Cards) === */
.companion-app .library-view.is-active {
  display: block;
  height: 100%;
  min-height: 0;
}
.library-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px 22px;
  box-shadow: 0 12px 36px rgba(68, 79, 128, 0.08);
  overflow: hidden;
}
.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.library-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.library-title-group h3 {
  margin: 0;
  font-size: 17px;
  color: var(--text);
}
.library-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lib-filter-pill {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid #dde2f2;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.lib-filter-pill.is-active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: #c5cde9;
  font-weight: 600;
}
.library-cards-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 195px));
  grid-auto-rows: 215px;
  gap: 14px;
  padding: 2px 2px 10px;
}
.library-empty-hint {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  font-size: 13px;
}
.lib-preview-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #f8f9fd;
  border: 1px solid #e1e5f2;
  box-shadow: 0 8px 22px rgba(68, 79, 128, 0.09);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.lib-preview-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 12px 28px rgba(68, 79, 128, 0.16);
}
.lib-card-thumb {
  position: absolute;
  inset: 0;
  padding: 12px 12px 66px;
  background: linear-gradient(165deg, #ffffff 0%, #f1f3fb 100%);
  overflow: hidden;
}
.lib-card-thumb.is-code {
  background: linear-gradient(165deg, #f4f6fc 0%, #e9edf8 100%);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.lib-thumb-sheet {
  height: 100%;
  padding: 10px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #e7ebf5;
  box-shadow: 0 2px 8px rgba(68, 79, 128, 0.04);
  overflow: hidden;
}
.lib-thumb-lines {
  font-size: 10.5px;
  line-height: 1.55;
  color: #54607d;
  word-break: break-word;
}
.lib-card-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 38%, rgba(56, 66, 108, 0.82) 78%, rgba(40, 48, 82, 0.94) 100%);
  pointer-events: none;
}
.lib-card-del {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.9);
  color: #64748b;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease, color .15s ease;
}
.lib-preview-card:hover .lib-card-del { opacity: 1; }
.lib-card-del:hover { color: #dc2626; }
.lib-card-bottom {
  position: relative;
  z-index: 2;
  padding: 10px 12px 11px;
  color: #ffffff;
}
.lib-card-title {
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lib-card-topics {
  margin-top: 5px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.lib-card-topics span {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: #f8faff;
}

/* 自习室 Session 右键菜单 */
.study-context-menu {
  position: fixed;
  z-index: 9999;
  min-width: 148px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(190, 199, 232, 0.78);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 30px rgba(42, 52, 92, 0.16);
}
.study-context-menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 8px 12px;
  border-radius: 8px;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
.study-context-menu-item.is-danger {
  color: #c53030;
}
.study-context-menu-item.is-danger:hover {
  background: rgba(229, 62, 62, 0.10);
  color: #9b2c2c;
}

/* 资料库拖拽批量上传提示层 */
.library-panel {
  position: relative;
}
.library-drop-overlay {
  position: absolute;
  inset: 12px;
  z-index: 30;
  border-radius: 18px;
  border: 2px dashed var(--accent);
  background: rgba(244, 246, 253, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .16s ease;
}
.library-drop-overlay strong {
  font-size: 16px;
  color: var(--accent-deep);
}
.library-drop-overlay span {
  font-size: 12.5px;
  color: var(--muted);
}
.library-panel.is-drag-over .library-drop-overlay {
  opacity: 1;
}

/* 统一微透明面板，稍微透出淡化背景（不加过重模糊，避免发白糊掉） */
.companion-app .surface,
.companion-app .library-panel,
.companion-app .study-panel,
.companion-app .chat-deck .chat-panel.is-front-card,
.companion-app .sent-media-panel.is-front-card {
  background: rgba(255, 255, 255, 0.76) !important;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border-radius: 24px !important;
  border: 1px solid rgba(255, 255, 255, 0.82) !important;
  box-shadow: 0 12px 42px rgba(72, 86, 136, 0.08) !important;
}
.companion-app .message-bubble {
  background: rgba(255, 255, 255, 0.86);
}
.companion-app .message-row.is-user .message-bubble {
  background: rgba(232, 236, 248, 0.88);
}
.companion-app .composer {
  background: rgba(255, 255, 255, 0.84);
}

/* 资料库真实缩略图 & 原文件在线预览 */
.lib-card-thumb.has-real-thumb {
  padding: 0;
  background: #f5f7fc;
}
.lib-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.lib-modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e7ebf5;
}
.lib-modal-tabs {
  display: flex;
  gap: 8px;
}
.lib-modal-tab {
  border: 1px solid #dde2f2;
  background: #ffffff;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
}
.lib-modal-tab.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}
.lib-modal-open-link {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-deep);
  text-decoration: none;
}
.lib-modal-open-link:hover {
  text-decoration: underline;
}
.lib-raw-preview-wrap {
  width: 100%;
  min-height: 58vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f6f8fd;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #e4e8f4;
}
.lib-raw-iframe {
  width: 100%;
  height: 62vh;
  border: 0;
  display: block;
}
.lib-raw-img {
  max-width: 100%;
  max-height: 62vh;
  object-fit: contain;
  display: block;
}

/* 资料库模式切换（资料卡片 / 知识图谱） */
.library-mode-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(234, 237, 248, 0.85);
  border: 1px solid rgba(190, 199, 232, 0.72);
  gap: 2px;
}
.lib-mode-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.lib-mode-btn.is-active {
  background: #ffffff;
  color: var(--accent-deep);
  box-shadow: 0 2px 6px rgba(80, 94, 153, 0.12);
}

/* 资料库无向知识图谱 */
.library-graph-shell {
  display: flex;
  gap: 14px;
  flex: 1;
  min-height: 0;
  height: calc(100% - 62px);
}
.library-graph-shell[hidden] { display: none !important; }
.library-graph-canvas-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #e4e8f4;
  border-radius: 16px;
  overflow: hidden;
}
.library-graph-stats {
  padding: 9px 14px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid #e7ebf5;
  background: rgba(255, 255, 255, 0.78);
}
.library-graph-svg {
  width: 100%;
  flex: 1;
  min-height: 400px;
  display: block;
  cursor: grab;
}
.library-graph-svg:active { cursor: grabbing; }
.kg-zoom-controls {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #dde2f2;
  box-shadow: 0 4px 14px rgba(56, 68, 112, 0.10);
}
.kg-zoom-controls button {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 7px;
  cursor: pointer;
}
.kg-zoom-controls button:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.kg-edge {
  stroke: rgba(104, 119, 179, 0.34);
  stroke-linecap: round;
  transition: opacity .16s ease, stroke .16s ease;
}
.kg-edge.is-highlighted {
  stroke: var(--accent-deep);
  opacity: 0.9;
}
.kg-edge.is-dimmed {
  opacity: 0.12;
}
.kg-node {
  cursor: pointer;
  transition: opacity .16s ease;
}
.kg-node.is-dimmed {
  opacity: 0.28;
}
.kg-node circle {
  fill: var(--accent);
  stroke: #ffffff;
  stroke-width: 1.8;
  transition: fill .15s ease, stroke .15s ease, stroke-width .15s ease;
}
.kg-node text {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 11px;
  font-weight: 400;
  fill: #475569;
  stroke: none !important;
  stroke-width: 0 !important;
  pointer-events: none;
  user-select: none;
}
.kg-node:hover circle,
.kg-node.is-selected circle {
  fill: var(--accent-deep);
  stroke: #1e293b;
  stroke-width: 2.2;
}
.kg-node:hover text,
.kg-node.is-selected text {
  fill: #0f172a;
  font-weight: 600;
}
.graph-chunk-sub {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}
.library-graph-card {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #dde2f2;
  overflow-y: auto;
}
.library-graph-card[hidden] { display: none !important; }
.graph-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.graph-card-head strong {
  font-size: 15px;
  color: var(--text);
}
.graph-card-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.graph-card-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.graph-card-chunks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.graph-chunk-item {
  padding: 9px 10px;
  border-radius: 10px;
  background: #f8faff;
  border: 1px solid #e4e8f4;
}
.graph-chunk-head {
  font-size: 12.5px;
  color: var(--accent-deep);
  margin-bottom: 4px;
}
.graph-chunk-snippet {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.5;
}
.graph-card-ask-form {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.graph-card-ask-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid #d7ddef;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  background: #ffffff;
}
.graph-card-answer {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f6f8fd;
  border: 1px solid #dde2f2;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}

/* 资料库内置分栏阅读器 */
.library-reader-shell {
  display: flex;
  gap: 14px;
  height: 100%;
  min-height: 0;
}
.library-reader-shell[hidden] { display: none !important; }
.lib-reader-sidebar {
  width: 230px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e4e8f4;
  padding-right: 12px;
  min-height: 0;
}
.lib-reader-side-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid #e7ebf5;
}
.lib-reader-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid #dde2f2;
  background: #ffffff;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lib-reader-close-btn:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}
.lib-reader-file-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lib-reader-file-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: background .14s ease, border-color .14s ease;
}
.lib-reader-file-item:hover {
  background: #ffffff;
  border-color: #d7ddef;
}
.lib-reader-file-item.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.lib-reader-file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}
.lib-reader-file-type {
  font-size: 11px;
  color: var(--muted);
}
.lib-reader-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.lib-reader-main-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid #e7ebf5;
}
.lib-reader-main-head strong {
  font-size: 15px;
  color: var(--text);
  margin-right: 8px;
}
.lib-reader-sub {
  font-size: 12px;
  color: var(--muted);
}
.lib-reader-tabs {
  display: inline-flex;
  gap: 6px;
}
.lib-reader-tab {
  border: 1px solid #dde2f2;
  background: #ffffff;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.lib-reader-tab.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}
.lib-reader-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #e4e8f4;
  padding: 14px;
}
.lib-reader-iframe {
  width: 100%;
  height: 100%;
  min-height: 62vh;
  border: 0;
  border-radius: 10px;
  display: block;
}
.lib-reader-img-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lib-reader-img {
  max-width: 100%;
  max-height: 66vh;
  object-fit: contain;
  border-radius: 10px;
}
.lib-reader-loading {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.lib-reader-doc-flow,
.lib-reader-chunks-flow {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lib-reader-page-card {
  padding: 14px 16px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #e7ebf5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lib-reader-page-head strong {
  font-size: 13.5px;
  color: var(--accent-deep);
}
.lib-reader-page-content {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==========================================================================
   Airy Light Theme & Motion Overrides (aligned with Figma redesign)
   ========================================================================== */
@keyframes larkFadeUp {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes larkPulseDot {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 3px rgba(229, 149, 107, 0.22);
  }
  50% {
    transform: scale(1.18);
    box-shadow: 0 0 0 6px rgba(229, 149, 107, 0.08);
  }
}

@keyframes larkMsgIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Left floating sidebar at the highest layer (does not squeeze main workspace) + full-height page columns */
.companion-app .workspace {
  grid-template-rows: minmax(0, 1fr) !important;
}

.companion-app .view-stack,
.companion-app:not([data-view="home"]) .view-stack {
  grid-row: 1 / -1;
  height: 100%;
  padding-top: 14px !important;
  padding-bottom: 16px !important;
}

.companion-app .topbar {
  position: fixed !important;
  top: 14px;
  left: 12px;
  bottom: 14px;
  width: 48px !important;
  height: auto !important;
  z-index: 95 !important;
  padding: 12px 7px !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0 !important;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42) !important;
  backdrop-filter: blur(20px) saturate(1.15) !important;
  -webkit-backdrop-filter: blur(20px) saturate(1.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.62) !important;
  box-shadow: 0 10px 30px rgba(34, 37, 42, 0.08) !important;
  overflow: hidden;
  transition:
    width 280ms cubic-bezier(0.16, 1, 0.3, 1),
    padding 280ms cubic-bezier(0.16, 1, 0.3, 1),
    border-radius 280ms cubic-bezier(0.16, 1, 0.3, 1),
    background 240ms ease,
    box-shadow 280ms ease;
}

.companion-app .topbar:is(:hover, :focus-within, .is-expanded) {
  width: 176px !important;
  padding: 16px 12px !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.62) !important;
  box-shadow: 0 18px 44px rgba(34, 37, 42, 0.14) !important;
}

.companion-app .topbar-left {
  width: 100%;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-bottom: 1px solid transparent;
  transition:
    flex 280ms cubic-bezier(0.16, 1, 0.3, 1),
    padding 240ms ease,
    border-color 240ms ease;
}

.companion-app .topbar:is(:hover, :focus-within, .is-expanded) .topbar-left {
  flex: 0 0 auto;
  justify-content: flex-start;
  padding: 2px 4px 10px;
  border-bottom-color: rgba(255, 255, 255, 0.56);
}

.companion-app .topbar-right {
  display: none !important;
}

.companion-app .companion-brand {
  width: auto;
  justify-content: center;
  gap: 0;
  padding: 3px;
  background: transparent;
  transition: gap 240ms cubic-bezier(0.16, 1, 0.3, 1), padding 240ms ease;
}

.companion-app .topbar:is(:hover, :focus-within, .is-expanded) .companion-brand {
  width: 100%;
  justify-content: flex-start;
  gap: 9px;
  padding: 6px 8px;
}

.companion-app .companion-brand:hover {
  background: rgba(255, 255, 255, 0.35);
}

.companion-app .brand-logo {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 4px 12px rgba(34, 37, 42, 0.08);
}

.companion-app .companion-brand > span:last-child {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transition:
    max-width 260ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 180ms ease;
}

.companion-app .topbar:is(:hover, :focus-within, .is-expanded) .companion-brand > span:last-child {
  max-width: 100px;
  opacity: 1;
}

/* Vertical nav list inside the floating left sidebar (collapsed in slim state, expanded on approach) */
.companion-app .top-nav {
  position: static !important;
  left: auto !important;
  transform: none !important;
  margin-left: 0 !important;
  width: 100% !important;
  max-width: none !important;
  flex: 0 0 0px;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  flex-direction: column !important;
  align-items: stretch !important;
  overflow: hidden;
  padding: 0 !important;
  border-radius: 0;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: 0 !important;
  box-shadow: none !important;
  gap: 4px;
  transition:
    flex 280ms cubic-bezier(0.16, 1, 0.3, 1),
    max-height 280ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 200ms ease;
}

.companion-app .topbar:is(:hover, :focus-within, .is-expanded) .top-nav {
  flex: 1 1 auto;
  max-height: 720px;
  opacity: 1;
  pointer-events: auto;
  overflow-y: auto;
}

.companion-app .top-nav .nav-item {
  width: 100%;
  justify-content: flex-start;
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 13px;
  color: rgba(34, 37, 42, 0.78);
  transition: background .22s cubic-bezier(0.22, 1, 0.36, 1), color .2s ease, transform .2s cubic-bezier(0.22, 1, 0.36, 1);
}

.companion-app .top-nav .nav-item:hover {
  background: rgba(255, 255, 255, 0.52);
  color: var(--text);
  transform: translateX(2px);
}

.companion-app .top-nav .nav-item.is-active {
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-deep);
  box-shadow: 0 2px 10px rgba(42, 50, 75, 0.06) !important;
}

/* Pull all page columns/surfaces to full available height from top to bottom */
.companion-app .app-view.is-active:not(.home-view) {
  height: 100%;
}

.companion-app .app-view.is-active:not(.home-view) > .surface,
.companion-app .library-panel,
.companion-app .chat-deck,
.companion-app .chat-panel,
.companion-app .study-workspace-layout,
.companion-app .study-panel {
  height: 100%;
}

/* Home View: slim sidebar takes almost no space, so cards sit at natural left offset */
.companion-app .home-view.is-active {
  align-items: flex-start;
  justify-content: center;
  padding-left: 48px;
  padding-bottom: 24px;
  gap: 20px;
}

.companion-app .home-quick-cards {
  display: grid;
  grid-template-columns: repeat(2, 260px);
  justify-content: start;
  gap: 14px;
  width: auto;
  max-width: 536px;
  margin-bottom: 0;
}

.companion-app .home-quick-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-width: 0;
  min-height: 108px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(18px) saturate(1.12);
  -webkit-backdrop-filter: blur(18px) saturate(1.12);
  border: 1px solid rgba(255, 255, 255, 0.56);
  box-shadow: 0 8px 26px rgba(34, 37, 42, 0.06);
  text-align: left;
  will-change: transform, box-shadow;
  animation: larkFadeUp .55s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  transition: transform .34s cubic-bezier(0.22, 1, 0.36, 1), background .26s ease, border-color .26s ease, box-shadow .34s cubic-bezier(0.22, 1, 0.36, 1);
}

.companion-app .home-quick-card::before,
.companion-app .lark-greeting-bubble::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.52), transparent 68%);
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease;
}

.companion-app .home-quick-card:nth-child(1) { animation-delay: .05s; }
.companion-app .home-quick-card:nth-child(2) { animation-delay: .10s; }
.companion-app .home-quick-card:nth-child(3) { animation-delay: .15s; }
.companion-app .home-quick-card:nth-child(4) { animation-delay: .20s; }

.companion-app .home-quick-card:hover {
  transform: perspective(820px) translateY(-6px) scale(1.015);
  background: rgba(255, 255, 255, 0.62);
  border-color: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 40px rgba(34, 37, 42, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.45) inset;
}

.companion-app .home-quick-card:hover::before,
.companion-app .lark-greeting-bubble:hover::before {
  opacity: 1;
}

.companion-app .home-quick-card:active {
  transform: perspective(820px) translateY(-2px) scale(0.99);
}

.companion-app .home-quick-card:hover .quick-tag {
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-deep);
  transform: translateY(-1px);
}

.companion-app .quick-card-head {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.companion-app .quick-card-head strong {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.companion-app .quick-tag {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(235, 242, 244, 0.72);
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
  transition: background .24s ease, transform .24s cubic-bezier(0.22, 1, 0.36, 1);
}

.companion-app .quick-sub {
  position: relative;
  z-index: 1;
  font-size: 12.5px;
  line-height: 1.5;
  color: rgba(34, 37, 42, 0.66);
}

/* Greeting Card below 2x2 quick cards */
.companion-app .lark-greeting-wrap {
  justify-content: flex-start;
  width: 534px;
  max-width: calc(100vw - 80px);
}

.companion-app .lark-greeting-bubble {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: none;
  align-items: flex-start;
  gap: 12px;
  padding: 22px 26px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.44);
  backdrop-filter: blur(18px) saturate(1.12);
  -webkit-backdrop-filter: blur(18px) saturate(1.12);
  border: 1px solid rgba(255, 255, 255, 0.56);
  box-shadow: 0 10px 30px rgba(34, 37, 42, 0.07);
  text-align: left;
  font-family: "Noto Serif SC", "Songti SC", "PingFang SC", serif;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.7;
  color: var(--text);
  will-change: transform, box-shadow;
  animation: larkFadeUp .55s cubic-bezier(0.22, 1, 0.36, 1) .18s backwards;
  transition: transform .34s cubic-bezier(0.22, 1, 0.36, 1), background .26s ease, border-color .26s ease, box-shadow .34s cubic-bezier(0.22, 1, 0.36, 1);
}

.companion-app .lark-greeting-bubble:hover {
  transform: perspective(900px) translateY(-5px) scale(1.01);
  background: rgba(255, 255, 255, 0.64);
  border-color: rgba(255, 255, 255, 0.86);
  box-shadow: 0 18px 38px rgba(34, 37, 42, 0.11);
}

.companion-app .lark-greeting-bubble:active {
  transform: perspective(900px) translateY(-2px) scale(0.992);
}

.companion-app .lark-greeting-dot,
.companion-app .lark-greeting-text {
  position: relative;
  z-index: 1;
}

.companion-app .lark-greeting-dot {
  margin-top: 10px;
  background: #e5956b;
  animation: larkPulseDot 2.8s ease-in-out infinite;
}

/* Higher translucency on buttons, surfaces, chat bubbles, composer */
.companion-app .surface {
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  border: 1px solid rgba(255, 255, 255, 0.62);
}

.companion-app .header-action,
.companion-app .button {
  background: rgba(255, 255, 255, 0.46);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-color: rgba(255, 255, 255, 0.62);
  transition: background .22s ease, transform .22s cubic-bezier(0.22, 1, 0.36, 1), border-color .22s ease;
}

.companion-app .header-action:hover,
.companion-app .button:hover {
  background: rgba(255, 255, 255, 0.72);
  transform: translateY(-1px);
}

.companion-app .button.button-primary,
.companion-app .send-button {
  background: rgba(104, 119, 179, 0.90);
  color: #ffffff;
  border-color: transparent;
}
.companion-app .button.button-primary:hover,
.companion-app .send-button:hover {
  background: rgba(82, 97, 157, 0.96);
}

.companion-app .message {
  animation: larkMsgIn .34s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.companion-app .bubble {
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 6px 22px rgba(34, 37, 42, 0.05);
}

.companion-app .message.is-user .bubble {
  background: rgba(243, 241, 235, 0.72);
  border-color: rgba(232, 229, 220, 0.72);
}

.companion-app .composer {
  background: rgba(255, 255, 255, 0.54);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.68);
  box-shadow: 0 10px 30px rgba(34, 37, 42, 0.06);
  transition: box-shadow .24s ease, background .24s ease;
}

.companion-app .composer:focus-within {
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 34px rgba(34, 37, 42, 0.08), 0 0 0 2px rgba(79, 123, 138, 0.25);
}

@media (max-width: 720px) {
  .companion-app .topbar {
    padding: 10px 14px 0;
  }
  .companion-app .home-view.is-active {
    padding-left: 0;
    align-items: stretch;
    justify-content: flex-end;
  }
  .companion-app .home-quick-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: none;
  }
  .companion-app .lark-greeting-wrap {
    width: 100%;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .companion-app .lark-greeting-bubble,
  .companion-app .lark-greeting-dot,
  .companion-app .home-quick-card,
  .companion-app .message {
    animation: none !important;
  }
}

/* Fullscreen card expansion keeps the floating left sidebar on the highest layer (z-index: 95) */
.companion-app.is-card-expanded .view-stack {
  grid-row: 1 / -1;
  z-index: 20;
  padding: 12px 18px !important;
}

.companion-app .chat-deck .deck-card {
  bottom: 0;
}

/* ==========================================================================
   Perplexity-inspired Chat + BeautifulUI Streaming Text Motion
   ========================================================================== */
@keyframes larkCaretIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes larkCaretBlink {
  0%, 48% { opacity: 1; }
  52%, 100% { opacity: 0.25; }
}

@keyframes larkChipPop {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.lark-stream-caret {
  display: inline-block;
  width: 2px;
  height: 15px;
  margin-left: 3px;
  vertical-align: -2px;
  border-radius: 999px;
  background: var(--accent);
  animation: larkCaretIn 150ms ease-out both, larkCaretBlink 900ms ease-in-out 150ms infinite;
}

.companion-app :is(.chat-panel .chat-list, .study-panel .study-chat-list) {
  width: 100%;
  padding: 20px 28px;
}

.companion-app :is(.chat-panel .composer, .study-panel .study-composer) {
  width: calc(100% - 32px);
  margin: 8px auto 14px;
}

.companion-app.is-card-expanded :is(.chat-panel .chat-list, .study-panel .study-chat-list) {
  max-width: none;
  padding: 24px 40px;
}

.companion-app.is-card-expanded :is(.chat-panel .composer, .study-panel .study-composer) {
  max-width: none;
  width: calc(100% - 64px);
  margin: 8px auto 16px;
}

.companion-app.is-card-expanded :is(.chat-panel .message-content, .study-panel .message-content) {
  max-width: min(1120px, 84%);
}

.companion-app :is(.chat-panel, .study-panel) .message.is-agent .bubble {
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  padding: 16px 22px;
  font-family: "Noto Serif SC", "Songti SC", "PingFang SC", serif;
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
  box-shadow: 0 4px 20px rgba(34, 37, 42, 0.04);
}

.companion-app :is(.chat-panel, .study-panel) .message.is-agent .bubble::before,
.companion-app :is(.chat-panel, .study-panel) .message.is-user .bubble::before {
  display: none;
}

.companion-app :is(.chat-panel, .study-panel) .message.is-user .bubble {
  background: rgba(243, 241, 235, 0.85);
  border: 1px solid rgba(232, 229, 220, 0.8);
  border-radius: 18px;
  padding: 12px 18px;
  font-size: 14.5px;
  line-height: 1.7;
}

.companion-app .bubble.is-stream-done .study-citation-chip,
.companion-app .bubble.is-stream-done .rag-topic-chip,
.companion-app .bubble.is-stream-done .cite-pill {
  animation: larkChipPop 250ms cubic-bezier(0.23, 1, 0.32, 1) both;
}

/* Streaming Text & Inline Citations staggered reveal for Study RAG panels */
@keyframes larkRagPanelFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes larkRagCardRise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.companion-app .study-rag-panel.is-stream-revealed {
  animation: larkRagPanelFade 400ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

.companion-app .study-rag-panel.is-stream-revealed .rag-card {
  animation: larkRagCardRise 350ms cubic-bezier(0.23, 1, 0.32, 1) both;
  animation-delay: calc(var(--rag-idx, 0) * 90ms);
}

/* ==========================================================================
   Craft-inspired Library Miniature Cards + Floating Popup Reader Card
   ========================================================================== */
@keyframes larkModalPop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.975);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.companion-app .library-cards-grid {
  gap: 18px;
}

.companion-app .lib-preview-card {
  padding: 7px;
  border-radius: 20px;
  background: rgba(238, 240, 250, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 24px rgba(42, 50, 75, 0.06);
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 240ms ease, background 240ms ease;
}

.companion-app .lib-preview-card:nth-child(even) {
  background: rgba(243, 241, 235, 0.8);
}

.companion-app .lib-preview-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 32px rgba(42, 50, 75, 0.12);
}

.companion-app .lib-card-thumb {
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(228, 232, 244, 0.7);
}

.companion-app .lib-card-bottom {
  border-radius: 0 0 14px 14px;
}

/* Study View: Top-level Popup Card for #studyFilesDrawer (关联资料) */
.study-files-modal:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(42, 50, 75, 0.26);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.study-files-popup-card {
  width: min(940px, calc(100vw - 48px));
  max-height: min(82vh, 700px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 24px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 28px 80px rgba(42, 50, 75, 0.22);
  animation: larkPopupIn 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes larkPopupIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.975);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.study-files-popup-card .study-files-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(228, 232, 244, 0.75);
  flex-shrink: 0;
}

.study-files-popup-card .study-files-drawer-title {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.study-files-popup-card .study-files-drawer-title strong {
  font-size: 16px;
  color: var(--text);
}

.study-files-popup-card .study-files-drawer-title span {
  font-size: 12px;
  color: var(--muted);
}

.study-files-popup-card .study-files-drawer-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.study-files-popup-card .study-files-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  overflow-y: auto;
  padding: 4px;
}

.study-lib-preview-card {
  cursor: pointer;
  min-height: 220px;
  padding: 7px;
  border-radius: 20px;
  background: rgba(238, 240, 250, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 24px rgba(42, 50, 75, 0.06);
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 240ms ease, border-color 240ms ease;
}

.study-lib-preview-card:nth-child(even) {
  background: rgba(243, 241, 235, 0.8);
}

.study-lib-preview-card.is-linked {
  border-color: rgba(104, 119, 179, 0.65);
  box-shadow: 0 10px 28px rgba(104, 119, 179, 0.16);
}

.study-lib-preview-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 32px rgba(42, 50, 75, 0.12);
}

.study-lib-preview-card .lib-card-thumb {
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(228, 232, 244, 0.7);
}

.study-lib-preview-card .lib-card-bottom {
  border-radius: 0 0 14px 14px;
}

.study-lib-float-check {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(228, 232, 244, 0.9);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(42, 50, 75, 0.08);
}

.study-lib-preview-card.is-linked .study-lib-float-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.study-lib-float-check input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: #ffffff;
}

.study-lib-float-chunks {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 4;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(228, 232, 244, 0.9);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(42, 50, 75, 0.08);
}
.study-lib-float-chunks:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.study-lib-card-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

@media (max-width: 720px) {
  .study-files-popup-card {
    width: calc(100vw - 24px);
    max-height: 84vh;
    padding: 16px;
  }
}

/* ==========================================================================
   Taskade-inspired Translucent Knowledge Graph Mode (Full-width leftward expansion)
   ========================================================================== */
.companion-app[data-view="library"] .view-stack {
  transition: padding-left 360ms cubic-bezier(0.16, 1, 0.3, 1);
}

.companion-app.is-library-graph[data-view="library"] .view-stack {
  padding-left: 72px !important;
  padding-right: 18px !important;
}

.companion-app.is-library-graph[data-view="library"] .companion-stage {
  z-index: 25;
  pointer-events: none;
  opacity: 1;
}

.companion-app.is-library-graph .library-panel {
  background: rgba(255, 255, 255, 0.56) !important;
  backdrop-filter: blur(14px) saturate(1.1) !important;
  -webkit-backdrop-filter: blur(14px) saturate(1.1) !important;
}

.companion-app .library-graph-shell {
  position: relative;
  display: block;
  flex: 1;
  min-height: 0;
  height: calc(100% - 58px);
}

.companion-app .library-graph-canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.55);
  overflow: hidden;
}

.companion-app .library-graph-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
.companion-app .library-graph-svg:active {
  cursor: grabbing;
}

.companion-app .library-graph-stats {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 6;
  max-width: min(520px, 60%);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.78);
  font-size: 11.5px;
  color: var(--text);
  box-shadow: 0 4px 16px rgba(42, 50, 75, 0.06);
  pointer-events: none;
}

.companion-app .kg-zoom-controls {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 20px rgba(42, 50, 75, 0.08);
  transition: right 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

.companion-app .library-graph-shell:has(#libraryGraphNodeCard:not([hidden])) .kg-zoom-controls {
  right: 368px;
}

.companion-app .kg-zoom-controls button {
  border: 0;
  background: transparent;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.companion-app .kg-zoom-controls button:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.companion-app .kg-node circle {
  fill: var(--accent);
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 2;
  filter: drop-shadow(0 2px 8px rgba(104, 119, 179, 0.35));
  transition: transform 180ms ease, fill 180ms ease;
}

.companion-app .kg-node.is-selected circle {
  fill: #e5956b;
  stroke: #ffffff;
  stroke-width: 2.5;
  filter: drop-shadow(0 0 12px rgba(229, 149, 107, 0.55));
}

.companion-app .kg-node text {
  font-size: 11.5px;
  font-weight: 500;
  fill: var(--text);
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.88);
  stroke-width: 3px;
}

.companion-app .kg-edge {
  stroke: rgba(104, 119, 179, 0.32);
  transition: stroke 180ms ease, opacity 180ms ease;
}
.companion-app .kg-edge.is-highlighted {
  stroke: rgba(104, 119, 179, 0.88);
}
.companion-app .kg-node.is-dimmed,
.companion-app .kg-edge.is-dimmed {
  opacity: 0.22;
}

/* Equal-height tall strip card for selected node detail + Q&A */
.companion-app .library-graph-card:not([hidden]) {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: 342px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(22px) saturate(1.1);
  -webkit-backdrop-filter: blur(22px) saturate(1.1);
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 46px rgba(42, 50, 75, 0.14);
  animation: larkPopupIn 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.companion-app .library-graph-card .graph-card-chunks {
  flex: 0 1 auto;
  max-height: 44%;
  min-height: 0;
  overflow-y: auto;
}

.companion-app .library-graph-card .graph-card-divider {
  height: 1px;
  background: rgba(218, 224, 240, 0.9);
  margin: 4px 0;
  flex-shrink: 0;
}

.companion-app .library-graph-card .graph-card-qa-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-right: 2px;
}

.companion-app .library-graph-card .graph-card-answer {
  max-height: none;
  overflow: visible;
  flex-shrink: 0;
  background: transparent !important;
  border: 0 !important;
  padding: 4px 0 !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.companion-app .library-graph-card .graph-card-answer[hidden] {
  display: none !important;
}

.graph-qa-msg {
  display: flex;
  width: 100%;
  animation: larkMsgIn 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.graph-qa-msg.is-user {
  justify-content: flex-end;
}

.graph-qa-msg.is-agent {
  justify-content: flex-start;
}

.graph-qa-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  word-break: break-word;
}

.graph-qa-msg.is-user .graph-qa-bubble {
  background: var(--bubble-user);
  border: 1px solid rgba(232, 229, 220, 0.85);
}

.graph-qa-msg.is-agent .graph-qa-bubble {
  background: rgba(238, 240, 250, 0.72);
  border: 1px solid rgba(220, 226, 244, 0.9);
}

.graph-qa-bubble.is-loading {
  color: var(--muted);
}

.graph-qa-bubble.is-error {
  color: #c53030;
  background: rgba(254, 242, 242, 0.9);
  border-color: rgba(252, 165, 165, 0.6);
}

.companion-app .library-graph-card .graph-card-ask-form {
  flex-shrink: 0;
}

@media (max-width: 820px) {
  .companion-app .library-graph-card:not([hidden]) {
    width: calc(100% - 24px);
    top: auto;
    height: 55%;
  }
  .companion-app .library-graph-shell:has(#libraryGraphNodeCard:not([hidden])) .kg-zoom-controls {
    right: 14px;
  }
}
