:root {
  color-scheme: light;
  --bg: #f6f3ef;
  --panel: #fffdf9;
  --panel-strong: #ffffff;
  --text: #24201c;
  --muted: #786f66;
  --line: #ded6cb;
  --accent: #d34f73;
  --accent-dark: #ad3858;
  --friend: #ffffff;
  --me: #ffe1eb;
  --shadow: 0 18px 45px rgba(44, 36, 28, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(135deg, rgba(211, 79, 115, 0.13), transparent 35%),
    var(--bg);
  color: var(--text);
}

button,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 360px);
  gap: 18px;
  overflow: hidden;
  transition: grid-template-columns 180ms ease, gap 180ms ease;
}

body.debug-collapsed .app-shell {
  grid-template-columns: minmax(0, 1fr) 0;
  gap: 0;
}

.chat-panel,
.debug-panel {
  background: rgba(255, 253, 249, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.chat-panel {
  position: relative;
  height: calc(100vh - 56px);
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border-radius: 16px;
}

.reference-toggle {
  border: 0;
  border-radius: 9px;
  padding: 8px 12px;
  background: #f5e8ed;
  color: var(--accent-dark);
  cursor: pointer;
  white-space: nowrap;
}

.reference-panel {
  position: absolute;
  z-index: 8;
  top: 76px;
  right: 18px;
  width: min(370px, calc(100% - 36px));
  max-height: calc(100% - 150px);
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf9;
  box-shadow: 0 18px 45px rgba(44, 36, 28, 0.2);
}

.reference-panel[hidden] {
  display: none;
}

.meme-panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 7;
  background: rgba(0, 0, 0, 0.08);
}

.meme-panel-backdrop[hidden] {
  display: none;
}

.meme-panel.reference-panel {
  width: min(480px, calc(100% - 36px));
  max-height: min(82vh, calc(100% - 96px));
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.meme-panel.reference-panel[hidden] {
  display: none;
}

.meme-panel .reference-panel-header {
  position: sticky;
  top: 0;
  z-index: 20;
  align-items: flex-start;
  padding: 16px;
  border-bottom: 1px solid rgba(214, 154, 178, 0.18);
  background: rgba(255, 253, 249, 0.98);
  backdrop-filter: blur(10px);
}

.meme-panel #closeMeme {
  position: sticky;
  top: 12px;
  z-index: 30;
  flex: 0 0 auto;
  min-width: 52px;
  min-height: 40px;
  font-weight: 600;
}

.meme-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 16px;
  -webkit-overflow-scrolling: touch;
}

.reference-panel-header,
.reference-upload-row,
.reference-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reference-panel h2,
.reference-panel h3,
.reference-panel p {
  margin: 0;
}

.reference-panel h2 { font-size: 17px; }
.reference-panel h3 { margin: 16px 0 8px; font-size: 14px; }
.reference-panel p,
.reference-upload-row span { color: var(--muted); font-size: 12px; }

.reference-panel button,
.reference-upload-button {
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  background: #f5e8ed;
  color: var(--accent-dark);
  cursor: pointer;
}

.reference-current {
  margin: 14px 0;
  text-align: center;
}

.reference-current img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 10px;
}

.reference-empty {
  padding: 40px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: #faf7f2;
}

.reference-empty[hidden],
.reference-current img[hidden] { display: none; }

.reference-version {
  margin-top: 8px;
  color: var(--accent-dark);
  font-size: 12px;
}

.memory-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.memory-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.memory-actions button {
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  background: #f5e8ed;
  color: var(--accent-dark);
  font-weight: 700;
}

.memory-log-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.memory-log-section h3 {
  margin: 0;
}

.memory-group {
  display: grid;
  gap: 8px;
}

.memory-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 250, 252, 0.84);
}

.memory-item p {
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}

.memory-item span {
  color: var(--muted);
  font-size: 11px;
}

.memory-item button {
  justify-self: end;
  padding: 5px 9px;
  font-size: 12px;
}

.meme-upload-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}

.meme-panel-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.meme-panel-actions button {
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  background: #f5e8ed;
  color: var(--accent-dark);
  cursor: pointer;
}

.meme-upload-form h3 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 14px;
}

.meme-upload-form input,
.meme-upload-form select,
.meme-upload-form textarea {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 9px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.meme-upload-form textarea {
  grid-column: 1 / -1;
  resize: vertical;
  min-height: 58px;
  line-height: 1.45;
}

.meme-placement-field,
.meme-checkbox {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.meme-placement-field {
  grid-column: 1 / -1;
  justify-content: space-between;
}

.meme-placement-field select {
  width: min(190px, 54%);
  padding: 6px 8px;
}

.meme-checkbox input {
  accent-color: var(--accent);
}

.meme-file-status {
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 8px 9px;
  border: 1px dashed var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: #faf7f2;
  font-size: 12px;
}

.meme-file-preview {
  grid-column: 1 / -1;
  width: 96px;
  max-height: 96px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.meme-file-preview[hidden] {
  display: none;
}

.meme-upload-form .reference-upload-button,
.meme-upload-form button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.meme-upload-form button[type="button"] {
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  background: #eee7df;
  color: var(--text);
  cursor: pointer;
}

.meme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.meme-card {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 250, 252, 0.82);
}

.meme-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 9px;
  background: #faf7f2;
}

.meme-card strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meme-card p,
.meme-card span {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.meme-card .meme-placement-tag {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 7px;
  background: #f5e8ed;
  color: var(--accent-dark);
  font-size: 10px;
  line-height: 1.2;
}

.meme-send-placement {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  border: 0;
  padding: 0;
  margin: 2px 0;
}

.meme-send-placement legend {
  flex-basis: 100%;
  color: rgba(85, 62, 48, 0.72);
  font-size: 10px;
}

.meme-send-placement label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 24px;
  border: 1px solid rgba(211, 79, 115, 0.18);
  border-radius: 8px;
  padding: 3px 5px;
  background: #fff;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 10px;
}

.meme-send-placement input {
  margin: 0;
  accent-color: var(--accent);
}

.meme-send-placement label:has(input:checked) {
  border-color: rgba(211, 79, 115, 0.42);
  background: #fff0f5;
}

.meme-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meme-card-actions button {
  padding: 5px 8px;
  font-size: 11px;
}

.meme-recommendations {
  margin: 0 18px 10px;
  padding: 10px;
  border: 1px solid rgba(211, 79, 115, 0.18);
  border-radius: 14px;
  background: rgba(255, 248, 251, 0.92);
}

.meme-recommendations[hidden] {
  display: none;
}

.meme-recommendation-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.meme-recommendations p {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 12px;
}

.meme-recommendation-heading p {
  margin: 0;
}

.meme-recommendation-heading button {
  border: 1px solid rgba(211, 79, 115, 0.20);
  border-radius: 999px;
  padding: 4px 9px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}

.meme-recommendation-heading button:hover {
  color: var(--accent-dark);
  background: #fff0f5;
}

.meme-recommendation-expand,
.meme-training-picker {
  width: fit-content;
  margin: 0 18px 10px;
  border: 1px solid rgba(211, 79, 115, 0.18);
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255, 248, 251, 0.92);
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(56, 44, 35, 0.04);
}

.meme-recommendation-expand[hidden],
.meme-training-picker[hidden] {
  display: none;
}

.meme-recommendation-expand:hover,
.meme-training-picker:hover {
  background: #ffeaf1;
}

.meme-training-picker {
  border-style: dashed;
  background: rgba(255, 250, 252, 0.92);
}

.meme-recommendation-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.meme-recommendation-card {
  flex: 0 0 auto;
  width: 112px;
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.meme-recommendation-send {
  display: grid;
  gap: 4px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.meme-recommendation-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
}

.meme-recommendation-card span,
.meme-recommendation-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meme-recommendation-card span {
  font-size: 12px;
  font-weight: 700;
}

.meme-recommendation-card small {
  color: var(--muted);
  font-size: 10px;
}

.meme-recommendation-card .meme-send-placement {
  width: 100%;
}

.meme-recommendation-bad {
  border: 0;
  border-radius: 999px;
  padding: 4px 7px;
  background: #f6eee8;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
}

.meme-recommendation-bad:hover {
  color: var(--accent-dark);
  background: #fff0f5;
}

.proactive-sequence-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.proactive-sequence-preview[hidden] {
  display: none;
}

.sequence-chip {
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef7f4;
  color: #28715f;
  font-size: 12px;
  font-weight: 600;
}

.sequence-chip.meme {
  background: #fff4dc;
  color: #8b5b15;
}

.sequence-chip.image {
  background: #eef0ff;
  color: #4b5fa8;
}

.meme-message .image-bubble {
  display: inline-flex;
  width: auto;
  max-width: 190px;
  padding: 4px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.reference-history-item {
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.reference-history-item span { margin-right: auto; }

.reference-section {
  margin-top: 14px;
}

.inspiration-section {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.inspiration-section p + p {
  margin-top: 4px;
}

.inspiration-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.inspiration-card {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.inspiration-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
}

.inspiration-card span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inspiration-card button {
  padding: 4px 6px;
  font-size: 11px;
}

/* --- Identity Candidates --- */

.candidate-section {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.candidate-section p + p {
  margin-top: 4px;
}

.candidate-actions {
  margin: 10px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.candidate-generate-button {
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  background: #f5e8ed;
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.candidate-generate-button:hover {
  background: #efd8e1;
}

.candidate-generate-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.candidate-cost-warning {
  color: #9a6a24;
  font-size: 11px;
  line-height: 1.4;
  max-width: 260px;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.candidate-card {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.candidate-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
}

.candidate-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.candidate-info span:first-child {
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-meta {
  color: var(--muted);
  font-size: 10px;
}

.candidate-card button {
  padding: 5px 8px;
  font-size: 11px;
  border: 0;
  border-radius: 7px;
  background: #f5e8ed;
  color: var(--accent-dark);
  cursor: pointer;
}

.candidate-card button:hover {
  background: #efd8e1;
}

.chat-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-strong);
  gap: 12px;
}

.chat-header h1,
.debug-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.chat-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.header-actions,
.debug-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.voice-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.voice-settings label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
}

.voice-settings input {
  accent-color: var(--accent);
}

.tts-audition-controls {
  display: grid;
  gap: 10px;
}

.tts-audition-controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.tts-audition-controls textarea,
.tts-audition-controls select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
}

.tts-tuning-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tts-voice-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.tts-voice-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-strong);
}

.tts-voice-card.is-current {
  border-color: var(--accent);
  background: #fff8fa;
}

.tts-voice-card-header,
.tts-voice-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tts-voice-card-header strong {
  font-size: 14px;
}

.tts-voice-card-header span {
  color: var(--accent-dark);
  font-size: 12px;
}

.tts-voice-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.tts-voice-actions button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff8fa;
  color: var(--accent-dark);
  cursor: pointer;
}

.tts-voice-actions button:disabled {
  cursor: default;
  color: var(--muted);
  background: #f4f1ed;
}

.tts-audition-result audio {
  width: 100%;
  height: 32px;
}

.status-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #28a260;
  box-shadow: 0 0 0 5px rgba(40, 162, 96, 0.13);
}

.status-dot.status-connected {
  background: #28a260;
  box-shadow: 0 0 0 5px rgba(40, 162, 96, 0.13);
}

.status-dot.status-disconnected {
  background: #e07b39;
  box-shadow: 0 0 0 5px rgba(224, 123, 57, 0.18);
}

.backend-status-label {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.backend-offline-notice {
  padding: 8px 14px;
  background: #fff3e6;
  border: 1px solid #e6b87e;
  border-radius: 8px;
  color: #8a5a2e;
  font-size: 13px;
  text-align: center;
}

.backend-offline-notice code {
  background: #f5e1c8;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
}

.backend-offline-notice[hidden] {
  display: none;
}

.emotion-particle-widget {
  display: none;
  position: absolute;
  z-index: 3;
  top: 88px;
  right: 18px;
  width: 230px;
  height: 188px;
  padding: 10px 10px 9px;
  border: 1px solid rgba(255, 210, 229, 0.24);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 74%, rgba(255, 100, 155, 0.28), transparent 34%),
    radial-gradient(circle at 22% 18%, rgba(120, 184, 255, 0.16), transparent 32%),
    linear-gradient(145deg, rgba(16, 12, 27, 0.82), rgba(47, 26, 47, 0.62));
  box-shadow:
    0 18px 42px rgba(38, 10, 32, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -24px 46px rgba(255, 105, 160, 0.08);
  pointer-events: none;
  backdrop-filter: blur(14px) saturate(1.24);
  opacity: 0.94;
  overflow: hidden;
}

.emotion-particle-stage {
  isolation: isolate;
}

.emotion-particle-widget::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent),
    radial-gradient(circle at 50% 82%, rgba(255, 199, 229, 0.13), transparent 38%);
  opacity: 0.9;
}

.emotion-particle-widget::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 30px;
  width: 68%;
  height: 20px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: radial-gradient(ellipse at center, rgba(255, 120, 178, 0.36), rgba(160, 212, 255, 0.1) 48%, transparent 72%);
  filter: blur(7px);
  opacity: 0.88;
}

.emotion-particle-widget canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 155px;
  border-radius: 16px;
}

.emotion-particle-widget span {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 4px;
  color: rgba(255, 241, 248, 0.82);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-align: center;
  text-shadow: 0 0 14px rgba(255, 123, 176, 0.35);
  user-select: none;
}

.messages {
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, rgba(255, 242, 247, 0.52), rgba(255, 253, 249, 0.76));
}

.history-load-more {
  display: flex;
  justify-content: center;
  margin: -4px 0 2px;
}

.history-load-more button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 12px;
}

.history-load-more button:disabled {
  cursor: default;
  opacity: 0.56;
}

.message {
  max-width: min(72%, 620px);
  display: grid;
  gap: 6px;
}

.message.me {
  align-self: flex-end;
}

.message.friend {
  align-self: flex-start;
}

.bubble {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 5px 16px rgba(56, 44, 35, 0.06);
}

.me .bubble {
  background: var(--me);
  border-color: #f4bed0;
  border-bottom-right-radius: 5px;
}

.friend .bubble {
  background: var(--friend);
  border-bottom-left-radius: 5px;
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.me .meta {
  text-align: right;
}

.message-footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.me .message-footer {
  justify-content: flex-end;
}

.assistant-media-action-message {
  margin-top: -4px;
}

.assistant-media-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.voice-play,
.photo-suggest {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: #fff8fa;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.2;
}

.assistant-action[data-status="succeeded"] {
  background: #f2fbf6;
  color: #2f6f4e;
}

.assistant-action[data-status="failed"] {
  background: #fff6ed;
  color: #8a4b1f;
}

.voice-play:hover,
.photo-suggest:hover {
  background: #ffeaf1;
}

.voice-play:disabled,
.photo-suggest:disabled {
  cursor: wait;
  color: var(--muted);
  background: #f4f1ed;
}

.typing-indicator .bubble {
  color: var(--muted);
  font-size: 13px;
  box-shadow: none;
}

.typing-indicator .typing-dots {
  animation: typingPulse 1.2s ease-in-out infinite;
}

@keyframes typingPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.composer {
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--panel-strong);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 72px 64px 72px 88px 82px;
  gap: 10px;
}

.pending-image-upload {
  grid-column: 1 / -1;
  min-width: 0;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid #efc2d1;
  border-radius: 8px;
  background: #fff7fa;
}

.pending-image-upload[hidden] {
  display: none;
}

.pending-image-upload img {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
}

.pending-image-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.pending-image-copy strong,
.pending-image-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-image-copy strong {
  color: var(--text);
  font-size: 13px;
}

.pending-image-copy span {
  color: var(--muted);
  font-size: 12px;
}

.composer .pending-image-upload button {
  min-height: 34px;
  padding: 0 10px;
  background: #f5e8ed;
  color: var(--accent-dark);
  font-weight: 600;
}

.composer textarea {
  width: 100%;
  min-height: 44px;
  max-height: 140px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
  background: #fff;
}

.composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(211, 79, 115, 0.16);
}

.image-intent {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 7px;
  background: #fffafc;
  color: var(--text);
  outline: none;
}

.image-intent:focus {
  border-color: var(--accent);
}

.composer button,
.debug-header button,
.debug-toggle {
  border: 0;
  border-radius: 9px;
  cursor: pointer;
}

.composer .send-button {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.composer .send-button:hover {
  background: var(--accent-dark);
}

.composer .image-button {
  background: #f5e8ed;
  color: var(--accent-dark);
  font-weight: 600;
}

.composer .image-button:hover {
  background: #efd8e1;
}

.composer button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.image-bubble {
  padding: 8px;
  overflow: hidden;
}

.image-bubble img {
  display: block;
  width: min(360px, 100%);
  max-height: 440px;
  border-radius: 10px;
  object-fit: cover;
}

.voice-input-bubble {
  width: min(220px, 100%);
  min-width: 132px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  cursor: pointer;
}

.voice-input-bubble:hover {
  border-color: #eab3c6;
  background: #ffeaf1;
}

.voice-message.is-pending .voice-input-bubble {
  cursor: wait;
  opacity: 0.78;
}

.voice-message.is-failed .voice-input-bubble {
  border-color: #ef9a9a;
  background: #fff3f3;
}

.voice-input-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(211, 79, 115, 0.12);
  color: var(--accent-dark);
  font-size: 12px;
}

.voice-input-label {
  flex: 1;
  text-align: right;
  font-weight: 600;
}

.meme-message .image-bubble img {
  width: auto;
  max-width: 140px;
  max-height: 140px;
  border-radius: 8px;
  object-fit: contain;
}

.image-error {
  display: block;
  min-width: 180px;
  padding: 28px 18px;
  color: var(--muted);
  text-align: center;
}

.image-error[hidden] {
  display: none;
}

.proactive-suggestion {
  margin: 0 14px 12px;
  padding: 12px 14px;
  border: 1px solid rgba(211, 79, 115, 0.22);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 248, 250, 0.96), rgba(255, 241, 230, 0.9));
  box-shadow: 0 8px 24px rgba(173, 56, 88, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.proactive-suggestion[hidden] {
  display: none;
}

.proactive-suggestion.proactive-empty {
  justify-content: center;
  text-align: center;
  border-style: dashed;
  background: rgba(255, 248, 250, 0.88);
}

.proactive-suggestion.proactive-empty p,
.proactive-suggestion.proactive-empty .proactive-actions {
  display: none;
}

.proactive-suggestion p {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.proactive-suggestion blockquote {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.proactive-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.proactive-actions button {
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  background: #f5e8ed;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.proactive-actions button:first-child {
  background: var(--accent);
  color: #fff;
}

.proactive-actions button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.debug-toggle {
  padding: 8px 12px;
  background: #eee7df;
  color: var(--text);
  white-space: nowrap;
}

.debug-toggle:hover,
.debug-header button:hover {
  background: #e5dbd0;
}

.debug-panel {
  min-width: 0;
  height: calc(100vh - 56px);
  min-height: 0;
  border-radius: 16px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  transition: opacity 180ms ease, transform 180ms ease;
}

body.debug-collapsed .debug-panel {
  pointer-events: none;
  opacity: 0;
  transform: translateX(12px);
}

.debug-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-strong);
  gap: 12px;
}

.debug-header h2 {
  font-size: 16px;
}

.debug-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.debug-header button {
  padding: 7px 10px;
  background: #eee7df;
  color: var(--text);
  white-space: nowrap;
}

.debug-warning {
  max-width: 180px;
  color: #9a6a24;
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
}

.debug-log {
  min-height: 0;
  padding: 16px;
  overflow: auto;
  color: #4b443e;
  font-size: 12px;
  line-height: 1.55;
  background: #faf7f2;
}

.debug-empty {
  margin: 0;
  color: var(--muted);
}

.debug-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  overflow: hidden;
}

.debug-item + .debug-item {
  margin-top: 10px;
}

.debug-summary {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

.debug-title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.debug-caret {
  flex: 0 0 auto;
  color: var(--muted);
}

.debug-item.is-error {
  border-color: #e3aaa2;
  background: #fff8f6;
}

.debug-item.is-error .debug-title {
  color: #9a3f35;
  font-weight: 700;
}

.debug-detail {
  margin: 0;
  padding: 0 12px 12px;
  color: #4b443e;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.debug-item.is-collapsed .debug-detail {
  display: none;
}

.debug-overlay {
  display: none;
}

@media (max-width: 880px) {
  .app-shell {
    width: min(100vw - 20px, 680px);
    grid-template-columns: 1fr;
    padding: 10px 0;
    gap: 0;
  }

  body.debug-collapsed .app-shell,
  body.debug-open .app-shell {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    height: calc(100vh - 20px);
  }

  .debug-panel {
    position: fixed;
    top: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 20;
    width: min(380px, calc(100vw - 20px));
    height: auto;
    opacity: 1;
    transform: translateX(calc(100% + 20px));
    pointer-events: none;
  }

  body.debug-open .debug-panel {
    transform: translateX(0);
    pointer-events: auto;
  }

  body.debug-open .debug-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 10;
    background: rgba(36, 32, 28, 0.28);
  }

  .message {
    max-width: 86%;
  }

  .meme-message .image-bubble img {
    max-width: 110px;
    max-height: 110px;
  }

  .chat-header {
    padding: 14px;
    align-items: flex-start;
  }

  .header-actions {
    align-items: flex-end;
    flex-direction: column-reverse;
  }

  .voice-settings {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .emotion-particle-widget {
    display: none;
  }

  .composer {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .composer textarea {
    grid-column: 1 / -1;
  }

  .image-intent {
    min-height: 44px;
  }

  .proactive-suggestion {
    margin: 0 10px 10px;
    align-items: flex-start;
    flex-direction: column;
  }
}
