:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a66;
  --border: #e3e1da;
  --accent: #356e5b;
  --accent-ghost: rgba(53, 110, 91, 0.1);
  --shadow: 0 18px 50px rgba(15, 14, 10, 0.08);
  --radius: 18px;
  --font: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(circle at top, #fdfcf9 0%, #f2f0ea 45%, #eeeae2 100%);
  color: var(--text);
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
}

.chat {
  width: min(720px, 100%);
  background: var(--surface);
  border-radius: 28px;
  padding: 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: min(80vh, 864px);
}

.chat__header h1 {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 600;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.subhead {
  margin: 0 0 24px;
  color: var(--muted);
}


.input {
  display: flex;
  gap: 12px;
  background: #f5f3ee;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 12px;
  position: relative;
  /* Added for tooltip positioning */
}

.tooltip {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(4px);
  pointer-events: none;
  white-space: nowrap;
  z-index: 1000;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Only show on hover when active and NOT focused */
.input:hover .tooltip.tooltip--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.input input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  outline: none;
}

.input input::placeholder {
  color: var(--muted);
  opacity: 0.5;
  font-style: italic;
}

.send {
  border: none;
  background: var(--accent);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 18px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
}

.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  background: #faf9f5;
  font-size: 14px;
  cursor: pointer;
}

.chips--footer {
  padding: 14px 16px;
  border-radius: 18px;
  background: #fbfaf6;
  border: 1px solid var(--border);
  margin-top: 8px;
  margin-bottom: 8px;
}

.telemetry {
  display: flex;
  justify-content: flex-end;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--muted);
  margin-top: 8px;
  margin-right: 12px;
  opacity: 0;
  transition: opacity 0.3s ease;
  height: 14px;
  /* Fix height to prevent layout shift */
}

.telemetry--visible {
  opacity: 0.6;
}

.messages {
  display: grid;
  gap: 12px;
  padding-right: 4px;
  padding-bottom: 24px;
  overflow-y: auto;
  flex: 1;
}

.message {
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.4;
}

.message__content>*:first-child {
  margin-top: 0;
}

.message__content>*:last-child {
  margin-bottom: 0;
}

.message__content p {
  margin: 0 0 10px;
}

.message__content ul,
.message__content ol {
  margin: 8px 0 10px 20px;
  padding: 0;
}

.message__content li {
  margin-bottom: 6px;
}

.message__content code {
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
  background: #efeee9;
  padding: 2px 6px;
  border-radius: 6px;
}

.message__content pre {
  background: #efeee9;
  padding: 12px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 10px 0;
}

.message__content pre code {
  background: none;
  padding: 0;
}

.message__content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.message__cta {
  margin-top: 14px;
  margin-bottom: 4px;
  display: flex;
  justify-content: flex-end;
}

.cta-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--accent-ghost);
  color: var(--accent);
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}

.message.user {
  background: #f0efe9;
  border: 1px solid var(--border);
  align-self: flex-end;
}

.message.assistant {
  background: #f6f8f5;
  border: 1px solid rgba(53, 110, 91, 0.18);
  align-self: flex-start;
}

.message--has-cta {
  padding-bottom: 18px;
}

.message.thinking {
  padding: 12px 18px;
  background: transparent;
  border: none;
  font-style: italic;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.neural-pulse {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  position: relative;
  animation: pulse-core 2s infinite ease-in-out;
}

.neural-pulse::before,
.neural-pulse::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid var(--accent);
  animation: pulse-ring 2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}

.neural-pulse::after {
  animation-delay: 0.5s;
}

@keyframes pulse-core {

  0%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }

  50% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes pulse-ring {
  0% {
    width: 100%;
    height: 100%;
    opacity: 0.8;
  }

  100% {
    width: 300%;
    height: 300%;
    opacity: 0;
  }
}

@media (max-width: 640px) {
  .chat {
    height: 85vh;
    padding: 24px;
  }
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.modal--open {
  display: flex;
}

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(17, 16, 12, 0.4);
  backdrop-filter: blur(4px);
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal__header h2 {
  margin: 0;
  font-size: 20px;
}

.modal__close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
}

.modal__form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field input,
.field textarea {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal__actions .ghost {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

.modal__actions .primary {
  border: none;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
}

.modal__status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.modal__status--error {
  color: #b4422e;
}

@media (max-width: 640px) {
  .modal {
    align-items: flex-end;
  }

  .modal__panel {
    width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: 90vh;
  }
}