:root {
  --coral: #c97b72;
  --coral-dark: #b56860;
  --coral-soft: #f7efee;
  --cream: #f6f1eb;
  --paper: #fffdf9;
  --ink: #181614;
  --muted: #6b6560;
  --line: #edeae6;
  --teal: #43877e;
  --blue: #4e83b4;
  --shadow: 0 22px 60px rgba(70, 54, 43, 0.12);
  --visual-height: 100dvh;
  --visual-offset-top: 0px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); }
body {
  color: var(--ink);
  background: var(--paper);
  font-family: "Space Grotesk", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

@media (min-width: 521px) {
  body { background: #e9e2da; }
}
button, input, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
svg { display: block; }

@keyframes splash-fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes splash-dot-pulse {
  0%, 80%, 100% { opacity: 0.24; transform: scale(0.82); }
  40% { opacity: 1; transform: scale(1); }
}
@keyframes sidebar-item-in {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.splash-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--paper);
}
.splash-view.is-leaving { opacity: 0; pointer-events: none; transition: opacity 360ms ease; }
.splash-enter {
  width: min(100%, 520px);
  height: 100%;
  min-height: 620px;
  padding: max(56px, env(safe-area-inset-top)) 28px max(42px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: var(--paper);
}
.splash-illustration-wrap {
  width: 130px;
  margin-bottom: 38px;
  display: block;
  animation: splash-fade-up 900ms ease 100ms both;
}
.splash-illustration { width: 100%; height: auto; display: block; }
.splash-copy { display: grid; justify-items: center; animation: splash-fade-up 720ms ease 720ms both; }
.splash-greeting {
  margin-bottom: 14px;
  color: var(--muted);
  font-family: Georgia, "Songti SC", serif;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.splash-name { font-family: Georgia, "Songti SC", serif; font-size: 40px; line-height: 1; font-weight: 500; }
.splash-return { margin-top: 5px; color: var(--coral); font-family: Georgia, "Songti SC", serif; font-size: 22px; font-style: italic; }
.splash-loader { margin-top: 46px; display: flex; gap: 8px; animation: splash-fade-up 560ms ease 1.2s both; }
.splash-loader i { width: 6px; height: 6px; background: var(--line); border-radius: 50%; animation: splash-dot-pulse 1.4s ease 1.35s infinite; }
.splash-loader i:first-child { background: var(--coral); }
.splash-loader i:nth-child(2) { animation-delay: 1.5s; }
.splash-loader i:nth-child(3) { animation-delay: 1.65s; }
.splash-hint { position: absolute; bottom: max(30px, env(safe-area-inset-bottom)); color: #c6beb6; font-size: 10px; letter-spacing: 0.08em; animation: splash-fade-up 560ms ease 1.7s both; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(39, 36, 33, 0.24);
  opacity: 0;
  transition: opacity 260ms ease;
}
.sidebar-backdrop.is-open { opacity: 1; }
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: max(0px, calc(50% - 260px));
  z-index: 40;
  width: min(84vw, 340px);
  padding: max(24px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-right: 1px solid var(--line);
  box-shadow: 18px 0 48px rgba(70, 54, 43, 0.14);
  transform: translateX(-104%);
  visibility: hidden;
  transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 300ms;
}
.sidebar.is-open { transform: translateX(0); visibility: visible; transition-delay: 0s; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.sidebar-identity { min-width: 0; display: flex; align-items: center; gap: 13px; }
.sidebar-avatar { width: 48px; height: 48px; flex: 0 0 48px; object-fit: cover; border: 1px solid var(--line); border-radius: 50%; background: #eee9e3; }
.sidebar-brand { display: grid; gap: 3px; font-family: Georgia, "Songti SC", serif; }
.sidebar-brand strong { font-size: 20px; line-height: 1.1; font-weight: 600; }
.sidebar-brand span { color: var(--muted); font-size: 12px; font-style: normal; }
.sidebar-close { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; color: var(--muted); background: transparent; border-radius: 8px; }
.sidebar-close:hover { color: var(--coral); background: var(--coral-soft); }
.sidebar-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.sidebar-nav { min-height: 0; margin-top: 34px; display: flex; flex: 1; flex-direction: column; overflow-y: auto; }
.sidebar-section { padding: 12px 0; border-top: 1px solid var(--line); }
.sidebar-section:first-child { border-top: 0; }
.sidebar-section-settings { margin-top: auto; }
.sidebar-section-label { padding: 0 12px 8px; display: block; color: #aaa29a; font-size: 9px; font-weight: 700; letter-spacing: 0.14em; }
.sidebar-item {
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  column-gap: 13px;
  align-items: center;
  color: #5f5953;
  background: transparent;
  border-radius: 7px;
  text-align: left;
  font-family: Georgia, "Songti SC", serif;
  font-size: 16px;
}
.sidebar-icon { width: 24px; height: 24px; display: grid; place-items: center; color: #aaa29a; }
.sidebar-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-item-label { min-width: 0; }
.sidebar-item:hover, .sidebar-item.active { color: var(--coral-dark); background: var(--coral-soft); }
.sidebar-item:hover .sidebar-icon, .sidebar-item.active .sidebar-icon { color: currentColor; }
.sidebar.is-open .sidebar-section { animation: sidebar-item-in 360ms ease both; }
.sidebar.is-open .sidebar-section:nth-child(2) { animation-delay: 60ms; }
.sidebar.is-open .sidebar-section:nth-child(3) { animation-delay: 110ms; }
.sidebar.is-open .sidebar-section:nth-child(4) { animation-delay: 160ms; }
.sidebar-count { min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; color: #fff; background: var(--coral); border-radius: 999px; font-family: Inter, sans-serif; font-size: 9px; }
.relationship-chevron { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; transition: transform 180ms ease; }
.relationship-parent[aria-expanded="true"] .relationship-chevron { transform: rotate(90deg); }
.relationship-submenu { padding: 1px 0 5px 49px; }
.relationship-submenu[hidden] { display: none; }
.relationship-subitem { width: 100%; min-height: 36px; display: flex; align-items: center; gap: 12px; color: #77716b; text-align: left; font-family: "Avenir Next", "SF Pro Text", "Helvetica Neue", "Segoe UI", sans-serif; font-size: 12.5px; }
.relationship-subitem span { width: 5px; height: 5px; flex: none; border-radius: 50%; background: #b7b1ab; }
.relationship-subitem:hover { color: var(--coral-dark); }
.relationship-subitem:hover span { background: currentColor; }

.app-shell {
  width: min(100%, 520px);
  height: var(--visual-height);
  min-height: 620px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.app-header {
  min-height: 66px;
  padding: 10px 18px 9px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  background: rgba(255, 253, 249, 0.96);
  border-bottom: 1px solid var(--line);
  z-index: 3;
}
.app-shell:not(.chat-mode) .header-title { grid-column: 2; }
.header-title { min-width: 0; grid-column: 2; }
.header-title h1 {
  margin: 3px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: Georgia, "Songti SC", serif;
  font-size: 24px;
  font-weight: 700;
}
.eyebrow {
  color: var(--coral);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
}
.eyebrow:empty { display: none; }
.header-actions { grid-column: 3; display: flex; align-items: center; gap: 3px; }
.header-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  color: #756f68;
  background: transparent;
  border-radius: 8px;
}
.header-button:hover { color: var(--coral); background: var(--coral-soft); }
.header-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.back-button { grid-column: 1; }
.menu-button { grid-column: 1; }
.app-shell.chat-mode .menu-button { display: none; }
.connection-dot { width: 9px; height: 9px; margin: 0 5px; border-radius: 50%; background: #b8b1aa; }
.connection-dot.ready { background: #49a27f; box-shadow: 0 0 0 4px rgba(73, 162, 127, 0.12); }
.connection-dot.busy { background: #d9a650; animation: pulse 1.2s infinite; }
.connection-dot.error { background: var(--coral); }
@keyframes pulse { 50% { opacity: 0.45; } }

.app-main { min-height: 0; position: relative; overflow: hidden; }
.primary-view, .chat-view { height: 100%; overflow-y: auto; overscroll-behavior: contain; }
.primary-view { background: var(--paper); }
.search-wrap {
  margin: 18px 18px 10px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  color: #aaa29a;
  background: #f0ece7;
  border-radius: 8px;
}
.search-wrap svg { width: 19px; height: 19px; flex: 0 0 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.search-wrap input { min-width: 0; flex: 1; padding: 0; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 14px; }
.search-wrap input::placeholder { color: #aaa29a; }

.contact-list { border-top: 1px solid var(--line); }
.contact-row {
  width: 100%;
  min-height: 86px;
  padding: 14px 20px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border-bottom: 1px solid var(--line);
}
.contact-row:hover { background: #fbf7f2; }
.contact-avatar {
  width: 54px;
  height: 54px;
  display: block;
  overflow: hidden;
  background: #eee9e3;
  border-radius: 12px;
  box-shadow: 0 5px 16px rgba(56, 45, 35, 0.1);
}
.draw-guess-history-view { padding-bottom: 24px; }
.draw-guess-history-intro { padding: 22px 20px 16px; border-bottom: 1px solid var(--line); }
.draw-guess-history-intro span { color: var(--coral); font-size: 9px; font-weight: 700; letter-spacing: .14em; }
.draw-guess-history-intro h2 { margin: 5px 0 3px; font-family: Georgia, "Noto Serif SC", "Songti SC", serif; font-size: 22px; font-weight: 600; letter-spacing: 0; }
.draw-guess-history-intro p { margin: 0; color: var(--muted); font-size: 11px; }
.draw-guess-history-list { min-height: 120px; }
.draw-guess-history-row { width: 100%; min-height: 76px; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; gap: 16px; color: var(--ink); background: transparent; border-bottom: 1px solid var(--line); text-align: left; }
.draw-guess-history-row:hover { background: #fbf7f2; }
.draw-guess-history-row:disabled { cursor: default; opacity: .58; }
.draw-guess-history-heading, .draw-guess-history-meta { min-width: 0; display: grid; gap: 4px; }
.draw-guess-history-heading { flex: 1; }
.draw-guess-history-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 500; }
.draw-guess-history-heading small, .draw-guess-history-meta small { color: var(--muted); font-size: 10px; }
.draw-guess-history-meta { flex: 0 0 auto; justify-items: end; text-align: right; }
.draw-guess-history-meta strong { color: var(--coral); font-size: 10px; font-weight: 600; }
.draw-guess-history-empty { margin: 42px auto; max-width: 260px; color: var(--muted); font-size: 12px; line-height: 1.7; text-align: center; }
.twenty-questions-history-view, .connect-four-history-view { padding-bottom: 24px; }
.twenty-questions-history-intro, .connect-four-history-intro { padding: 22px 20px 16px; border-bottom: 1px solid var(--line); }
.twenty-questions-history-intro span, .connect-four-history-intro span { color: var(--coral); font-size: 9px; font-weight: 700; letter-spacing: .14em; }
.twenty-questions-history-intro h2, .connect-four-history-intro h2 { margin: 5px 0 3px; font-family: Georgia, "Noto Serif SC", "Songti SC", serif; font-size: 22px; font-weight: 600; letter-spacing: 0; }
.twenty-questions-history-intro p, .connect-four-history-intro p { margin: 0; color: var(--muted); font-size: 11px; }
.twenty-questions-history-list, .connect-four-history-list { min-height: 120px; }
.twenty-questions-history-row { width: 100%; min-height: 76px; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; gap: 16px; color: var(--ink); background: transparent; border-bottom: 1px solid var(--line); text-align: left; }
.connect-four-history-row { width: 100%; min-height: 76px; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; gap: 16px; color: var(--ink); background: transparent; border-bottom: 1px solid var(--line); text-align: left; }
.twenty-questions-history-row:hover, .connect-four-history-row:hover { background: #fbf7f2; }
.twenty-questions-history-row:disabled, .connect-four-history-row:disabled { cursor: default; opacity: .58; }
.twenty-questions-history-heading, .twenty-questions-history-meta, .connect-four-history-heading, .connect-four-history-meta { min-width: 0; display: grid; gap: 4px; }
.twenty-questions-history-heading, .connect-four-history-heading { flex: 1; }
.twenty-questions-history-heading strong, .connect-four-history-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 500; }
.twenty-questions-history-heading small, .twenty-questions-history-meta small, .connect-four-history-heading small, .connect-four-history-meta small { color: var(--muted); font-size: 10px; }
.twenty-questions-history-meta, .connect-four-history-meta { flex: 0 0 auto; justify-items: end; text-align: right; }
.twenty-questions-history-meta strong, .connect-four-history-meta strong { color: var(--coral); font-size: 10px; font-weight: 600; }
.twenty-questions-history-empty, .connect-four-history-empty { margin: 42px auto; max-width: 260px; color: var(--muted); font-size: 12px; line-height: 1.7; text-align: center; }
.contact-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.contact-copy { min-width: 0; display: grid; gap: 6px; }
.contact-copy strong { font-size: 16px; }
.contact-preview { overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.contact-meta { align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; color: #aaa29a; font-size: 10px; }
.contact-unread, .inbox-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: var(--coral);
  border-radius: 999px;
  font-size: 10px;
  line-height: 18px;
}

.chat-view { display: flex; flex-direction: column; background: #faf7f2; }
.conversation {
  min-height: 0;
  flex: 1;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}
.empty-state { margin: auto; max-width: 320px; text-align: center; }
.empty-symbol { width: 52px; height: 52px; margin: 0 auto 16px; display: grid; place-items: center; color: var(--coral); background: var(--coral-soft); border-radius: 15px; font-size: 26px; }
.empty-state h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 22px; }
.empty-state p { margin: 9px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.message { position: relative; max-width: 86%; display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; }
.message.user { align-self: flex-end; align-items: flex-end; }
.message.assistant { align-self: flex-start; align-items: flex-start; }
.message-meta { color: var(--coral); font-size: 11px; font-weight: 500; letter-spacing: .06em; }
.message-origin { margin-left: 7px; color: #a86f64; font-size: 9px; }
.message-highlight { animation: message-highlight 1.8s ease-out; }
@keyframes message-highlight { 0% { outline: 2px solid rgba(168, 111, 100, .55); outline-offset: 5px; } 100% { outline: 2px solid transparent; outline-offset: 12px; } }
.message-bubble { padding: 0; white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.78; letter-spacing: .01em; }
.message.user .message-bubble { max-width: 270px; padding: 11px 16px; color: #fff; background: var(--coral); border-radius: 20px 20px 4px 20px; font-weight: 300; line-height: 1.62; }
.message.assistant .message-bubble { max-width: 300px; background: transparent; border-radius: 0; font-weight: 300; }
.message.assistant .message-bubble > :first-child { margin-top: 0; }
.message.assistant .message-bubble > :last-child { margin-bottom: 0; }
.message.assistant .message-bubble h1, .message.assistant .message-bubble h2, .message.assistant .message-bubble h3 { margin: 12px 0 6px; color: var(--ink); font-family: Georgia, "Noto Serif SC", "Songti SC", serif; line-height: 1.35; }
.message.assistant .message-bubble h1 { font-size: 19px; }
.message.assistant .message-bubble h2 { font-size: 17px; }
.message.assistant .message-bubble h3 { font-size: 15px; }
.message.assistant .message-bubble p { margin: 0 0 9px; }
.message.assistant .message-bubble ul, .message.assistant .message-bubble ol { margin: 0 0 9px; padding-left: 21px; }
.message.assistant .message-bubble blockquote { margin: 8px 0; padding: 4px 10px; color: #665e58; border-left: 3px solid #c8b8ab; }
.message.assistant .message-bubble hr { margin: 10px 0; border: 0; border-top: 1px solid #d7cec5; }
.message.assistant .message-bubble :not(pre) > code { padding: 1px 4px; color: #57433d; background: #e2dad2; border-radius: 4px; font-size: 0.9em; }
.message.assistant .message-bubble a { color: #2f746d; text-decoration: underline; overflow-wrap: anywhere; }
.message.assistant .message-bubble table { width: 100%; margin: 8px 0; border-collapse: collapse; font-size: 12px; }
.message.assistant .message-bubble th, .message.assistant .message-bubble td { padding: 5px 6px; text-align: left; border: 1px solid #d5cbc1; vertical-align: top; }
.message.assistant .message-bubble th { color: #554c45; background: #e5ddd4; }
.message-time { margin-top: -1px; color: #b8b2ab; font-size: 10px; font-weight: 400; letter-spacing: .02em; line-height: 1.2; }
.message-channel { margin-left: 6px; color: #aaa39c; font-size: 9px; }
.message.user .message-time { align-self: flex-end; }
.markdown-code-block { position: relative; margin: 9px 0; padding-top: 28px; background: #292522; border-radius: 8px; overflow: hidden; }
.markdown-code-block pre { margin: 0; padding: 0 11px 11px; overflow-x: auto; color: #f5eee7; white-space: pre; font-size: 12px; line-height: 1.55; }
.markdown-code-copy { position: absolute; top: 5px; right: 6px; min-width: 40px; min-height: 25px; padding: 3px 7px; color: #eee5dc; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.18); border-radius: 5px; font-size: 10px; }
.markdown-code-copy:hover { background: rgba(255,255,255,0.22); }
.markdown-code-toggle { position: absolute; top: 5px; right: 52px; min-width: 40px; min-height: 25px; padding: 3px 7px; color: #eee5dc; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.18); border-radius: 5px; font-size: 10px; }
.markdown-code-block.is-collapsed pre { max-height: 210px; overflow: hidden; }
.markdown-code-block.is-collapsed::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 54px; pointer-events: none; background: linear-gradient(transparent, #292522); }
.markdown-copy-status { position: absolute; top: 8px; left: 10px; color: #d6b9aa; font-size: 10px; }
.generation-status { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }
.generation-stopped { color: #8c7564; }
.generation-timeout, .generation-network, .generation-empty { color: var(--coral-dark); }
.generation-retry { min-height: 28px; margin-top: 7px; padding: 4px 8px; color: #fff; background: var(--coral); border-radius: 6px; font-size: 11px; }
.generation-retry:hover { background: var(--coral-dark); }
.message-image { display: block; max-width: min(330px, 100%); max-height: 380px; margin-bottom: 7px; border-radius: 9px; object-fit: contain; }
.message-sticker {
  width: min(230px, 70vw);
  height: min(230px, 70vw);
  display: block;
  object-fit: contain;
}
.message-sticker-fallback {
  min-height: 44px;
  padding: 10px 12px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  background: #f0ebe5;
  border: 1px dashed #d8cfc6;
  border-radius: 8px;
  font-size: 12px;
}
.message-actions { display: flex; gap: 13px; margin-top: 5px; opacity: 0.42; }
.message:hover .message-actions, .message-actions:focus-within { opacity: 1; }
.message-action { width: 22px; height: 22px; display: grid; place-items: center; color: #b8b2ab; background: transparent; border-radius: 7px; }
.message-action:hover { color: var(--teal); background: #eae4dd; }
.message-action:hover { color: var(--coral); background: transparent; }
.message-action svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.message-quote { margin: -2px -2px 8px; padding: 6px 8px; display: grid; gap: 2px; color: #6f6760; background: rgba(255, 255, 255, 0.38); border-left: 2px solid rgba(106, 96, 87, 0.35); border-radius: 2px 6px 6px 2px; font-size: 10px; line-height: 1.4; }
.message.user .message-quote { color: rgba(255, 255, 255, 0.9); background: rgba(255, 255, 255, 0.13); border-left-color: rgba(255, 255, 255, 0.55); }
.message-quote strong { font-size: 10px; font-weight: 600; }
.message-quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-reactions { display: flex; flex-wrap: wrap; gap: 4px; }
.message-reactions span { padding: 3px 7px; color: #746b63; background: #f1ece6; border: 1px solid #e2dad1; border-radius: 999px; font-size: 10px; }
.reaction-picker { width: 190px; padding: 7px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; background: #fffdfa; border: 1px solid #ded6cd; border-radius: 10px; box-shadow: 0 8px 24px rgba(56, 45, 35, 0.13); z-index: 3; }
.message.user .reaction-picker { align-self: flex-end; }
.reaction-picker button { width: 30px; height: 30px; display: grid; place-items: center; background: transparent; border-radius: 7px; font-size: 17px; }
.reaction-picker button:hover, .reaction-picker button.selected { background: #eee7df; }
.message-bubble.pending { color: var(--muted); }
.autonomous-activity-message { width: min(100%, 340px); }
.autonomous-activity-capsule { overflow: hidden; border: 1px solid #d8cec5; border-left: 3px solid #4f8f87; border-radius: 8px; background: #faf8f5; box-shadow: 0 4px 14px rgba(45, 39, 34, .06); }
.autonomous-activity-capsule.status-failed,.autonomous-activity-capsule.status-interrupted { border-left-color: #c97b72; }
.autonomous-activity-toggle { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; width: 100%; min-height: 64px; padding: 12px 14px; border: 0; color: var(--ink); background: transparent; text-align: left; cursor: pointer; }
.autonomous-activity-heading { align-self: end; font-size: 14px; font-weight: 600; }
.autonomous-activity-toggle small { grid-column: 1; overflow-wrap: anywhere; color: var(--muted); font-size: 12px; line-height: 1.5; }
.autonomous-activity-toggle i { grid-column: 2; grid-row: 1 / span 2; align-self: center; width: 22px; color: #766d66; font-style: normal; font-size: 18px; text-align: center; }
.autonomous-activity-detail { border-top: 1px solid #e6ddd5; padding: 2px 14px 12px; }
.autonomous-activity-channel { margin: 9px 0 0; color: #a39b94; font-size: 11px; }
.autonomous-activity-item { padding-top: 11px; }
.autonomous-activity-item + .autonomous-activity-item { margin-top: 10px; border-top: 1px solid #ebe4de; }
.autonomous-activity-item strong { font-size: 12px; }
.autonomous-activity-item p,.autonomous-activity-item blockquote { margin: 5px 0 0; color: #665e58; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.autonomous-activity-item blockquote { padding-left: 9px; border-left: 2px solid #d8cec5; white-space: pre-wrap; }
.draw-guess-message-capsule { width: fit-content; max-width: 100%; margin: 2px 0 8px; padding: 7px 11px; display: inline-flex; align-items: center; gap: 7px; color: #6f5550; background: #fff8f5; border: 1px solid #e7c9c1; border-radius: 8px; font: inherit; font-size: 11px; line-height: 1.3; text-align: left; }
.draw-guess-message-capsule:hover { background: #fff1ec; }
.draw-guess-message-capsule svg { width: 15px; height: 15px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.game-message-capsule { width: fit-content; max-width: min(100%, 300px); margin: 2px 0 8px; padding: 8px 11px; color: #5f5550; background: #f7f3ef; border-left: 3px solid #c9786d; border-radius: 0 6px 6px 0; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.game-message-capsule.pending { color: #756b65; border-left-color: #aaa19a; }
.game-message-capsule.failed { color: #9a443b; border-left-color: #bd574b; }
.game-invitation-capsule { width: min(100%, 300px); margin-top: 8px; color: var(--ink); background: #f7f1ec; border: 1px solid #e6ddd5; border-radius: 14px; overflow: hidden; }
.game-invitation-toggle { width: 100%; min-height: 38px; padding: 0 12px; display: flex; align-items: center; gap: 8px; color: inherit; background: transparent; border: 0; font: inherit; font-size: 12px; text-align: left; }
.game-invitation-toggle:hover { background: #f1e8e1; }
.game-invitation-glyph { color: var(--coral); font-size: 17px; line-height: 1; }
.game-invitation-chevron { margin-left: auto; color: var(--muted); font-size: 18px; transition: transform .18s ease; }
.game-invitation-capsule.expanded .game-invitation-chevron { transform: rotate(90deg); }
.game-invitation-detail { padding: 0 12px 11px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.game-invitation-detail p { margin: 0 0 9px; }
.game-invitation-actions { display: flex; gap: 7px; }
.game-invitation-actions button { min-height: 28px; padding: 0 10px; color: var(--coral); background: #fffaf6; border: 1px solid #dfcfc5; border-radius: 8px; font: inherit; font-size: 11px; }
.game-invitation-actions button:hover { background: #f4e6df; }
.game-invitation-actions small { color: var(--muted); }
.twenty-questions-modal { width: min(92vw, 390px); }
.twenty-questions-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.twenty-questions-roles button { min-height: 42px; color: var(--ink); background: #fbf7f3; border: 1px solid #dfd4ca; border-radius: 8px; font: inherit; font-size: 13px; }
.twenty-questions-roles button:hover { color: var(--coral); background: #f6eae5; }
.twenty-questions-panel { display: grid; gap: 12px; }
.twenty-questions-status { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.twenty-questions-status strong { color: var(--coral); font-size: 12px; }
.twenty-questions-panel p { min-height: 18px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.twenty-questions-panel label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.choice-card {
  width: min(330px, 72vw);
  margin: 10px -4px -3px;
  padding: 13px;
  display: grid;
  gap: 10px;
  color: var(--ink);
  white-space: normal;
  background: rgba(255, 253, 250, 0.86);
  border: 1px solid #dfd2c9;
  border-left: 3px solid #c98277;
  border-radius: 10px;
  box-shadow: 0 3px 12px rgba(83, 60, 45, 0.06);
}
.message-bubble > .choice-card:first-child { margin-top: -3px; }
.choice-eyebrow { color: #a55c53; font-size: 9px; font-weight: 700; }
.choice-question { margin: -3px 0 0; font-family: Georgia, "Songti SC", serif; font-size: 15px; line-height: 1.5; letter-spacing: 0; }
.choice-options, .choice-rank-list { margin: 0; padding: 0; display: grid; gap: 7px; }
.choice-option {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #413b36;
  text-align: left;
  background: #f8f3ed;
  border: 1px solid #e3dad1;
  border-radius: 8px;
}
.choice-option:hover { border-color: #cda99f; background: #f7eee8; }
.choice-option.selected { border-color: #bd7469; background: #f5e5e0; box-shadow: inset 0 0 0 1px rgba(189, 116, 105, 0.12); }
.choice-option-indicator { width: 17px; height: 17px; flex: 0 0 17px; display: grid; place-items: center; border: 1.5px solid #b6aaa0; border-radius: 50%; }
.choice-multi-select .choice-option-indicator { border-radius: 4px; }
.choice-option.selected .choice-option-indicator { border-color: #bd7469; background: #bd7469; box-shadow: inset 0 0 0 4px #f8ece8; }
.choice-multi-select .choice-option.selected .choice-option-indicator { box-shadow: none; }
.choice-multi-select .choice-option.selected .choice-option-indicator::after { content: "✓"; color: #fff; font-size: 12px; line-height: 1; }
.choice-option-label { min-width: 0; flex: 1; overflow-wrap: anywhere; font-size: 12px; line-height: 1.45; }
.choice-rank-list { list-style: none; }
.choice-rank-option {
  min-height: 44px;
  padding: 6px 7px;
  display: grid;
  grid-template-columns: 22px 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  background: #f8f3ed;
  border: 1px solid #e3dad1;
  border-radius: 8px;
}
.choice-rank-option:active { border-color: #cda99f; background: #f7eee8; }
.choice-rank-position { width: 22px; height: 22px; display: grid; place-items: center; color: #fff; background: #ba766c; border-radius: 6px; font-size: 10px; font-weight: 700; }
.choice-drag-handle { color: #a49a91; cursor: grab; font-size: 14px; line-height: 1; }
.choice-rank-controls { display: flex; gap: 2px; }
.choice-rank-controls button { width: 29px; height: 29px; padding: 0; display: grid; place-items: center; color: #827870; background: transparent; border-radius: 6px; font-size: 16px; }
.choice-rank-controls button:hover:not(:disabled) { color: #a65d54; background: #eee3db; }
.choice-rank-controls button:disabled { opacity: 0.28; }
.choice-hint { margin: -2px 0 0; color: #8b8179; font-size: 9px; line-height: 1.4; }
.choice-submit { min-height: 38px; padding: 8px 12px; color: #fff; background: #bb7066; border-radius: 8px; font-size: 11px; font-weight: 700; }
.choice-submit:hover:not(:disabled) { background: #a95e55; }
.choice-submit:disabled { opacity: 0.42; cursor: default; }
.choice-card.choice-answered { gap: 7px; border-left-color: #9a8f86; background: rgba(248, 244, 239, 0.9); box-shadow: none; }
.choice-answered .choice-eyebrow { color: #81776f; }
.choice-answer-summary { padding-top: 8px; display: grid; gap: 3px; border-top: 1px solid #e1d8d0; }
.choice-answer-summary span { color: #8a8078; font-size: 9px; }
.choice-answer-summary strong { color: #4b443f; font-size: 12px; line-height: 1.55; font-weight: 600; }
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: pulse 1s infinite; }
.typing-dots i:nth-child(2) { animation-delay: 0.12s; }
.typing-dots i:nth-child(3) { animation-delay: 0.24s; }
.edit-area { width: min(360px, 76vw); min-height: 86px; padding: 11px; color: var(--ink); background: #fff; border: 1px solid var(--teal); border-radius: 9px; resize: vertical; outline: 0; line-height: 1.55; }
.mail-status { max-width: 270px; margin-top: 4px; padding: 12px 14px; display: grid; gap: 3px; color: var(--muted); background: var(--paper); border: 0; border-radius: 14px; box-shadow: 0 2px 12px rgba(20,16,12,.07); font-size: 11.5px; }
.mail-status strong { color: var(--ink); font-size: 13.5px; font-weight: 600; }
.mail-status.sent strong, .mail-status.queued strong { color: var(--ink); }
.mail-status.failed { border: 1px solid #f0dad8; background: #fffafa; }
.mail-status.failed strong { color: #b55a52; }
.mail-status.failed button { justify-self: start; margin-top: 3px; padding: 0; color: var(--coral); background: transparent; font-size: 11.5px; }

@media (max-width: 520px) {
  .message:has(.choice-card) { max-width: calc(100% - 20px); }
  .choice-card { width: min(330px, calc(100vw - 76px)); }
}

@media (prefers-reduced-motion: reduce) {
  .choice-option, .choice-submit, .choice-rank-option { transition: none; }
}

.connect-four-dock {
  padding: 8px 12px 10px;
  background: #fffdf9;
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 22px rgba(55, 43, 34, 0.055);
}
.connect-four-dock[hidden] { display: none; }
.connect-four-dock-head {
  width: 100%;
  min-height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}
.connect-four-head-main { min-width: 0; display: grid; gap: 2px; }
.connect-four-head-main strong { font-family: Georgia, "Noto Serif SC", "Songti SC", serif; font-size: 16px; line-height: 1.15; }
.connect-four-head-main small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.connect-four-chevron { width: 24px; height: 24px; display: grid; place-items: center; color: #8f857d; font-size: 13px; transform: rotate(0deg); transition: transform .16s ease; }
.connect-four-dock-head[aria-expanded="false"] .connect-four-chevron { transform: rotate(-90deg); }
.connect-four-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: start;
  padding-top: 6px;
}
.connect-four-panel[hidden] { display: none; }
.connect-four-meta {
  min-width: 0;
  color: #746b63;
  font-size: 10px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.connect-four-board {
  width: min(100%, 210px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  padding: 6px;
  grid-row: 1 / span 3;
  grid-column: 2;
  background: #efe7df;
  border: 1px solid #dfd3c8;
  border-radius: 8px;
}
.connect-four-cell {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  display: grid;
  place-items: center;
  color: #756e67;
  background: #fffaf5;
  border: 1px solid #d8cfc6;
  border-radius: 7px;
}
.connect-four-cell:not(:disabled):hover { border-color: var(--teal); background: #f6fbf9; }
.connect-four-cell:disabled { cursor: default; }
.connect-four-token { width: 62%; height: 62%; display: block; border-radius: 50%; opacity: 0; }
.connect-four-cell.nini .connect-four-token { opacity: 1; background: var(--coral); box-shadow: inset 0 -2px 0 rgba(80, 42, 35, 0.14); }
.connect-four-cell.model .connect-four-token { opacity: 1; background: var(--teal); box-shadow: inset 0 -2px 0 rgba(22, 65, 59, 0.14); }
.connect-four-cell.pending .connect-four-token { opacity: 1; background: transparent; border: 2px dashed var(--coral); }
.connect-four-cell.oldest .connect-four-token { box-shadow: 0 0 0 3px rgba(215, 168, 62, 0.28), inset 0 -2px 0 rgba(80, 42, 35, 0.14); }
.connect-four-cell.winning { border-color: #d7a83e; background: #fff7df; }
.connect-four-pending-list {
  min-height: 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  color: #7b6f67;
  font-size: 10px;
}
.connect-four-pending-list button {
  min-height: 24px;
  padding: 0 7px;
  color: var(--coral-dark);
  background: #f7efee;
  border-radius: 7px;
  font-size: 10px;
}
.connect-four-status-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.connect-four-status { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.connect-four-finish { min-height: 30px; padding: 6px 9px; flex: 0 0 auto; }
.connect-four-attachment-chip { color: #5f5550; background: #f2f8f6; border-color: #cfe2de; }
.twenty-questions-attachment-chip { color: #7a5757; background: #fff3f1; border-color: #ead0cc; }

@media (max-width: 520px) {
  .connect-four-panel { grid-template-columns: 1fr; }
  .connect-four-board { width: min(100%, 244px); grid-column: 1; grid-row: auto; justify-self: center; }
  .connect-four-status-row { align-items: flex-start; }
}

.composer-wrap { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); }
.composer { padding: 9px 10px 7px; background: #fff; border: 1px solid #d8d0c7; border-radius: 13px; box-shadow: 0 4px 14px rgba(56, 45, 35, 0.05); }
.composer:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(67, 135, 126, 0.1); }
.composer-main { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea { min-width: 0; min-height: 34px; max-height: 130px; flex: 1; padding: 6px 0; resize: none; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 14px; line-height: 1.5; }
.composer textarea::placeholder { color: #aaa29a; }
.attach-button, .send-button, .stop-button { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 10px; }
.attach-button { color: var(--muted); background: transparent; }
.attach-button:hover { color: var(--teal); background: #f2ede7; }
.attach-button svg, .send-button svg, .stop-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.send-button { color: #fff; background: var(--coral); }
.send-button:hover { background: var(--coral-dark); }
.send-button:disabled { opacity: 0.45; cursor: wait; }
.stop-button { color: #fff; background: #7d655d; }
.stop-button:hover { background: #66504a; }
.stop-button[hidden] { display: none; }
.composer-hint { display: block; margin: 4px 44px 0; color: var(--muted); font-size: 10px; }
.composer-tools-menu { position: absolute; left: 12px; bottom: 58px; z-index: 8; width: 176px; padding: 6px; display: grid; gap: 3px; background: #fffdfa; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(56, 45, 35, 0.14); }
.composer-tools-menu[hidden] { display: none; }
.composer-tool-item { width: 100%; padding: 9px 10px; display: flex; align-items: center; gap: 9px; color: var(--ink); background: transparent; border-radius: 8px; text-align: left; font-size: 12px; }
.composer-tool-item:hover, .composer-tool-item:focus-visible { background: #f4eee8; }
.composer-tool-item svg { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.composer { position: relative; }
.draw-guess-modal { width: min(92vw, 430px); }
.draw-guess-preview-modal { width: min(92vw, 430px); }
.draw-guess-preview-frame { min-height: 180px; display: grid; place-items: center; overflow: hidden; background: #fff; border: 1px solid #ded4ca; border-radius: 12px; }
.draw-guess-preview-frame img { display: block; width: 100%; height: auto; max-height: min(68vh, 520px); object-fit: contain; }
.draw-guess-setup { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: -4px 0 10px; }
.draw-guess-setup label, .draw-size-label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.draw-guess-setup select { min-height: 32px; border: 1px solid #ded4ca; border-radius: 8px; background: #fff; color: var(--ink); padding: 0 8px; }
.draw-guess-prompt { margin: -2px 0 8px; color: var(--coral); font-size: 18px; font-weight: 700; }
.draw-guess-instruction { margin: -5px 0 12px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.draw-guess-start { margin: 0 0 12px; display: flex; justify-content: flex-end; }
.draw-guess-tools { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.draw-guess-colors { display: flex; gap: 6px; }
.draw-color { width: 22px; height: 22px; padding: 0; border: 2px solid transparent; border-radius: 50%; background: var(--draw-color); }
.draw-color.active { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }
.draw-size-label { flex: 1; grid-template-columns: auto 1fr; align-items: center; }
.draw-size-label input { width: 100%; accent-color: var(--coral); }
.draw-eraser.active { background: var(--coral); color: #fff; }
.draw-guess-canvas-wrap { width: 100%; aspect-ratio: 1; overflow: hidden; background: #fff; border: 1px solid #ded4ca; border-radius: 12px; touch-action: none; }
#drawGuessCanvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.draw-guess-actions { margin-top: 12px; display: flex; justify-content: flex-end; gap: 8px; }
.draw-guess-actions button { min-height: 36px; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 5px; }
.composer-reply-preview { margin: 0 0 7px 43px; padding: 6px 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); background: #f4efe9; border-left: 2px solid #b9aaa0; border-radius: 2px 7px 7px 2px; }
.composer-reply-preview[hidden] { display: none; }
.composer-reply-preview span { min-width: 0; display: grid; gap: 1px; }
.composer-reply-preview strong { color: var(--ink); font-size: 10px; }
.composer-reply-preview small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.composer-reply-preview button { width: 22px; height: 22px; flex: 0 0 22px; display: grid; place-items: center; color: var(--muted); background: transparent; border-radius: 6px; font-size: 18px; }
.attachment-chip { max-width: 100%; padding: 5px 7px; display: inline-flex; align-items: center; gap: 6px; overflow: hidden; color: var(--muted); background: #f2ede7; border: 1px solid var(--line); border-radius: 7px; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.attachment-remove { width: 17px; height: 17px; padding: 0; display: grid; place-items: center; color: var(--muted); background: transparent; border-radius: 50%; }

.letters-list { padding: 18px; gap: 12px; background: var(--cream); }
.push-inbox { display: grid; }
.letter-card {
  --letter-accent: #c78b80;
  padding: 16px 18px 17px;
  display: grid;
  gap: 8px;
  background: #fff;
  border: 0;
  border-left: 3px solid var(--letter-accent);
  border-radius: 13px;
  box-shadow: 0 2px 9px rgba(83, 60, 45, 0.055);
}
.letter-card.letter-deepseek {
  --letter-accent: #89a9be;
}
.letter-card.letter-gpt {
  --letter-accent: #96918b;
}
.letter-card.letter-kimi {
  --letter-accent: #756d91;
}
.letter-card.unread { box-shadow: 0 3px 12px rgba(83, 60, 45, 0.075); }
.letter-card-link { cursor: pointer; }
.letter-card-link:focus-visible { outline: 2px solid var(--letter-accent); outline-offset: 3px; }
.letter-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.letter-model { min-width: 0; display: flex; align-items: center; gap: 6px; color: #756f69; }
.letter-model-avatar { width: 21px; height: 21px; display: block; object-fit: cover; border-radius: 6px; box-shadow: 0 2px 5px rgba(56, 45, 35, 0.1); }
.letter-model strong { font-size: 11px; font-weight: 600; }
.letter-kind { color: var(--letter-accent); font-size: 12px; font-weight: 700; }
.letter-time { color: var(--muted); font-size: 11px; }
.letter-content { margin: 0; color: var(--ink); font-size: 14px; line-height: 1.62; white-space: pre-wrap; word-break: break-word; }
.push-inbox-empty { margin: 0; padding: 70px 20px; text-align: center; color: var(--muted); font-size: 12px; }

.diary-tool svg { stroke-width: 1.7; }
#diaryView { background: #fdf8f6; }
.diary-filter-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  overflow-x: auto;
  background: rgba(253, 248, 246, 0.97);
  border-bottom: 1px solid #f0ddda;
  scrollbar-width: none;
}
.diary-filter-bar::-webkit-scrollbar { display: none; }
.diary-author-filters { display: flex; gap: 6px; flex: 0 0 auto; }
.diary-filter {
  min-width: 58px;
  min-height: 32px;
  padding: 0 11px;
  flex: 0 0 auto;
  color: #9c7f7d;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 11px;
}
.diary-filter:hover { color: #7d5e5a; background: #f5e8e6; }
.diary-filter.active { color: #2d1f1e; background: #fff; border-color: #ead5d1; font-weight: 700; }
.diary-date-filter {
  min-width: 104px;
  min-height: 32px;
  padding: 0 26px 0 9px;
  flex: 0 0 auto;
  color: #7d5e5a;
  background-color: #fff;
  border: 1px solid #ead5d1;
  border-radius: 7px;
  font: inherit;
  font-size: 11px;
}
.diary-date-filter:focus-visible { outline: 2px solid #c86557; outline-offset: 1px; }
.diary-feed { min-height: 100%; padding: 5px 0 88px; }
.diary-date-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px 3px;
  color: #9c7f7d;
  font-size: 10px;
}
.diary-date-divider::before,
.diary-date-divider::after { content: ""; height: 1px; flex: 1; background: #f0ddda; }
.diary-entry {
  padding: 17px 20px 16px;
  background: transparent;
  border-bottom: 1px solid #f0ddda;
  animation: diary-fade 0.24s ease;
}
@keyframes diary-fade { from { opacity: 0; transform: translateY(4px); } }
.diary-entry.highlighted { background: #fff4f1; }
.diary-entry-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.diary-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fff;
  background: #c86557;
  border: 2px solid #f3dfdc;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: 700;
}
.diary-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.diary-author { min-width: 0; flex: 1; }
.diary-author-name { font-size: 14px; font-weight: 700; }
.diary-entry.diary-claude .diary-author-name { color: #c86557; }
.diary-entry.diary-deepseek .diary-author-name { color: #6f91ad; }
.diary-entry.diary-gpt .diary-author-name { color: #77736e; }
.diary-entry.diary-kimi .diary-author-name { color: #756d91; }
.diary-entry.diary-nini .diary-author-name { color: #2d1f1e; }
.diary-time { margin-top: 3px; color: #9c7f7d; font-size: 10px; }
.diary-entry-body { margin-left: 54px; }
.diary-text {
  margin: 0 0 11px;
  color: #2d1f1e;
  font-family: Georgia, "Noto Serif SC", "Songti SC", "STSong", serif;
  font-size: 14.5px;
  line-height: 1.82;
  white-space: pre-wrap;
  word-break: break-word;
}
.diary-mentions { margin: -3px 0 9px; display: flex; align-items: center; flex-wrap: wrap; gap: 5px; color: #9c7f7d; font-size: 10px; }
.diary-mention-chip { height: 23px; padding: 2px 7px 2px 3px; display: inline-flex; align-items: center; gap: 4px; color: #6e5551; background: #f4e8e5; border: 1px solid #ead7d3; border-radius: 12px; }
.diary-mention-chip img { width: 17px; height: 17px; object-fit: cover; border-radius: 50%; }
.diary-mention-deepseek { color: #5f7f99; background: #eaf0f4; border-color: #d7e3ea; }
.diary-mention-gpt { color: #696662; background: #efeeec; border-color: #dfddda; }
.diary-mention-kimi { color: #756d91; background: #efedf4; border-color: #ddd8e7; }
.diary-comment .diary-mentions { margin: 3px 0 0 12px; display: inline-flex; vertical-align: middle; }
.diary-comment .diary-mention-chip { height: 20px; padding-right: 6px; }
.diary-comment .diary-mention-chip img { width: 14px; height: 14px; }
.diary-actions { min-height: 27px; display: flex; align-items: center; gap: 14px; color: #9c7f7d; }
.diary-action {
  min-height: 27px;
  padding: 3px 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: inherit;
  background: transparent;
  font-size: 11px;
}
.diary-action:hover { color: #c86557; }
.diary-action.liked { color: #c86557; }
.diary-action svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.diary-action.liked svg { fill: currentColor; }
.diary-delete { margin-left: auto; }
.diary-model-likes { display: inline-flex; align-items: center; gap: 5px; color: #9c7f7d; font-size: 11px; }
.diary-like-avatars { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; }
.diary-like-avatar { width: 19px; height: 19px; margin-left: -5px; object-fit: cover; border: 2px solid #fdf8f6; border-radius: 50%; }
.diary-comments {
  margin-top: 7px;
  padding: 10px 12px;
  background: #f3ece9;
  border-radius: 8px;
}
.diary-comment { position: relative; padding: 3px 0; color: #493b39; font-size: 12px; line-height: 1.62; }
.diary-comment.is-reply { padding-left: 12px; }
.diary-comment.is-reply::before { content: ""; position: absolute; top: 7px; bottom: 6px; left: 2px; width: 2px; background: #e5d4d0; }
.diary-comment-author { color: #c86557; font-weight: 700; }
.diary-comment.diary-comment-deepseek .diary-comment-author { color: #6f91ad; }
.diary-comment.diary-comment-gpt .diary-comment-author { color: #77736e; }
.diary-comment.diary-comment-kimi .diary-comment-author { color: #756d91; }
.diary-comment.diary-comment-nini .diary-comment-author { color: #6e5551; }
.diary-comment-controls { display: inline-flex; gap: 6px; margin-left: 6px; }
.diary-comment-link { padding: 0; color: #9c7f7d; background: transparent; font-size: 10px; }
.diary-comment-link:hover { color: #c86557; }
.diary-comment-input-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid #ead7d3;
}
.diary-comment-input {
  min-width: 0;
  min-height: 32px;
  flex: 1;
  padding: 6px 12px;
  color: #2d1f1e;
  background: #fff;
  border: 1px solid #ead7d3;
  border-radius: 16px;
  outline: 0;
  font-size: 12px;
}
.diary-comment-input:focus { border-color: #d9a096; }
.diary-comment-input::placeholder { font-size: 12px; }
.diary-comment-send {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #c86557;
  border-radius: 50%;
}
.diary-comment-send svg { width: 14px; height: 14px; fill: currentColor; }
.diary-empty-state { padding: 92px 26px; text-align: center; color: #9c7f7d; }
.diary-empty-state strong { display: block; color: #2d1f1e; font-family: Georgia, "Songti SC", serif; font-size: 19px; }
.diary-empty-state span { display: block; margin-top: 8px; font-size: 11px; }
.web-sources { width: min(100%, 290px); margin: 4px 0 0; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 0; }
.web-sources-heading { display: block; margin-bottom: 6px; color: #b8b2ab; font-size: 10px; font-weight: 500; letter-spacing: .08em; }
.web-sources-list { display: flex; gap: 7px; overflow-x: auto; }
.web-sources-list::-webkit-scrollbar { display: none; }
.web-source-card { min-width: 150px; padding: 8px 10px; display: grid; grid-template-columns: auto minmax(0,1fr); gap: 6px; background: var(--paper); border-radius: 14px; box-shadow: 0 2px 12px rgba(20,16,12,.07); }
.web-source-card > strong { color: var(--coral); font-size: 10px; }
.web-source-title { display: block; overflow: hidden; color: var(--ink); font-size: 11.5px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.web-source-meta { display: block; margin-top: 2px; overflow: hidden; color: #b8b2ab; font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }
.web-source-card { min-width: 150px; display: grid; grid-template-columns: auto minmax(0,1fr); gap: 6px; padding: 8px 10px; color: inherit; background: var(--paper); border: 0; border-radius: 14px; box-shadow: 0 2px 12px rgba(20,16,12,.07); text-decoration: none; }
.web-source-card:hover { background: var(--sand); border-color: transparent; }
.web-source-card > strong { color: var(--coral); font-size: 10px; line-height: 1.45; }
.web-source-card > span { min-width: 0; }
.web-source-title { display: block; overflow: hidden; color: var(--ink); font-size: 11.5px; font-weight: 500; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.web-source-meta { display: block; overflow: hidden; margin-top: 2px; color: #b8b2ab; font-size: 9.5px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.diary-composer-modal { background: #fdf8f6; }
.diary-post-input {
  width: 100%;
  min-height: 180px;
  margin-top: 18px;
  padding: 14px;
  resize: vertical;
  color: #2d1f1e;
  background: #fff;
  border: 1px solid #ead7d3;
  border-radius: 8px;
  outline: 0;
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 15px;
  line-height: 1.75;
}
.diary-post-input:focus { border-color: #d9a096; box-shadow: 0 0 0 3px rgba(200, 101, 87, 0.08); }
.diary-mention-choices { margin: 10px 0 2px; display: flex; gap: 7px; }
.diary-mention-choice { min-width: 0; padding: 4px 8px 4px 4px; display: inline-flex; align-items: center; gap: 5px; color: #8d817b; background: transparent; border: 1px solid #eadfd9; border-radius: 15px; font-size: 10px; }
.diary-mention-choice img { width: 22px; height: 22px; object-fit: cover; border-radius: 50%; filter: saturate(0.78); }
.diary-mention-choice.selected { color: #6e5551; background: #f4e8e5; border-color: #d8aaa2; }
.diary-mention-choice.selected img { filter: none; }
.diary-compose-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #9c7f7d; font-size: 10px; }
.diary-compose-footer .modal-actions { margin-top: 10px; }

.settings-view { padding: 18px 16px 32px; background: var(--cream); }
.settings-group { margin-bottom: 22px; }
.settings-group h2 { margin: 0 0 8px 6px; color: var(--muted); font-size: 11px; font-weight: 600; }
.settings-row, .settings-card { width: 100%; color: var(--ink); background: var(--paper); border: 1px solid var(--line); }
.settings-row { min-height: 66px; padding: 11px 14px; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 11px; text-align: left; }
.settings-row:first-of-type { border-radius: 9px 9px 0 0; }
.settings-row + .settings-row { margin-top: -1px; border-radius: 0 0 9px 9px; }
.settings-row:hover { background: #fbf7f2; }
.settings-row-icon { width: 34px; height: 34px; display: grid; place-items: center; color: #fff; border-radius: 9px; font-size: 18px; }
.settings-row-icon.coral { background: var(--coral); }
.settings-row-icon.teal { background: var(--teal); }
.settings-row > span:nth-child(2), .settings-card-head span { min-width: 0; display: grid; gap: 3px; }
.settings-row strong, .settings-card strong { font-size: 13px; }
.settings-row small, .settings-card small { color: var(--muted); font-size: 10px; }
.row-status { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
.status-mini { width: 7px; height: 7px; background: #49a27f; border-radius: 50%; }
.row-status.disconnected .status-mini { background: #b8b1aa; }
.row-chevron { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.settings-card { padding: 15px; border-radius: 9px; }
.settings-card-head { display: flex; align-items: center; justify-content: space-between; }
.settings-actions, .modal-actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 7px; }
.primary-button, .secondary-button { padding: 9px 12px; border-radius: 8px; font-size: 11px; font-weight: 700; }
.primary-button { color: #fff; background: var(--coral); }
.secondary-button { color: var(--ink); background: #eee8e1; }
.settings-inbox { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--paper); }
.settings-inbox { padding: 10px; gap: 8px; }
.settings-inbox .letter-card { padding: 11px 12px; box-shadow: none; }
.settings-inbox .letter-card:nth-child(n+4) { display: none; }
.settings-inbox .letter-content { font-size: 11px; }

.bottom-nav {
  min-height: 60px;
  padding: 5px 10px calc(5px + env(safe-area-inset-bottom));
  display: none;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 253, 249, 0.98);
  border-top: 1px solid var(--line);
  z-index: 4;
}
.nav-item { position: relative; min-width: 0; display: grid; justify-items: center; align-content: center; gap: 2px; color: #918980; background: transparent; font-size: 10px; }
.nav-item.active { color: var(--coral); }
.nav-icon-outline, .nav-icon-fill { width: 25px; height: 25px; }
.nav-icon-fill { display: none; }
.nav-item.active .nav-icon-outline { display: none; }
.nav-item.active .nav-icon-fill { display: block; }
.nav-icon-outline svg, .nav-icon-fill svg { width: 25px; height: 25px; }
.nav-icon-outline svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-icon-fill svg { fill: currentColor; }
.nav-item .inbox-count { position: absolute; top: 1px; left: calc(50% + 8px); min-width: 16px; height: 16px; line-height: 16px; font-size: 9px; }

.drawer-backdrop, .modal-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(39, 36, 33, 0.35); }
.conversation-drawer { position: absolute; top: 0; right: 0; width: min(288px, 92vw); height: 100%; padding: 56px 18px 14px; overflow-y: auto; background: var(--paper); border-left: 1px solid var(--line); box-shadow: -18px 0 50px rgba(56, 45, 35, 0.14); }
.drawer-heading, .modal-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.drawer-heading h2, .modal-heading h2 { margin: 0; font-family: "Noto Sans SC", "PingFang SC", sans-serif; font-size: 17px; font-weight: 700; }
.drawer-heading .eyebrow { display: none; }
.drawer-heading .header-button { display: none; }
.new-conversation-button { position: absolute; top: 54px; right: 18px; width: auto; margin: 0; padding: 0; color: var(--coral); background: transparent; border-radius: 0; font-size: 12.5px; font-weight: 600; }
.new-conversation-button span { font-size: 15px; vertical-align: -1px; }
.conversation-list { display: grid; gap: 0; margin: 20px -18px 0; }
.conversation-row { display: flex; align-items: stretch; gap: 0; border: 0; border-radius: 0; }
.conversation-row.active { background: #f7efee; }
.conversation-select { min-width: 0; min-height: 54px; flex: 1; padding: 9px 18px; display: grid; gap: 1px; text-align: left; color: var(--ink); background: transparent; }
.conversation-select strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 1.15; font-weight: 500; }
.conversation-row.active .conversation-select strong { color: var(--coral-dark); }
.conversation-select small { color: #b8b2ab; font-size: 11.5px; line-height: 1.2; }
.conversation-delete { align-self: center; }
.conversation-delete { width: 34px; height: 34px; margin-right: 10px; opacity: .35; }
.conversation-drawer #thinkingControl { grid-template-columns: minmax(0, 1fr) auto; min-height: 54px; margin-top: 16px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; }
.conversation-drawer #thinkingControl .settings-row-icon { display: none; }
.conversation-drawer #thinkingControl > span:nth-child(2) { grid-column: 1; margin-left: 0; }
.conversation-drawer #thinkingControl > input { grid-column: 2; grid-row: 1; }
.conversation-drawer #thinkingControl strong { font-size: 11px; }
.conversation-drawer #thinkingControl small { font-size: 9px; }
.conversation-drawer #thinkingControl > input { transform: scale(.82); transform-origin: center right; }

.modal-backdrop { display: grid; place-items: center; padding: 20px; }
.settings-modal { width: min(420px, 100%); padding: 22px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.field-label { display: block; margin-top: 22px; color: var(--muted); font-size: 11px; font-weight: 700; }
.text-input { width: 100%; margin-top: 7px; padding: 11px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; outline: 0; }
.field-note { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.modal-actions { justify-content: flex-end; }
.status-line { min-height: 17px; margin-top: 10px; color: var(--coral-dark); font-size: 11px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; max-width: calc(100% - 32px); padding: 10px 14px; color: #fff; background: #35312c; border-radius: 8px; box-shadow: var(--shadow); font-size: 11px; opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: 0.2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 760px) {
  body { padding: 24px; }
  .app-shell { height: calc(100dvh - 48px); border: 1px solid rgba(116, 96, 82, 0.14); border-radius: 22px; }
}

@media (max-width: 759px) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  .app-shell {
    position: fixed;
    top: var(--visual-offset-top, 0px);
    right: 0;
    left: 0;
    width: 100%;
    height: var(--visual-height, 100dvh);
    min-height: 0;
    margin: 0;
  }
  .app-header { min-height: 58px; padding: 7px 10px 6px; }
  .bottom-nav { min-height: 56px; padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); }
  .diary-filter-bar { gap: 4px; padding-right: 8px; padding-left: 8px; }
  .diary-author-filters { gap: 2px; }
  .diary-filter { min-width: 46px; padding-right: 7px; padding-left: 7px; }
  .diary-date-filter { min-width: 88px; padding-right: 20px; padding-left: 6px; }
  .app-shell:has(.diary-comment-input:focus) .bottom-nav { display: none; }
  .header-title h1 { font-size: 21px; }
  .contact-row { min-height: 82px; padding-right: 17px; padding-left: 17px; }
  .conversation { padding: 20px 14px; }
  .composer textarea,
  .search-wrap input,
  .text-input,
  .edit-area,
  .diary-comment-input,
  .diary-post-input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
