:root {
  color-scheme: light;
  --forest: #12372a;
  --forest-soft: #214e3e;
  --mint: #d8ebdf;
  --cream: #f6f3eb;
  --paper: #fffdf8;
  --ink: #17211d;
  --muted: #64716b;
  --line: #dce3de;
  --danger: #a7372a;
  --shadow: 0 24px 70px rgb(18 55 42 / 12%);
  --radius: 12px;
  --transition: 180ms ease;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgb(216 235 223 / 75%), transparent 32rem),
    var(--cream);
  color: var(--ink);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
    box-shadow var(--transition), opacity var(--transition);
}

.hidden {
  display: none !important;
}

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

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgb(18 55 42 / 14%);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgb(18 55 42 / 24%);
}

@supports (scrollbar-width: thin) {
  * {
    scrollbar-width: thin;
    scrollbar-color: rgb(18 55 42 / 14%) transparent;
  }
}

:focus-visible {
  outline: 2px solid rgb(18 55 42 / 40%);
  outline-offset: 2px;
  border-radius: 4px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid rgb(18 55 42 / 10%);
  background: rgb(246 243 235 / 86%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--forest);
  text-decoration: none;
  transition: opacity var(--transition);
}

.brand:hover {
  opacity: 0.8;
}

.brand span {
  display: grid;
}

.brand strong {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.member-email {
  color: var(--muted);
  font-size: 13px;
}

.button {
  min-height: 40px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 650;
}

.button-primary {
  color: white;
  background: var(--forest);
  box-shadow: 0 1px 3px rgb(18 55 42 / 20%);
}

.button-primary:hover {
  background: var(--forest-soft);
  box-shadow: 0 3px 10px rgb(18 55 42 / 22%);
}

.button-primary:active {
  transform: scale(0.97);
}

.button-secondary,
.button-quiet {
  color: var(--forest);
  background: transparent;
  border-color: var(--line);
}

.button-quiet {
  min-height: 34px;
  padding-inline: 12px;
  border-color: transparent;
}

.button-secondary:hover,
.button-quiet:hover {
  background: rgb(18 55 42 / 6%);
  border-color: rgb(18 55 42 / 18%);
}

.button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.full-width {
  width: 100%;
}

.login-view {
  width: min(1120px, calc(100% - 40px));
  min-height: calc(100vh - 72px);
  margin: auto;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.7fr);
  gap: 54px;
  align-items: center;
  padding: 70px 0;
}

.login-card {
  max-width: 680px;
}

.eyebrow {
  margin-bottom: 14px;
  color: #46705e;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.login-card h1 {
  max-width: 650px;
  margin: 0;
  color: var(--forest);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(44px, 6vw, 76px);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.login-card > p {
  max-width: 570px;
  margin: 28px 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.google-signin {
  min-height: 44px;
  margin-top: 34px;
}

.login-card .login-note {
  margin-top: 13px;
  font-size: 12px;
}

.status,
.error-text {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

.promise-card {
  display: flex;
  gap: 15px;
  padding: 26px;
  border: 1px solid rgb(18 55 42 / 11%);
  border-radius: 20px;
  background: rgb(255 253 248 / 80%);
  box-shadow: 0 20px 60px rgb(18 55 42 / 10%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.promise-icon {
  display: grid;
  flex: 0 0 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--forest);
}

.promise-card strong {
  color: var(--forest);
}

.promise-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.chat-view {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgb(255 253 248 / 52%);
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.conversation-history {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.conversation-history h2 {
  margin: 2px 10px 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.conversation-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 3px;
  overflow-y: auto;
}

.conversation-list-status {
  margin: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.conversation-link {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  transition: background var(--transition), box-shadow var(--transition),
    color var(--transition);
}

.conversation-link:hover {
  background: rgb(18 55 42 / 7%);
}

.conversation-link.active {
  color: var(--forest);
  background: rgb(18 55 42 / 8%);
  box-shadow: inset 3px 0 var(--forest);
  font-weight: 500;
}

.conversation-link span {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-link time {
  color: var(--muted);
  font-size: 10px;
}

.nav-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 10px;
  border: 0;
  border-radius: 9px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  font-size: 14px;
}

.nav-button:hover {
  background: rgb(18 55 42 / 6%);
  color: var(--forest);
}

.nav-button span:last-child {
  font-size: 18px;
  color: var(--muted);
  transition: transform var(--transition);
}

.nav-button:hover span:last-child {
  transform: translateX(2px);
  color: var(--forest);
}

.sidebar-note {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: 13px;
  color: var(--forest);
  background: linear-gradient(160deg, rgb(216 235 223 / 70%), rgb(216 235 223 / 40%));
  border: 1px solid rgb(18 55 42 / 8%);
  font-size: 12px;
  line-height: 1.45;
}

.sidebar-note span {
  color: #49685b;
}

.conversation {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: rgb(255 253 248 / 42%);
}

.messages {
  width: min(820px, calc(100% - 36px));
  margin: 0 auto;
  padding: 48px 0 28px;
  flex: 1;
  overflow-y: auto;
}

.empty-state {
  min-height: 55vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.agent-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: white;
  background: linear-gradient(145deg, var(--forest), var(--forest-soft));
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  box-shadow: 0 6px 20px rgb(18 55 42 / 22%);
}

.empty-state h2 {
  margin: 20px 0 7px;
  color: var(--forest);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 500;
}

.empty-state > p {
  margin: 0;
  color: var(--muted);
}

.suggestions {
  max-width: 640px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-top: 28px;
}

.suggestion {
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--forest);
  background: var(--paper);
  font-size: 14px;
}

.suggestion:hover {
  border-color: #8caa9d;
  background: white;
  box-shadow: 0 2px 10px rgb(18 55 42 / 8%);
  transform: translateY(-1px);
}

.suggestion:active {
  transform: translateY(0);
  box-shadow: none;
}

.message {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 28px;
  animation: message-in 280ms ease-out both;
}

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

.message-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--forest);
  background: var(--paper);
  font-size: 12px;
  font-weight: 750;
  flex-shrink: 0;
}

.message.user .message-avatar {
  color: white;
  background: linear-gradient(145deg, #587267, #3d5a4f);
  border-color: transparent;
}

.message-body {
  min-width: 0;
}

.message-author {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.message-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.7;
  font-size: 15px;
}

.message.user .message-text {
  background: rgb(18 55 42 / 4%);
  padding: 12px 16px;
  border-radius: 14px 14px 14px 4px;
}

.sources {
  display: grid;
  gap: 6px;
  margin: 13px 0 0;
  padding: 12px 14px;
  border-left: 3px solid #8caa9d;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: rgb(216 235 223 / 35%);
}

.sources strong {
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.sources a {
  overflow: hidden;
  color: var(--forest-soft);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
  border-bottom: 1px solid rgb(33 78 62 / 20%);
  width: fit-content;
  transition: border-color var(--transition);
}

.sources a:hover {
  border-color: var(--forest-soft);
}

.typing .message-text {
  color: var(--muted);
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.typing .message-avatar {
  animation: pulse 1.6s ease-in-out infinite;
}

.composer {
  position: relative;
  width: min(820px, calc(100% - 36px));
  margin: 0 auto 24px;
  padding: 13px 58px 28px 16px;
  border: 1px solid #cbd6d0;
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 12px 34px rgb(18 55 42 / 8%);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.composer:focus-within {
  border-color: #5c8b72;
  box-shadow: 0 12px 38px rgb(18 55 42 / 13%), 0 0 0 3px rgb(18 55 42 / 6%);
}

.composer textarea {
  width: 100%;
  max-height: 190px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: #89938e;
}

.send-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 11px;
  color: white;
  background: var(--forest);
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 2px 6px rgb(18 55 42 / 20%);
}

.send-button:hover:not(:disabled) {
  background: var(--forest-soft);
  box-shadow: 0 4px 12px rgb(18 55 42 / 28%);
}

.send-button:active:not(:disabled) {
  transform: scale(0.92);
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.45;
  box-shadow: none;
}

.composer-hint {
  position: absolute;
  left: 16px;
  bottom: 8px;
  color: #8b958f;
  font-size: 10px;
}

.dialog {
  width: min(680px, calc(100% - 32px));
  max-height: min(760px, calc(100vh - 40px));
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 32px 80px rgb(18 55 42 / 18%), 0 0 0 1px rgb(18 55 42 / 5%);
  animation: dialog-in 240ms ease-out;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
}

.dialog::backdrop {
  background: rgb(10 25 19 / 45%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: backdrop-in 200ms ease-out;
}

@keyframes backdrop-in {
  from { opacity: 0; }
}

.dialog form {
  padding: 26px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.dialog h2 {
  margin: 0;
  color: var(--forest);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 500;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 24px;
}

.icon-button:hover {
  background: rgb(18 55 42 / 7%);
}

.dialog-description {
  color: var(--muted);
  line-height: 1.5;
}

.action-content {
  max-height: 360px;
  margin-top: 16px;
  padding: 16px 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #28332e;
  background: #f4f6f2;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
}

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

.skills-list {
  min-height: 80px;
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.memory-list {
  min-height: 80px;
  display: grid;
  gap: 9px;
  margin-top: 20px;
}

.memory-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.memory-row:hover {
  border-color: rgb(18 55 42 / 18%);
  box-shadow: 0 2px 8px rgb(18 55 42 / 5%);
}

.memory-row p {
  margin: 0;
  line-height: 1.45;
}

.memory-row .button {
  flex: 0 0 auto;
}

.audit-list {
  max-height: 440px;
  display: grid;
  gap: 9px;
  margin-top: 18px;
  overflow-y: auto;
}

.cost-summary {
  min-height: 110px;
  margin-top: 18px;
}

.cost-card {
  padding: 16px;
  border: 1px solid rgb(18 55 42 / 14%);
  border-radius: var(--radius);
  background: #faf9f4;
}

.cost-card-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.cost-card-heading span {
  color: var(--muted);
  font-size: 12px;
}

.cost-card-heading strong {
  color: var(--forest);
  font-size: 24px;
}

.cost-progress {
  height: 7px;
  margin-top: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(18 55 42 / 10%);
}

.cost-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--forest);
}

.cost-details,
.cost-update {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.cost-update {
  margin-top: 4px;
}

.audit-heading {
  margin: 22px 0 0;
  color: var(--forest);
  font-size: 14px;
}

.audit-row {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #faf9f4;
  transition: border-color var(--transition);
}

.audit-row:hover {
  border-color: rgb(18 55 42 / 18%);
}

.audit-row-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.audit-row-heading strong {
  color: var(--forest);
  font-size: 14px;
}

.audit-row-heading time,
.audit-actor,
.audit-details {
  color: var(--muted);
  font-size: 11px;
}

.audit-actor {
  margin: 5px 0 0;
}

.audit-details {
  margin: 7px 0 0;
  line-height: 1.45;
}

.skill-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.skill-card:hover {
  border-color: rgb(18 55 42 / 18%);
  box-shadow: 0 4px 14px rgb(18 55 42 / 6%);
}

.skill-card strong {
  color: var(--forest);
  font-size: 14px;
}

.skill-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 14px 18px;
  border-radius: var(--radius);
  color: white;
  background: var(--forest);
  box-shadow: 0 16px 48px rgb(18 55 42 / 28%);
  font-size: 13px;
  animation: toast-in 260ms ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 760px) {
  .topbar {
    height: 64px;
    padding: 0 16px;
  }

  .member-email {
    display: none !important;
  }

  .login-view {
    min-height: calc(100vh - 64px);
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 48px 0;
  }

  .login-card h1 {
    font-size: 48px;
  }

  .promise-card {
    max-width: 520px;
  }

  .chat-view {
    height: calc(100vh - 64px);
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .messages {
    padding-top: 28px;
  }

  .empty-state {
    min-height: 50vh;
  }

  .composer {
    margin-bottom: 12px;
  }
}
