:root {
  color-scheme: light;
  --ink: #1d2925;
  --muted: #78827d;
  --line: #e8ebe6;
  --green: #245c4b;
  --green-dark: #194b3d;
  --green-soft: #eaf3ed;
  --canvas: #f6f7f3;
  --white: #fff;
  --shadow: 0 16px 48px rgba(32, 54, 43, 0.07);
  font-family: "DM Sans", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

body {
  height: 100%;
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 68% 4%, rgba(233, 241, 231, 0.65), transparent 38%),
    var(--canvas);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  width: min(1440px, 100%);
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.46);
}

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 32px 21px 20px;
  background: rgba(255, 255, 255, 0.78);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 0 49px 3px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  color: white;
  background: var(--green);
  border-radius: 14px;
  box-shadow: 0 6px 15px rgba(36, 92, 75, 0.2);
}

.brand-mark svg {
  width: 27px;
  height: 27px;
}

.brand-copy,
.workspace-copy,
.account-copy {
  display: grid;
  gap: 3px;
}

.brand-copy strong {
  font-size: 15px;
  letter-spacing: 0.15em;
}

.brand-copy span {
  color: #8c9690;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.sidebar-label {
  margin: 0 0 12px 9px;
  color: #929b96;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.workspace-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 11px;
  background: #f6f8f5;
  border: 1px solid #e8ede7;
  border-radius: 12px;
}

.workspace-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--green);
  background: #e8f1e9;
  border-radius: 10px;
}

.workspace-icon svg,
.privacy-icon svg,
.auth-lock svg {
  width: 20px;
  height: 20px;
}

.workspace-copy {
  min-width: 0;
  flex: 1;
}

.workspace-copy strong {
  font-size: 12px;
  font-weight: 600;
}

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

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: #55a775;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(85, 167, 117, 0.12);
}

.prompt-label {
  margin-top: 37px;
}

.suggestion-list {
  display: grid;
  gap: 4px;
}

.suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 9px;
  color: #59645f;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-size: 11px;
  transition: background 160ms ease, color 160ms ease;
}

.suggestion span {
  display: inline-grid;
  width: 18px;
  color: #8c9a91;
  font-size: 15px;
  place-items: center;
}

.suggestion:hover {
  color: var(--green-dark);
  background: var(--green-soft);
}

.sidebar-footer {
  display: grid;
  gap: 18px;
  margin-top: auto;
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 10px;
  color: #6d7972;
  background: #f7f8f5;
  border-radius: 10px;
  font-size: 10px;
  line-height: 1.5;
}

.privacy-icon {
  display: grid;
  flex: 0 0 auto;
  color: #77937e;
  place-items: center;
}

.account-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 3px 0;
  border-top: 1px solid var(--line);
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  color: #35624f;
  background: #e4eee6;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  place-items: center;
}

.account-copy {
  min-width: 0;
  flex: 1;
}

.account-copy strong,
.account-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy strong {
  font-size: 11px;
  font-weight: 600;
}

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

.text-button,
.mobile-account {
  padding: 5px;
  color: #77827c;
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 10px;
}

.text-button:hover,
.mobile-account:hover {
  color: var(--green);
}

.main-panel {
  display: flex;
  min-width: 0;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  height: 69px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  padding: 0 44px;
  border-bottom: 1px solid rgba(232, 235, 230, 0.8);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #8b948e;
  font-size: 11px;
}

.breadcrumb strong {
  color: #35423c;
  font-weight: 600;
}

.breadcrumb-slash {
  color: #c1c8c2;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.connection-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  color: #587261;
  background: rgba(233, 242, 235, 0.72);
  border-radius: 20px;
  font-size: 10px;
  font-weight: 500;
}

.connection-pill .status-dot {
  width: 6px;
  height: 6px;
}

.conversation {
  display: flex;
  width: min(790px, calc(100% - 72px));
  flex: 1 1 auto;
  flex-direction: column;
  align-self: center;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 36px 0 25px;
  scrollbar-color: #d7dfd8 transparent;
  scrollbar-width: thin;
}

.welcome {
  margin: auto 0;
  padding: 24px 0 40px;
  animation: rise-in 420ms ease both;
}

.welcome-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #76857b;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.sparkle {
  color: #699475;
  font-size: 15px;
}

h1 {
  margin: 22px 0 13px;
  font-size: clamp(32px, 4vw, 46px);
  font-weight: 600;
  letter-spacing: -0.055em;
  line-height: 1.25;
}

h1 span {
  color: var(--green);
}

.welcome-copy {
  margin: 0;
  color: #75817a;
  font-size: 13px;
  line-height: 1.9;
}

.welcome-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 37px;
}

.question-card {
  display: flex;
  min-height: 93px;
  align-items: center;
  gap: 11px;
  padding: 14px 12px;
  text-align: left;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid #e9ede7;
  border-radius: 13px;
  box-shadow: 0 5px 16px rgba(32, 54, 43, 0.025);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.question-card:hover {
  border-color: #cbd9ce;
  box-shadow: 0 9px 22px rgba(32, 54, 43, 0.07);
  transform: translateY(-2px);
}

.card-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 10px;
  font-size: 16px;
  place-items: center;
}

.mint {
  color: #477b5c;
  background: #eaf3e9;
}

.peach {
  color: #b17c51;
  background: #fbf0e5;
}

.lilac {
  color: #7772a5;
  background: #efeff8;
}

.question-card > span:nth-child(2) {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 5px;
}

.question-card strong {
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.question-card small {
  color: #87918a;
  font-size: 9px;
  white-space: nowrap;
}

.card-arrow {
  align-self: flex-start;
  color: #9da69f;
  font-size: 12px;
}

.messages {
  display: grid;
  gap: 23px;
  margin-top: auto;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  animation: rise-in 260ms ease both;
}

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

.message-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  color: white;
  background: var(--green);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  place-items: center;
}

.message.user .message-avatar {
  order: 2;
  color: #52635a;
  background: #e5eae5;
}

.message-content {
  display: grid;
  max-width: min(650px, 82%);
  gap: 6px;
}

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

.message-label {
  color: #8b948e;
  font-size: 10px;
  font-weight: 600;
}

.message-bubble {
  padding: 13px 15px;
  color: #35423c;
  background: white;
  border: 1px solid #ebeee9;
  border-radius: 3px 13px 13px;
  box-shadow: 0 4px 14px rgba(32, 54, 43, 0.035);
  font-size: 13px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

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

.message-bubble p + p {
  margin-top: 11px;
}

.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
  margin: 12px 0 6px;
  color: #294d3f;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.message-bubble h2:first-child,
.message-bubble h3:first-child,
.message-bubble h4:first-child {
  margin-top: 0;
}

.message-bubble ul,
.message-bubble ol {
  display: grid;
  gap: 7px;
  margin: 8px 0 10px;
  padding-left: 21px;
}

.message-bubble li {
  padding-left: 2px;
}

.message-bubble li::marker {
  color: #73947e;
}

.message-bubble strong {
  color: #294d3f;
  font-weight: 700;
}

.message.user .message-bubble strong {
  color: white;
}

.message-bubble code {
  padding: 2px 5px;
  color: #385e4b;
  background: #edf3ee;
  border-radius: 4px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
}

.message-bubble pre {
  margin: 9px 0;
  padding: 11px 12px;
  overflow-x: auto;
  background: #f3f6f2;
  border: 1px solid #e8eee8;
  border-radius: 8px;
  line-height: 1.65;
}

.message-bubble pre code {
  padding: 0;
  background: transparent;
  border-radius: 0;
  white-space: pre;
}

.message.user .message-bubble {
  color: white;
  background: var(--green);
  border-color: var(--green);
  border-radius: 13px 3px 13px 13px;
}

.message.error .message-bubble {
  color: #8b4940;
  background: #fff8f6;
  border-color: #f1ddd8;
}

.sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.sources-label {
  color: #859089;
  font-size: 9px;
}

.source-chip {
  max-width: 100%;
  padding: 4px 8px;
  overflow: hidden;
  color: #547360;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #edf4ee;
  border-radius: 20px;
  font-size: 9px;
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 5px 1px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: #88a192;
  border-radius: 50%;
  animation: dot-bounce 950ms infinite ease-in-out;
}

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

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

.composer-wrap {
  width: min(790px, calc(100% - 72px));
  flex: 0 0 auto;
  align-self: center;
  padding: 0 0 20px;
}

.auth-panel {
  margin-bottom: 12px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid #e6ebe5;
  border-radius: 14px;
  box-shadow: 0 7px 24px rgba(32, 54, 43, 0.04);
}

.auth-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 13px;
}

.auth-lock {
  display: grid;
  width: 34px;
  height: 34px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 10px;
  place-items: center;
}

.auth-heading > div {
  display: grid;
  gap: 3px;
}

.auth-heading strong {
  font-size: 12px;
}

.auth-heading span:not(.auth-lock) {
  color: var(--muted);
  font-size: 10px;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  gap: 8px;
}

.auth-form input {
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  color: var(--ink);
  background: #fbfcfa;
  border: 1px solid #e5eae4;
  border-radius: 8px;
  outline: none;
  font-size: 11px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.auth-form input:focus,
.composer:focus-within {
  border-color: #a6c2ad;
  box-shadow: 0 0 0 3px rgba(80, 129, 95, 0.09);
}

.primary-button {
  padding: 0 16px;
  color: white;
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  transition: background 150ms ease;
}

.primary-button:hover {
  background: var(--green-dark);
}

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

.auth-switch {
  padding: 0 5px;
  color: #64736a;
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 10px;
  white-space: nowrap;
}

.auth-switch:hover {
  color: var(--green);
}

.auth-message {
  min-height: 0;
  margin: 0;
  color: #a14c43;
  font-size: 10px;
}

.auth-message:not(:empty) {
  margin-top: 10px;
}

.composer {
  padding: 11px 12px 8px 17px;
  background: white;
  border: 1px solid #e1e7e0;
  border-radius: 14px;
  box-shadow: var(--shadow);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.composer:focus-within {
  border-color: #a6c2ad;
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 34px;
  max-height: 150px;
  padding: 4px 2px 6px;
  resize: none;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
  line-height: 1.7;
}

.composer textarea::placeholder {
  color: #a0a9a2;
}

.composer textarea:disabled {
  cursor: not-allowed;
}

.composer-bottom,
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.composer-bottom {
  min-height: 32px;
}

.composer-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #9aa39d;
  font-size: 9px;
}

.return-icon {
  display: inline-grid;
  width: 17px;
  height: 17px;
  color: #829087;
  background: #f0f3ef;
  border-radius: 5px;
  font-size: 11px;
  place-items: center;
}

.composer-actions {
  gap: 12px;
}

.character-count {
  color: #a0a9a2;
  font-size: 9px;
}

.send-button {
  display: grid;
  width: 31px;
  height: 31px;
  color: white;
  background: var(--green);
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  place-items: center;
  transition: background 150ms ease, transform 150ms ease;
}

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

.send-button:hover:not(:disabled) {
  background: var(--green-dark);
  transform: translateY(-1px);
}

.send-button:disabled {
  color: #9eaaa2;
  background: #e8ede8;
  cursor: not-allowed;
}

.disclaimer {
  margin: 10px 0 0;
  color: #a0a8a2;
  text-align: center;
  font-size: 9px;
}

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

[hidden] {
  display: none !important;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 235px minmax(0, 1fr);
  }

  .sidebar {
    padding-right: 16px;
    padding-left: 16px;
  }

  .topbar {
    padding: 0 28px;
  }

  .conversation,
  .composer-wrap {
    width: calc(100% - 52px);
  }

  .welcome-cards {
    gap: 8px;
  }

  .question-card {
    gap: 8px;
    padding: 11px 9px;
  }

  .card-icon {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 720px) {
  body {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .sidebar {
    height: 66px;
    min-height: 66px;
    flex: 0 0 66px;
    padding: 16px 19px 0;
    background: rgba(255, 255, 255, 0.86);
    border-right: 0;
  }

  .brand {
    margin: 0 0 13px;
  }

  .brand-mark {
    width: 37px;
    height: 37px;
    border-radius: 12px;
  }

  .brand-mark svg {
    width: 24px;
    height: 24px;
  }

  .sidebar-label,
  .workspace-card,
  .suggestion-list,
  .sidebar-footer {
    display: none;
  }

  .main-panel {
    height: calc(100dvh - 66px);
    min-height: 0;
    flex: 1 1 0%;
    overflow: hidden;
  }

  .topbar {
    height: 49px;
    min-height: 49px;
    flex: 0 0 49px;
    padding: 0 19px;
  }

  .breadcrumb {
    font-size: 10px;
  }

  .connection-pill {
    padding: 6px 8px;
    font-size: 9px;
  }

  .conversation {
    width: calc(100% - 38px);
    min-height: 0;
    flex: 1 1 0%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 23px 0 18px;
  }

  .welcome {
    padding: 24px 0;
  }

  h1 {
    margin-top: 18px;
    font-size: clamp(32px, 9vw, 41px);
  }

  .welcome-copy {
    font-size: 12px;
  }

  .welcome-cards {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 25px;
  }

  .question-card {
    min-height: 65px;
    padding: 10px 12px;
  }

  .question-card strong {
    font-size: 11px;
  }

  .question-card small {
    font-size: 10px;
  }

  .card-icon {
    width: 34px;
    height: 34px;
  }

  .composer-wrap {
    width: calc(100% - 28px);
    flex: 0 0 auto;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .auth-panel {
    padding: 14px;
  }

  .auth-form {
    grid-template-columns: 1fr 1fr;
  }

  .auth-submit {
    min-height: 38px;
  }

  .auth-switch {
    min-height: 38px;
  }

  .disclaimer {
    font-size: 8px;
  }

  .mobile-account {
    display: block;
  }
}

@media (max-width: 420px) {
  .auth-form {
    grid-template-columns: 1fr;
  }

  .auth-submit,
  .auth-switch {
    min-height: 39px;
  }

  .auth-switch {
    grid-row: 4;
  }

  .topbar-right {
    gap: 7px;
  }

  .connection-pill {
    gap: 6px;
    padding: 6px 7px;
  }
}

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