:root {
  --fa-bg: #f6f7f4;
  --fa-panel: #ffffff;
  --fa-panel-2: #f1f5f2;
  --fa-line: #d9dfd8;
  --fa-ink: #111814;
  --fa-muted: #5b665f;
  --fa-soft: #e7f4ed;
  --fa-green: #176c4b;
  --fa-green-2: #0f5138;
  --fa-accent: #bf4f2b;
  --fa-blue: #285f8f;
  --fa-warn: #8a6200;
  --fa-shadow: 0 18px 50px rgba(17, 24, 20, 0.12);
  --fa-radius: 14px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--fa-bg);
  color: var(--fa-ink);
}
a { color: inherit; }
button, textarea { font: inherit; }
button { cursor: pointer; }
a:focus-visible, button:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(191, 79, 43, 0.34);
  outline-offset: 3px;
}

.fa-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.fa-topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  min-height: 58px;
  border-bottom: 1px solid var(--fa-line);
  background: rgba(246, 247, 244, 0.92);
  backdrop-filter: blur(16px);
}
.fa-topbar-inner {
  width: min(1220px, 100%);
  min-height: 58px;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.fa-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--fa-ink);
  font-size: 1.12rem;
  font-weight: 820;
  text-decoration: none;
  white-space: nowrap;
}
.fa-brand-badge {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: var(--fa-green);
  color: #fff;
  font-weight: 900;
  font-size: 0.86rem;
}
.fa-brand span { color: var(--fa-green); }
.fa-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
}
.fa-nav a {
  color: var(--fa-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 720;
}
.fa-nav a:hover,
.fa-nav a.active { color: var(--fa-green); }

.fa-shell {
  width: min(1220px, 100%);
  min-height: calc(100vh - 58px);
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
}

.fa-side {
  min-height: calc(100vh - 94px);
  align-self: stretch;
  padding: 16px;
  border: 1px solid var(--fa-line);
  border-radius: var(--fa-radius);
  background: #fbfcfa;
  box-shadow: 0 2px 18px rgba(17, 24, 20, 0.05);
}
.fa-side-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.fa-side h1 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.2;
}
.fa-side p {
  margin: 0 0 14px;
  color: var(--fa-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}
.fa-new-chat {
  margin-left: auto;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #bddbcc;
  border-radius: 8px;
  background: var(--fa-soft);
  color: var(--fa-green-2);
  font-size: 0.8rem;
  font-weight: 820;
}
.fa-side-label {
  display: block;
  margin: 16px 0 8px;
  color: var(--fa-muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.fa-side-actions,
.fa-side-prompts {
  display: grid;
  gap: 7px;
}
.fa-side-actions button,
.fa-side-prompts button {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--fa-line);
  border-radius: 10px;
  background: var(--fa-panel);
  color: var(--fa-ink);
  text-align: left;
  font-size: 0.84rem;
  font-weight: 730;
}
.fa-side-prompts button {
  color: var(--fa-muted);
  font-weight: 650;
}
.fa-side-actions button:hover,
.fa-side-prompts button:hover {
  border-color: #9ccbb6;
  background: var(--fa-soft);
  color: var(--fa-green-2);
}
.fa-note {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #ead9b2;
  border-radius: 10px;
  background: #fff8e7;
  color: #645025;
  font-size: 0.78rem;
  line-height: 1.55;
}

.fa-chat-panel {
  min-height: calc(100vh - 94px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  border: 1px solid var(--fa-line);
  border-radius: var(--fa-radius);
  background: var(--fa-panel);
  box-shadow: var(--fa-shadow);
}
.fa-chat-head {
  min-height: 64px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid var(--fa-line);
  background: rgba(255, 255, 255, 0.94);
}
.fa-chat-head .fa-avatar,
.fa-message .fa-avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--fa-green);
  color: #fff;
  font-weight: 900;
  font-size: 0.82rem;
  flex: 0 0 auto;
}
.fa-title {
  font-weight: 850;
  line-height: 1.2;
}
.fa-status {
  margin-top: 2px;
  color: var(--fa-muted);
  font-size: 0.78rem;
}
.fa-restart {
  margin-left: auto;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--fa-line);
  border-radius: 9px;
  background: var(--fa-panel-2);
  color: var(--fa-ink);
  font-size: 0.82rem;
  font-weight: 800;
}
.fa-restart:hover { background: var(--fa-soft); color: var(--fa-green-2); }

.fa-messages {
  overflow-y: auto;
  padding: 22px clamp(14px, 4vw, 54px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}
.fa-messages::-webkit-scrollbar { width: 8px; }
.fa-messages::-webkit-scrollbar-thumb {
  border: 2px solid #fff;
  border-radius: 99px;
  background: #c6d1ca;
}
.fa-message {
  width: min(820px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 11px;
}
.fa-message.user {
  justify-content: flex-end;
}
.fa-message.user .fa-avatar { display: none; }
.fa-bubble {
  max-width: min(720px, 100%);
  padding: 13px 15px;
  border: 1px solid var(--fa-line);
  border-radius: 14px;
  background: var(--fa-panel-2);
  color: var(--fa-ink);
  font-size: 0.96rem;
  line-height: 1.62;
}
.fa-message.assistant .fa-bubble {
  border-color: transparent;
  background: transparent;
  padding-top: 4px;
}
.fa-message.user .fa-bubble {
  max-width: min(620px, 84%);
  border-color: #d7eadf;
  background: #eaf4ef;
}
.fa-bubble p { margin: 8px 0 0; }
.fa-bubble p:first-child { margin-top: 0; }
.fa-bubble ul {
  margin: 8px 0 0;
  padding-left: 18px;
}
.fa-bubble li { margin: 3px 0; }
.fa-bubble strong { font-weight: 820; }
.fa-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 8px;
  padding: 0 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: var(--fa-blue);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fa-thinking .fa-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fa-muted);
}
.fa-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.fa-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fa-muted);
  animation: faPulse 1.1s ease-in-out infinite;
}
.fa-dots span:nth-child(2) { animation-delay: 0.16s; }
.fa-dots span:nth-child(3) { animation-delay: 0.32s; }
@keyframes faPulse {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.42; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.fa-result {
  margin: 12px 0 4px;
  overflow: hidden;
  border: 1px solid #bddbcc;
  border-radius: 12px;
  background: #fbfffd;
}
.fa-result-main {
  padding: 13px 14px;
  display: grid;
  gap: 4px;
  border-bottom: 1px solid #d9ece3;
  background: var(--fa-soft);
}
.fa-result-main span,
.fa-result-row span {
  color: var(--fa-muted);
  font-size: 0.78rem;
  font-weight: 760;
}
.fa-result-main strong {
  color: var(--fa-green-2);
  font-size: 1.24rem;
  line-height: 1.2;
}
.fa-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 14px;
  border-top: 1px solid #e4f0eb;
}
.fa-result-row:first-of-type { border-top: 0; }
.fa-result-row strong { text-align: right; }
.fa-inline-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-top: 9px;
  padding: 0 12px;
  border-radius: 9px;
  background: var(--fa-green);
  color: #fff;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 820;
}

.fa-suggestions {
  width: min(820px, 100%);
  margin: 0 auto;
  padding: 0 16px 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.fa-suggestions button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--fa-line);
  border-radius: 999px;
  background: var(--fa-panel);
  color: var(--fa-muted);
  font-size: 0.82rem;
  font-weight: 750;
}
.fa-suggestions button:hover {
  border-color: #9ccbb6;
  background: var(--fa-soft);
  color: var(--fa-green-2);
}

.fa-form {
  padding: 0 16px 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0), #fff 25%);
}
.fa-composer {
  width: min(820px, 100%);
  margin: 0 auto;
  padding: 8px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid #cbd6cf;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(17, 24, 20, 0.09);
}
.fa-composer:focus-within {
  border-color: #8cc7ad;
  box-shadow: 0 0 0 4px rgba(23, 108, 75, 0.12), 0 10px 28px rgba(17, 24, 20, 0.09);
}
.fa-form textarea {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  max-height: 150px;
  padding: 8px 10px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--fa-ink);
  line-height: 1.45;
}
.fa-form button {
  min-width: 64px;
  min-height: 38px;
  border: 0;
  border-radius: 11px;
  background: var(--fa-green);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 850;
}
.fa-form button:hover { background: var(--fa-green-2); }
.fa-form button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .fa-shell {
    grid-template-columns: 1fr;
    padding: 10px;
    gap: 10px;
  }
  .fa-side {
    min-height: 0;
    padding: 12px;
  }
  .fa-side p,
  .fa-note,
  .fa-side-label,
  .fa-side-prompts { display: none; }
  .fa-side-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow-x: auto;
  }
  .fa-side-actions button {
    white-space: nowrap;
    text-align: center;
  }
  .fa-chat-panel { min-height: calc(100vh - 198px); }
  .fa-nav a:not(.active) { display: none; }
}

@media (max-width: 560px) {
  .fa-topbar-inner { padding: 0 12px; }
  .fa-brand { font-size: 1rem; }
  .fa-shell {
    padding: 0;
    gap: 0;
  }
  .fa-side {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .fa-side-actions { display: none; }
  .fa-chat-panel {
    min-height: calc(100vh - 115px);
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .fa-chat-head { min-height: 58px; padding: 10px 12px; }
  .fa-restart { padding: 0 10px; }
  .fa-messages {
    padding: 16px 12px;
    gap: 14px;
  }
  .fa-message { gap: 8px; }
  .fa-message .fa-avatar {
    width: 30px;
    height: 30px;
  }
  .fa-bubble {
    font-size: 0.93rem;
    padding: 11px 12px;
  }
  .fa-message.assistant .fa-bubble { padding-right: 0; }
  .fa-suggestions {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0 12px 8px;
  }
  .fa-suggestions button { flex: 0 0 auto; }
  .fa-form {
    position: sticky;
    bottom: 0;
    padding: 0 10px 10px;
  }
  .fa-form button { min-width: 58px; }
}
