:root {
  --bg-app: #F8EEF1;
  --bg-sidebar: #F6E8EC;
  --bg-main: #FBF6F7;
  --bg-user-bubble: #F3E4E8;
  --ink: #2A1F24;
  --muted: #8A7A80;
  --line: #EADDE1;
  --accent: #E85A7A;
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
body {
  font-family: var(--font-base);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg-app);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; touch-action: manipulation; }
.hidden { display: none !important; }

.app {
  display: flex;
  width: 100%;
  height: 100%;
}
aside {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.side-head {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: block;
}
.side-label { padding: 8px 16px; font-size: 12px; color: var(--muted); }
.conv-list { flex: 1; overflow: auto; padding: 0 8px 8px; }
.side-foot { padding: 12px 16px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: #f0e6e8; color: var(--ink); }
.menu-btn { display: none; }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-main);
  min-width: 0;
  height: 100%;
  overflow: hidden;
  border-top-left-radius: 18px;
}
.topbar {
  flex-shrink: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-main);
  z-index: 10;
}
.conv-title { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 2px; }
.chat-body {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}
.messages {
  flex: 1;
  overflow: auto;
  padding: 16px 16px 8px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--bg-main);
}
.composer {
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-main);
  flex-shrink: 0;
}
.composer-inner { width: 100%; max-width: 40rem; margin: 0 auto; }
.input-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}
.input-card:focus-within {
  border-color: #d4b8be;
}
.input-card textarea {
  display: block;
  width: 100%;
  resize: none;
  max-height: 12rem;
  min-height: 44px;
  padding: 14px 16px 4px;
  border: 0;
  outline: none;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: transparent;
}
.input-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 8px 8px 6px;
}
.input-tools { display: flex; align-items: center; gap: 0; }
.send-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.send-btn svg { display: block; }
.send-btn .ico-stop { display: none; }
.send-btn.is-stop .ico-send { display: none; }
.send-btn.is-stop .ico-stop { display: block; }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.camera-btn { display: none; }
.image-preview { display: flex; gap: 8px; overflow-x: auto; }

.msg-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.msg-copy {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 0;
  cursor: pointer;
}
.msg-copy:hover { color: var(--accent); }

@media (max-width: 768px) {
  .menu-btn { display: inline-flex; }
  main { border-radius: 0; }
  .messages { padding-left: 12px; padding-right: 12px; }
  .composer { padding-left: 12px; padding-right: 12px; }
  .camera-btn { display: inline-flex; }
  aside {
    width: 86%;
    max-width: 320px;
    padding-top: env(safe-area-inset-top);
  }
}

.photo-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.conv-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 2px;
}
.conv-item-title {
  font-size: 14px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-item-preview {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-item.active { background: rgba(139, 58, 74, 0.08); }
.conv-item.active .conv-item-title { font-weight: 600; }
.thumb-wrap { position: relative; flex-shrink: 0; }
.preview-img { height: 64px; width: 64px; object-fit: cover; border-radius: 12px; border: 1px solid #fce7f3; display: block; }
.remove-img {
  position: absolute; top: -4px; right: -4px;
  width: 16px; height: 16px; border: 0; border-radius: 999px;
  background: #1f2937; color: #fff; font-size: 11px; line-height: 16px; cursor: pointer;
}
.loading-label { color: #9ca3af; font-size: 12px; }
.msg-img { max-width: 100%; border-radius: 12px; margin-bottom: 8px; display: block; }


/* unused leftover from 豆包 demo removed */

.markdown-body {
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  font-size: 16px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.markdown-body > *:first-child { margin-top: 0 !important; }
.markdown-body > *:last-child { margin-bottom: 0 !important; }
.markdown-body p {
  margin: 0.55em 0;
}

.user-bubble .markdown-body {
  color: var(--ink);
  width: auto;
}
.bot-bubble .markdown-body {
  color: var(--ink);
}

/* Sidebar Toggle for Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}
.sidebar-open .sidebar-overlay {
  display: block;
}
@media (max-width: 768px) {
  aside {
    position: fixed;
    left: -110%;
    top: 0;
    bottom: 0;
    z-index: 50;
    transition: left 0.3s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar-open aside {
    left: 0;
  }
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 20px;
  z-index: 5;
  background-color: var(--bg-main);
  background-image: url("/timi/static/kitty-tile.svg?v=20260813j");
  background-size: 160px 160px;
}
.empty-state.hidden {
  display: none;
}
.empty-state .mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  margin-bottom: 16px;
  display: block;
}
.empty-state h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 8px;
  letter-spacing: 0.02em;
}
.empty-state p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 15px;
}
.empty-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  pointer-events: auto;
  max-width: 520px;
}
.empty-chip {
  border: 1px solid #ececec;
  background: #fff;
  color: #374151;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.empty-chip:hover {
  border-color: #f4b4c4;
  background: #fff7f9;
  box-shadow: 0 4px 12px rgba(212, 106, 134, 0.08);
}

.markdown-body img {
  max-width: min(420px, 100%);
  border-radius: 12px;
}

.msg-row {
  display: flex;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto 1rem;
  align-items: flex-start;
}
.msg-row-user { justify-content: flex-end; }
.msg-row-bot { justify-content: flex-start; }

.msg-user {
  max-width: min(75%, 34rem);
  width: fit-content;
  background: var(--bg-user-bubble);
  color: var(--ink);
  border-radius: 18px 4px 18px 18px;
  padding: 10px 14px;
  overflow: hidden;
}
.msg-bot {
  width: 100%;
  max-width: 100%;
  padding: 0;
  background: transparent;
  overflow: visible;
}

.markdown-body blockquote {
  border-left: 2px solid #ead7dd;
  background: transparent;
  color: inherit;
  padding: 0 0 0 12px;
  margin: 0.6em 0;
}

.edit-tray {
  margin: 0 0 10px;
  padding: 10px 12px 8px;
  background: #faf7f8;
  border: 1px solid #f0e4e8;
  border-radius: 18px;
}
.edit-tray.hidden { display: none; }
.edit-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.edit-hint {
  border: 1px solid #ead7dd;
  background: #fff;
  color: #6b4a54;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
}
.edit-hint:hover { background: #fff7f9; }

.photo-result {
  margin: 0 0 12px;
  max-width: 520px;
}
.photo-pair.one { grid-template-columns: 1fr; }
.photo-pair figure {
  margin: 0;
  background: #f7f7f8;
  border-radius: 14px;
  overflow: hidden;
}
.photo-pair img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
}
.photo-pair figcaption {
  font-size: 11px;
  color: #9ca3af;
  padding: 6px 10px 8px;
}
.photo-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.photo-actions a,
.photo-actions button {
  font-size: 12px;
  color: #6b4a54;
  background: #fff;
  border: 1px solid #ead7dd;
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  text-decoration: none;
}

.tarot-spread {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 0 0 14px;
  perspective: 800px;
}
.tarot-card {
  width: 86px;
  height: 132px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.7s ease;
  flex-shrink: 0;
}
.tarot-spread.n-5 .tarot-card,
.tarot-spread.n-7 .tarot-card { width: 72px; height: 112px; }
.tarot-spread.n-10 .tarot-card { width: 58px; height: 90px; }
.tarot-card.flipped { transform: rotateY(180deg); }
.tarot-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(80, 40, 50, 0.12);
}
.tarot-back {
  background:
    url("/timi/static/kitty-tile.svg?v=20260813j"),
    linear-gradient(160deg, #3a2430 0%, #5a3340 55%, #2a1a22 100%);
  background-size: 48px 48px, auto;
  border: 1px solid rgba(244, 212, 220, 0.18);
}
.tarot-front {
  color: #3a2430;
  transform: rotateY(180deg);
  border: 1px solid #e6d5c4;
  background: linear-gradient(180deg, #fbf7f2 0%, #f3e6d8 100%);
}
.tarot-front.tone-major { background: linear-gradient(180deg, #fbf4f6 0%, #f3dce3 100%); }
.tarot-front.tone-wands { background: linear-gradient(180deg, #fff8f1 0%, #f6e4cc 100%); }
.tarot-front.tone-cups { background: linear-gradient(180deg, #fff5f7 0%, #f8d7e0 100%); }
.tarot-front.tone-swords { background: linear-gradient(180deg, #f5f7fb 0%, #d9e1ee 100%); }
.tarot-front.tone-pents { background: linear-gradient(180deg, #f7f8f1 0%, #e4ead0 100%); }
.tarot-front .no { font-size: 10px; letter-spacing: 0.08em; color: #9a7b6a; margin-bottom: 4px; }
.tarot-front .name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.tarot-spread.n-10 .tarot-front .name { font-size: 11px; }
.tarot-front .pos { font-size: 10px; color: #b08996; margin-top: 6px; }
.tarot-front .orient { font-size: 11px; color: #9a7b6a; margin-top: 4px; }
.tarot-spread.n-3 .tarot-card:nth-child(1) { transform: rotate(-6deg); }
.tarot-spread.n-3 .tarot-card:nth-child(3) { transform: rotate(6deg); }
.tarot-spread.n-3 .tarot-card.flipped:nth-child(1) { transform: rotate(-6deg) rotateY(180deg); }
.tarot-spread.n-3 .tarot-card.flipped:nth-child(3) { transform: rotate(6deg) rotateY(180deg); }

.followups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.followup {
  border: 1px solid #eee;
  background: #fff;
  color: #4b5563;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.followup:hover {
  border-color: #f4b4c4;
  background: #fff7f9;
}

@media (max-width: 640px) {
  .photo-pair { grid-template-columns: 1fr; }
  .photo-pair img { height: 220px; }
  .tarot-card { width: 72px; height: 112px; }
  .tarot-spread.n-7 .tarot-card,
  .tarot-spread.n-10 .tarot-card { width: 56px; height: 88px; }
}
