@font-face {
  font-family: 'Ark Pixel';
  src: url('./fonts/ark-pixel-12px.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ===== Foundation ===== */
:root {
  --bg: #FFFFFF;
  --bg-secondary: #F8F8F8;
  --bg-tertiary: #F0F0F0;
  --bg-hover: #EBEBEB;
  --text-primary: #111111;
  --text-secondary: #6B6B6B;
  --text-tertiary: #ABABAB;
  --border: #E8E8E8;
  --border-light: #F0F0F0;

  --bubble-user: #1A1A1A;
  --bubble-user-text: #FFFFFF;
  --bubble-ai: #F2F2F2;
  --bubble-ai-text: #111111;
  --bubble-thinking: #EDF2FE;
  --bubble-thinking-text: #3B5998;

  --accent: #1A1A1A;
  --accent-hover: #333333;
  --danger: #E54D2E;

  --font-display: 'Outfit', 'Noto Sans SC', sans-serif;
  --font-body: 'Outfit', 'Noto Sans SC', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);

  --sidebar-width: 260px;
  --header-height: 54px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea { font-family: inherit; border: none; outline: none; }
textarea { resize: none; }

/* ===== Layout ===== */
#app {
  display: flex;
  height: 100%;
  position: relative;
}

/* ===== Sidebar ===== */
#sidebar {
  width: var(--sidebar-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
  transition: transform 0.35s var(--ease-out);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 12px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.02em;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.sidebar-search {
  padding: 0 12px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  margin: 0 12px 8px;
  border-radius: var(--radius-md);
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  transition: border-color 0.2s;
}

.sidebar-search:focus-within {
  border-color: var(--text-tertiary);
}

.sidebar-search svg { color: var(--text-tertiary); flex-shrink: 0; }

.sidebar-search input {
  flex: 1;
  background: transparent;
  font-size: 13px;
  color: var(--text-primary);
}

.sidebar-search input::placeholder { color: var(--text-tertiary); }

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.sidebar-list::-webkit-scrollbar { width: 4px; }
.sidebar-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.conv-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-bottom: 1px;
  transition: background 0.15s;
  position: relative;
}

.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg); box-shadow: var(--shadow-sm); }

.conv-item-content {
  flex: 1;
  min-width: 0;
}

.conv-item-title {
  font-size: 13px;
  font-weight: 450;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.conv-item-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  letter-spacing: 0.01em;
}

.conv-item-delete {
  opacity: 0;
  color: var(--text-tertiary);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: opacity 0.15s, color 0.15s;
}

.conv-item:hover .conv-item-delete { opacity: 1; }
.conv-item-delete:hover { color: var(--danger); }

.search-msg-item {
  padding: 4px 12px 4px 28px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  line-height: 1.45;
  display: flex;
  gap: 4px;
  align-items: baseline;
  margin-bottom: 1px;
}
.search-msg-item:active { background: var(--bg-hover); }
.search-msg-role {
  flex-shrink: 0;
  color: var(--text-tertiary);
  font-size: 11px;
}
.search-msg-snippet {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.search-msg-snippet mark {
  background: #866E99;
  color: #fff;
  border-radius: 2px;
  padding: 0 2px;
  font-style: normal;
}
.search-conv-more {
  padding: 2px 12px 6px 28px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-footer-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  width: 100%;
  letter-spacing: -0.01em;
}

.sidebar-footer-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-footer-btn svg { color: var(--text-tertiary); }

/* ===== Icon Button ===== */
.icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ===== Mobile Sidebar Toggle ===== */
#sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  background: var(--bg);
}

/* ===== Chat Area ===== */
#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.chat-header {
  height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0px) 20px 0;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-header-left h2 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.chat-header-left:hover #btn-gen-title { opacity: 0.4; }
#btn-gen-title:hover { opacity: 1 !important; }

/* ===== Model Selector ===== */
.model-selector {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 450;
  color: var(--text-secondary);
  transition: all 0.15s;
  letter-spacing: -0.01em;
}

.model-selector:hover { border-color: var(--text-tertiary); color: var(--text-primary); }

.model-dot {
  display: none;
}

.model-dropdown {
  position: absolute;
  top: calc(var(--header-height) + env(safe-area-inset-top, 0px) + 4px);
  right: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: none;
  flex-direction: row;
  overflow: hidden;
}

.model-dropdown.open { display: flex; }

.model-provider-list {
  width: 100px;
  border-right: 1px solid var(--border);
  padding: 4px;
  flex-shrink: 0;
}

.model-list {
  width: 160px;
  padding: 4px;
}

.model-provider-item,
.model-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-provider-item:hover,
.model-item:hover { background: var(--bg-secondary); color: var(--text-primary); }

.model-provider-item.active,
.model-item.active { background: var(--bg-secondary); color: var(--text-primary); font-weight: 500; }

/* ===== Messages ===== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  opacity: 0.9;
}

.welcome-avatars {
  display: flex;
  gap: 8px;
  align-items: center;
}

.welcome-avatar-circle {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.03em;
  background-size: cover;
  background-position: center;
}

.welcome-avatar-circle--user {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.welcome h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: -0.03em;
  color: var(--text-tertiary);
}

/* ===== Message Bubbles ===== */
.msg-row {
  display: flex;
  padding: 6px 20px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.msg-row.user { justify-content: flex-end; }
.msg-row.ai { justify-content: flex-start; }

.msg-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  min-width: 40px;
}

.msg-row.user .msg-wrapper { align-items: flex-end; }
.msg-row.ai .msg-wrapper { align-items: flex-start; }

.bubble {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.65;
  letter-spacing: -0.01em;
  position: relative;
  cursor: pointer;
  transition: transform 0.25s var(--ease-spring), box-shadow 0.2s;
  word-break: break-word;
}

.bubble:active {
  transform: scale(0.97);
}

.msg-row.user .bubble {
  background: var(--bubble-user);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 4px;
}

.msg-row.ai .bubble {
  background: var(--bubble-ai);
  color: var(--bubble-ai-text);
  border-bottom-left-radius: 4px;
}

/* Thinking bubble */
.thinking-block {
  border-left: 2.5px solid #5C4A72;
  padding: 0 0 0 12px;
  cursor: pointer;
  margin-bottom: 6px;
  max-width: 85%;
}

.thinking-summary {
  font-size: 13px;
  color: #5C4A72;
  font-weight: 500;
  padding: 2px 0 4px;
  white-space: nowrap;
}

.thinking-detail {
  display: none;
  margin-top: 6px;
  font-size: 13px;
  color: #866E99;
  line-height: 1.6;
  white-space: pre-wrap;
}

.thinking-block.open .thinking-detail {
  display: block;
}

/* ===== Message Meta ===== */
.msg-meta {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 0;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
}

.msg-row.show-actions .msg-meta { display: flex; }

.msg-model {
  font-weight: 500;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.msg-tokens,
.msg-time,
.msg-cost {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
}

/* ===== Message Actions ===== */
.msg-actions {
  display: none;
  align-items: center;
  gap: 2px;
  padding: 4px 0 0;
}

.msg-row.show-actions .msg-actions { display: flex; }

.msg-actions .action-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: all 0.15s;
}

.msg-actions .action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.msg-actions .action-btn.danger:hover {
  background: #FEE2E2;
  color: var(--danger);
}

.version-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.version-label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  min-width: 24px;
  text-align: center;
}

/* ===== Streaming indicator ===== */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bubble-ai);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* ===== File Upload ===== */
.file-upload-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(92, 74, 114, 0.07);
  border: 1px solid rgba(92, 74, 114, 0.18);
  border-radius: 6px;
  padding: 4px 8px 4px 6px;
  font-size: 12px;
  color: #5C4A72;
  margin-bottom: 6px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-upload-chip svg { flex-shrink: 0; }

/* ===== Scroll Nav Button ===== */
.scroll-nav-btn {
  position: fixed;
  right: 16px;
  bottom: 80px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(26, 26, 26, 0.4);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 100;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
.scroll-nav-btn.visible {
  opacity: 1;
  pointer-events: auto;
}
.scroll-nav-btn svg {
  width: 14px;
  height: 14px;
  stroke: #fff;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* ===== Input Area ===== */
.input-area {
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.input-staged {
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.staged-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
}

.staged-msg span { flex: 1; }

.staged-msg button {
  color: var(--text-tertiary);
  padding: 2px;
  border-radius: 4px;
}

.staged-msg button:hover { color: var(--danger); }

.input-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 6px 6px 6px 4px;
  transition: border-color 0.2s;
}

.input-container:focus-within { border-color: var(--text-tertiary); }

.input-action {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-action:hover { color: var(--text-primary); }
.input-action svg { width: 16px; height: 16px; }

.input-wrapper { flex: 1; min-width: 0; }

.input-wrapper textarea {
  width: 100%;
  max-height: 120px;
  padding: 5px 4px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: transparent;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
}

.input-wrapper textarea::placeholder { color: var(--text-tertiary); }

.send-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}

.send-btn svg { width: 16px; height: 16px; }
.send-btn:disabled { opacity: 0.3; }
.send-btn:not(:disabled):hover { transform: scale(1.05); }
.send-btn:not(:disabled):active { transform: scale(0.95); }

/* ===== Panels & Overlays ===== */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.2);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  backdrop-filter: blur(2px);
}

.panel {
  width: 380px;
  max-width: 100%;
  height: 100%;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  animation: panel-in 0.3s var(--ease-out);
}

@keyframes panel-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.setting-group {
  margin-bottom: 24px;
}

.setting-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.setting-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: border-color 0.2s;
}

.setting-textarea:focus { border-color: var(--text-tertiary); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  color: var(--text-primary);
}
.toggle-row .toggle {
  margin-right: 12px;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 10px;
  transition: background 0.2s;
  cursor: pointer;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ===== Dialog ===== */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.dialog {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  max-width: 320px;
  width: 90%;
  animation: dialog-in 0.2s var(--ease-out);
}

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

.dialog p {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.dialog-btn {
  padding: 7px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  transition: all 0.15s;
}

.dialog-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.dialog-btn.danger {
  background: #1a1a1a;
  color: #fff;
}

.dialog-btn.danger:hover { opacity: 0.8; }

/* ===== Mobile ===== */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    transform: translateX(-100%);
  }

  #sidebar.open { transform: translateX(0); }

  #sidebar-toggle { display: flex; }

  .chat-header { padding-left: 52px; }

  .msg-row { padding: 2px 16px; }

  .input-area { padding: 10px 12px calc(14px + env(safe-area-inset-bottom, 0px)); }

  .panel { width: 100%; }
}

/* ===== Settings Panel ===== */
.settings-nav {
  display: flex;
  gap: 4px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.settings-nav-btn {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  transition: all 0.15s;
  letter-spacing: -0.01em;
}

.settings-nav-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.settings-nav-btn.active { background: var(--accent); color: #fff; }

.settings-section { display: none; }
.settings-section.active { display: block; }

.setting-slider {
  width: 100%;
  margin-top: 8px;
  accent-color: var(--accent);
}

.setting-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: border-color 0.2s;
  margin-top: 6px;
  box-sizing: border-box;
}
.setting-input:focus { outline: none; border-color: var(--text-tertiary); }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}
.setting-row label {
  font-size: 13px;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.setting-row .setting-input {
  width: auto;
  text-align: right;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text-primary);
  padding: 2px 4px;
  margin-top: 0;
}
.setting-row .setting-input:focus {
  outline: none;
}

.avatar-row {
  display: flex;
  gap: 24px;
  margin-top: 8px;
}

.avatar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.avatar-preview {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
}

.avatar-change-btn {
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.15s;
}

.avatar-change-btn:hover { color: var(--text-primary); border-color: var(--text-tertiary); }

.avatar-name-input {
  width: 60px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  outline: none;
  font-family: var(--font-body);
  transition: border-color 0.2s;
}
.avatar-name-input:focus { border-bottom-color: var(--border); }

.prompt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.prompt-history-btn {
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.15s;
}

.prompt-history-btn:hover { color: var(--text-primary); }

/* ===== Animations ===== */
.msg-row {
  animation: msg-in 0.3s var(--ease-out);
}

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

/* Bubble press animation */
.bubble.pressed {
  animation: bubble-press 0.3s var(--ease-spring);
}

@keyframes bubble-press {
  0% { transform: scale(1); }
  40% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

/* ===== Memory Panel ===== */
.memory-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
  min-height: 22px;
}

.memory-stat-item {
  font-size: 12px;
  color: var(--text-secondary);
}

.memory-stat-item strong {
  color: var(--text-primary);
  font-weight: 600;
}

.memory-stat-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-secondary);
}

.memory-stat-tag em {
  font-style: normal;
  color: var(--text-tertiary);
}

.memory-search-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.memory-search-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: border-color 0.2s;
}

.memory-search-input:focus { border-color: var(--text-tertiary); }
.memory-search-input::placeholder { color: var(--text-tertiary); }

.memory-search-btn {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.memory-search-btn:hover { opacity: 0.8; }

.memory-search-clear {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 13px;
  transition: background 0.15s;
  white-space: nowrap;
}

.memory-search-clear:hover { background: var(--bg-hover); }

.memory-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 40px;
}

.memory-loading,
.memory-empty {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 20px 0;
  text-align: center;
}

.memory-card {
  position: relative;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  transition: border-color 0.15s;
}

.memory-card:hover { border-color: var(--border); }

.memory-card-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 6px;
  padding-right: 40px;
}

.memory-card-name {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-all;
}

.memory-domain-tag {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
  margin-top: 1px;
}

.memory-card-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.memory-card-meta span {
  font-size: 11px;
  color: var(--text-tertiary);
}

.memory-delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  color: var(--danger);
  opacity: 0.5;
  transition: opacity 0.15s;
  padding: 2px 4px;
}

.memory-delete-btn:hover { opacity: 1; }

.memory-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.memory-page-btn {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.memory-page-btn:hover:not(:disabled) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.memory-page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.memory-page-info {
  font-size: 12px;
  color: var(--text-tertiary);
  min-width: 48px;
  text-align: center;
}

/* ===== Provider Panel ===== */
.setting-btn {
  padding: 7px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.setting-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.setting-btn-primary {
  padding: 7px 14px;
  border-radius: var(--radius-md);
  background: var(--accent);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  transition: opacity 0.15s;
}

.setting-btn-primary:hover { opacity: 0.85; }
.setting-btn-primary:disabled { opacity: 0.4; cursor: default; }

.provider-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 20px;
}

.provider-card {
  position: relative;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  transition: border-color 0.15s;
}

.provider-card:hover { border-color: var(--border); }

.provider-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.provider-card-meta {
  font-size: 11px;
  color: var(--text-tertiary);
}

.provider-delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  color: #1a1a1a;
  opacity: 0.5;
  transition: opacity 0.15s;
  padding: 2px 4px;
}

.provider-delete-btn:hover { opacity: 1; }

.provider-empty {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 12px 0;
}

/* ===== Reply-to ===== */
#reply-preview-bar {
  margin: 0;
  padding: 0 0 6px 0;
}
.reply-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #e8e8e8;
  border-radius: 10px;
  margin: 4px 0 4px;
}
.reply-bar-line {
  width: 2.5px;
  height: 24px;
  background: #aaa;
  border-radius: 2px;
  flex-shrink: 0;
}
.reply-bar-name {
  font-size: 11px;
  color: var(--text-tertiary);
  display: block;
}
.reply-bar-preview {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reply-bar-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.reply-bar-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.msg-reply-ref {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  justify-content: flex-end;
}
.msg-reply-line {
  width: 2px;
  height: 16px;
  background: #aaa;
  border-radius: 1px;
  flex-shrink: 0;
}
.msg-reply-preview {
  font-size: 12px;
  color: var(--text-tertiary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Injection Cards ===== */
.injection-card {
  border: 0.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.injection-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
}
.injection-title {
  font-size: 14px;
  font-weight: 500;
}
.injection-preview {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 4px 0 0;
  line-height: 1.5;
}

.staged-msg-reply {
  border-left: 2.5px solid #bbb;
  padding-left: 10px;
}

/* ===== 世界書 ===== */
.wb-tabs, .wb-tab, .wb-item, .wb-item-name, .wb-item-content,
.wb-item-meta, .wb-add-btn, .wb-empty, .wb-icon-btn {
  font-family: var(--font-body);
}
.wb-tabs{display:flex;gap:4px;margin-top:12px;margin-bottom:12px;background:rgba(0,0,0,0.06);border-radius:10px;padding:3px}
.wb-tab{flex:1;padding:6px 0;border:none;background:transparent;border-radius:8px;font-size:13px;color:var(--text-secondary,#888);cursor:pointer;transition:all .2s}
.wb-tab.active{background:var(--bg-primary,#fff);color:#1a1a1a;font-weight:600;box-shadow:0 1px 3px rgba(0,0,0,.12)}
.wb-panel{display:none}.wb-panel.active{display:block}
.wb-list{display:flex;flex-direction:column;gap:8px;margin-bottom:10px;min-height:4px}
.wb-empty{color:#bbb;font-size:13px;text-align:center;padding:16px 0}
.wb-item{background:var(--bg-secondary,#f7f7f7);border-radius:10px;padding:10px 12px;display:flex;align-items:flex-start;gap:10px}
.wb-item-body{flex:1;min-width:0}
.wb-item-name{font-size:14px;font-weight:600;color:var(--text-primary,#333);margin-bottom:2px}
.wb-item-meta{font-size:12px;color:#999;margin-bottom:3px}
.wb-item-content{font-size:13px;color:var(--text-primary,#555);white-space:pre-wrap;word-break:break-all}
.wb-item-actions{display:flex;flex-direction:column;gap:8px;align-items:flex-end;flex-shrink:0;padding-left:8px;}
.wb-toggle{width:36px;height:20px;background:#ccc;border-radius:10px;border:none;cursor:pointer;position:relative;transition:background .2s;flex-shrink:0}
.wb-toggle.on{background:#1a1a1a}
.wb-toggle::after{content:'';position:absolute;width:16px;height:16px;background:#fff;border-radius:50%;top:2px;left:2px;transition:left .2s}
.wb-toggle.on::after{left:18px}
.wb-icon-btn{background:none;border:none;cursor:pointer;font-size:14px;color:#ccc;padding:2px;line-height:1}
.wb-icon-btn:hover{color:#e57373}
.wb-add-btn{width:100%;padding:9px;border:1px solid #e5e5e5;background:transparent;border-radius:10px;color:#888;font-size:13px;cursor:pointer;transition:background .15s}
.wb-add-btn:hover{background:rgba(92,74,114,.06)}
.wb-modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:1000;display:flex;align-items:flex-end;justify-content:center}
.wb-modal{background:var(--bg-primary,#fff);border-radius:18px 18px 0 0;padding:20px 20px 40px;width:100%;max-width:480px;display:flex;flex-direction:column;gap:10px;max-height:85vh;overflow-y:auto}
.wb-modal-title{font-size:16px;font-weight:700;color:var(--text-primary,#333);margin-bottom:4px}
.wb-input,.wb-textarea{width:100%;padding:10px 12px;border:1.5px solid #e5e5e5;border-radius:10px;font-size:14px;color:var(--text-primary,#333);background:var(--bg-secondary,#f9f9f9);box-sizing:border-box;font-family:inherit}
.wb-input:focus,.wb-textarea:focus{outline:none;border-color:#bbb}
.wb-textarea{min-height:80px;resize:vertical}
.wb-radio-group{display:flex;gap:16px;font-size:14px;color:var(--text-primary,#333);padding:4px 0}
.wb-radio-group label{display:flex;align-items:center;gap:6px;cursor:pointer}
.wb-modal-actions{display:flex;gap:10px;margin-top:4px}
.wb-btn-cancel,.wb-btn-save{flex:1;padding:11px;border-radius:10px;border:none;font-size:14px;font-weight:600;cursor:pointer}
.wb-btn-cancel{background:var(--bg-secondary,#f0f0f0);color:var(--text-secondary,#888)}
.wb-btn-save{background:#1a1a1a;color:#fff}
.wb-action-btn{background:none;border:none;font-size:12px;color:#555;cursor:pointer;padding:3px 10px;border-radius:5px;font-family:inherit;}
.wb-action-btn:hover{background:#f5f5f5;color:#1a1a1a;}
.wb-delete-btn:hover{background:#f5f5f5;color:#1a1a1a;border-color:#e5e5e5;}
.wb-radio-group input[type="radio"]{accent-color:#1a1a1a;}
.mcp-list{display:flex;flex-direction:column;gap:8px;margin-top:4px;}
.mcp-item{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;background:var(--bg-secondary,#f7f7f7);border-radius:10px;border:1px solid #e5e5e5;}
.mcp-item-body{flex:1;}
.mcp-item-name{font-size:14px;font-weight:500;color:var(--text-primary,#1a1a1a);}
.mcp-item-desc{font-size:12px;color:#999;margin-top:2px;}

.activity-indicator-row{display:flex;align-items:center;gap:7px;padding:4px 16px;margin:2px 0;opacity:1;transition:opacity 0.4s;}
.activity-indicator-row.activity-fade{opacity:0;}
.activity-dot{width:6px;height:6px;border-radius:50%;background:#5C4A72;animation:activity-pulse 1s infinite;flex-shrink:0;}
.activity-text{font-size:12px;color:#999;font-family:var(--font-display);}
@keyframes activity-pulse{0%,100%{opacity:0.3;transform:scale(0.8);}50%{opacity:1;transform:scale(1.1);}}
.activity-memory-block { border-left: none; padding: 0; cursor: pointer; margin-bottom: 6px; }
.activity-memory-summary { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.activity-memory-icon { font-size: 14px; color: #5C4A72; font-weight: 700; }
.activity-memory-block.open .activity-memory-icon { transform: rotate(90deg); }
.activity-memory-label { font-size: 13px; color: #5C4A72; font-weight: 500; padding: 2px 0 4px; display: block; }
.activity-memory-detail { display: none; margin-top: 4px; margin-left: 18px; font-size: 13px; color: #866E99; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }
.activity-memory-block.open .activity-memory-detail { display: block; }
.tool-trace-block { border-left: none; padding: 0; cursor: pointer; margin-bottom: 6px; max-width: 85%; }
.tool-trace-summary { display: flex; align-items: center; gap: 4px; }
.tool-trace-icon { font-size: 16px; color: #5C4A72; font-weight: 700; line-height: 1; }
.tool-trace-label { font-size: 13px; color: #5C4A72; font-weight: 500; }
.tool-call-tag{font-size:12px;color:#5C4A72;}
.tool-call-tag+.tool-call-tag::before{content:'、';}
.tool-trace-detail{display:none;margin-top:6px;font-size:13px;color:#866E99;line-height:1.6;white-space:pre-wrap;}
.tool-trace-block.open .tool-trace-detail{display:block;}
/* 圖片解讀區塊 */
.image-describe-block { cursor: pointer; margin-top: 6px; }
.image-describe-summary { display: flex; align-items: center; gap: 4px; }
.image-describe-dot { font-size: 12px; color: #5C4A72; }
.image-describe-label { font-size: 13px; color: #5C4A72; font-weight: 500; }
.image-describe-detail { display: none; margin-top: 4px; margin-left: 18px; font-size: 13px; color: #866E99; line-height: 1.6; white-space: pre-wrap; }
.image-describe-block.open .image-describe-detail { display: block; }
.logs-toolbar { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.logs-select { padding: 6px 8px; border: 1px solid #e5e5e5; border-radius: 8px; font-size: 12px; color: #555; background: #f9f9f9; font-family: inherit; }
.logs-search { flex: 1; min-width: 80px; padding: 6px 10px; border: 1px solid #e5e5e5; border-radius: 8px; font-size: 12px; color: #333; background: #f9f9f9; font-family: inherit; }
.logs-search:focus { outline: none; border-color: #5C4A72; }
.logs-refresh-btn { padding: 6px 14px; border: 1px solid #e5e5e5; border-radius: 8px; font-size: 12px; color: #555; background: none; cursor: pointer; font-family: inherit; }
.logs-refresh-btn:hover { background: #f5f5f5; }
.logs-output { background: #1a1a1a; color: #e0e0e0; font-family: var(--font-mono, monospace); font-size: 11px; line-height: 1.6; padding: 12px; border-radius: 10px; max-height: 400px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; min-height: 60px; }
.more-menu { position: absolute; bottom: 52px; left: 8px; background: var(--bg-primary, #fff); border: 1px solid #e5e5e5; border-radius: 10px; padding: 4px; box-shadow: 0 4px 16px rgba(0,0,0,0.1); min-width: 120px; z-index: 100; }
.more-menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; border: none; background: none; font-size: 13px; color: var(--text-primary, #333); cursor: pointer; border-radius: 8px; font-family: inherit; }
.more-menu-item:hover { background: #f5f5f5; }

.fullscreen-panel {
  position: fixed;
  inset: 0;
  background: var(--bg-primary, #fff);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  animation: panel-slide-in 0.2s ease;
}
@keyframes panel-slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.fullscreen-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: #f5f5f5;
  border-bottom: 1px solid var(--border-light, #f0f0f0);
  flex-shrink: 0;
}
.fullscreen-back-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-primary, #1a1a1a);
  padding: 4px;
  display: flex;
  align-items: center;
}
.fullscreen-panel-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  font-family: var(--font-display);
}
.fullscreen-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
@keyframes panel-slide-out {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

/* ===== 月曆板塊 CSS ===== */

/* 月曆主容器 */
.calendar-container {
  padding: 16px;
  max-width: 100%;
}

/* 月份導航 */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.calendar-nav-btn {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: #1a1a1a;
  font-size: 14px;
}
.calendar-nav-title {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
}
.calendar-nav-today {
  font-size: 12px;
  color: #999;
  cursor: pointer;
  margin-left: 8px;
}

/* 月曆網格 */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 4px;
}
.calendar-weekday {
  font-size: 11px;
  color: #999;
  padding: 4px 0;
  font-family: 'Outfit', sans-serif;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  font-size: 14px;
  color: #1a1a1a;
  transition: background 0.15s;
}
.calendar-day:hover {
  background: #f5f5f5;
}
.calendar-day.other-month {
  color: #ccc;
}
.calendar-day.today {
  font-weight: 700;
}
.calendar-day.today::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #1a1a1a;
}
.calendar-day.selected {
  background: #1a1a1a;
  color: #fff;
}
.calendar-day.selected::after {
  background: #fff;
}

/* 活躍度色塊 */
.calendar-day.activity-1 { background: rgba(92, 74, 114, 0.08); }
.calendar-day.activity-2 { background: rgba(92, 74, 114, 0.16); }
.calendar-day.activity-3 { background: rgba(92, 74, 114, 0.25); }
.calendar-day.activity-4 { background: rgba(92, 74, 114, 0.35); }
.calendar-day.selected.activity-1,
.calendar-day.selected.activity-2,
.calendar-day.selected.activity-3,
.calendar-day.selected.activity-4 {
  background: #1a1a1a;
}

/* 事件指示點 */
.calendar-day-dots {
  display: flex;
  gap: 2px;
  position: absolute;
  bottom: 2px;
}
.calendar-day-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
}
.calendar-day-dot.checkin { background: #1a1a1a; }
.calendar-day-dot.anniversary { background: #5C4A72; }
.calendar-day-dot.countdown { background: #866E99; }
.calendar-day-dot.period { background: #c97878; }
.calendar-day-dot.todo { background: #999; }

/* 打卡按鈕 */
.calendar-checkin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  margin: 12px 0;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: #1a1a1a;
  transition: all 0.15s;
}
.calendar-checkin-btn:hover {
  background: #f5f5f5;
}
.calendar-checkin-btn.checked {
  background: #f5f5f5;
  color: #999;
  cursor: default;
}

/* 日詳情 */
.calendar-day-detail {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e5e5;
}
.calendar-detail-date {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 12px;
}

/* 統計卡片 */
.calendar-stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.calendar-stat-card {
  background: #f8f8f8;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 10px;
}
.calendar-stat-label {
  font-size: 11px;
  color: #999;
  margin-bottom: 2px;
}
.calendar-stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
}
.calendar-stat-unit {
  font-size: 11px;
  color: #999;
  margin-left: 2px;
}

/* 分區標題 */
.calendar-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 16px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.calendar-section-add {
  background: none;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  color: #999;
  cursor: pointer;
}
.calendar-section-add:hover {
  color: #1a1a1a;
  border-color: #ccc;
}

/* 事件列表項 */
.calendar-event-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: #f8f8f8;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.calendar-event-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.calendar-event-type-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.calendar-event-title {
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calendar-event-meta {
  font-size: 11px;
  color: #999;
  flex-shrink: 0;
  margin-left: 8px;
}
.calendar-event-actions {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}
.calendar-event-action-btn {
  background: none;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  color: #999;
  cursor: pointer;
}
.calendar-event-action-btn:hover {
  color: #1a1a1a;
}

/* To-do */
.calendar-todo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #f8f8f8;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  margin-bottom: 6px;
}
.calendar-todo-checkbox {
  width: 16px;
  height: 16px;
  border: 1.5px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.calendar-todo-checkbox.checked {
  background: #1a1a1a;
  border-color: #1a1a1a;
}
.calendar-todo-checkbox.checked svg {
  display: block;
}
.calendar-todo-checkbox svg {
  display: none;
  width: 10px;
  height: 10px;
}
.calendar-todo-text {
  font-size: 13px;
  color: #1a1a1a;
  flex: 1;
}
.calendar-todo-text.completed {
  text-decoration: line-through;
  color: #ccc;
}
.calendar-todo-actions {
  display: flex;
  gap: 4px;
}

/* 紀念日/倒數日卡片 */
.calendar-countdown-card {
  background: #f8f8f8;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 6px;
}
.calendar-countdown-title {
  font-size: 13px;
  color: #1a1a1a;
  margin-bottom: 4px;
}
.calendar-countdown-days {
  font-family: 'Outfit', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: #5C4A72;
}
.calendar-countdown-label {
  font-size: 11px;
  color: #999;
}

/* 生理期 */
.calendar-period-section {
  margin-top: 12px;
}
.calendar-period-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: #f8f8f8;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  margin-bottom: 6px;
}
.calendar-period-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c97878;
}
.calendar-period-info {
  font-size: 13px;
  color: #1a1a1a;
  flex: 1;
}
.calendar-period-toggle-btn {
  background: none;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: #1a1a1a;
  cursor: pointer;
}
.calendar-day.period-day {
  background: rgba(201, 120, 120, 0.12);
}
.calendar-day.period-day.selected {
  background: #1a1a1a;
}

/* Modal */
.calendar-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 1200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.calendar-modal-overlay.active {
  display: flex;
}
.calendar-modal {
  background: #fff;
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 20px 16px 32px;
  animation: calModalSlideUp 0.25s ease-out;
}
@keyframes calModalSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.calendar-modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 16px;
}
.calendar-modal-field {
  margin-bottom: 12px;
}
.calendar-modal-label {
  font-size: 12px;
  color: #999;
  margin-bottom: 4px;
  display: block;
}
.calendar-modal-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  font-size: 14px;
  color: #1a1a1a;
  background: #fff;
  outline: none;
  box-sizing: border-box;
}
.calendar-modal-input:focus {
  border-color: #ccc;
}
.calendar-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.calendar-modal-save {
  flex: 1;
  padding: 10px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.calendar-modal-cancel {
  padding: 10px 16px;
  background: none;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  font-size: 14px;
  color: #999;
  cursor: pointer;
}

/* 月統計摘要 */
.calendar-month-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: #f8f8f8;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
}
.calendar-month-summary-item {
  text-align: center;
}
.calendar-month-summary-value {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
}
.calendar-month-summary-label {
  font-size: 11px;
  color: #999;
}

/* 底部 Tab */
.calendar-bottom-tabs {
  display: flex;
  border-top: 1px solid #e5e5e5;
  margin: 16px -16px -16px;
  padding: 0 16px;
}
.calendar-bottom-tab {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  font-size: 12px;
  color: #999;
  cursor: pointer;
  border: none;
  background: none;
  border-top: 2px solid transparent;
  margin-top: -1px;
}
.calendar-bottom-tab.active {
  color: #1a1a1a;
  font-weight: 600;
  border-top-color: #1a1a1a;
}

.calendar-empty {
  text-align: center;
  padding: 20px;
  color: #ccc;
  font-size: 13px;
}

.image-preview-bar { padding: 8px 12px 4px; display: flex; align-items: center; gap: 10px; }
.image-preview-inner { position: relative; display: inline-block; }
.image-preview-inner img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid #e5e5e5; }
.image-preview-remove { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; background: #1a1a1a; color: #fff; border: none; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; }
.image-preview-status { font-size: 12px; color: #999; }

body.no-bubble-mode .msg-row.ai .bubble {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  border-radius: 0 !important;
}

.setting-section-label {
  font-size: 11px;
  font-weight: 600;
  color: #999;
  letter-spacing: 0.05em;
  padding: 28px 0 8px;
  margin-bottom: 0;
}

.setting-section-label:first-of-type {
  padding-top: 8px;
}

/* ===== 郵箱板塊 ===== */
.mail-container {
  padding: 16px;
}
.mail-tabs {
  display: flex;
  border-bottom: 1px solid #e5e5e5;
  margin-bottom: 12px;
}
.mail-tab {
  flex: 1;
  padding: 8px 0;
  text-align: center;
  font-size: 13px;
  color: #999;
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.mail-tab.active {
  color: #1a1a1a;
  font-weight: 600;
  border-bottom-color: #1a1a1a;
}
.mail-item {
  padding: 12px;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.mail-item:hover {
  background: #f8f8f8;
}
.mail-item-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 4px;
}
.mail-item-from {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}
.mail-item-date {
  font-size: 11px;
  color: #999;
  flex-shrink: 0;
}
.mail-item-subject {
  font-size: 13px;
  color: #1a1a1a;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mail-item-preview {
  font-size: 12px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mail-detail {
  padding: 16px;
}
.mail-detail-back {
  background: none;
  border: none;
  font-size: 13px;
  color: #999;
  cursor: pointer;
  padding: 0;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.mail-detail-from {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 2px;
}
.mail-detail-subject {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 4px;
  font-family: 'Outfit', sans-serif;
}
.mail-detail-date {
  font-size: 11px;
  color: #999;
  margin-bottom: 16px;
}
.mail-detail-body {
  font-size: 13px;
  color: #1a1a1a;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.mail-draft-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.mail-draft-approve {
  flex: 1;
  padding: 10px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.mail-draft-reject {
  padding: 10px 16px;
  background: none;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  font-size: 14px;
  color: #999;
  cursor: pointer;
}
.mail-empty {
  text-align: center;
  padding: 32px 16px;
  color: #ccc;
  font-size: 13px;
}
.mail-refresh-btn {
  background: none;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: #999;
  cursor: pointer;
  margin-bottom: 12px;
}
.mail-refresh-btn:hover {
  color: #1a1a1a;
  border-color: #ccc;
}

/* ===== 論壇板塊 ===== */
#panel-forum .fullscreen-panel-body {
  padding: 0;
  height: calc(100% - 50px);
}
#forumIframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ===== 日記板塊 ===== */
/* ===== 日記重設計 ===== */
.diary-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 12px;
  border-bottom: 1px solid #f0f0f0;
}
.diary-nav-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: #aaa;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.diary-nav-btn:disabled { opacity: 0.2; cursor: default; }
.diary-nav-date {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: 0.5px;
}
.diary-entry-wrap { padding: 16px; }
.diary-entry-content {
  font-size: 13px;
  color: #1a1a1a;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}
.diary-selection-btn {
  position: fixed;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  z-index: 9000;
  display: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.diary-annotations-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid #f0f0f0; }
.diary-annotation-card {
  padding: 10px 12px;
  background: #faf8ff;
  border-left: none;
  border-radius: 0 6px 6px 0;
  margin-bottom: 8px;
  position: relative;
}
.diary-annotation-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 2px;
  background: #866E99;
  border-radius: 1px;
}
.diary-ann-selected {
  font-size: 11px;
  color: #866E99;
  font-style: italic;
  margin-bottom: 4px;
  white-space: pre-wrap;
}
.diary-ann-response { font-size: 13px; color: #444; line-height: 1.6; white-space: pre-wrap; }
.diary-ann-delete {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 11px;
}
.diary-response-btn {
  background: none;
  border: 1px dashed #ccc;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  color: #aaa;
  cursor: pointer;
  margin-top: 4px;
}
.diary-empty { padding: 40px 20px; text-align: center; color: #bbb; font-size: 13px; }
.diary-ann-underline {
  text-decoration: underline;
  text-decoration-color: #866E99;
  text-underline-offset: 3px;
  cursor: pointer;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
/* 批注 modal */
.diary-annotate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9100;
  display: none;
}
.diary-annotate-overlay.active { display: block; }
.diary-annotate-modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px 32px;
  z-index: 9200;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  max-height: 80vh;
  overflow-y: auto;
}
.diary-annotate-modal.active { transform: translateY(0); }
.diary-annotate-label { font-size: 11px; color: #999; margin-bottom: 6px; }
.diary-annotate-selected {
  border-left: none;
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  color: #5C4A72;
  line-height: 1.6;
  margin-bottom: 12px;
  word-break: break-word;
  white-space: normal;
  overflow: visible;
  min-height: 36px;
  display: block;
  position: relative;
}
.diary-annotate-selected::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 2px;
  background: #866E99;
  border-radius: 1px;
}
.diary-annotate-textarea {
  width: 100%;
  min-height: 80px;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  outline: none;
  resize: none;
  box-sizing: border-box;
  font-family: inherit;
}
.diary-annotate-textarea:focus { border-color: #e5e5e5; box-shadow: none; outline: none; }
.diary-annotate-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.diary-annotate-actions button:first-child {
  flex: 1;
  padding: 10px;
  border: 1px solid #e5e5e5;
  background: none;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  color: #666;
}
.diary-annotate-actions button:last-child {
  flex: 2;
  padding: 10px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
/* 摘要 section */
.diary-summary-section {
  margin: 16px 16px 0;
  padding: 14px;
  background: #f8f8f8;
  border: 1px solid #ececec;
  border-radius: 10px;
}
.diary-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.diary-summary-title { font-size: 11px; color: #999; }
.diary-underline {
  text-decoration: underline;
  text-decoration-color: #866E99;
  text-underline-offset: 3px;
  cursor: pointer;
}
.diary-response-inline {
  display: none;
  color: #866E99;
  font-size: 12px;
}
.diary-response-inline.expanded {
  display: inline;
}
.diary-summary-tab {
  font-size: 11px;
  color: #1a1a1a;
  background: none;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
}
.diary-summary-tab.active {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}
.diary-summary-gen-btn {
  font-size: 11px;
  color: #1a1a1a;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.diary-summary-body {
  font-size: 12px;
  color: #444;
  line-height: 1.7;
  min-height: 32px;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}
.diary-summary-body:empty::before { content: '尚無摘要'; color: #bbb; }
.diary-summary-save-hint { font-size: 10px; color: #bbb; margin-top: 4px; display: none; }

/* 已讀標記 */
.seen-indicator-bubble {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
  padding-right: 4px;
}
.msg-row.show-actions .seen-indicator-bubble { display: none; }
.seen-indicator-toolbar {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
}

/* ===== 記帳板塊 ===== */
.finance-container { padding: 16px; }
.finance-month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.finance-month-title { font-family: 'Outfit', sans-serif; font-size: 16px; font-weight: 600; color: #1a1a1a; }
.finance-month-btn { background: none; border: none; border-radius: 6px; padding: 4px 10px; cursor: pointer; color: #1a1a1a; }
.finance-summary { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.finance-summary-card { background: #f8f8f8; border: 1px solid #e5e5e5; border-radius: 8px; padding: 10px; }
.finance-summary-label { font-size: 11px; color: #999; margin-bottom: 2px; }
.finance-summary-value { font-family: 'Outfit', sans-serif; font-size: 20px; font-weight: 700; color: #1a1a1a; }
.finance-summary-value.over { color: #c97878; }
.finance-budget-bar { height: 4px; background: #e5e5e5; border-radius: 2px; margin-bottom: 14px; }
.finance-budget-fill { height: 100%; border-radius: 2px; background: #1a1a1a; transition: width 0.3s; }
.finance-budget-fill.warning { background: #c97878; }
.finance-entry-item { display: flex; align-items: center; padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
.finance-entry-date { font-size: 10px; color: #ccc; margin-right: 10px; white-space: nowrap; }
.finance-entry-time { font-size: 10px; color: #ccc; margin-right: 8px; white-space: nowrap; }
.finance-entry-cat { font-size: 11px; color: #999; background: #f5f5f5; padding: 2px 6px; border-radius: 4px; margin-right: 8px; white-space: nowrap; }
.finance-entry-note { font-size: 13px; color: #1a1a1a; flex: 1; }
.finance-entry-amount { font-family: 'Outfit', sans-serif; font-size: 15px; font-weight: 600; color: #1a1a1a; margin-left: 8px; white-space: nowrap; }
.finance-entry-amount.income { color: #866E99; }
.finance-entry-edit { background: none; border: none; color: #ccc; cursor: pointer; font-size: 11px; margin-left: 6px; }
.finance-entry-delete { background: none; border: none; color: #ccc; cursor: pointer; font-size: 11px; margin-left: 6px; }
.finance-add-btn { display: flex; align-items: center; justify-content: center; width: 100%; padding: 10px; margin-top: 4px; border: 1px dashed #e5e5e5; border-radius: 10px; background: none; cursor: pointer; font-size: 13px; color: #999; }
.finance-add-btn:hover { border-color: #ccc; color: #1a1a1a; }
.finance-cat-select { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.finance-cat-btn { padding: 4px 10px; border: 1px solid #e5e5e5; border-radius: 6px; background: none; font-size: 12px; color: #999; cursor: pointer; }
.finance-cat-btn.active { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.finance-type-toggle { display: flex; margin-bottom: 12px; }
.finance-type-btn { flex: 1; padding: 6px; text-align: center; font-size: 13px; cursor: pointer; border: 1px solid #e5e5e5; color: #999; background: none; }
.finance-type-btn:first-child { border-radius: 6px 0 0 6px; }
.finance-type-btn:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
.finance-type-btn.active { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }

/* ===== 飲食記錄 ===== */
.diet-container { padding: 16px; }
.diet-date-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.diet-date-title { font-family: 'Outfit', sans-serif; font-size: 15px; font-weight: 600; color: #1a1a1a; }
.diet-date-btn { background: none; border: none; border-radius: 6px; padding: 4px 10px; cursor: pointer; color: #1a1a1a; }
.diet-kcal-summary { text-align: center; padding: 16px; background: #f8f8f8; border: 1px solid #e5e5e5; border-radius: 10px; margin-bottom: 16px; }
.diet-kcal-value { font-family: 'Outfit', sans-serif; font-size: 32px; font-weight: 700; color: #5C4A72; }
.diet-kcal-label { font-size: 11px; color: #999; margin-top: 2px; }
.diet-meal-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
/* 分享卡片 — 聊天內嵌 */
.share-card { background: #f8f8f8; border: 1px solid #e5e5e5; border-radius: 10px; overflow: hidden; cursor: pointer; max-width: 280px; }
.share-card-img-wrap { position: relative; width: 100%; }
.share-card-thumb { width: 100%; max-height: 200px; object-fit: cover; display: block; }
.share-card-play { position: absolute; bottom: 8px; right: 8px; opacity: 0.9; }
.share-card-video-placeholder { background: #2a2a2a; height: 140px; display: flex; align-items: center; justify-content: center; border-radius: 10px 10px 0 0; }
.share-card-play-icon { width: 0; height: 0; border-style: solid; border-width: 14px 0 14px 26px; border-color: transparent transparent transparent rgba(255,255,255,0.8); margin-left: 6px; }
.share-card-body { padding: 10px 12px; }
.share-card-title { font-size: 13px; font-weight: 600; color: #1a1a1a; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.share-card-summary { font-size: 12px; color: #888; margin-top: 4px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.share-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.share-card-author {
  font-size: 11px;
  color: #999;
}
.share-card-source {
  font-size: 10px;
  color: #bbb;
}
.share-card-quote { display: flex; margin-top: 8px; padding-top: 8px; border-top: 1px solid #eee; }
.share-card-quote-bar { width: 2px; background: #866E99; border-radius: 1px; margin-right: 8px; flex-shrink: 0; }
.share-card-quote-text { font-size: 11px; color: #666; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* 聊天圖片卡片 */
.chat-img-card { margin-bottom: 6px; cursor: pointer; border-radius: 8px; overflow: hidden; max-width: 200px; }
.chat-img-thumb { width: 100%; display: block; border-radius: 8px; }
/* 圖片放大查看器 */
.image-viewer-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.85); z-index: 10000; display: flex; align-items: center; justify-content: center; }
.image-viewer-img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 4px; }
.diet-meal-name { font-size: 13px; color: #1a1a1a; flex: 1; }
.diet-meal-portion { font-size: 11px; color: #999; margin-left: 6px; }
.diet-meal-kcal { font-family: 'Outfit', sans-serif; font-size: 13px; color: #866E99; margin-left: 8px; }
.diet-meal-kcal.estimated { color: #866E99; font-style: normal; }
.diet-meal-time { font-size: 10px; color: #ccc; margin-right: 8px; white-space: nowrap; }
.diet-meal-delete { background: none; border: none; color: #ccc; cursor: pointer; font-size: 11px; margin-left: 6px; }
.diet-tabs { display: flex; border-bottom: 1px solid #e5e5e5; margin-bottom: 14px; }
.diet-tab { flex: 1; padding: 8px; text-align: center; font-size: 13px; color: #999; cursor: pointer; border: none; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.diet-tab.active { color: #1a1a1a; font-weight: 600; border-bottom-color: #1a1a1a; }
.diet-weight-input-row { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.diet-weight-input { flex: 1; padding: 8px 10px; border: 1px solid #e5e5e5; border-radius: 8px; font-size: 14px; outline: none; }
.diet-weight-save { padding: 8px 16px; background: #1a1a1a; color: #fff; border: none; border-radius: 8px; font-size: 13px; cursor: pointer; }

/* ===== 碎碎念 ===== */
.murmur-container { padding: 16px; }
.murmur-input-area { display: flex; gap: 8px; margin-bottom: 20px; }
.murmur-input {
  flex: 1; padding: 10px 12px; border: 1px solid #e5e5e5; border-radius: 10px;
  font-size: 13px; outline: none; color: #1a1a1a; background: #fff;
}
.murmur-input::placeholder { color: #ccc; }
.murmur-send {
  padding: 10px 14px; background: #1a1a1a; color: #fff; border: none;
  border-radius: 10px; font-size: 13px; cursor: pointer; flex-shrink: 0;
}
.murmur-note {
  background: #fafaf8; border: 1px solid #e5e5e5; border-radius: 8px;
  padding: 12px 14px; margin-bottom: 8px; position: relative;
}
.murmur-note:nth-child(odd) { transform: rotate(-0.3deg); }
.murmur-note:nth-child(even) { transform: rotate(0.2deg); }
.murmur-note:nth-child(3n) { transform: rotate(-0.5deg); }
.murmur-note-text { font-size: 13px; color: #1a1a1a; line-height: 1.6; white-space: pre-wrap; padding-right: 44px; }
.murmur-note-time { font-size: 10px; color: #ccc; margin-top: 6px; }
.murmur-note-delete {
  background: none; border: none;
  color: #ddd; cursor: pointer; font-size: 14px; line-height: 1; padding: 0;
}
.murmur-note-delete:hover { color: #999; }

/* ===== Roleplay ===== */
.rp-container { padding: 16px; display: flex; flex-direction: column; }
.rp-prompt-area {
  width: 100%; min-height: 80px; padding: 10px; border: 1px solid #e5e5e5;
  border-radius: 8px; font-size: 13px; color: #1a1a1a; resize: vertical;
  outline: none; font-family: inherit; box-sizing: border-box;
}
.rp-prompt-area::placeholder { color: #ccc; }
.rp-start-btn {
  flex: 1; padding: 10px; background: #1a1a1a; color: #fff; border: none;
  border-radius: 8px; font-size: 14px; cursor: pointer;
}
.rp-saved-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border: 1px solid #e5e5e5; border-radius: 8px;
  margin-bottom: 6px; cursor: pointer; font-size: 13px; color: #1a1a1a;
}
.rp-saved-item:hover { background: #f8f8f8; }
.rp-saved-delete { background: none; border: none; color: #ccc; font-size: 11px; cursor: pointer; }
.rp-chat-area { flex: 1; overflow-y: auto; padding: 8px 0; }
.rp-msg { margin-bottom: 10px; max-width: 85%; }
.rp-msg.user { margin-left: auto; }
.rp-msg-bubble {
  padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.rp-msg.user .rp-msg-bubble { background: #1a1a1a; color: #fff; }
.rp-msg.assistant .rp-msg-bubble { background: #f5f5f5; color: #1a1a1a; }
.rp-input-row { display: flex; gap: 8px; padding-top: 10px; border-top: 1px solid #f0f0f0; margin-top: auto; }
.rp-input {
  flex: 1; padding: 8px 12px; border: 1px solid #e5e5e5; border-radius: 8px;
  font-size: 13px; outline: none;
}
.rp-send-btn {
  padding: 8px 14px; background: #1a1a1a; color: #fff; border: none;
  border-radius: 8px; font-size: 13px; cursor: pointer;
}
.rp-toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.rp-toolbar-btn {
  background: none; border: 1px solid #e5e5e5; border-radius: 6px;
  padding: 4px 10px; font-size: 12px; color: #999; cursor: pointer;
}

/* ===== Share Link Modal ===== */
.share-link-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 300;
  display: flex;
  align-items: flex-end;
}

.share-link-sheet {
  width: 100%;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 20px 20px 32px;
  animation: sheet-up 0.25s ease-out;
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.share-link-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.share-link-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 500;
  color: #1a1a1a;
}

.share-link-input {
  width: 100%;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  margin-bottom: 10px;
  box-sizing: border-box;
  outline: none;
}

.share-link-textarea {
  width: 100%;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  margin-bottom: 6px;
  box-sizing: border-box;
  resize: none;
  outline: none;
  line-height: 1.5;
}

.share-link-input:focus, .share-link-textarea:focus {
  border-color: #bbb;
}

.share-link-hint {
  color: #bbb;
  font-size: 12px;
  margin: 0 0 16px;
  font-family: 'Noto Sans SC', sans-serif;
}

.share-link-submit-btn {
  width: 100%;
  padding: 12px;
  background: none;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  color: #1a1a1a;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 14px;
  cursor: pointer;
}

.share-link-submit-btn:active { background: #f5f5f5; }
.share-link-submit-btn:disabled { color: #bbb; cursor: default; }

.share-link-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: #999;
  font-size: 22px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

/* ===== Plus Popup ===== */
.plus-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  padding: 4px 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.10);
  z-index: 100;
}

.plus-popup-item {
  padding: 7px 16px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13px;
  color: #1a1a1a;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.plus-popup-item:active { background: #f5f5f5; }

.plus-popup-disabled {
  color: #ccc;
  cursor: default;
  pointer-events: none;
}

/* ===== Fallback Share Card (isFallbackCover) ===== */
.share-card-fallback {
  max-width: 280px;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
}

.share-card-fallback-bg {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.fallback-bg-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
}

.fallback-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 8px;
}





.fallback-title {
  position: relative;
  z-index: 1;
  color: #fff;
  font-size: 15px;
  font-family: 'Ark Pixel', 'Noto Sans SC', sans-serif;
  font-weight: 500;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  max-width: 80%;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fallback-quote {
  position: relative;
  z-index: 1;
  color: rgba(255,255,255,0.82);
  font-size: 12px;
  font-family: 'Ark Pixel', 'Noto Sans SC', sans-serif;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  max-width: 80%;
}

/* ── 單窗模式 ── */
.hidden { display: none !important; }

.single-mode-header {
  display: flex;
  align-items: center;
  justify-content: center;
  /* sidebar-header 外層已帶 safe-area padding，這裡只加內間距 */
  padding: 8px 0 12px;
  width: 100%;
}

.single-mode-avatars {
  display: flex;
  align-items: center;
  gap: 6px;
}

.single-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.single-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  background: #1a1a1a;
  color: #fff;
}

.single-mode-nav {
  padding: 4px 16px;
  flex: 1;
  overflow-y: auto;
}

.single-nav-item {
  padding: 10px 0;
  font-size: 13px;
  color: #1a1a1a;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.single-nav-item:hover { color: #1a1a1a; }

/* 設置 panel-header 在單窗模式下隱藏 */
#settings-panel .panel-header { display: none; }

/* 模型選擇列表（Settings > API） */
.settings-model-item {
  padding: 7px 0;
  font-size: 12px;
  color: #555;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  gap: 8px;
  align-items: center;
}
.settings-model-item.active { color: #1a1a1a; font-weight: 500; }
.settings-model-item:hover { color: #1a1a1a; }
.settings-model-provider { color: #aaa; font-size: 11px; min-width: 60px; }

.single-nav-divider {
  height: 1px;
  background: #e5e5e5;
  margin: 4px 0;
}

/* ===== load-earlier button ===== */
.load-earlier {
  text-align: center;
  padding: 10px 0 4px;
}
.load-earlier button {
  background: none;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 4px 16px;
  font-size: 12px;
  color: #888;
  cursor: pointer;
}
.load-earlier button:hover { background: #f5f5f5; color: #555; }

/* ===== message avatars ===== */
.msg-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin-top: 4px;
  align-self: flex-start;
}
.msg-row.ai .msg-avatar { margin-right: 8px; }
.msg-row.user .msg-avatar { margin-left: 8px; }
.msg-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.msg-avatar-fallback {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e5e5e5;
  color: #666;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== search section ===== */
.search-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.search-highlight {
  background: #ffe066;
  border-radius: 2px;
  padding: 0 1px;
}
.search-flash { animation: searchFlash 1.5s ease; }
@keyframes searchFlash {
  0%, 100% { background: transparent; }
  20%, 60% { background: #fffbcc; }
}
.search-result-item {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8f8f8;
  margin-bottom: 8px;
  cursor: pointer;
}
.search-result-item:hover { background: #f0f0f0; }
.search-result-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.search-result-title { font-size: 12px; font-weight: 600; color: #333; }
.search-result-time { font-size: 11px; color: #aaa; }
.search-result-snippet { font-size: 13px; color: #555; line-height: 1.5; word-break: break-all; }
.search-empty { color: #aaa; font-size: 13px; text-align: center; padding: 24px 0; }
