@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=IBM+Plex+Sans:wght@400;500;600&display=swap");

:root {
  --bg: #f3f5ef;
  --surface: #fbfcf8;
  --surface-2: #f0f4eb;
  --line: #d4ddcc;
  --text: #1d2b1f;
  --muted: #5e6f60;
  --accent: #1f7a43;
  --accent-strong: #146436;
  --danger: #b7412b;
  --shadow: 0 2px 6px rgba(30, 55, 33, 0.05), 0 14px 34px rgba(30, 55, 33, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 15px;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 50% 48%, #f8fbf4 0%, #f5f9ef 45%, #e7f0df 72%, #d7e6ca 100%),
    radial-gradient(520px 360px at 8% 12%, rgba(157, 197, 129, 0.28) 0%, rgba(157, 197, 129, 0) 78%),
    radial-gradient(520px 360px at 92% 12%, rgba(157, 197, 129, 0.24) 0%, rgba(157, 197, 129, 0) 78%),
    linear-gradient(180deg, #eff6e8 0%, #f4f8ef 100%);
  min-height: 100vh;
  overflow: hidden;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 20px auto;
  padding: 0 16px;
  height: calc(100vh - 40px);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: visible;
}

.hidden {
  display: none !important;
}

.login-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(460px, 96vw);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(160deg, #fcfef9, #edf5e3);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.login-brand > div:last-child {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 56px;
}

.login-brand h1 {
  margin: 0;
  line-height: 1.12;
  font-size: 2rem;
}

.login-brand p {
  margin: 4px 0 0;
  line-height: 1.25;
  font-size: 1rem;
  color: var(--muted);
}

.login-card h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

.login-form {
  margin-top: 10px;
}

.login-form .btn.primary {
  display: block;
  margin: 0 auto;
}

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

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #1f7a43, #79ba49);
  color: #fff;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  flex: 0 0 auto;
}

.login-brand .brand-mark {
  width: 56px;
  height: 56px;
}

.brand h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.18rem;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.hint {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.field span {
  font-size: 0.85rem;
  color: var(--muted);
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(31, 122, 67, 0.12);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #fdfefb, #eef6e6);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  margin-bottom: 12px;
}

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

.user-badge {
  border: 1px solid #c8d8c2;
  background: #f5fbef;
  color: #214c2f;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.86rem;
  font-weight: 600;
}

.chat-stage {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.chat-header {
  padding: 14px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #f8fbf5, #edf6e4);
}

.chat-header h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.2rem;
  line-height: 1.2;
}

.chat-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.messages {
  padding: 18px;
  overflow-y: auto;
}

.message-row {
  display: flex;
  margin-bottom: 14px;
}

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

.bubble {
  max-width: 80%;
  padding: 12px 12px;
  border-radius: 5px;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  line-height: 1.4;
}

.message-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.message-tools {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #5e6f60;
}

.feedback-label {
  font-size: 0.86rem;
  font-weight: 600;
}

.tool-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  color: #5e6f60;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.tool-btn svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.tool-btn:hover {
  color: #1f7a43;
  background: rgba(31, 122, 67, 0.1);
}

.tool-btn.active.copy {
  color: #1f7a43;
}

.tool-btn.active.like {
  color: #1f7a43;
}

.tool-btn.active.dislike {
  color: #b7412b;
}

.bubble strong {
  font-weight: 700;
}

.bubble code {
  font-size: 0.88em;
  background: #eef3e8;
  border: 1px solid #d6dfcd;
  border-radius: 6px;
  padding: 1px 5px;
}

.message-row.user .bubble {
  background: linear-gradient(135deg, #1f7a43, #155e34);
  color: #fff;
  border-color: #155e34;
  width: max-content;
  max-width: 100%;
  text-align: left;
  align-self: flex-end;
}

.message-row.assistant .bubble {
  background: #fff;
  white-space: normal;
  width: auto;
  max-width: 80%;
}

.message-row.assistant .bubble h1,
.message-row.assistant .bubble h2,
.message-row.assistant .bubble h3 {
  font-family: "Space Grotesk", sans-serif;
  margin: 16px 0 6px;
  font-size: 1rem;
  line-height: 1.4;
}

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

.message-row.assistant .bubble p {
  margin: 0 0 10px;
  line-height: 1.65;
}

.message-row.assistant .bubble p:last-child {
  margin-bottom: 0;
}

.message-row.assistant .bubble ul,
.message-row.assistant .bubble ol {
  margin: 6px 0 10px;
  padding-left: 24px;
}

.message-row.assistant .bubble ol {
  list-style-type: decimal;
}

.message-row.assistant .bubble ul {
  list-style-type: disc;
}

.message-row.assistant .bubble ol > li > ul {
  margin: 6px 0 4px;
  padding-left: 20px;
  list-style-type: circle;
}

.message-row.assistant .bubble li {
  margin-bottom: 6px;
  line-height: 1.65;
  padding-left: 4px;
}

.message-row.assistant .bubble hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 14px 0;
}

.message-row.user .message-tools {
  justify-content: flex-end;
  color: rgba(255, 255, 255, 0.82);
}

.message-row.user .message-block {
  margin-left: auto;
  align-items: flex-end;
  max-width: 80%;
}

.message-row.user .tool-btn {
  color: rgba(255, 255, 255, 0.82);
}

.message-row.user .tool-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
}

.bubble.thinking {
  min-width: 180px;
}

.thinking-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #3c5d42;
  font-weight: 600;
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.thinking-dots i {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #2f7a45;
  opacity: 0.35;
  animation: pulse-dot 1s infinite ease-in-out;
}

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

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

@keyframes pulse-dot {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  50% {
    transform: translateY(-2px);
    opacity: 1;
  }
}

.composer {
  border-top: 1px solid var(--line);
  padding: 12px;
  background: #f7faf3;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.composer textarea {
  resize: none;
  max-height: 140px;
  font-size: 0.98rem;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn.primary:hover {
  background: var(--accent-strong);
}

.btn.ghost {
  background: #fff;
  color: var(--text);
}

.btn.ghost:hover {
  background: #f7fbf2;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: rgba(23, 28, 25, 0.54);
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(680px, 95vw);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 16px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.26);
}

.modal-card h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

.modal-card p {
  margin: 6px 0 12px;
  color: var(--muted);
}

.modal-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 3000;
  display: grid;
  gap: 8px;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  color: #fff;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.18);
}

.toast.info {
  background: #498f72;
}

.toast.success {
  background: #1f7a43;
}

.toast.error {
  background: #af3a2a;
}

@media (max-width: 1024px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: calc(100vh - 20px);
  }

  .login-brand h1 {
    font-size: 1.8rem;
  }

  .login-brand p {
    font-size: 0.95rem;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .account-actions {
    width: 100%;
    justify-content: space-between;
  }

  .chat-stage {
    min-height: 76vh;
    height: auto;
  }
}

