* { box-sizing: border-box; }
:root {
  --bg-top: #fff7f0;
  --bg-bottom: #ffeef2;
  --text: #3f3a3d;
  --muted: #9f7f8a;
  --accent: #ff8da0;
  --accent-strong: #ff6f88;
  --border: #ffd1dc;
  --card: #ffffff;
  --danger: #e1667f;
  --shadow: 0 8px 22px rgba(255, 176, 194, 0.2);
}
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(to bottom, var(--bg-top), var(--bg-bottom));
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", sans-serif;
  overflow-x: hidden;
}
body.is-scroll-locked {
  overflow: hidden;
}
.app-shell {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px 28px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
.topbar-side {
  min-width: 72px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.topbar-side.is-right {
  justify-content: flex-end;
}
.topbar-title {
  margin: 0;
  font-size: 15px;
  color: var(--accent-strong);
  letter-spacing: 1px;
  text-align: center;
}
.topbar-title[data-chat-action] {
  cursor: pointer;
}
.topbar--title-left {
  justify-content: flex-start;
}
.topbar--title-left .topbar-side {
  display: none;
}
.topbar-title.is-left {
  text-align: left;
}
.topbar-back {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--accent-strong);
  border-radius: 999px;
  padding: 6px 12px;
}
.section-card, .entry-card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 228, 235, 0.8);
}
.section-card { padding: 14px; margin-bottom: 12px; }
.entry-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.entry-card {
  display: block;
  padding: 14px;
  text-decoration: none;
  color: inherit;
}
.entry-title { margin: 0 0 4px; font-size: 16px; color: #c96279; }
.entry-subtitle { margin: 0; color: var(--muted); font-size: 13px; }
.welcome-title { margin: 0 0 8px; color: #d7657d; font-size: 22px; }
.welcome-text { margin: 0; line-height: 1.6; color: #765f67; font-size: 14px; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
button {
  border: none; cursor: pointer; font: inherit;
}
.btn-primary, .btn-secondary, .btn-danger {
  border-radius: 999px; padding: 9px 16px; font-size: 14px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: #fff8fa; border: 1px solid var(--border); color: #c35f76; }
.btn-danger { background: #fff; border: 1px solid #efb1bf; color: var(--danger); }
.field { margin-bottom: 10px; }
.label { display: block; font-size: 13px; color: #8c6f79; margin-bottom: 6px; }
.input, .textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  outline: none;
  background: #fffafd;
  color: #4c4347;
  font-size: 16px;
  line-height: 1.2;
}
.input {
  min-height: 48px;
}
select.input {
  height: 48px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font-size: 16px;
  box-sizing: border-box;
  background-color: #fffafd;
  line-height: 1.2;
}
input[type="time"].input {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 12px;
}
input[type="time"].input::-webkit-date-and-time-value {
  text-align: left;
}
.textarea { min-height: 130px; resize: vertical; }
.pill-tabs { display: flex; gap: 8px; margin: 10px 0 12px; }
.pill-tab {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; color: #9d6f7d;
}
.pill-tab.active { background: #ffeaf0; color: #ca5f78; }
.list-item { border: 1px solid #f7dfe6; border-radius: 14px; padding: 10px; margin-bottom: 8px; }
.list-item-updated {
  border-color: #ff97ad;
  background: #fff7fa;
  box-shadow: 0 0 0 2px rgba(255, 141, 160, 0.22);
  transition: box-shadow 220ms ease, background 220ms ease, border-color 220ms ease;
}
.item-title { font-size: 12px; color: #ab7b89; margin-bottom: 6px; }
.item-content { font-size: 14px; margin: 0 0 6px; white-space: pre-wrap; }
.item-meta { font-size: 12px; color: #9d7e88; margin-bottom: 8px; }
.item-update-badge {
  display: inline-block;
  margin: -2px 0 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #ffe6ee;
  color: #be5570;
  font-size: 11px;
  font-weight: 600;
}
.placeholder-note { color: #977783; font-size: 14px; margin: 6px 0 0; }
.debug-result-item .item-title {
  font-size: 14px;
  color: #8f5566;
}
.debug-cleaned-query {
  margin: 0;
  color: #6f5961;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.debug-page-title {
  font-size: 18px;
  margin-bottom: 6px;
}
.modal-overlay {
  position: fixed; inset: 0; background: rgba(90, 58, 70, 0.28);
  display: flex; justify-content: center; align-items: center; padding: 16px;
  z-index: 1000;
}
.modal {
  width: 100%; max-width: 540px; background: #fff; border-radius: 18px;
  padding: 0; box-shadow: 0 10px 30px rgba(76, 40, 52, 0.2);
  max-height: min(88dvh, calc(100dvh - 32px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 14px 14px 0;
  flex: 0 0 auto;
}
.modal h3 { margin: 4px 0 12px; color: #cb5f78; }
.modal-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 14px 14px;
  overflow: hidden;
}
.modal-content--legacy {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-footer {
  flex: 0 0 auto;
  background: #fff;
  padding: 0 14px 14px;
}
.modal-body {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-footer-row {
  flex: 0 0 auto;
  background: #fff;
  padding-top: 10px;
  margin-top: 6px;
}
.memory-modal-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.modal-body-memory {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}
.memory-modal-footer {
  margin-bottom: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, #fff 24%);
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}
.memory-modal-status {
  margin-bottom: max(2px, env(safe-area-inset-bottom));
}
.status-line { font-size: 12px; color: #9d7e88; margin-top: 6px; min-height: 1em; }
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: #7d616a;
  font-size: 14px;
}
.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-strong);
}
@media (max-width: 420px) {
  .app-shell { padding: 14px 10px 24px; }
  .welcome-title { font-size: 20px; }
  .modal-overlay {
    padding: 12px 10px;
  }
  .modal {
    border-radius: 16px;
    max-height: calc(100dvh - 16px);
  }
}

.heart-counter {
  margin-top: 14px;
  padding: 10px 8px 2px;
  display: grid;
  justify-items: center;
  gap: 10px;
}
.heart-counter-button {
  width: 176px;
  height: 146px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  position: relative;
}
.heart-counter-glow {
  position: absolute;
  inset: 18px 24px 8px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 183, 202, 0.46) 0%, rgba(255, 183, 202, 0) 72%);
  filter: blur(2px);
}
.heart-counter-svg {
  width: 100%;
  height: 100%;
  display: block;
  transform-origin: 50% 56%;
  animation: heartBeat 1.6s ease-in-out infinite;
}
.heart-counter-path {
  fill: url(#heartFill);
  filter: drop-shadow(0 10px 18px rgba(243, 116, 148, 0.26));
}
.heart-counter-shine {
  fill: url(#heartShine);
}
.heart-counter-button.is-pop .heart-counter-svg {
  animation: heartPop 300ms ease-out, heartBeat 1.6s ease-in-out 300ms infinite;
}
.heart-counter-whisper {
  margin: 0;
  min-height: 1.4em;
  color: #c75e79;
  font-size: 13px;
  letter-spacing: 0.2px;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.24s ease, transform 0.24s ease;
}
.heart-counter-whisper.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.heart-counter-text {
  margin: 0;
  font-size: 14px;
  color: #7f6670;
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  20% { transform: scale(1.06); }
  36% { transform: scale(1.01); }
  52% { transform: scale(1.045); }
}

@keyframes heartPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

.chat-header-card {
  padding: 9px 11px;
}
.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.chat-page-shell {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  overflow: hidden;
  padding-bottom: 14px;
  position: relative;
}
.chat-page-shell > .topbar {
  margin-bottom: 0;
}
.chat-page-shell > .section-card {
  margin-bottom: 0;
}
.chat-header-main { flex: 1; min-width: 0; }
.chat-window-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.chat-window-title-trigger {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  text-align: left;
  font-size: 15px;
  color: #b94b67;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.2px;
  width: 100%;
}
.chat-window-title-input {
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  font-size: 15px;
  color: #b94b67;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.2px;
  width: 100%;
  padding: 0 0 2px;
}
.chat-window-title-input:focus {
  outline: none;
  border-bottom-color: #e9a0b4;
}
.chat-model-line {
  margin: 0;
  font-size: 11px;
  color: #b7a1aa;
  line-height: 1.2;
}
.chat-user-pill {
  border: 1px solid #f3d0da;
  background: #fff9fb;
  color: #9f6f7d;
  border-radius: 999px;
  padding: 5px 9px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.chat-avatar {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #ffe8ef;
  border: 1px solid #f4ccd8;
  overflow: hidden;
}
.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chat-user-pill-name {
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.chat-message-list {
  display: grid;
  gap: 8px;
  align-content: start;
}
.chat-message-section {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  position: relative;
  overflow: hidden;
  padding: 8px 8px 6px;
  align-self: start;
  max-height: 100%;
}
.chat-message-scroll {
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-gutter: stable;
}
.chat-message-row {
  min-width: 0;
  max-width: 94%;
}
.chat-message-row.is-user {
  justify-self: end;
}
.chat-message-row.is-assistant {
  justify-self: start;
}
.chat-message-row.is-search-focused .chat-message-bubble {
  border-color: #e59cb2;
  box-shadow: 0 0 0 2px rgba(229, 156, 178, 0.18);
}
.chat-message-track {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}
.chat-message-row.is-user .chat-message-track {
  flex-direction: row-reverse;
}
.chat-message-main {
  display: grid;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
}
.chat-message-main.is-user {
  justify-items: end;
}
.chat-message-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  margin-top: 3px;
}
.chat-message-meta-top {
  font-size: 11px;
  color: #af8e98;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.chat-message-row.is-user .chat-message-meta-top {
  justify-content: flex-end;
}
.chat-message-bubble {
  border: 1px solid #f5dbe3;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14.5px;
  line-height: 1.68;
  background: #fff8fa;
  white-space: pre-wrap;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-message-row.is-user .chat-message-bubble {
  background: #ffe9f0;
  border-color: #f5bdcb;
}
.chat-message-row.is-assistant .chat-message-bubble {
  background: #ffffff;
}
.chat-message-content {
  white-space: pre-wrap;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-message-content a {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-message-bubble-wrap {
  position: relative;
  display: block;
  min-width: 0;
  max-width: min(420px, 100%);
  padding-bottom: 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-kebab-btn {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #fff8fb;
  padding: 4px;
}
.chat-icon-btn {
  border: 1px solid #f2d9e1;
  background: #fff;
  color: #b47587;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  padding: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chat-icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
.chat-icon-btn:hover:not(:disabled) {
  background: #fff2f6;
  border-color: #edc7d2;
}
.chat-icon-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.chat-composer-shell { display: grid; gap: 8px; }
.chat-error-banner {
  border: 1px solid #f4c6d1;
  background: linear-gradient(180deg, #fff5f8 0%, #ffeef3 100%);
  color: #9f4e62;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
}
.chat-composer-input {
  min-height: 66px;
  max-height: 124px;
  overflow-y: auto;
  opacity: 0.9;
}
.chat-composer-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.chat-composer-actions .btn-primary {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chat-composer-actions .btn-primary svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}
.chat-composer-actions .btn-primary.is-stop {
  background: #fff1f5;
  border-color: #efbfd0;
  color: #af4c67;
}
.chat-empty {
  color: #9f7f8a;
  font-size: 14px;
  padding: 14px 10px;
  text-align: center;
}
.chat-action-menu-wrap {
  position: relative;
  position: absolute;
  bottom: -12px;
}
.chat-action-menu-wrap.is-user {
  right: -12px;
}
.chat-action-menu-wrap.is-assistant {
  left: -12px;
}
.chat-action-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 156px;
  background: #fff;
  border: 1px solid #ebd4dc;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(151, 92, 113, 0.2);
  padding: 6px;
  z-index: 20;
  display: grid;
  gap: 4px;
}
.chat-message-row.is-assistant .chat-action-menu {
  left: 0;
  right: auto;
}
.chat-top-icon-btn {
  border: 1px solid #f2d9e1;
  background: #fff;
  color: #b47587;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chat-top-icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  pointer-events: none;
}
.chat-top-icon-btn:hover {
  background: #fff2f6;
  border-color: #edc7d2;
}
.chat-tool-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(76, 45, 57, 0.2);
  z-index: 25;
}
.chat-tool-panel {
  position: absolute;
  z-index: 30;
  background: linear-gradient(180deg, #fffafc 0%, #fff5f9 100%);
  border: 1px solid #f2d8e1;
  box-shadow: 0 18px 34px rgba(153, 92, 113, 0.2);
  border-radius: 18px;
  display: grid;
  gap: 10px;
  padding: 12px;
  transition: transform 180ms ease, opacity 180ms ease;
  opacity: 0;
  pointer-events: none;
}
.chat-tool-panel.is-open {
  opacity: 1;
  pointer-events: auto;
}
.chat-tool-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-tool-panel-header h3 {
  margin: 0;
  font-size: 14px;
  color: #9f6176;
}
.chat-window-panel {
  left: 10px;
  top: 56px;
  width: min(78vw, 300px);
  max-height: min(65vh, 520px);
  transform: translateX(-16px);
}
.chat-window-panel.is-open {
  transform: translateX(0);
}
.chat-window-list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}
.chat-window-item {
  border: 1px solid #f0d4de;
  background: #fff;
  color: #9a6676;
  border-radius: 12px;
  padding: 6px 7px 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-window-item.is-active {
  border-color: #ebaac0;
  background: #fff0f5;
}
.chat-window-item-main {
  background: transparent;
  color: inherit;
  border: none;
  padding: 3px 0;
  text-align: left;
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.chat-window-item-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-window-item-meta {
  font-size: 11px;
  color: #b28a97;
}
.chat-window-delete-btn {
  border: 1px solid #f1c4d1;
  background: #fff7fa;
  color: #cc6a82;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  padding: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.chat-window-delete-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}
.chat-window-delete-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.chat-search-panel {
  right: 10px;
  top: 56px;
  width: min(90vw, 360px);
  max-height: min(72vh, 560px);
  transform: translateY(-10px);
}
.chat-search-panel.is-open {
  transform: translateY(0);
}
.chat-search-input-wrap {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 1px solid #f0d4de;
  border-radius: 12px;
  background: #fff;
  padding: 0 10px;
  color: #b57c8d;
}
.chat-search-input-wrap svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}
.chat-search-input {
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 10px 0;
  font-size: 13px;
  color: #8f5f6e;
}
.chat-search-input:focus {
  outline: none;
}
.chat-search-results {
  overflow-y: auto;
  display: grid;
  gap: 8px;
}
.chat-search-result-item {
  border: 1px solid #f0d7df;
  background: #fff;
  color: #8d5f6d;
  border-radius: 12px;
  padding: 9px 10px;
  text-align: left;
  display: grid;
  gap: 5px;
}
.chat-search-result-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #af8593;
}
.chat-search-result-item p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
}
.chat-search-empty {
  margin: 0;
  color: #a98692;
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 4px;
}
.chat-action-menu-item {
  border: none;
  background: transparent;
  text-align: left;
  color: #8e6573;
  font-size: 13px;
  line-height: 1.2;
  padding: 9px 10px;
  border-radius: 9px;
  font-weight: 500;
}
.chat-action-menu-item:hover {
  background: #fff0f5;
}
.chat-action-menu-item.is-danger {
  color: #c5657d;
}
.chat-typing-bubble {
  min-width: 64px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chat-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #d8b8c4;
  animation: chatTypingDot 1.2s ease-in-out infinite;
}
.chat-typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}
.chat-typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes chatTypingDot {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}
.chat-thinking-panel {
  margin-top: 5px;
  width: 100%;
  max-width: min(432px, 100%);
  border: 1px solid rgba(224, 193, 203, 0.48);
  background: rgba(255, 248, 252, 0.52);
  border-radius: 11px;
  overflow: hidden;
}
.chat-thinking-toggle {
  border: none;
  background: transparent;
  color: #aa7f8d;
  font-size: 12.5px;
  line-height: 1.34;
  padding: 7px 11px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
  width: 100%;
}
.chat-thinking-toggle-label {
  font-weight: 500;
}
.chat-thinking-toggle-arrow {
  display: inline-flex;
  color: #b58897;
  transition: transform 150ms ease;
}
.chat-thinking-toggle-arrow svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
.chat-thinking-panel.is-expanded .chat-thinking-toggle-arrow {
  transform: rotate(180deg);
}
.chat-thinking-content {
  margin-top: 0;
  border-top: 1px solid rgba(223, 191, 203, 0.38);
  background: rgba(255, 252, 254, 0.42);
  padding: 8px 11px 9px;
  font-size: 12.5px;
  color: #96717f;
  line-height: 1.56;
  white-space: pre-wrap;
}
.chat-thinking-content.is-collapsed {
  display: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.is-hidden {
  display: none !important;
}
.chat-scroll-bottom-btn {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(42, 42, 45, 0.8);
  color: #fff;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(25, 25, 30, 0.25);
  transition: opacity 150ms ease, transform 150ms ease;
}
.chat-scroll-bottom-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}
.chat-scroll-bottom-btn.is-hidden {
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
}

.diary-day-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.diary-recent-event {
  margin: 0 0 10px;
  color: #936d7a;
  font-size: 12px;
}
.diary-board {
  border: 1px solid #f4ced9;
  border-radius: 16px;
  background: linear-gradient(180deg, #fffdf8 0%, #fff8fb 100%);
  padding: 12px;
  min-height: 320px;
  max-height: 58vh;
  overflow: auto;
  margin-bottom: 12px;
}
.diary-paragraph-card {
  border-bottom: 1px dashed #f1c9d5;
  padding: 8px 0 12px;
}
.diary-paragraph-card:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}
.diary-paragraph-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.diary-author {
  color: #bd5e76;
  font-size: 14px;
  font-weight: 600;
}
.diary-meta {
  color: #a98491;
  font-size: 12px;
  margin-bottom: 6px;
}
.diary-paragraph-content {
  margin: 0;
  color: #59444c;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.diary-author-switch {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.diary-compose-form {
  border: 1px solid #f4d5df;
  border-radius: 14px;
  padding: 10px 10px 8px;
  background: rgba(255, 249, 252, 0.72);
}
.diary-compose-input {
  min-height: 74px;
}
.diary-compose-actions {
  justify-content: flex-end;
  margin-top: 8px;
}
.diary-entry-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.diary-link-btn {
  border: none;
  background: transparent;
  color: #8f6d79;
  font-size: 12px;
  padding: 2px 0;
}
.diary-link-danger {
  color: #c85b76;
}
.diary-promote-wrap {
  margin-top: 8px;
  position: relative;
  padding-right: 54px;
}
.diary-promote-toggle {
  padding: 4px 10px;
  font-size: 12px;
}
.diary-promote-inline-feedback {
  position: absolute;
  right: 2px;
  top: 2px;
  min-width: 46px;
  text-align: right;
  font-size: 16px;
  line-height: 1;
  color: #c45572;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.diary-promote-inline-feedback.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.diary-promote-inline-feedback.is-error {
  font-size: 14px;
  color: #c05d76;
}
.diary-promote-menu {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  border: 1px solid #f3d7e0;
  border-radius: 12px;
  background: #fffdfd;
  overflow: hidden;
  max-width: 240px;
}
.diary-promote-menu-item {
  border: none;
  border-bottom: 1px solid #f6e3e9;
  background: transparent;
  text-align: left;
  color: #8d6674;
  padding: 8px 10px;
  font-size: 13px;
}
.diary-promote-menu-item.is-success {
  background: #fff1f6;
  color: #c25472;
}
.diary-promote-menu-item:last-child {
  border-bottom: none;
}
.diary-inline-editor {
  min-height: 90px;
}
.diary-inline-actions {
  margin-top: 8px;
}

.assistant-prompt-textarea.textarea {
  min-height: 45vh;
  max-height: 70vh;
  line-height: 1.65;
  font-size: 14px;
  resize: vertical;
}
.assistant-prompt-entry-wrap {
  position: relative;
}
.assistant-prompt-entry-wrap .assistant-prompt-textarea.textarea {
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}
.assistant-prompt-entry-wrap .assistant-prompt-textarea.textarea:hover {
  border-color: #e8b8c9;
  background: #fff9fc;
}
.assistant-prompt-entry-wrap .assistant-prompt-textarea.textarea:focus-visible {
  border-color: #dc9fb4;
  background: #fff9fc;
  box-shadow: 0 0 0 2px rgba(220, 159, 180, 0.2);
}
.assistant-avatar-preview-wrap {
  margin-top: 8px;
  margin-bottom: 10px;
}
.settings-help-text,
.settings-muted-note,
.settings-inline-note {
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #a98a95;
}
.assistant-mini-btn {
  padding: 6px 12px;
  font-size: 13px;
}
.assistant-advanced {
  margin-top: 8px;
}
.assistant-advanced summary {
  cursor: pointer;
  font-size: 12.5px;
  color: #a98a95;
}
.assistant-toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 13px;
  color: #8f717c;
}
.assistant-toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-strong);
}
@media (max-width: 420px) {
  .assistant-prompt-textarea.textarea {
    min-height: 45vh;
    max-height: 70vh;
  }
}

.assistant-prompt-modal {
  max-width: 920px;
  max-height: min(96dvh, calc(100dvh - 8px));
}
.assistant-prompt-modal .modal-content {
  padding-bottom: 12px;
}
.assistant-prompt-modal-textarea {
  width: 100%;
  min-height: 65vh;
  height: 70vh;
  line-height: 1.65;
  font-size: 15px;
  resize: vertical;
}
@media (max-width: 640px) {
  .assistant-prompt-modal {
    border-radius: 14px;
    max-height: 98dvh;
  }
}


@media (max-width: 720px) {
  .chat-page-shell {
    gap: 8px;
    padding-bottom: 10px;
  }

  .chat-header-card {
    padding: 8px 10px;
  }

  .chat-header {
    gap: 8px;
  }

  .chat-window-title-trigger,
  .chat-window-title-input {
    font-size: 14px;
    line-height: 1.1;
  }

  .chat-model-line {
    font-size: 10px;
    line-height: 1.15;
  }

  .chat-user-pill {
    padding: 4px 8px;
    gap: 6px;
  }

  .chat-message-section {
    padding: 6px 6px 4px;
  }

  .chat-message-list {
    gap: 6px;
  }

  .chat-message-row {
    max-width: 97%;
  }

  .chat-message-track {
    gap: 8px;
  }

  .chat-message-main {
    gap: 4px;
  }

  .chat-message-avatar {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
    margin-top: 2px;
  }

  .chat-message-meta-top {
    font-size: 10px;
    color: #c3b1b8;
    gap: 5px;
  }

  .chat-message-tokens {
    opacity: 0.62;
  }

  .chat-message-bubble-wrap {
    max-width: 100%;
  }

  .chat-message-bubble {
    padding: 8px 10px;
    font-size: 14px;
    line-height: 1.58;
    border-radius: 13px;
  }

  .chat-composer-shell {
    gap: 7px;
  }

  .chat-composer-input {
    min-height: 58px;
    max-height: 112px;
    padding: 8px 10px;
    line-height: 1.35;
  }

  .chat-composer-actions {
    gap: 5px;
  }

  .chat-icon-btn {
    width: 27px;
    height: 27px;
    padding: 4px;
  }

  .chat-composer-actions .btn-primary {
    padding: 8px 14px;
    min-height: 36px;
  }
}

.chat-tool-event-card {
  box-sizing: border-box;
  margin: 4px 0 7px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid rgba(239, 199, 213, 0.66);
  background: linear-gradient(180deg, rgba(255, 250, 253, 0.86), rgba(255, 244, 249, 0.72));
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(184, 119, 142, 0.08);
  overflow: hidden;
  white-space: normal;
}
.chat-tool-event-toggle {
  width: 100%;
  border: none;
  background: transparent;
  color: #9c6375;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  font-size: 12.5px;
  line-height: 1.35;
}
.chat-tool-event-title {
  font-weight: 650;
}
.chat-tool-event-arrow {
  display: inline-flex;
  color: #b98597;
  transition: transform 150ms ease;
  flex: 0 0 auto;
}
.chat-tool-event-arrow svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}
.chat-tool-event-card.is-expanded .chat-tool-event-arrow {
  transform: rotate(180deg);
}
.chat-tool-event-details {
  border-top: 1px solid rgba(231, 194, 207, 0.48);
  padding: 7px;
  display: grid;
  gap: 6px;
  min-width: 0;
}
.chat-tool-event-details.has-web-search {
  max-height: 320px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(205, 142, 163, 0.58) rgba(255, 244, 249, 0.74);
}
.chat-tool-event-details.has-web-search::-webkit-scrollbar {
  width: 6px;
}
.chat-tool-event-details.has-web-search::-webkit-scrollbar-track {
  background: rgba(255, 244, 249, 0.74);
  border-radius: 999px;
}
.chat-tool-event-details.has-web-search::-webkit-scrollbar-thumb {
  background: rgba(205, 142, 163, 0.58);
  border-radius: 999px;
}
.chat-tool-event-details.is-collapsed {
  display: none;
}
.chat-tool-event-item {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(241, 211, 221, 0.78);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  padding: 8px 9px;
  color: #8d6471;
}
.chat-tool-event-item.is-error {
  border-color: rgba(236, 151, 169, 0.62);
  background: rgba(255, 243, 246, 0.82);
}
.chat-tool-event-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.chat-tool-event-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #935d70;
}
.chat-tool-event-status {
  border-radius: 999px;
  background: rgba(255, 236, 243, 0.86);
  color: #a46b7e;
  font-size: 11px;
  line-height: 1;
  padding: 4px 7px;
  white-space: nowrap;
}
.chat-tool-event-summary {
  margin: 3px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: #936d7a;
  overflow-wrap: anywhere;
}

@media (max-width: 520px) {
  .chat-tool-event-card {
    max-width: 100%;
    margin-right: 0;
  }
  .chat-tool-event-toggle {
    padding: 8px 10px;
  }
  .chat-tool-event-item-head {
    align-items: flex-start;
  }
}

.chat-attachment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.chat-attachment-strip.is-pending {
  margin: 0;
  padding: 2px 0 4px;
}
.chat-attachment-thumb {
  position: relative;
  width: 86px;
  height: 86px;
  border: 1px solid #f3cdda;
  border-radius: 14px;
  overflow: hidden;
  background: #fff5f8;
  box-shadow: 0 6px 18px rgba(180, 117, 135, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  padding: 0;
}
.chat-attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
  vertical-align: middle;
}
.chat-attachment-thumb.is-uploading img,
.chat-attachment-thumb.is-failed img {
  filter: saturate(0.82) brightness(0.78);
}
.chat-attachment-status {
  position: absolute;
  left: 6px;
  bottom: 6px;
  max-width: calc(100% - 12px);
  border-radius: 999px;
  background: rgba(255, 245, 248, 0.9);
  color: #9e5f73;
  font-size: 11px;
  line-height: 1;
  padding: 5px 7px;
  box-shadow: 0 4px 10px rgba(117, 57, 77, 0.14);
}
.chat-attachment-thumb.is-uploading::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: #d77d9b;
  border-radius: 14px;
  animation: chat-upload-spin 1s linear infinite;
  pointer-events: none;
}
.chat-attachment-thumb.is-failed {
  border-color: #f0a0a0;
}
.chat-attachment-error {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 30px;
  color: #fff;
  font-size: 11px;
  line-height: 1.25;
  text-shadow: 0 1px 4px rgba(89, 31, 46, 0.65);
}
@keyframes chat-upload-spin {
  to { transform: rotate(360deg); }
}
.chat-attachment-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  background: rgba(150, 74, 94, 0.82);
  color: #fff;
  line-height: 18px;
  font-size: 16px;
  padding: 0;
}
.chat-upload-status {
  color: #af7082;
  font-size: 12px;
  padding-left: 2px;
}
.chat-attachment-preview-btn {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: inherit;
  background: transparent;
  padding: 0;
  display: block;
  line-height: 0;
  cursor: zoom-in;
}
.chat-attachment-preview-btn:focus-visible {
  outline: 2px solid #ff8da0;
  outline-offset: -3px;
}
.image-preview-modal {
  width: min(100%, 960px);
  max-width: calc(100vw - 24px);
  height: auto;
  max-height: calc(100dvh - 24px);
  background: rgba(255, 250, 252, 0.96);
  border: 1px solid rgba(255, 209, 220, 0.9);
  border-radius: 22px;
  box-shadow: 0 18px 42px rgba(85, 45, 61, 0.26);
}
.image-preview-overlay {
  background: rgba(76, 40, 52, 0.54);
  padding: 12px;
}
.image-preview-content {
  position: relative;
  min-height: 0;
  padding: 12px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.image-preview-close {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 12px;
  z-index: 1100;
  width: 48px;
  height: 48px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid rgba(255, 198, 214, 0.9);
  border-radius: 999px;
  background: rgba(255, 250, 252, 0.86);
  color: #b95b72;
  box-shadow: 0 8px 22px rgba(85, 45, 61, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 24px;
  line-height: 1;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 3px;
  pointer-events: auto;
  touch-action: manipulation;
  cursor: pointer;
}
.image-preview-close:focus-visible {
  outline: 2px solid rgba(255, 141, 160, 0.95);
  outline-offset: 3px;
}
.image-preview-img {
  display: block;
  max-width: calc(100vw - 48px);
  max-height: calc(100dvh - 48px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(96, 54, 68, 0.18);
  background: #fff7fa;
}
@media (max-width: 520px) {
  .image-preview-modal {
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 18px;
  }
  .image-preview-overlay {
    padding: 8px;
  }
  .image-preview-content {
    padding: 8px;
  }
  .image-preview-img {
    max-width: calc(100vw - 32px);
    max-height: calc(100dvh - 32px);
    border-radius: 14px;
  }
}
.chat-attachment-status,
.chat-attachment-error {
  pointer-events: none;
}
.chat-tool-event-item.is-web-search {
  min-width: 0;
}
.chat-tool-event-websearch {
  display: grid;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-tool-event-results {
  display: grid;
  gap: 6px;
  margin-top: 4px;
  min-width: 0;
}
.chat-tool-event-result {
  border: 1px solid rgba(241, 211, 221, 0.62);
  background: rgba(255, 251, 253, 0.82);
  border-radius: 10px;
  min-width: 0;
  padding: 7px 8px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-tool-event-result-title {
  color: #87586a;
  display: -webkit-box;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.chat-tool-event-result-source {
  color: #b17a8d;
  font-size: 11px;
  margin-top: 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-tool-event-result-snippet {
  color: #936d7a;
  display: -webkit-box;
  font-size: 11.5px;
  line-height: 1.45;
  margin: 4px 0 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.chat-tool-event-result-url {
  color: #a1667a;
  display: block;
  font-size: 11px;
  line-height: 1.35;
  margin-top: 4px;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-decoration-color: rgba(161, 102, 122, 0.35);
  word-break: break-word;
}
@media (max-width: 520px) {
  .chat-tool-event-details.has-web-search {
    max-height: 260px;
  }
}

.api-settings-heading-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.api-settings-card-title {
  margin: 0;
  color: #c96279;
  font-size: 18px;
}
.chat-profile-chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 2px 4px;
  scrollbar-width: none;
}
.chat-profile-chip-row::-webkit-scrollbar { display: none; }
.chat-profile-chip {
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff8fa;
  color: #b65b72;
  padding: 8px 12px;
  font-size: 14px;
  box-shadow: 0 6px 14px rgba(232, 121, 151, 0.08);
}
.chat-profile-chip.is-selected {
  background: #ffeaf0;
  border-color: #f4a8ba;
  color: #c55270;
  font-weight: 700;
}
.chat-profile-chip.is-current {
  box-shadow: 0 0 0 2px rgba(255, 151, 173, 0.22);
}
.chat-profile-editor {
  margin-top: 12px;
  border: 1px solid #f7dfe6;
  border-radius: 16px;
  background: #fffafd;
  padding: 12px;
}
.chat-profile-active-line {
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff0f5;
  color: #bd5b73;
  font-size: 13px;
  font-weight: 700;
}
.advanced-provider-details {
  margin-bottom: 12px;
}
.advanced-provider-details > summary {
  list-style: none;
  cursor: pointer;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 228, 235, 0.9);
  border-radius: 18px;
  background: #fff8fa;
  color: #c35f76;
  box-shadow: var(--shadow);
  font-weight: 700;
}
.advanced-provider-details > summary::-webkit-details-marker { display: none; }
.advanced-provider-details > summary::after {
  content: "展开";
  float: right;
  color: #977783;
  font-weight: 400;
}
.advanced-provider-details[open] > summary::after { content: "收起"; }
.advanced-provider-body {
  padding-top: 2px;
}
