:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --line: #e6e9ee;
  --text: #1d232f;
  --muted: #6f7785;
  --accent: #256f68;
  --accent-strong: #17534d;
  --assistant: #ffffff;
  --user: #e8f3ef;
  --shadow: 0 18px 48px rgba(24, 35, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(37, 111, 104, 0.08), transparent 260px),
    var(--bg);
}

.doctor-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.doctor-profile img,
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.new-chat,
.composer button {
  border: 0;
  cursor: pointer;
}

.new-chat {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 650;
}

.new-chat:hover,
.composer button:hover {
  background: var(--accent-strong);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 100vh;
  width: min(1080px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.messages {
  overflow-y: auto;
  padding: 34px 28px;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 860px;
  margin: 0 auto 18px;
}

.user-message {
  justify-content: flex-end;
}

.user-message .bubble {
  background: var(--user);
}

.assistant-message .bubble {
  background: var(--assistant);
  box-shadow: var(--shadow);
}

.bubble {
  max-width: min(680px, 78vw);
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.bubble p {
  margin: 0;
  white-space: pre-wrap;
}

.typing .bubble p::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
  animation: pulse 0.9s ease-in-out infinite;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: min(880px, calc(100% - 32px));
  margin: 0 auto 20px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.composer textarea {
  max-height: 160px;
  min-height: 44px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 10px 8px;
  color: var(--text);
  line-height: 1.55;
}

.composer button {
  align-self: end;
  min-width: 78px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 650;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    padding: 14px 16px;
  }

  .doctor-profile {
    align-items: flex-start;
  }

  .doctor-profile img {
    width: 42px;
    height: 42px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .topbar p {
    max-width: 210px;
    line-height: 1.45;
  }

  .new-chat {
    padding: 9px 11px;
    white-space: nowrap;
  }

  .messages {
    padding: 20px 16px;
  }

  .message {
    gap: 9px;
    margin-bottom: 14px;
  }

  .avatar {
    width: 32px;
    height: 32px;
  }

  .bubble {
    max-width: calc(100vw - 76px);
    padding: 11px 12px;
    font-size: 15px;
  }

  .composer {
    width: calc(100% - 20px);
    margin-bottom: 10px;
    grid-template-columns: minmax(0, 1fr) 64px;
  }

  .composer textarea {
    min-height: 62px;
    padding: 12px 8px;
  }

  .composer textarea::placeholder {
    white-space: normal;
  }

  .composer button {
    height: 62px;
    min-width: 64px;
  }
}
