:root {
  --navy: #0b2f6b;
  --blue: #1758c7;
  --blue-strong: #1048a6;
  --blue-soft: #eaf1fc;
  --teal: #0f8a70;
  --amber: #b56a06;
  --ink: #142033;
  --muted: #62708a;
  --line: #dce3ee;
  --surface: #ffffff;
  --surface-alt: #f5f7fa;
  --danger: #b42318;
  --shadow: 0 18px 55px rgba(21, 43, 80, 0.13);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--ink);
  background: #eef2f7;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.app-shell {
  width: 100%;
  height: 100dvh;
  max-width: 1360px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.app-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  width: 94px;
  height: auto;
  object-fit: contain;
}

.brand-divider {
  width: 1px;
  height: 34px;
  margin: 0 15px;
  background: var(--line);
}

.brand-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 1.25;
}

.brand-text strong {
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-text small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.usage-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #cfe5dc;
  border-radius: var(--radius);
  color: #17634f;
  background: #f1faf7;
  font-size: 13px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 138, 112, 0.12);
}

.account-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.account-button:hover {
  border-color: #aebbd0;
  background: var(--surface-alt);
}

.account-button svg {
  width: 17px;
  height: 17px;
  margin-right: 7px;
}

.app-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  height: calc(100dvh - 72px);
}

.sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 28px 22px 22px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.sidebar-intro {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  margin-bottom: 12px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow svg {
  width: 16px;
  height: 16px;
  margin-right: 6px;
}

.sidebar-intro h1 {
  margin: 0;
  color: var(--navy);
  font-size: 22px;
  line-height: 1.35;
  letter-spacing: 0;
}

.sidebar-intro p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.guide-section {
  padding-top: 22px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: #34435a;
  font-size: 13px;
  font-weight: 700;
}

.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 99px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
}

.guide-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.guide-button {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 16px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #27364d;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.guide-button:hover {
  border-color: #ccdaef;
  color: var(--blue-strong);
  background: var(--blue-soft);
}

.guide-button svg {
  width: 16px;
  height: 16px;
  color: var(--blue);
}

.guide-button svg:last-child {
  width: 14px;
  height: 14px;
  color: #8290a6;
}

.guide-button span {
  padding: 0 8px;
  font-size: 13px;
  line-height: 1.4;
}

.scope-section {
  padding-top: 24px;
}

.scope-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.scope-list li {
  position: relative;
  padding-left: 17px;
  color: var(--muted);
  font-size: 13px;
}

.scope-list li::before {
  position: absolute;
  top: 9px;
  left: 1px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--teal);
  content: "";
}

.sidebar-note {
  padding-top: 18px;
  margin: auto 0 0;
  border-top: 1px solid var(--line);
  color: #7a8799;
  font-size: 12px;
}

.chat-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--surface);
}

.messages {
  flex: 1;
  min-height: 0;
  padding: 34px 32px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  width: min(100%, 850px);
  margin: 0 auto 26px;
}

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

.message-assistant {
  align-items: flex-start;
}

.assistant-mark {
  display: flex;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  align-items: center;
  justify-content: center;
  margin-right: 11px;
  border: 1px solid #c7d8f2;
  border-radius: var(--radius);
  color: var(--blue);
  background: var(--blue-soft);
}

.assistant-mark svg {
  width: 19px;
  height: 19px;
}

.message-content {
  min-width: 0;
  max-width: calc(100% - 45px);
}

.message-label {
  margin-bottom: 6px;
  color: #64738b;
  font-size: 12px;
  font-weight: 700;
}

.assistant-bubble,
.user-bubble {
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}

.assistant-bubble {
  padding: 15px 17px;
  border: 1px solid #e1e7f0;
  color: #253249;
  background: #f8fafc;
}

.assistant-bubble p {
  margin: 0;
}

.assistant-bubble p + p {
  margin-top: 10px;
}

.assistant-bubble ul,
.assistant-bubble ol {
  padding-left: 20px;
  margin: 8px 0 0;
}

.assistant-bubble li + li {
  margin-top: 5px;
}

.assistant-bubble strong {
  color: #172846;
}

.user-bubble {
  padding: 12px 15px;
  color: #ffffff;
  background: var(--blue);
  box-shadow: 0 5px 15px rgba(23, 88, 199, 0.16);
}

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

.welcome-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.suggestion-button {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid #c9d8ee;
  border-radius: var(--radius);
  color: #23426f;
  background: #ffffff;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.suggestion-button:hover {
  border-color: #8facd8;
  color: var(--blue-strong);
  background: var(--blue-soft);
}

.message-meta {
  margin: 8px 0 0;
  color: #8793a5;
  font-size: 12px;
}

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.source-item {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 25px;
  padding: 3px 8px;
  border: 1px solid #d9e1ec;
  border-radius: var(--radius);
  color: #637087;
  background: #ffffff;
  font-size: 11px;
}

.source-item svg {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  margin-right: 5px;
}

.source-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typing-bubble {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7f91ad;
  animation: typing 1.15s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%,
  70%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.composer-area {
  position: relative;
  z-index: 5;
  padding: 12px 30px calc(13px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.composer {
  width: min(100%, 850px);
  margin: 0 auto;
  padding: 9px 10px 8px 14px;
  border: 1px solid #bcc9dc;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 7px 24px rgba(26, 48, 84, 0.07);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.composer:focus-within {
  border-color: #6f94cf;
  box-shadow: 0 0 0 3px rgba(23, 88, 199, 0.1);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 34px;
  max-height: 130px;
  padding: 6px 4px;
  overflow-y: auto;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: #929daf;
}

.composer-footer {
  display: flex;
  align-items: center;
  min-height: 34px;
}

.input-hint {
  color: #8a96a8;
  font-size: 11px;
}

.char-count {
  margin-left: auto;
  color: #8a96a8;
  font-size: 11px;
}

.char-count.is-near-limit {
  color: var(--amber);
}

.send-button {
  display: flex;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  align-items: center;
  justify-content: center;
  margin-left: 10px;
  border: 0;
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--blue);
  cursor: pointer;
  transition: background 0.18s ease, opacity 0.18s ease;
}

.send-button:hover {
  background: var(--blue-strong);
}

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

.send-button svg {
  width: 17px;
  height: 17px;
}

.disclaimer {
  width: min(100%, 850px);
  margin: 8px auto 0;
  color: #8a96a8;
  font-size: 11px;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 22, 43, 0.55);
  backdrop-filter: blur(3px);
}

.modal-backdrop[hidden] {
  display: none;
}

.auth-modal {
  position: relative;
  width: min(100%, 430px);
  max-height: calc(100dvh - 40px);
  padding: 26px;
  overflow-y: auto;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(4, 17, 40, 0.3);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius);
  color: #62708a;
  background: transparent;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--surface-alt);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.auth-heading {
  display: flex;
  align-items: flex-start;
  padding-right: 28px;
}

.auth-icon {
  display: flex;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  margin-right: 13px;
  border-radius: var(--radius);
  color: var(--blue);
  background: var(--blue-soft);
}

.auth-icon svg {
  width: 21px;
  height: 21px;
}

.auth-heading h2 {
  margin: 0;
  color: var(--navy);
  font-size: 20px;
}

.auth-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 22px 0 18px;
  padding: 4px;
  border-radius: var(--radius);
  background: #eef2f7;
}

.auth-tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: #657187;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.auth-tab.is-active {
  color: var(--navy);
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(24, 45, 77, 0.08);
}

.auth-form {
  display: none;
}

.auth-form.is-active {
  display: block;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span:first-child {
  display: block;
  margin-bottom: 6px;
  color: #35445b;
  font-size: 13px;
  font-weight: 700;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #c4cfdf;
  border-radius: var(--radius);
  outline: 0;
  color: var(--ink);
  background: #ffffff;
}

.field input:focus {
  border-color: #6590d4;
  box-shadow: 0 0 0 3px rgba(23, 88, 199, 0.1);
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  color: #718096;
  background: transparent;
  cursor: pointer;
}

.password-toggle:hover {
  background: var(--surface-alt);
}

.password-toggle svg {
  width: 17px;
  height: 17px;
}

.form-error {
  min-height: 20px;
  margin: -4px 0 10px;
  color: var(--danger);
  font-size: 12px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  border: 1px solid var(--blue);
  color: #ffffff;
  background: var(--blue);
}

.primary-button:hover {
  border-color: var(--blue-strong);
  background: var(--blue-strong);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.secondary-button {
  padding: 0 16px;
  border: 1px solid #c4cfdf;
  color: #31435f;
  background: #ffffff;
}

.privacy-note {
  margin: 17px 0 0;
  color: #8793a5;
  font-size: 11px;
  text-align: center;
}

.auth-signed-in {
  padding-top: 22px;
}

.account-summary {
  display: flex;
  flex-direction: column;
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.account-summary span {
  color: var(--muted);
  font-size: 12px;
}

.account-summary strong {
  margin: 5px 0 2px;
  color: var(--navy);
  font-size: 17px;
}

.summary-label {
  color: var(--blue) !important;
  font-weight: 700;
}

.toast {
  position: fixed;
  z-index: 120;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 11px 14px;
  border: 1px solid #f2c2bd;
  border-radius: var(--radius);
  color: #8a1c13;
  background: #fff5f4;
  box-shadow: 0 12px 30px rgba(35, 24, 24, 0.15);
  font-size: 13px;
}

.toast[hidden] {
  display: none;
}

@media (max-width: 900px) {
  body {
    background: var(--surface);
  }

  .app-shell {
    max-width: none;
    box-shadow: none;
  }

  .app-header {
    min-height: 64px;
    padding: 0 14px;
  }

  .brand-logo {
    width: 76px;
  }

  .brand-divider {
    height: 29px;
    margin: 0 10px;
  }

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

  .brand-text small {
    display: none;
  }

  .app-layout {
    display: block;
    height: calc(100dvh - 64px);
  }

  .sidebar {
    display: none;
  }

  .chat-panel {
    height: 100%;
  }

  .messages {
    padding: 22px 14px 18px;
  }

  .message {
    margin-bottom: 22px;
  }

  .assistant-mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
    margin-right: 8px;
  }

  .assistant-mark svg {
    width: 17px;
    height: 17px;
  }

  .message-content {
    max-width: calc(100% - 38px);
  }

  .assistant-bubble {
    padding: 13px 14px;
  }

  .user-bubble {
    max-width: 88%;
    padding: 11px 13px;
  }

  .composer-area {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .input-hint {
    display: none;
  }

  .char-count {
    margin-left: 0;
  }

  .disclaimer {
    display: none;
  }

  .auth-modal {
    width: 100%;
    max-height: calc(100dvh - 24px);
    padding: 22px 18px;
  }
}

@media (max-width: 520px) {
  .usage-badge {
    min-height: 32px;
    padding: 0 9px;
    font-size: 12px;
  }

  .account-button {
    width: 36px;
    min-height: 36px;
    padding: 0;
  }

  .account-button svg {
    margin: 0;
  }

  .account-button span {
    display: none;
  }

  .welcome-suggestions {
    flex-direction: column;
  }

  .suggestion-button {
    width: 100%;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    max-width: calc(100vw - 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;
  }
}
