/* Lattice Pulse chat — matches lattice-site homepage tokens */

.pulse-app {
  --pulse-bg: #0a0a0f;
  --pulse-bg-elevated: #0e0e14;
  --pulse-surface: #12121a;
  --pulse-surface-2: #1a1a24;
  --pulse-border: #1f1f2e;
  --pulse-border-soft: #181822;
  --pulse-text: #e8e8ed;
  --pulse-muted: #8b8b9e;
  --pulse-accent: #6366f1;
  --pulse-accent-hover: #4f46e5;
  --pulse-accent-soft: rgba(99, 102, 241, 0.15);
  --pulse-accent-glow: rgba(99, 102, 241, 0.15);
  --pulse-warm: #fbbf24;
  --pulse-danger: #f87171;
  --pulse-sidebar-w: 260px;
  --pulse-composer-max: 720px;
  --pulse-radius: 12px;
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  margin: 0;
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  background: var(--pulse-bg);
  color: var(--pulse-text);
  font-family: var(--font-display);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body.pulse-app::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--pulse-accent-glow), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(99, 102, 241, 0.06), transparent);
}

.pulse-sidebar,
.pulse-main {
  position: relative;
  z-index: 1;
}

.pulse-sidebar {
  width: var(--pulse-sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--pulse-bg-elevated);
  border-right: 1px solid var(--pulse-border);
  z-index: 40;
}

.pulse-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1rem 0.65rem;
}

.pulse-brand {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--pulse-text);
}

.pulse-sidebar-close {
  display: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--pulse-muted);
  cursor: pointer;
}

.pulse-new-chat-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0.85rem 0.85rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--pulse-border);
  border-radius: var(--pulse-radius);
  background: var(--pulse-surface);
  color: var(--pulse-text);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.pulse-new-chat-btn:hover {
  border-color: #2a2a3d;
  background: var(--pulse-surface-2);
}

.pulse-session-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.5rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pulse-session-row {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  border-radius: 8px;
}

.pulse-session-row.is-active {
  background: var(--pulse-accent-soft);
}

.pulse-session-item {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 0.6rem 0.7rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--pulse-muted);
  font-family: inherit;
  font-size: 0.8125rem;
  line-height: 1.35;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pulse-session-row:hover .pulse-session-item,
.pulse-session-row.is-active .pulse-session-item {
  color: var(--pulse-text);
}

.pulse-session-delete {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-right: 0.25rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--pulse-muted);
  opacity: 0;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.pulse-session-row:hover .pulse-session-delete,
.pulse-session-row.is-active .pulse-session-delete {
  opacity: 1;
}

.pulse-session-delete:hover {
  background: rgba(248, 113, 113, 0.12);
  color: var(--pulse-danger);
}

.pulse-sidebar-foot {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--pulse-border);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pulse-sidebar-foot p {
  margin: 0;
  font-size: 0.6875rem;
  color: var(--pulse-muted);
  line-height: 1.4;
}

.pulse-clear-all {
  border: none;
  background: transparent;
  color: var(--pulse-muted);
  font-family: inherit;
  font-size: 0.6875rem;
  text-align: left;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pulse-clear-all:hover {
  color: var(--pulse-danger);
}

.pulse-sidebar-backdrop {
  display: none;
}

.pulse-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pulse-sidebar-toggle {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 20;
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--pulse-border);
  border-radius: 10px;
  background: rgba(18, 18, 26, 0.9);
  color: var(--pulse-muted);
  cursor: pointer;
}

.pulse-topbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--pulse-muted);
  cursor: pointer;
}

.pulse-scroll {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  scrollbar-gutter: stable;
}

.pulse-scroll::-webkit-scrollbar { width: 8px; }
.pulse-scroll::-webkit-scrollbar-track { background: transparent; }
.pulse-scroll::-webkit-scrollbar-thumb {
  background: #2a2a3d;
  border-radius: 999px;
}

.pulse-messages {
  max-width: var(--pulse-composer-max);
  margin: 0 auto;
  padding: 2rem 1.5rem 2.5rem;
  width: 100%;
  min-height: 100%;
}

.pulse-welcome {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 3.5rem 0 2rem;
  animation: pulse-fade-in 0.4s ease;
}

.pulse-welcome.is-hidden { display: none; }

.pulse-welcome-eyebrow {
  margin: 0 0 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pulse-accent);
}

.pulse-welcome-title {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin: 0 0 0.85rem;
}

.pulse-welcome-sub {
  font-size: 1rem;
  color: var(--pulse-muted);
  margin: 0 0 1.75rem;
  max-width: 28rem;
  line-height: 1.55;
}

.pulse-suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  width: 100%;
  max-width: 34rem;
}

@media (max-width: 520px) {
  .pulse-suggestions { grid-template-columns: 1fr; }
}

.pulse-chip {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  padding: 0.9rem 1rem;
  border-radius: var(--pulse-radius);
  border: 1px solid var(--pulse-border);
  background: var(--pulse-surface);
  color: var(--pulse-text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.35;
}

.pulse-chip:hover {
  border-color: rgba(99, 102, 241, 0.35);
  background: #15151f;
}

.pulse-turn {
  display: flex;
  gap: 0.85rem;
  padding: 1.1rem 0;
  animation: pulse-fade-in 0.25s ease;
}

.pulse-turn + .pulse-turn {
  border-top: 1px solid var(--pulse-border-soft);
}

.pulse-turn:hover .pulse-turn-actions { opacity: 1; }

.pulse-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  margin-top: 2px;
}

.pulse-turn-assistant .pulse-avatar {
  background: var(--pulse-accent);
  color: white;
}

.pulse-turn-user .pulse-avatar {
  background: var(--pulse-border);
  color: var(--pulse-muted);
}

.pulse-turn-content { flex: 1; min-width: 0; }

.pulse-turn-meta {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--pulse-muted);
  margin-bottom: 0.3rem;
}

.pulse-turn-body {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--pulse-text);
}

.pulse-turn-body p { margin: 0 0 0.75rem; }
.pulse-turn-body p:last-child { margin-bottom: 0; }

.pulse-turn-body code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: var(--pulse-surface-2);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.pulse-turn-body pre {
  position: relative;
  margin: 0.75rem 0;
  padding: 0.9rem 1rem;
  background: #0c0c12;
  border: 1px solid var(--pulse-border);
  border-radius: var(--pulse-radius);
  overflow-x: auto;
}

.pulse-turn-body pre code {
  background: none;
  padding: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.pulse-code-copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  border: 1px solid var(--pulse-border);
  background: var(--pulse-surface);
  color: var(--pulse-muted);
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.pulse-code-copy:hover { color: var(--pulse-text); }

.pulse-turn-body ul,
.pulse-turn-body ol {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.pulse-turn-body strong { font-weight: 600; }

.pulse-turn-error .pulse-turn-body { color: var(--pulse-danger); }

.pulse-turn-actions {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.45rem;
  opacity: 0;
  transition: opacity 0.15s;
}

@media (hover: none) {
  .pulse-turn-actions { opacity: 1; }
}

.pulse-turn-action {
  border: none;
  background: transparent;
  color: var(--pulse-muted);
  font-family: inherit;
  font-size: 0.6875rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.pulse-turn-action:hover {
  background: var(--pulse-surface);
  color: var(--pulse-text);
}

.pulse-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.pulse-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pulse-accent);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.pulse-typing span:nth-child(2) { animation-delay: 0.15s; }
.pulse-typing span:nth-child(3) { animation-delay: 0.3s; }

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

@keyframes pulse-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.pulse-composer-wrap {
  flex-shrink: 0;
  padding: 0.5rem 1.5rem max(0.85rem, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--pulse-bg) 72%, transparent);
}

.pulse-status {
  max-width: var(--pulse-composer-max);
  margin: 0 auto 0.5rem;
  font-size: 0.75rem;
  color: var(--pulse-muted);
  text-align: center;
  min-height: 1rem;
}

.pulse-status:not([hidden]) { display: block; }
.pulse-status[data-kind="warm"] { color: #a5b4fc; }
.pulse-status[data-kind="busy"] { color: var(--pulse-warm); }
.pulse-status[data-kind="error"] { color: var(--pulse-danger); }
.pulse-status[data-kind="ready"] { color: #86efac; }
.pulse-status[data-kind="warn"] { color: var(--pulse-warm); }

.pulse-composer {
  max-width: var(--pulse-composer-max);
  margin: 0 auto;
}

.pulse-input-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem 0.95rem 0.7rem;
  background: var(--pulse-surface);
  border: 1px solid var(--pulse-border);
  border-radius: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pulse-input-box:focus-within {
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 0 0 1px var(--pulse-accent-glow);
}

.pulse-input-box textarea {
  width: 100%;
  resize: none;
  border: none;
  background: transparent;
  color: var(--pulse-text);
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.5;
  max-height: 200px;
  padding: 0.1rem 0.15rem 0.3rem;
  outline: none;
}

.pulse-input-box textarea::placeholder { color: var(--pulse-muted); }

.pulse-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.pulse-composer-right {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.pulse-kbd-hint {
  display: none;
  font-size: 0.65rem;
  color: var(--pulse-muted);
  margin-right: 0.35rem;
}

@media (min-width: 720px) {
  .pulse-kbd-hint { display: inline; }
}

.pulse-model-wrap { position: relative; margin-right: auto; }

.pulse-model-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--pulse-border);
  background: transparent;
  color: var(--pulse-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.pulse-model-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pulse-accent);
}

.pulse-model-dot[data-model="pulse2"] {
  background: #a78bfa;
}

.pulse-model-btn:hover,
.pulse-model-btn[aria-expanded="true"] {
  background: var(--pulse-surface-2);
  color: var(--pulse-text);
  border-color: #2a2a3d;
}

.pulse-model-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  min-width: 230px;
  padding: 0.35rem;
  background: var(--pulse-surface);
  border: 1px solid var(--pulse-border);
  border-radius: var(--pulse-radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  z-index: 50;
}

.pulse-model-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--pulse-text);
  font-family: inherit;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
}

.pulse-model-option:hover { background: var(--pulse-surface-2); }
.pulse-model-option.is-active { background: var(--pulse-accent-soft); }

.pulse-model-option-name {
  font-size: 0.8125rem;
  font-weight: 600;
}

.pulse-model-option-meta {
  font-size: 0.6875rem;
  color: var(--pulse-muted);
}

.pulse-icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--pulse-muted);
  cursor: pointer;
}

.pulse-icon-btn:hover {
  background: var(--pulse-surface-2);
  color: var(--pulse-text);
}

.pulse-send {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pulse-surface-2);
  color: var(--pulse-muted);
  cursor: not-allowed;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.pulse-send.is-ready {
  background: var(--pulse-accent);
  color: white;
  cursor: pointer;
}

.pulse-send.is-ready:hover { background: var(--pulse-accent-hover); }
.pulse-send.is-ready:active { transform: scale(0.94); }

.pulse-footnote {
  max-width: var(--pulse-composer-max);
  margin: 0.65rem auto 0;
  font-size: 0.6875rem;
  color: var(--pulse-muted);
  text-align: center;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .pulse-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .pulse-sidebar.is-open { transform: translateX(0); }

  .pulse-sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #sidebar-open { display: flex; }

  .pulse-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 30;
  }

  .pulse-sidebar-backdrop[hidden] { display: none; }

  .pulse-messages { padding-top: 3.5rem; }
}
