:root {
  --page-bg: #f4f7fb;
  --page-bg-soft: #eef3f9;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --surface-muted: #edf2f8;
  --surface-accent: #f7f2e7;
  --border-soft: #d7e0ea;
  --border-strong: #c8d4e1;
  --text: #162031;
  --text-muted: #5e6c7d;
  --text-soft: #7b8798;
  --primary: #173c70;
  --primary-strong: #11315d;
  --primary-soft: #dce9f8;
  --primary-soft-strong: #c8dbf4;
  --accent: #dcc59a;
  --accent-soft: #f4ecda;
  --success: #2d7057;
  --warning: #9d6720;
  --error: #b34b46;
  --shadow-soft: 0 14px 34px rgba(21, 44, 79, 0.08);
  --shadow-card: 0 10px 26px rgba(17, 49, 93, 0.08);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(220, 233, 248, 0.55), transparent 28%),
    linear-gradient(180deg, var(--page-bg) 0%, var(--page-bg-soft) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

body {
  min-height: 100dvh;
}

button,
textarea {
  font: inherit;
}

button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
}

.app-shell {
  min-height: 100dvh;
  max-width: 768px;
  margin: 0 auto;
  padding: 14px 14px calc(128px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 14px;
  background: linear-gradient(
    180deg,
    rgba(244, 247, 251, 0.95) 0%,
    rgba(244, 247, 251, 0.78) 78%,
    rgba(244, 247, 251, 0) 100%
  );
  backdrop-filter: blur(10px);
}

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

.brand__avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  flex: 0 0 auto;
  box-shadow: var(--shadow-soft);
}

.brand__copy {
  min-width: 0;
}

.brand__copy h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.15;
  color: var(--primary-strong);
}

.brand__subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
}

.brand__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-soft);
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
  flex: 0 0 auto;
}

.health-dot--checking {
  background: var(--accent);
}

.health-dot--error {
  background: var(--error);
}

.topbar__action {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(23, 60, 112, 0.08);
  box-shadow: 0 6px 18px rgba(17, 49, 93, 0.06);
  color: var(--primary-strong);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.service-notice {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(179, 75, 70, 0.08);
  border: 1px solid rgba(179, 75, 70, 0.16);
  color: #8d3733;
  font-size: 13px;
  line-height: 1.55;
}

.main-viewport {
  min-height: calc(100dvh - 176px);
  overflow-y: auto;
  padding-bottom: 12px;
}

.home-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 8px;
}

.welcome-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 255, 0.94));
  box-shadow: var(--shadow-card);
}

.welcome-card__badge {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: var(--surface-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.welcome-card__avatar {
  width: 34px;
  height: 34px;
  border-radius: 12px;
}

.welcome-card__body {
  min-width: 0;
}

.welcome-card__eyebrow,
.section-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--text-soft);
}

.welcome-card__body h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  color: var(--primary-strong);
}

.welcome-card__body p:last-child {
  margin: 10px 0 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-muted);
}

.question-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.question-section__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.question-section__header h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
  color: var(--primary-strong);
}

.question-toggle {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(23, 60, 112, 0.06);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.question-grid {
  display: grid;
  gap: 12px;
}

.question-extra {
  margin-top: -2px;
}

.question-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 18px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 22px rgba(17, 49, 93, 0.05);
  text-align: left;
  cursor: pointer;
}

.question-card__label {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  font-weight: 600;
}

.question-card__arrow {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 15px;
  flex: 0 0 auto;
}

.conversation-section {
  min-height: 100%;
  padding-top: 8px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

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

.message--user .message__avatar {
  display: none;
}

.message--system .message__avatar {
  display: none;
}

.message__avatar {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  flex: 0 0 auto;
  box-shadow: 0 8px 18px rgba(17, 49, 93, 0.08);
}

.message__stack {
  max-width: min(86%, 560px);
  min-width: 0;
}

.message__bubble {
  border-radius: 22px;
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-soft);
}

.message--assistant .message__bubble {
  background: rgba(255, 255, 255, 0.96);
  border-top-left-radius: 10px;
}

.message--user .message__bubble {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: #ffffff;
  border-top-right-radius: 10px;
}

.message--system .message__bubble {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(179, 75, 70, 0.16);
  box-shadow: none;
}

.message__content {
  min-width: 0;
}

.message__plain {
  margin: 0;
  font-size: 15px;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}

.assistant-rich > *:first-child {
  margin-top: 0;
}

.assistant-rich > *:last-child {
  margin-bottom: 0;
}

.assistant-rich h3 {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.35;
  color: var(--primary-strong);
}

.assistant-rich h4 {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--primary-strong);
}

.assistant-rich p {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.78;
  color: var(--text);
  word-break: break-word;
}

.assistant-rich strong {
  font-weight: 700;
  color: var(--primary-strong);
}

.assistant-rich ul,
.assistant-rich ol {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.assistant-rich li {
  position: relative;
  padding-left: 18px;
  font-size: 15px;
  line-height: 1.72;
  color: var(--text);
}

.assistant-rich ul li::before {
  content: "";
  position: absolute;
  top: 11px;
  left: 4px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--primary);
}

.assistant-rich ol {
  counter-reset: answer-ol;
}

.assistant-rich ol li {
  padding-left: 42px;
  min-height: 30px;
}

.assistant-rich ol li::before {
  counter-increment: answer-ol;
  content: counter(answer-ol);
  position: absolute;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.assistant-callout {
  margin: 0 0 12px;
  padding: 14px 14px 14px 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(248, 251, 255, 0.98), rgba(237, 242, 248, 0.92));
  border: 1px solid rgba(23, 60, 112, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.assistant-callout--warning {
  background: linear-gradient(180deg, rgba(250, 244, 232, 0.98), rgba(247, 239, 220, 0.94));
  border-color: rgba(157, 103, 32, 0.16);
}

.assistant-callout p {
  margin: 0;
}

.message__footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.message__time {
  font-size: 12px;
  color: var(--text-soft);
}

.message--user .message__time {
  color: rgba(255, 255, 255, 0.74);
}

.message__note {
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid rgba(23, 60, 112, 0.08);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-soft);
}

.message--user .message__note,
.message--system .message__note {
  display: none;
}

.composer {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  width: min(768px, 100%);
  transform: translateX(-50%);
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(244, 247, 251, 0.12), rgba(244, 247, 251, 0.95) 24%),
    rgba(244, 247, 251, 0.9);
  backdrop-filter: blur(16px);
}

.composer__shell {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 28px rgba(17, 49, 93, 0.1);
}

.composer__field-wrap {
  flex: 1;
  min-width: 0;
}

.composer textarea {
  width: 100%;
  min-height: 48px;
  max-height: 160px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
  resize: none;
  line-height: 1.6;
}

.composer textarea::placeholder {
  color: var(--text-soft);
}

.composer textarea:focus {
  border-color: rgba(23, 60, 112, 0.18);
  background: #ffffff;
}

.composer__send {
  min-width: 82px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.composer__send[disabled],
.topbar__action[disabled],
.question-toggle[disabled],
.question-card[disabled] {
  opacity: 0.6;
  cursor: default;
}

.composer__hint {
  margin: 8px 6px 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-soft);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(116px + env(safe-area-inset-bottom));
  z-index: 40;
  width: calc(100% - 28px);
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(17, 49, 93, 0.92);
  color: #ffffff;
  font-size: 13px;
  line-height: 1.55;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.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 (min-width: 720px) {
  .app-shell {
    padding-left: 20px;
    padding-right: 20px;
  }

  .welcome-card__body h2 {
    font-size: 30px;
  }
}
