:root {
  --ink: #14251f;
  --forest: #153f35;
  --muted: #6b7772;
  --line: #e2e7e3;
  --paper: #fbfcfa;
  --soft: #f2f6f3;
  --mint: #e5f3e9;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'DM Sans', 'Noto Sans TC', sans-serif;
}
button, textarea { font: inherit; }
button { cursor: pointer; }

.chat-app { min-height: 100vh; padding-bottom: 142px; }
.chat-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 920px) / 2));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(18px);
}
.chat-brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--forest);
  color: white;
  font: italic 16px Georgia, serif;
}
.chat-brand strong, .chat-brand small, .connection-copy strong, .connection-copy small { display: block; }
.chat-brand strong { font-size: 14px; }
.chat-brand small, .connection-copy small { margin-top: 1px; color: var(--muted); font-size: 9px; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: #54bd7e; box-shadow: 0 0 0 4px #54bd7e18; }
.connection-copy strong { font-size: 10px; }
.usage-copy { min-width: 82px; margin-left: 8px; padding-left: 12px; border-left: 1px solid var(--line); text-align: right; }
.usage-copy strong, .usage-copy small { display: block; }
.usage-copy strong { font-size: 10px; }
.usage-copy small { margin-top: 1px; color: var(--muted); font-size: 8px; }
.text-button { margin-left: 12px; padding: 7px 10px; border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.auth-button { min-height: 34px; display: inline-flex; align-items: center; gap: 7px; margin-left: 4px; padding: 7px 12px; border: 1px solid #cbd8d1; border-radius: 18px; background: white; color: var(--forest); font-size: 10px; font-weight: 600; }
.auth-button:hover { background: var(--soft); }
.auth-button.local { cursor: default; border-color: transparent; background: var(--soft); color: var(--muted); }
.auth-button.signed-in { max-width: 210px; padding: 4px 9px 4px 5px; }
.auth-button.signed-in > span:not(.auth-avatar) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-button small { color: var(--muted); font-size: 8px; font-weight: 500; }
.auth-avatar { width: 24px; height: 24px; flex: 0 0 24px; display: grid; place-items: center; border-radius: 50%; background: var(--forest); color: white; font-size: 9px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 50% 35%, #e8f3eb 0, var(--paper) 44%); }
.login-card { width: min(430px, 100%); padding: 44px 38px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.9); box-shadow: 0 24px 80px rgba(21,63,53,.11); text-align: center; }
.login-mark { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto; border-radius: 50%; background: var(--forest); color: white; font: italic 22px Georgia, serif; }
.login-eyebrow { margin: 18px 0 5px !important; color: #537165 !important; font-size: 9px !important; font-weight: 700; letter-spacing: 1.8px; text-transform: uppercase; }
.login-card h1 { margin: 18px 0 10px; font-size: 28px; letter-spacing: -.7px; }
.login-eyebrow + h1 { margin-top: 7px; }
.login-card p { margin: 0 auto; color: var(--muted); font-size: 12px; line-height: 1.75; }
.login-card .running-circle { display: block; margin: 22px auto 0; }
.google-login { width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 26px; border: 1px solid #cbd8d1; border-radius: 13px; background: var(--forest); color: white; font-size: 12px; font-weight: 700; }
.google-login:hover { background: #0e332a; }
.google-login:disabled { cursor: not-allowed; opacity: .5; }
.google-login span { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: white; color: #315e4d; font-weight: 700; }
.login-card > small { display: block; margin-top: 16px; color: #89938e; font-size: 8px; line-height: 1.6; }

.conversation { width: min(820px, calc(100% - 40px)); margin: 0 auto; padding: 44px 0 30px; }
.welcome { min-height: calc(100vh - 290px); display: grid; place-items: center; align-content: center; text-align: center; }
.welcome-orb { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--forest); color: white; font-size: 17px; }
.welcome h1 { margin: 18px 0 8px; font-size: clamp(25px, 4vw, 36px); letter-spacing: -1px; }
.welcome p { max-width: 510px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.welcome .auth-notice { margin-top: 12px; color: #315e4d; font-size: 11px; font-weight: 600; }
.prompt-examples { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
.prompt-examples button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 20px; background: white; color: #47665a; font-size: 10px; }
.prompt-examples button:hover { border-color: #9eb7aa; background: var(--soft); }

.message { margin: 0 0 32px; }
.user-message { display: flex; justify-content: flex-end; }
.user-message-content { max-width: min(620px, 85%); display: flex; flex-direction: column; align-items: flex-end; }
.message-bubble { max-width: 100%; padding: 12px 15px; border-radius: 17px 17px 4px 17px; background: var(--forest); color: white; font-size: 13px; line-height: 1.65; white-space: pre-wrap; }
.message-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; width: 100%; margin-bottom: 7px; }
.message-file { padding: 4px 7px; border-radius: 7px; background: #dfece4; color: #345b4c; font-size: 9px; }
.agent-message { display: grid; grid-template-columns: 30px 1fr; gap: 12px; }
.agent-avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--mint); color: var(--forest); font-size: 12px; }
.agent-name { display: block; margin: 5px 0 12px; font-size: 11px; }
.agent-output { font-size: 13px; line-height: 1.8; }
.agent-output h2 { margin: 9px 0 8px; font-size: 20px; line-height: 1.45; letter-spacing: -.3px; }
.agent-output > p { margin: 8px 0 16px; }

.agent-running-head { display: flex; align-items: center; gap: 11px; min-height: 42px; }
.agent-running-head strong, .agent-running-head small { display: block; }
.agent-running-head small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.running-circle { width: 17px; height: 17px; border: 2px solid #bdd2c5; border-top-color: var(--forest); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.agent-activity { max-height: 180px; overflow: auto; display: grid; gap: 8px; margin: 14px 0 0 8px; padding-left: 15px; border-left: 1px solid #cbd9d1; list-style: none; }
.agent-activity li { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: center; color: var(--muted); font-size: 10px; }
.agent-activity li.active { color: var(--ink); font-weight: 600; }
.activity-mark { width: 16px; height: 16px; margin-left: -24px; display: grid; place-items: center; border: 1px solid #b3c8bc; border-radius: 50%; background: var(--paper); color: #337158; font-size: 8px; }
.agent-activity li.active .activity-mark { background: var(--forest); border-color: var(--forest); box-shadow: 0 0 0 4px #27604b13; }

.activity-complete { margin-bottom: 16px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--soft); }
.activity-complete summary { cursor: pointer; color: #50665d; font-size: 10px; font-weight: 600; }
.activity-complete ol { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 9px; }
.activity-complete li span { margin-right: 7px; color: #3d7b62; }
.workflow-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 16px; }
.workflow-summary strong { width: 100%; font-size: 11px; }
.workflow-summary span { padding: 4px 7px; border-radius: 20px; background: var(--mint); color: #426557; font-size: 9px; font-weight: 600; }
.risk { display: inline-block; padding: 3px 7px; border-radius: 20px; background: #edf0ed; color: #58665f; font-size: 9px; font-weight: 700; }
.risk.high { background: #f4d8d5; color: #8c332b; }
.risk.medium { background: #f4e5c9; color: #805814; }
.risk.low { background: #d7ecdf; color: #286642; }
.answer-block { margin: 17px 0; padding-left: 13px; border-left: 2px solid #b9d3c4; }
.answer-block strong { font-size: 11px; }
.answer-block p, .answer-block ol { margin: 5px 0 0; padding-left: 18px; }
.answer-block li { margin: 4px 0; }
.caveat { color: var(--muted); font-size: 9px; }
.error-message { color: #9b4038; }

.composer-wrap { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; padding: 12px 20px 14px; background: linear-gradient(transparent, var(--paper) 22%); }
.attachment-list { width: min(820px, 100%); display: flex; flex-wrap: wrap; gap: 6px; margin: 0 auto 7px; }
.attachment-chip { display: flex; align-items: center; gap: 6px; max-width: 240px; padding: 6px 8px; border: 1px solid #d6dfd9; border-radius: 9px; background: white; color: #476158; font-size: 9px; }
.attachment-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip button { width: auto; height: auto; padding: 0; border: 0; background: transparent; color: #829088; font-size: 13px; }
.attachment-error { color: #9b4038; font-size: 9px; }
.composer { width: min(820px, 100%); min-height: 54px; display: grid; grid-template-columns: 38px 1fr 40px; align-items: end; gap: 8px; margin: 0 auto; padding: 7px; border: 1px solid #cfd8d2; border-radius: 18px; background: white; box-shadow: 0 10px 35px rgba(24, 55, 44, .09); }
.composer textarea { width: 100%; min-height: 38px; max-height: 160px; margin: 0; padding: 9px 0 6px; resize: none; overflow-y: auto; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; line-height: 1.55; }
.composer textarea:disabled { cursor: not-allowed; color: var(--muted); }
.composer .send-button { width: 38px; height: 38px; border: 0; border-radius: 12px; background: var(--forest); color: white; font-size: 18px; }
.composer .attach-button { width: 38px; height: 38px; border: 0; border-radius: 12px; background: transparent; color: #61736b; font-size: 22px; }
.composer .attach-button:hover { background: var(--soft); }
.composer button:disabled { cursor: wait; opacity: .45; }
.composer-wrap > p { margin: 7px auto 0; color: #929b96; text-align: center; font-size: 8px; }

@media (max-width: 620px) {
  .chat-header { height: 62px; padding: 0 15px; }
  .connection-copy, .text-button, .usage-copy { display: none; }
  .auth-button.signed-in > span:not(.auth-avatar), .auth-button.signed-in small { display: none; }
  .conversation { width: calc(100% - 28px); padding-top: 28px; }
  .message-bubble { max-width: 92%; }
  .composer-wrap { padding-inline: 10px; }
  .login-card { padding: 36px 24px; }
}

@media (prefers-reduced-motion: reduce) { .running-circle { animation-duration: 1.6s; } }
@media print {
  .chat-header, .composer-wrap, .user-message, .welcome { display: none !important; }
  .chat-app { padding: 0; }
  .conversation { width: 100%; padding: 0; }
}
