:root {
  color-scheme: light;
  --ink: #0b2831;
  --ink-soft: #34505a;
  --paper: #f3f7f5;
  --surface: #ffffff;
  --jade: #0c9b70;
  --jade-dark: #087b5a;
  --jade-pale: #e1f3ed;
  --amber: #d88817;
  --amber-pale: #fff2d8;
  --line: #dce6e2;
  --muted: #71858b;
  --danger: #b83d34;
  --shadow: 0 18px 55px rgba(8, 42, 50, 0.12);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
}

body {
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button,
summary {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(12, 155, 112, 0.25);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.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;
}

.eyebrow {
  margin: 0;
  color: var(--jade);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.offline-banner {
  position: fixed;
  z-index: 100;
  top: 0;
  left: 0;
  width: 100%;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;
  background: var(--amber);
  color: #fff;
  text-align: center;
  font-size: 12px;
}

.login-view {
  display: grid;
  min-height: 100dvh;
  padding: 24px;
  place-items: center;
  background:
    linear-gradient(rgba(8, 57, 65, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(8, 57, 65, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}

.login-card {
  position: relative;
  width: min(100%, 430px);
  padding: 34px 30px 28px;
  overflow: hidden;
  border: 1px solid rgba(11, 40, 49, 0.08);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background: var(--jade);
  content: "";
}

.brand-lockup {
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: 19px 19px 19px 5px;
  background: var(--ink);
  color: #fff;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 16px;
  font-weight: 800;
  place-items: center;
}

.brand-mark i {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #48e5ad;
  box-shadow: 0 0 0 4px rgba(72, 229, 173, 0.16);
}

.brand-lockup h1 {
  margin: 4px 0 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(25px, 7vw, 32px);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.login-intro {
  margin: 28px 0 24px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.75;
}

.login-form {
  display: grid;
  gap: 17px;
}

.login-form label {
  display: grid;
  gap: 8px;
}

.login-form label > span {
  font-size: 13px;
  font-weight: 650;
}

.login-form input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfdfc;
  font-size: 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-form input:focus {
  border-color: var(--jade);
  box-shadow: 0 0 0 4px rgba(12, 155, 112, 0.08);
  outline: none;
}

.login-form input::placeholder,
.composer textarea::placeholder {
  color: #9aabad;
}

.primary-button {
  display: flex;
  width: 100%;
  min-height: 52px;
  margin-top: 4px;
  padding: 0 14px 0 19px;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  transition: background 160ms ease, transform 160ms ease;
}

.primary-button:hover {
  background: #123a44;
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.primary-button svg {
  width: 28px;
  height: 28px;
  padding: 6px;
  border-radius: 9px;
  background: var(--jade);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.form-error {
  margin: -4px 0;
  color: var(--danger);
  font-size: 13px;
}

.data-note {
  display: flex;
  margin-top: 24px;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 0 4px var(--jade-pale);
}

.app-view {
  display: grid;
  min-height: 100dvh;
  grid-template-rows: auto 1fr auto;
}

.app-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  min-height: calc(68px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 14px 0;
  align-items: center;
  border-bottom: 1px solid rgba(11, 40, 49, 0.08);
  background: rgba(243, 247, 245, 0.94);
  backdrop-filter: blur(16px);
  grid-template-columns: 48px 1fr 48px;
}

.header-title {
  text-align: center;
}

.header-title p {
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 17px;
  font-weight: 700;
}

.header-title span {
  display: inline-flex;
  margin-top: 3px;
  gap: 5px;
  align-items: center;
  color: var(--muted);
  font-size: 10px;
}

.header-title span i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--jade);
}

.header-title span b {
  color: inherit;
  font-weight: 500;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  place-items: center;
}

.icon-button:hover {
  background: rgba(11, 40, 49, 0.06);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.chat-stage {
  width: min(100%, 760px);
  min-height: 0;
  margin: 0 auto;
  padding: 24px 18px 154px;
}

.empty-state {
  display: flex;
  min-height: calc(100dvh - 260px);
  align-items: center;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.signal-orbit {
  position: relative;
  display: grid;
  width: 92px;
  height: 92px;
  margin-bottom: 27px;
  border: 1px solid rgba(12, 155, 112, 0.22);
  border-radius: 50%;
  place-items: center;
}

.signal-orbit::before,
.signal-orbit::after {
  position: absolute;
  border: 1px solid rgba(12, 155, 112, 0.12);
  border-radius: 50%;
  content: "";
  inset: -11px;
}

.signal-orbit::after {
  inset: -23px;
}

.signal-orbit span {
  display: grid;
  width: 55px;
  height: 55px;
  border-radius: 18px 18px 18px 5px;
  background: var(--ink);
  color: #fff;
  font-family: "Songti SC", serif;
  font-size: 25px;
  font-weight: 700;
  place-items: center;
}

.signal-orbit i {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--jade);
}

.signal-orbit i:nth-of-type(1) {
  top: -3px;
  left: 42px;
}

.signal-orbit i:nth-of-type(2) {
  right: 5px;
  bottom: 12px;
  opacity: 0.55;
}

.signal-orbit i:nth-of-type(3) {
  bottom: 4px;
  left: 8px;
  opacity: 0.3;
}

.empty-state h1 {
  margin: 10px 0 12px;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(30px, 9vw, 44px);
  line-height: 1.2;
  letter-spacing: -0.05em;
}

.empty-copy {
  max-width: 340px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.8;
}

.quick-prompts {
  display: flex;
  margin-top: 28px;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.quick-prompts button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-soft);
  font-size: 12px;
}

.quick-prompts button:hover {
  border-color: var(--jade);
  color: var(--jade-dark);
}

.message-list {
  display: grid;
  gap: 22px;
}

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

.user-message p {
  max-width: min(82%, 540px);
  margin: 0;
  padding: 13px 16px;
  border-radius: 17px 17px 4px 17px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.assistant-message {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(11, 40, 49, 0.08);
  border-radius: 21px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(8, 42, 50, 0.07);
}

.assistant-message::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 74px;
  background: var(--jade);
  content: "";
}

.answer-heading {
  display: flex;
  padding: 20px 20px 0;
  gap: 11px;
  align-items: center;
}

.mini-mark {
  display: grid;
  width: 34px;
  height: 34px;
  border-radius: 11px 11px 11px 3px;
  background: var(--jade-pale);
  color: var(--jade-dark);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  place-items: center;
}

.answer-heading strong,
.answer-heading small {
  display: block;
}

.answer-heading strong {
  font-size: 14px;
}

.answer-heading small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.answer-copy {
  padding: 17px 20px 15px;
  color: #183b43;
  font-size: 15px;
  line-height: 1.85;
  white-space: pre-wrap;
}

.answer-actions {
  display: flex;
  padding: 0 16px 16px 20px;
  align-items: center;
  justify-content: space-between;
}

.copy-button {
  display: inline-flex;
  min-height: 42px;
  padding: 0 14px;
  gap: 7px;
  align-items: center;
  border: 0;
  border-radius: 12px;
  background: var(--jade);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.copy-button:hover {
  background: var(--jade-dark);
}

.copy-button svg,
.feedback-button svg,
.review-notice svg,
.new-thread-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.feedback-actions {
  display: flex;
  gap: 2px;
}

.feedback-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  place-items: center;
}

.feedback-button:hover,
.feedback-button.selected {
  background: var(--paper);
  color: var(--jade-dark);
}

.review-notice {
  display: flex;
  margin: 0 16px 16px;
  padding: 11px 12px;
  gap: 9px;
  align-items: flex-start;
  border-radius: 12px;
  background: var(--amber-pale);
  color: #8a570e;
  font-size: 12px;
  line-height: 1.55;
}

.review-notice svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.sales-details {
  border-top: 1px solid var(--line);
}

.sales-details summary {
  min-height: 47px;
  padding: 15px 20px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
  list-style: none;
}

.sales-details summary::-webkit-details-marker {
  display: none;
}

.sales-details summary::after {
  float: right;
  color: var(--muted);
  content: "＋";
}

.sales-details[open] summary::after {
  content: "－";
}

.sales-notes {
  padding: 0 20px 14px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.source-list {
  display: grid;
  padding: 0 20px 17px;
  gap: 6px;
}

.source-item {
  display: flex;
  gap: 8px;
  align-items: baseline;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.source-item b {
  color: var(--jade-dark);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
}

.typing-card {
  display: flex;
  width: 95px;
  height: 54px;
  gap: 5px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(11, 40, 49, 0.08);
  border-radius: 17px 17px 17px 5px;
  background: #fff;
}

.typing-card i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--jade);
  animation: typing 1.1s infinite ease-in-out;
}

.typing-card i:nth-child(2) {
  animation-delay: 120ms;
}

.typing-card i:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.composer-shell {
  position: fixed;
  z-index: 9;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 10px 14px calc(8px + var(--safe-bottom));
  background: linear-gradient(to top, var(--paper) 78%, rgba(243, 247, 245, 0));
}

.composer {
  display: flex;
  width: min(100%, 730px);
  min-height: 58px;
  margin: 0 auto;
  padding: 7px 7px 7px 17px;
  gap: 8px;
  align-items: flex-end;
  border: 1px solid rgba(11, 40, 49, 0.11);
  border-radius: 19px;
  background: #fff;
  box-shadow: 0 12px 35px rgba(8, 42, 50, 0.12);
}

.composer:focus-within {
  border-color: rgba(12, 155, 112, 0.55);
}

.composer textarea {
  width: 100%;
  max-height: 124px;
  min-height: 42px;
  padding: 10px 0 8px;
  resize: none;
  border: 0;
  background: transparent;
  font-size: 16px;
  line-height: 1.5;
  outline: none;
}

.send-button {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  place-items: center;
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.45;
}

.send-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.composer-shell > p {
  margin: 6px auto 0;
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.history-dialog {
  width: min(92vw, 420px);
  max-height: min(760px, 88dvh);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.history-dialog::backdrop {
  background: rgba(6, 30, 37, 0.5);
  backdrop-filter: blur(4px);
}

.dialog-header {
  display: flex;
  padding: 24px 20px 17px;
  align-items: center;
  justify-content: space-between;
}

.dialog-header h2 {
  margin: 4px 0 0;
  font-family: "Songti SC", serif;
  font-size: 24px;
}

.new-thread-button {
  display: flex;
  width: calc(100% - 40px);
  min-height: 46px;
  margin: 0 20px 12px;
  gap: 8px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(12, 155, 112, 0.24);
  border-radius: 13px;
  background: var(--jade-pale);
  color: var(--jade-dark);
  font-size: 13px;
  font-weight: 700;
}

.conversation-list {
  display: grid;
  max-height: 430px;
  padding: 4px 12px 12px;
  overflow-y: auto;
  gap: 3px;
}

.conversation-item {
  display: grid;
  min-height: 58px;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  grid-template-columns: 1fr auto;
}

.conversation-item:hover,
.conversation-item.active {
  background: var(--paper);
}

.conversation-item strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item span {
  color: var(--muted);
  font-size: 10px;
}

.conversation-item time {
  align-self: center;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  grid-column: 2;
  grid-row: 1 / span 2;
}

.conversation-empty {
  padding: 34px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.account-strip {
  display: grid;
  min-height: 74px;
  padding: 13px 20px calc(13px + var(--safe-bottom));
  align-items: center;
  border-top: 1px solid var(--line);
  grid-template-columns: 38px 1fr auto;
  gap: 10px;
}

.account-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-family: "Songti SC", serif;
  font-size: 15px;
  place-items: center;
}

.account-strip strong,
.account-strip span {
  display: block;
}

.account-strip strong {
  font-size: 12px;
}

.account-strip span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.account-strip button {
  min-width: 48px;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.account-actions {
  display: flex;
  gap: 2px;
}

.password-dialog {
  width: min(92vw, 420px);
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.password-dialog::backdrop {
  background: rgba(6, 30, 37, 0.5);
  backdrop-filter: blur(4px);
}

.password-fields {
  display: grid;
  padding: 0 20px 24px;
  gap: 14px;
}

.password-fields label {
  display: grid;
  gap: 7px;
}

.password-fields label > span {
  font-size: 12px;
  font-weight: 650;
}

.password-fields input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfc;
  font-size: 16px;
}

.password-fields .primary-button {
  margin-top: 5px;
}

.toast {
  position: fixed;
  z-index: 200;
  bottom: calc(108px + var(--safe-bottom));
  left: 50%;
  max-width: calc(100vw - 40px);
  padding: 11px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 10px 28px rgba(8, 42, 50, 0.2);
  font-size: 12px;
  text-align: center;
  transform: translateX(-50%);
}

@media (max-width: 520px) {
  .login-view {
    padding: 0;
    background: var(--surface);
  }

  .login-card {
    width: 100%;
    min-height: 100dvh;
    padding: calc(45px + env(safe-area-inset-top, 0px)) 24px 28px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .login-card::before {
    width: 88px;
    height: 6px;
  }

  .history-dialog {
    width: 100%;
    max-width: none;
    max-height: 86dvh;
    margin: auto 0 0;
    border-radius: 24px 24px 0 0;
  }
}

@media (min-width: 800px) {
  .chat-stage {
    padding-top: 36px;
  }

  .assistant-message {
    border-radius: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
