.chat-shell { display: grid; grid-template-columns: 310px 1fr; height: 100vh; overflow: hidden; }
.sidebar {
  position: relative;
  background: rgba(255, 255, 255, 0.82);
  border-right: 1px solid var(--line);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  backdrop-filter: blur(16px);
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}
.sidebar-close,
.sidebar-overlay { display: none; }
.new-chat { width: 100%; }
.chat-list { display: flex; flex-direction: column; gap: 0.35rem; overflow: auto; flex: 1; min-height: 0; }
.chat-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.25rem;
  align-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  min-height: 46px;
  padding: 0.45rem 0.55rem;
  border-radius: 12px;
  text-align: left;
  overflow: hidden;
}
.chat-item.active, .chat-item:hover { border-color: var(--line); background: #fbf7f7; }
.chat-item .open-chat {
  min-width: 0;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  padding: 0;
  justify-content: flex-start;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chat-item .tiny { padding: 0.25rem 0.4rem; border-radius: 8px; background: #efe5e6; color: var(--biocard); }
.sidebar-user { border-top: 1px solid var(--line); padding-top: 1rem; color: var(--muted); }
.sidebar-user form button { background: transparent; color: var(--biocard); padding: 0.2rem 0; }
.privacy-link { display: block; margin-top: 0.8rem; font-size: 0.9rem; }
.chat-main { position: relative; display: grid; grid-template-rows: auto 1fr auto; min-width: 0; min-height: 0; height: 100vh; }
.top-auth-actions {
  position: absolute;
  top: 1.4rem;
  right: 1.6rem;
  z-index: 3;
}
.mobile-top { display: none; padding: 0.75rem; border-bottom: 1px solid var(--line); background: #fff; }
.messages { overflow-y: auto; min-height: 0; padding: 2rem 1rem 8rem; }
.welcome { max-width: 860px; margin: 8vh auto 0; text-align: center; }
.welcome-logo { width: 68px; height: 68px; }
.welcome h1 { font-size: clamp(2.2rem, 5vw, 4.8rem); line-height: 1; margin: 1rem 0 0.7rem; color: var(--biocard); letter-spacing: -0.06em; }
.welcome p { color: var(--muted); font-size: 1.08rem; }
.prompt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; margin-top: 2rem; }
.prompt-card {
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(125, 39, 42, 0.07);
  min-height: 92px;
  text-align: left;
  justify-content: flex-start;
}
.prompt-card:hover { color: #fff; }
.message { max-width: 860px; margin: 0 auto 1rem; display: flex; }
.message .bubble { padding: 0.9rem 1rem; border-radius: 18px; line-height: 1.6; white-space: pre-wrap; }
.message.user { justify-content: flex-end; }
.message.user .bubble { background: var(--biocard); color: #fff; border-bottom-right-radius: 5px; max-width: 70%; }
.message.assistant .bubble { background: #fff; border: 1px solid var(--line); box-shadow: 0 8px 26px rgba(55, 20, 23, 0.06); max-width: 82%; }
.message.assistant .bubble { white-space: normal; }
.message.assistant .bubble > *:first-child { margin-top: 0; }
.message.assistant .bubble > *:last-child { margin-bottom: 0; }
.message.assistant h1,
.message.assistant h2,
.message.assistant h3 {
  color: var(--biocard);
  line-height: 1.25;
  margin: 1rem 0 0.45rem;
}
.message.assistant h1 { font-size: 1.35rem; }
.message.assistant h2 { font-size: 1.2rem; }
.message.assistant h3 { font-size: 1.05rem; }
.message.assistant p { margin: 0.55rem 0; }
.message.assistant ul { margin: 0.55rem 0 0.75rem; padding-left: 1.35rem; }
.message.assistant li { margin: 0.25rem 0; }
.message.assistant code {
  background: #f4eeee;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--biocard);
  padding: 0.08rem 0.32rem;
}
.message.assistant .code-block {
  position: relative;
  margin: 0.75rem 0;
}
.message.assistant .copy-code {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  color: #fff;
  font-size: 0.8rem;
  padding: 0.35rem 0.55rem;
}
.message.assistant pre {
  overflow-x: auto;
  background: #251d1f;
  color: #fff;
  border-radius: 14px;
  margin: 0;
  padding: 2.45rem 0.9rem 0.9rem;
  white-space: pre;
}
.message.assistant pre code {
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
}
.message.assistant a { color: var(--biocard); font-weight: 700; text-decoration: underline; text-underline-offset: 0.18em; }
.limit-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.9rem; }
.limit-button {
  display: inline-flex;
  border-radius: 12px;
  background: var(--biocard);
  color: #fff;
  padding: 0.65rem 0.85rem;
  font-weight: 700;
}
.message.assistant .limit-button {
  color: #fff;
  text-decoration: none;
}
.limit-link {
  display: inline-flex;
  align-items: center;
  color: var(--biocard);
  font-weight: 700;
}
.composer {
  position: fixed;
  left: 310px;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  background: linear-gradient(180deg, transparent, var(--mist) 26%);
}
.composer textarea {
  flex: 0 1 760px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  min-height: 56px;
  max-height: 160px;
  overflow-y: auto;
  outline: none;
}
.composer textarea:focus { border-color: rgba(125, 39, 42, 0.45); box-shadow: 0 0 0 4px rgba(125, 39, 42, 0.08); }
.composer.is-busy textarea,
.composer textarea:disabled {
  background: #e7e1e2;
  border-color: #d7cbcd;
  color: #7b7073;
  cursor: wait;
}
.composer.is-busy button,
.composer button:disabled {
  background: #b7acad;
  cursor: wait;
}

@media (max-width: 820px) {
  .chat-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 6; transform: translateX(-102%); transition: transform 0.2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: #f5eeee;
    color: var(--biocard);
    font-size: 1.35rem;
    line-height: 1;
    padding: 0;
  }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 5;
    background: rgba(31, 20, 22, 0.32);
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.open { display: block; }
  .mobile-top { display: flex; align-items: center; gap: 1rem; }
  .top-auth-actions { top: 0.65rem; right: 0.75rem; }
  .composer { left: 0; }
  .composer textarea { flex: 1; }
  .prompt-grid { grid-template-columns: 1fr; }
  .message.user .bubble, .message.assistant .bubble { max-width: 94%; }
}
