:root {
  --sidebar-w: 280px;
  --sidebar-bg: #141416;
  --sidebar-hover: #222226;
  --sidebar-active: #2a2a30;
  --sidebar-text: #ececf1;
  --sidebar-muted: #9b9ba7;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --main-bg: #f6f7f9;
  --surface: #ffffff;
  --text: #15171c;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --accent-ink: #115e59;
  --danger-soft: #fee2e2;
  --danger: #b91c1c;
  --warn-soft: #ffedd5;
  --warn: #c2410c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --font: "Figtree", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html {
  margin: 0;
  background: var(--main-bg);
}
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--main-bg);
  -webkit-font-smoothing: antialiased;
}

/* —— Login —— */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 50% at 50% 30%, #1a2e2c 0%, transparent 55%),
    #0b1220;
  color: #e8fffb;
}
.login-screen[hidden] { display: none !important; }
.login-card {
  width: min(400px, 100%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.login-card h1 {
  margin: 4px 0 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.login-lead {
  margin: 0 0 8px;
  color: rgba(204, 251, 241, 0.72);
  font-size: 0.95rem;
  line-height: 1.55;
}
.google-btn-slot {
  min-height: 44px;
  display: flex;
  justify-content: center;
  margin-top: 8px;
}
.btn-google-fallback {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 12px 18px;
  border-radius: 999px;
  background: #fff;
  color: #1f2937;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.btn-google-fallback[hidden] { display: none !important; }
.btn-google-fallback:not([hidden]) {
  display: inline-flex;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 10px 0 2px;
  color: rgba(204, 251, 241, 0.45);
  font-size: 0.78rem;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(204, 251, 241, 0.18);
}
.password-login {
  width: 100%;
  display: grid;
  gap: 8px;
  margin-top: 4px;
}
.password-login input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(204, 251, 241, 0.22);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.45);
  color: #e8fffb;
  font-size: 0.95rem;
  outline: none;
}
.password-login input::placeholder {
  color: rgba(204, 251, 241, 0.4);
}
.password-login input:focus {
  border-color: rgba(45, 212, 191, 0.55);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12);
}
.btn-password-login {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: #0f766e;
  color: #fff;
  font-weight: 650;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn-password-login:hover { background: #0d9488; }
.btn-password-login:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.login-error {
  margin: 8px 0 0;
  color: #fecaca;
  font-size: 0.85rem;
}
.login-hint {
  margin: 16px 0 0;
  font-size: 0.72rem;
  color: rgba(204, 251, 241, 0.4);
}
.theme-empty {
  padding: 10px 12px;
  font-size: 0.78rem;
  color: var(--sidebar-muted);
}

/* In-chat ingest result */
.ingest-bubble { max-width: 100%; }
.ing-head {
  font-weight: 650;
  margin-bottom: 10px;
  color: var(--accent-ink);
}
.ing-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fafafa;
}
.ing-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.ing-rel { color: var(--accent); }
.ing-title { font-weight: 650; margin-bottom: 4px; }
.ing-body {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 6px;
}
.ing-sec {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: 8px;
  font-size: 0.8rem;
  padding: 4px 0;
  border-top: 1px solid var(--border);
}
.ing-sec-k { color: var(--accent-ink); font-weight: 650; }
.ing-sec-t { color: var(--text); line-height: 1.4; }
.ing-foot {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}
.ing-empty { color: var(--muted); font-size: 0.9rem; }

.obj-list { display: flex; flex-direction: column; gap: 10px; }
.obj-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface);
}
.obj-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}
.obj-card h3 { margin: 0 0 8px; font-size: 1.05rem; }
.obj-body { margin: 0 0 8px; color: var(--muted); line-height: 1.5; font-size: 0.92rem; }
.obj-sec {
  border-top: 1px solid var(--border);
  padding: 6px 0;
  font-size: 0.88rem;
}
.obj-sec summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--accent-ink);
}
.obj-sec p { margin: 6px 0 0; line-height: 1.5; color: var(--text); }
.empty-row .sub { color: var(--muted); }
.btn-logout {
  margin: 16px 0 40px;
  display: inline-flex;
  padding: 12px 18px;
  border-radius: 12px;
  background: #111827;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.btn-logout:hover { background: #1f2937; }
.settings-card .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  word-break: break-all;
}
/* 侧栏全屏打开时，底下壳子也跟着深色，避免露白 */
html.nav-open,
body.nav-open,
body.nav-open .app-shell {
  background: var(--sidebar-bg) !important;
}
button, input { font: inherit; color: inherit; }
button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}
a { color: inherit; text-decoration: none; }

/* —— Splash —— */
.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background:
    radial-gradient(ellipse 80% 50% at 50% 40%, #1a2e2c 0%, transparent 60%),
    #0b1220;
  color: #e8fffb;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
.splash.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-logo {
  width: 72px;
  height: 72px;
  animation: splash-pop 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.splash-word {
  font-size: 1.55rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  animation: splash-fade 0.8s 0.15s both;
}
.splash-sub {
  font-size: 0.85rem;
  color: rgba(204, 251, 241, 0.65);
  animation: splash-fade 0.8s 0.28s both;
}
@keyframes splash-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes splash-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* —— Shell —— */
.app-shell {
  display: flex;
  width: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  opacity: 0;
  transition: opacity 0.35s ease;
  background: var(--main-bg);
}
.app-shell.is-ready { opacity: 1; }

/* 桌面：左右栏，主区内部滚动 */
@media (min-width: 861px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }
  .app-shell {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    z-index: 2;
  }
}

/* —— Sidebar —— */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  z-index: 40;
  overflow: hidden; /* 整栏不滚；只滚中间菜单 */
  min-height: 0;
}
.sidebar-top {
  padding: 14px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 12px;
}
.brand-row img { width: 28px; height: 28px; border-radius: 8px; }
.brand-row strong {
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.nav-primary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 8px;
}
.nav-think-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 4px;
}
.nav-think-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 4px 40px;
}
.nav-think-meta[hidden],
.nav-draft-list[hidden] {
  display: none !important;
}
.nav-draft-hint {
  flex: 1;
  min-width: 0;
  font-size: 0.72rem;
  color: var(--sidebar-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-draft-new {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 500;
  color: #5eead4;
  padding: 2px 6px;
  border-radius: 6px;
}
.nav-draft-new:hover {
  background: var(--sidebar-hover);
  color: #99f6e4;
}
.nav-draft-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 0 6px 28px;
}
.nav-draft-item {
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  color: #c4c4ce;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-draft-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  transition: background 0.15s ease;
}
.nav-btn:hover { background: var(--sidebar-hover); }
.nav-btn.is-active { background: var(--sidebar-active); }
.nav-btn .ico {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  opacity: 0.9;
}
.nav-btn .label {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 500;
}
.nav-btn .chev {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  opacity: 0.55;
  transition: transform 0.2s ease;
}
.nav-fold[aria-expanded="false"] .chev {
  transform: rotate(-90deg);
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 6px 8px;
}
.nav-group.is-collapsed .nav-sub { display: none; }
.theme-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  color: #c4c4ce;
  transition: background 0.15s ease;
}
.theme-item:hover { background: var(--sidebar-hover); }
.theme-item.is-active { background: var(--sidebar-active); color: #fff; }
.theme-item .dot {
  width: 6px;
  height: 6px;
  margin-top: 7px;
  border-radius: 50%;
  background: #2dd4bf;
  flex: 0 0 6px;
  opacity: 0.7;
}
.theme-item .t-title {
  font-size: 0.84rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.theme-item .t-meta {
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--sidebar-muted);
}
.nav-more {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px 8px 24px;
  border-radius: 10px;
  color: #5eead4;
  font-size: 0.8rem;
  font-weight: 500;
}
.nav-more:hover { background: var(--sidebar-hover); color: #99f6e4; }

.sidebar-scroll {
  flex: 1 1 0; /* basis 0：占满剩余高度，多了才在这里滚 */
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 12px 8px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #3a3a42 transparent;
}
/* 用户/设置：钉在侧栏底部，不参与滚动 */
.sidebar-foot {
  flex: 0 0 auto;
  flex-shrink: 0;
  margin-top: auto;
  border-top: 1px solid var(--sidebar-border);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--sidebar-bg);
  z-index: 1;
}
.profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  text-align: left;
}
.profile-btn:hover { background: var(--sidebar-hover); }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2dd4bf, #0f766e);
  color: #042f2e;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex: 0 0 32px;
}
.profile-meta { min-width: 0; }
.profile-meta .name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-meta .hint {
  font-size: 0.72rem;
  color: var(--sidebar-muted);
}

/* —— Backdrop ——
   注意：不能盖在侧栏上。手机侧栏是全屏抽屉，不需要遮罩。 */
.backdrop {
  display: none !important;
}

/* —— Main —— */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 70% -10%, rgba(45, 212, 191, 0.08), transparent 55%),
    var(--main-bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  border-bottom: 1px solid transparent;
}
.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
}
.menu-btn:hover { background: rgba(15, 23, 42, 0.06); }
.menu-btn svg { width: 22px; height: 22px; }
.topbar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.topbar-spacer { flex: 1; }
.topbar-pill {
  font-size: 0.75rem;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 550;
}

.main-scroll {
  flex: 1;
  padding: 8px 20px 28px;
  min-height: 0;
}
@media (min-width: 861px) {
  .main-scroll {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  .main-scroll.is-chat {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 8px;
  }
}

.view { display: none; animation: view-in 0.28s ease both; }
.view.is-active { display: block; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.home-hero {
  max-width: 820px;
  margin: 12px auto 28px;
}
.home-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.home-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
  max-width: 36rem;
}

.draft-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  width: 100%;
  max-width: 640px;
  margin: 18px 0 0;
  padding: 12px 14px;
  text-align: left;
  border-radius: 12px;
  border: 1px solid rgba(45, 212, 191, 0.35);
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.12), rgba(45, 212, 191, 0.04));
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.draft-banner[hidden] {
  display: none !important;
}
.draft-banner:hover {
  border-color: rgba(45, 212, 191, 0.55);
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.18), rgba(45, 212, 191, 0.06));
}
.draft-banner-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #0f766e;
  text-transform: uppercase;
}
.draft-banner-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 500;
  color: #134e4a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.draft-banner-go {
  font-size: 0.84rem;
  font-weight: 600;
  color: #0d9488;
}

.composer-teaser {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 640px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.composer-teaser:hover {
  border-color: #99f6e4;
  transform: translateY(-1px);
}
.composer-teaser .placeholder {
  flex: 1;
  color: var(--muted);
  font-size: 0.95rem;
}
.composer-teaser .go {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
}
.composer-teaser .go svg { width: 16px; height: 16px; }

.panel-grid {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}
.panel-head h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 650;
}
.panel-head .link {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 550;
}
.panel-head .link:hover { text-decoration: underline; }
.panel-body { padding: 10px 10px 12px; }

.synth-card {
  display: grid;
  gap: 10px;
}
@media (min-width: 720px) {
  .synth-card { grid-template-columns: 1fr 1fr; }
}
.synth-item {
  text-align: left;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.synth-item:hover {
  background: #f0fdfa;
  border-color: #99f6e4;
}
.synth-item .s-title {
  font-weight: 650;
  font-size: 0.92rem;
  margin-bottom: 4px;
}
.synth-item .s-count {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.synth-item ul {
  margin: 0;
  padding-left: 1.1rem;
  color: #374151;
  font-size: 0.84rem;
  line-height: 1.45;
}
.synth-item li + li { margin-top: 3px; }

.list-rows { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 10px;
  border-radius: 10px;
  transition: background 0.15s ease;
}
.list-row:hover { background: #f3f4f6; }
.list-row + .list-row { box-shadow: inset 0 1px 0 var(--border); }
.badge {
  flex: 0 0 auto;
  margin-top: 2px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 6px;
}
.badge.high { background: var(--danger-soft); color: var(--danger); }
.badge.medium { background: var(--warn-soft); color: var(--warn); }
.badge.low { background: #e5e7eb; color: #4b5563; }
.badge.type { background: var(--accent-soft); color: var(--accent-ink); }
.list-row .body { min-width: 0; flex: 1; }
.list-row .title {
  font-size: 0.9rem;
  font-weight: 550;
  line-height: 1.35;
}
.list-row .sub {
  margin-top: 3px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.page-header {
  max-width: 820px;
  margin: 8px auto 18px;
}
.page-header h1 {
  margin: 0 0 6px;
  font-size: 1.45rem;
  font-weight: 700;
}
.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* —— Chat / 思考 —— */
.view[data-view="think"].is-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  min-height: 0;
}
.chat-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 4px 16px;
  -webkit-overflow-scrolling: touch;
}
.chat-empty {
  max-width: 28rem;
  margin: 8vh auto 0;
  text-align: center;
  padding: 0 12px;
}
.chat-empty h1 {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 0 0 8px;
}
.chat-empty p {
  color: var(--muted);
  margin: 0;
  line-height: 1.55;
  font-size: 0.95rem;
}
.msg {
  display: flex;
  gap: 10px;
  margin: 0 0 14px;
  padding: 0 6px;
}
.msg-bubble {
  max-width: min(100%, 640px);
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
}
.msg.user { justify-content: flex-end; }
.msg.user .msg-bubble {
  background: #134e4a;
  color: #f0fdfa;
  border-bottom-right-radius: 6px;
}
.msg.assistant .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 6px;
}
.chat-dock {
  flex-shrink: 0;
  padding: 0 0 max(8px, env(safe-area-inset-bottom, 0px));
}
.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  text-align: left;
}
.chat-composer textarea {
  flex: 1;
  border: 0;
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 160px;
  background: transparent;
  line-height: 1.45;
  font-size: 0.98rem;
  padding: 10px 4px;
}
.composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding-bottom: 4px;
}
.chat-composer .mic {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg, #f6f7f9);
  color: var(--text);
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.chat-composer .mic:hover {
  border-color: #99f6e4;
  color: #0f766e;
}
.chat-composer .mic.is-listening {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
  animation: mic-pulse 1.2s ease-in-out infinite;
}
.chat-composer .mic:disabled {
  opacity: 0.4;
  cursor: default;
}
.chat-composer .mic .mic-stop { display: none; }
.chat-composer .mic.is-listening .mic-ico { display: none; }
.chat-composer .mic.is-listening .mic-stop { display: block; }
@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.voice-hint {
  margin: 8px 4px 0;
  font-size: 0.8rem;
  color: #b91c1c;
  text-align: center;
}
.chat-composer .send {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 36px;
}
.chat-composer .send:disabled { opacity: 0.4; cursor: default; }

/* 聊透后出现在消息流最下方 */
.save-cue {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 6px 18px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f0fdfa;
  border: 1px dashed #5eead4;
  max-width: min(100%, 420px);
}
.save-cue.is-visible { display: flex; }
.save-cue-text {
  margin: 0;
  font-size: 0.82rem;
  color: var(--accent-ink);
  line-height: 1.45;
}
.btn-save-inline {
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-ink);
  font-size: 0.78rem;
  font-weight: 650;
  border: 1px solid #5eead4;
  white-space: nowrap;
}
.btn-save-inline:hover { background: var(--accent-soft); }
.btn-save-inline:disabled {
  opacity: 0.45;
  cursor: default;
}

/* 存入认知托盘 */
.save-sheet[hidden] { display: none !important; }
.save-sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.save-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.save-sheet-panel {
  position: relative;
  width: min(100%, 560px);
  max-height: min(88dvh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(15, 23, 42, 0.18);
  animation: sheet-up 0.28s ease both;
}
@keyframes sheet-up {
  from { transform: translateY(16px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}
.save-sheet-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 18px 8px;
}
.save-sheet-head h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 700;
}
.save-sheet-head p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.4;
}
.save-sheet-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.save-sheet-close:hover { background: #f3f4f6; }
.save-sheet-body {
  flex: 1;
  overflow: auto;
  padding: 8px 14px 12px;
  -webkit-overflow-scrolling: touch;
}
.save-sheet-loading {
  margin: 24px 8px;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}
.msg.typing .msg-bubble,
.msg.typing .live-bubble {
  color: var(--ink);
  font-style: normal;
}
.live-bubble,
.digest-live-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.digest-live {
  margin: 12px 4px 20px;
  padding: 14px 14px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, #fafbfc 0%, #f3f4f6 100%);
}
.live-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}
.live-elapsed {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--muted);
}
.live-detail {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  min-height: 1em;
}
.live-think {
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.04);
  border-left: 3px solid rgba(15, 23, 42, 0.18);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
  max-height: 7.5em;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}
.live-reply {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}
.live-reply:not([hidden])::after {
  content: "|";
  display: inline-block;
  margin-left: 1px;
  animation: live-caret 1s step-end infinite;
  color: var(--muted);
}
.live-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.live-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent, #2563eb);
  opacity: 0.35;
  animation: live-dot 1.2s ease-in-out infinite;
}
.live-dots i:nth-child(2) { animation-delay: 0.2s; }
.live-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes live-dot {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
@keyframes live-caret {
  50% { opacity: 0; }
}
.save-group { margin-bottom: 14px; }
.save-group h3 {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.save-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  background: #fafafa;
}
.save-card input {
  margin-top: 3px;
  accent-color: var(--accent);
}
.save-card .sc-body { flex: 1; min-width: 0; }
.save-card .sc-kind {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-soft);
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  margin-bottom: 4px;
}
.save-card .sc-title {
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.35;
}
.save-card .sc-text {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}
.save-sheet-foot {
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
}
.btn-ghost,
.btn-primary {
  flex: 1;
  height: 44px;
  border-radius: 12px;
  font-weight: 650;
  font-size: 0.95rem;
}
.btn-ghost {
  background: #f3f4f6;
  color: var(--text);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.05); }
.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 90;
  background: #134e4a;
  color: #f0fdfa;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 550;
  box-shadow: var(--shadow);
  max-width: min(90vw, 360px);
  text-align: center;
}
.toast[hidden] { display: none !important; }

@media (min-width: 861px) {
  .save-sheet {
    align-items: center;
    padding: 24px;
  }
  .save-sheet-panel {
    border-radius: 18px;
    max-height: min(80vh, 680px);
  }
}
@media (max-width: 860px) {
  .chat-dock { padding-left: 0; padding-right: 0; }
  .view[data-view="think"] .chat-view { max-width: none; }
  .save-cue { margin-right: 12px; }
}

/* —— Cognitive network / second-brain viz —— */
.brain-strip {
  max-width: 820px;
  margin: 0 auto 22px;
  padding: 16px 16px 12px;
  border-radius: 18px;
  background: linear-gradient(160deg, #14181c 0%, #1a2226 55%, #121518 100%);
  color: #e8eeef;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.brain-strip-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  padding: 0 4px;
}
.brain-strip-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.brain-strip-head p {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: rgba(232, 238, 239, 0.55);
  line-height: 1.4;
}
.brain-strip-head .link {
  color: #5eead4;
  font-size: 0.82rem;
  white-space: nowrap;
}
.brain-canvas { margin: 0 -4px; }

.theme-net-wrap {
  margin: 0 0 20px;
  padding: 12px 10px 8px;
  border-radius: 16px;
  background: linear-gradient(160deg, #14181c 0%, #1a2226 55%, #121518 100%);
  color: #e8eeef;
  overflow: hidden;
}
.theme-net-head {
  display: flex;
  justify-content: space-between;
  padding: 0 8px 4px;
}
.theme-net-kicker {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #5eead4;
}
.theme-net-sub {
  margin-top: 2px;
  font-size: 0.78rem;
  color: rgba(232, 238, 239, 0.5);
}

.cog-net {
  position: relative;
  width: 100%;
}
.cog-net.is-empty {
  min-height: 120px;
  display: grid;
  place-items: center;
  padding: 24px;
}
.cog-net-empty {
  font-size: 0.88rem;
  color: rgba(232, 238, 239, 0.5);
  text-align: center;
}
.cog-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 300px;
}
.cog-edge {
  stroke: rgba(148, 163, 184, 0.22);
  stroke-width: 1.2;
  fill: none;
  opacity: 0;
  animation: edge-in 0.7s ease forwards;
  animation-delay: calc(var(--i, 0) * 28ms);
}
.cog-edge.tone-soft { stroke: rgba(94, 234, 212, 0.22); }
.cog-edge.tone-link { stroke: rgba(125, 211, 252, 0.35); stroke-dasharray: 3 3; }
.cog-edge.tone-conflict { stroke: rgba(248, 113, 113, 0.55); stroke-width: 1.6; }
.cog-edge.tone-faint { stroke: rgba(148, 163, 184, 0.12); stroke-width: 1; }
.cog-node {
  cursor: pointer;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: node-in 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  animation-delay: calc(80ms + var(--i, 0) * 35ms);
}
.cog-node .cog-glow {
  fill: rgba(45, 212, 191, 0.12);
  animation: breathe 3.6s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 120ms);
}
.cog-node .cog-core {
  fill: #2dd4bf;
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 1;
  transition: r 0.2s ease, fill 0.2s ease;
}
.cog-node.is-hub .cog-core {
  fill: #99f6e4;
  stroke: rgba(255, 255, 255, 0.55);
}
.cog-node.is-hub .cog-glow {
  fill: rgba(153, 246, 228, 0.18);
}
.cog-node.tone-question .cog-core { fill: #fbbf24; }
.cog-node.tone-question .cog-glow { fill: rgba(251, 191, 36, 0.16); }
.cog-node.tone-action .cog-core { fill: #38bdf8; }
.cog-node.tone-action .cog-glow { fill: rgba(56, 189, 248, 0.16); }
.cog-node.tone-evidence .cog-core { fill: #94a3b8; }
.cog-node.tone-evidence .cog-glow { fill: rgba(148, 163, 184, 0.14); }
.cog-node.tone-conflict .cog-core,
.cog-node.is-conflict .cog-core { fill: #f87171; }
.cog-node.tone-conflict .cog-glow,
.cog-node.is-conflict .cog-glow {
  fill: rgba(248, 113, 113, 0.22);
  animation: conflict-pulse 1.8s ease-in-out infinite;
}
.cog-node.is-highlight .cog-core {
  stroke: #fff;
  stroke-width: 2;
}
.cog-node:hover .cog-core { filter: brightness(1.15); }
.cog-label {
  fill: rgba(232, 238, 239, 0.72);
  font-size: 10px;
  font-family: var(--font);
  pointer-events: none;
}
.cog-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 2px 8px 6px;
  font-size: 0.68rem;
  color: rgba(232, 238, 239, 0.45);
}
.cog-legend .lg::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  background: #2dd4bf;
}
.cog-legend .tone-question::before { background: #fbbf24; }
.cog-legend .tone-action::before { background: #38bdf8; }
.cog-legend .tone-evidence::before { background: #94a3b8; }
.cog-legend .tone-conflict::before { background: #f87171; }

.cog-net.is-growing .cog-node.is-grow {
  animation: grow-pop 0.7s cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
  animation-delay: calc(120ms + var(--i, 0) * 70ms);
}
.cog-net.is-growing .cog-edge {
  animation: edge-draw 0.8s ease forwards;
  animation-delay: calc(200ms + var(--i, 0) * 50ms);
}

@keyframes node-in {
  from { opacity: 0; transform: scale(0.4); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes edge-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes edge-draw {
  from { opacity: 0; stroke-dasharray: 4 80; }
  to { opacity: 1; stroke-dasharray: 1 0; }
}
@keyframes breathe {
  0%, 100% { opacity: 0.35; r: 12; }
  50% { opacity: 0.7; r: 16; }
}
@keyframes conflict-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.9; }
}
@keyframes grow-pop {
  0% { opacity: 0; transform: scale(0.2); }
  60% { opacity: 1; transform: scale(1.25); }
  100% { opacity: 1; transform: scale(1); }
}

.growth-moment {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 12, 14, 0.55);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.28s ease;
}
.growth-moment.is-in { opacity: 1; }
.growth-card {
  width: min(520px, 100%);
  padding: 20px 18px 16px;
  border-radius: 20px;
  background: linear-gradient(165deg, #171c20 0%, #1e272c 100%);
  color: #e8eeef;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.growth-moment.is-in .growth-card {
  transform: none;
}
.growth-kicker {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5eead4;
}
.growth-card h2 {
  margin: 8px 0 4px;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}
.growth-card > p {
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: rgba(232, 238, 239, 0.6);
}
.growth-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
  padding: 0 4px;
}
.growth-actions .link { color: #99f6e4; }

.obj-card.is-pulse {
  outline: 2px solid rgba(45, 212, 191, 0.65);
  box-shadow: 0 0 0 6px rgba(45, 212, 191, 0.12);
  transition: outline 0.2s ease, box-shadow 0.2s ease;
}

.theme-detail {
  max-width: 720px;
  margin: 0 auto;
}
.theme-detail .lead {
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
  margin: 0 0 18px;
}
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  color: var(--muted);
}
.stat strong { color: var(--text); font-weight: 650; }

.settings-card {
  max-width: 520px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.settings-card .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
}
.settings-card .row + .row { border-top: 1px solid var(--border); }
.settings-card .k { font-weight: 550; }
.settings-card .v { color: var(--muted); font-size: 0.9rem; }

.whitelist-card {
  margin-top: 16px;
}
.whitelist-card h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 650;
}
.whitelist-card .whitelist-head p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}
.whitelist-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.accounts-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
@media (min-width: 560px) {
  .whitelist-form {
    grid-template-columns: 1.4fr 1fr auto;
    align-items: center;
  }
  .accounts-form {
    grid-template-columns: 1fr 1fr 1fr auto;
    align-items: center;
  }
}
.whitelist-form input,
.accounts-form input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
  background: var(--bg, #f6f7f9);
  color: var(--text);
  outline: none;
}
.whitelist-form input:focus,
.accounts-form input:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}
.btn-primary {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  background: #0f766e;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn-primary:hover { background: #0d9488; }
.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.whitelist-msg {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--warn, #b45309);
}
.whitelist-msg.is-ok { color: #0f766e; }
.whitelist-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}
.whitelist-list:empty::after {
  content: "还没有试用用户。添加 Gmail 后对方即可登录。";
  display: block;
  padding: 14px 0 4px;
  color: var(--muted);
  font-size: 0.88rem;
}
#accounts-list:empty::after {
  content: "还没有试用账号。录入用户名和密码后对方即可登录。";
}
.whitelist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.whitelist-item:last-child { border-bottom: 0; }
.whitelist-item .email {
  font-weight: 550;
  font-size: 0.92rem;
  word-break: break-all;
}
.whitelist-item .meta {
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--muted);
}
.whitelist-item .btn-remove {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}
.whitelist-item .btn-remove:hover {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

.search-box {
  max-width: 640px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.search-box input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 0.98rem;
}
.search-results {
  max-width: 640px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* —— Mobile：像普通网页整页滚，不切上中下 —— */
@media (max-width: 860px) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* 侧栏打开 / 聊天页时再锁住 body */
  body.nav-open,
  body.is-chat {
    overflow: hidden;
    height: 100%;
    height: 100dvh;
    height: 100svh;
  }

  .app-shell {
    position: relative;
    display: block;
    width: 100%;
    min-height: 100dvh;
    min-height: 100svh;
    height: auto;
    z-index: 2;
  }
  body.nav-open .app-shell,
  body.is-chat .app-shell {
    position: fixed;
    inset: 0;
    display: flex;
    height: auto;
    overflow: hidden;
  }

  .main {
    display: block;
    width: 100%;
    min-height: 100dvh;
    min-height: 100svh;
    background: var(--main-bg);
    /* 给 fixed 顶栏留空，避免内容顶上去 */
    padding-top: calc(var(--safe-top) + 52px);
  }
  body.is-chat .main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    padding-top: 0;
  }

  /* 真正钉在视口顶部（sticky 在 iOS 整页滚时常失效） */
  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: calc(var(--safe-top) + 52px);
    padding: calc(10px + var(--safe-top)) 12px 10px 10px;
    background: rgba(246, 247, 249, 0.96);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(229, 231, 235, 0.9);
  }
  body.is-chat .topbar {
    position: relative;
    background: var(--main-bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom-color: transparent;
    flex-shrink: 0;
  }
  body.nav-open .topbar {
    /* 侧栏全屏时顶栏藏在下面，避免挡关闭按钮 */
    visibility: hidden;
    pointer-events: none;
  }

  .main-scroll {
    overflow: visible;
    height: auto;
    flex: none;
    padding: 14px 14px 32px;
  }
  body.is-chat .main-scroll {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 8px;
  }

  /* 侧栏：全屏抽屉；中间菜单可滚；底部用户信息钉死 */
  .sidebar {
    position: fixed;
    inset: 0;
    width: auto;
    max-width: none;
    height: auto;
    flex: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: none;
    background: var(--sidebar-bg);
    z-index: 50;
    padding-bottom: 0;
  }
  .sidebar.is-open {
    transform: none;
    pointer-events: auto;
  }
  .sidebar-top {
    flex: 0 0 auto;
    padding-top: calc(var(--safe-top) + 22px);
  }
  .sidebar-scroll {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }
  .sidebar-foot {
    flex: 0 0 auto;
    flex-shrink: 0;
    margin-top: auto;
    display: block;
    /* 略加大左边距；底边尽量贴底（安全区只留一点，别空一大截） */
    padding: 6px 16px 0 20px;
    padding-bottom: max(6px, calc(env(safe-area-inset-bottom, 0px) - 18px), calc(constant(safe-area-inset-bottom, 0px) - 18px));
    background: var(--sidebar-bg);
  }
  .sidebar-foot .profile-btn {
    width: 100%;
    justify-content: flex-start;
    gap: 10px;
    padding: 10px 8px 12px;
    text-align: left;
  }
  .sidebar-foot .profile-meta {
    text-align: left;
  }

  .menu-btn { display: inline-flex; }
  .home-hero { margin-top: 10px; margin-bottom: 24px; }
  .home-hero h1 { font-size: 1.45rem; }
  .panel-grid { gap: 14px; padding-bottom: 8px; }
  .panel:last-child { margin-bottom: 0; }
}

/* Personal knowledge base */
.kb-upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.kb-file-btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--accent, #0d9488);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn-secondary {
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}
.kb-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted, #6b7280);
  line-height: 1.45;
}
.kb-paste {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 12px;
}
.kb-paste input,
.kb-paste textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}
.kb-paste .btn-primary {
  align-self: flex-start;
  flex: none;
  padding: 0 16px;
  width: auto;
  min-width: 88px;
}
.kb-doc-row {
  align-items: center;
}
.kb-doc-row .kb-del {
  flex: 0 0 auto;
  margin-left: 8px;
  border: none;
  background: transparent;
  color: #b91c1c;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
}
.kb-doc-row .kb-del:hover {
  text-decoration: underline;
}

/* Answer sources (RAG) */
.msg-sources {
  margin: 6px 8px 12px;
  max-width: min(100%, 420px);
  font-size: 0.78rem;
  color: var(--muted, #6b7280);
}
.msg-sources summary {
  cursor: pointer;
  color: #0f766e;
  font-weight: 600;
}
.msg-sources ul {
  margin: 6px 0 0;
  padding: 8px 10px;
  list-style: none;
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
  border-radius: 10px;
}
.msg-sources li {
  margin: 4px 0;
  line-height: 1.4;
}
.msg-sources .src-tag {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #ccfbf1;
  color: #0f766e;
  font-size: 0.7rem;
  font-weight: 700;
}
.msg-sources .src-tag.cog {
  background: #e0e7ff;
  color: #3730a3;
}
.msg-sources em {
  font-style: normal;
  opacity: 0.55;
  font-size: 0.7rem;
}

/* Object cards: reality + conflict */
.obj-card.is-conflict {
  border: 1px solid #fecaca;
  background: #fff7f7;
}
.obj-card.is-archived {
  opacity: 0.72;
}
.status-pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  font-size: 0.75rem;
}
.status-pill.status-冲突 { background: #fee2e2; color: #b91c1c; }
.status-pill.status-站住 { background: #dcfce7; color: #166534; }
.status-pill.status-已碰到现实 { background: #dbeafe; color: #1d4ed8; }
.status-pill.status-被削弱 { background: #ffedd5; color: #c2410c; }
.status-pill.status-待验证 { background: #f3f4f6; color: #4b5563; }
.conflict-box {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  background: #fff1f2;
  border: 1px dashed #fda4af;
}
.conflict-note {
  font-size: 0.85rem;
  color: #9f1239;
  margin-bottom: 8px;
  line-height: 1.4;
}
.obj-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.obj-actions button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.obj-actions button:hover {
  border-color: #99f6e4;
  color: #0f766e;
}
.archived-fold {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fafafa;
}
.archived-fold summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--muted, #6b7280);
}
.blind-cta {
  margin-top: 4px !important;
  color: #0f766e !important;
  font-weight: 600;
}
