:root {
  --ink: #15233b;
  --muted: #687083;
  --line: #dce1e7;
  --paper: #f3f4f0;
  --white: #ffffff;
  --yellow: #f5c84b;
  --blue: #174ba4;
  --green: #1c9c57;
  --shadow: 0 18px 48px rgba(21, 35, 59, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  background: var(--paper);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, var(--yellow) 0 92px, transparent 92px) top left / 100% 7px no-repeat,
    var(--paper);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

button,
textarea {
  font: inherit;
}

.topbar {
  width: min(960px, calc(100% - 32px));
  height: 74px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(21, 35, 59, 0.1);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-number {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--yellow);
  border-radius: 7px;
  font-family: Georgia, serif;
  font-size: 28px;
  line-height: 1;
}

.brand-copy {
  display: grid;
  gap: 1px;
}

.brand-copy strong {
  font-size: 17px;
  letter-spacing: 0.02em;
}

.brand-copy small {
  color: var(--muted);
  font-size: 12px;
}

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

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aab1bd;
  box-shadow: 0 0 0 4px rgba(170, 177, 189, 0.14);
}

.system-status.ready .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(28, 156, 87, 0.13);
}

.app-shell {
  width: min(960px, calc(100% - 32px));
  height: calc(100vh - 106px);
  min-height: 560px;
  margin: 18px auto;
}

.chat-panel {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 17px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.toolbar-label {
  display: block;
  margin-bottom: 2px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.chat-toolbar h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.3;
}

.plain-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.messages {
  overflow-y: auto;
  padding: 22px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #b9c1cd transparent;
  background:
    linear-gradient(rgba(21, 35, 59, 0.026) 1px, transparent 1px) 0 0 / 100% 30px,
    #fbfbfa;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: #b9c1cd;
  border: 2px solid #fbfbfa;
  border-radius: 999px;
}

.message {
  max-width: 86%;
  margin-bottom: 18px;
}

.message.user {
  margin-left: auto;
}

.message-role {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 10px;
}

.message.user .message-role {
  text-align: right;
}

.bubble {
  padding: 13px 15px;
  color: #253148;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.message.user .bubble {
  color: var(--white);
  background: var(--blue);
  border-color: var(--blue);
}

.message.loading .bubble {
  color: var(--muted);
}

.citation-box {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.citation-box summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}

.citation-list {
  margin: 7px 0 0;
  padding-left: 17px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.message-actions {
  margin-top: 7px;
}

.handoff-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: #8a5b00;
  cursor: pointer;
  font-size: 11px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px 16px 10px;
  border-top: 1px solid var(--line);
  background: var(--white);
}

.composer textarea {
  width: 100%;
  min-height: 44px;
  max-height: 126px;
  resize: none;
  padding: 11px 12px;
  color: var(--ink);
  background: #f7f8f6;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  line-height: 1.45;
}

.composer textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 75, 164, 0.1);
}

.composer button {
  min-width: 74px;
  height: 44px;
  border: 0;
  border-radius: 7px;
  color: var(--white);
  background: var(--blue);
  cursor: pointer;
  font-weight: 700;
}

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

.privacy-note {
  margin: 0;
  padding: 0 16px 11px;
  color: var(--muted);
  background: var(--white);
  font-size: 10px;
  line-height: 1.45;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 620px) {
  .topbar,
  .app-shell {
    width: calc(100% - 20px);
  }

  .topbar {
    height: 66px;
  }

  .brand-number {
    width: 38px;
    height: 38px;
    font-size: 25px;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .system-status {
    max-width: 112px;
    justify-content: flex-end;
    text-align: right;
  }

  .app-shell {
    height: calc(100dvh - 84px);
    min-height: 520px;
    margin: 10px auto;
  }

  .chat-toolbar {
    padding: 14px 15px 12px;
  }

  .chat-toolbar h1 {
    font-size: 17px;
  }

  .messages {
    padding: 16px 13px;
  }

  .message {
    max-width: 94%;
  }

  .bubble {
    padding: 12px 13px;
    font-size: 13px;
  }

  .composer {
    padding-inline: 12px;
  }

  .composer button {
    min-width: 66px;
  }

  .privacy-note {
    padding-inline: 12px;
  }
}
